meta: replace bluelib references with fx
This commit is contained in:
@@ -24,10 +24,10 @@ if (NOT MIE_STATIC)
|
||||
endif ()
|
||||
|
||||
if (MIE_STATIC)
|
||||
set(Bluelib_STATIC TRUE)
|
||||
set(FX_STATIC TRUE)
|
||||
endif ()
|
||||
|
||||
find_package(Bluelib REQUIRED)
|
||||
find_package(FX REQUIRED)
|
||||
|
||||
add_subdirectory(mie)
|
||||
add_subdirectory(tool)
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindBluelib
|
||||
------------
|
||||
|
||||
Find the Bluelib library and header directories
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` target:
|
||||
|
||||
``Bluelib::Bluelib``
|
||||
The Bluelib library, if found
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``Bluelib_FOUND``
|
||||
true if the Bluelib C headers and libraries were found
|
||||
``Bluelib_INCLUDE_DIR``
|
||||
directories containing the Bluelib C headers.
|
||||
|
||||
``Bluelib_LIBRARY``
|
||||
the C library to link against
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
The user may set the environment variable ``Bluelib_PREFIX`` to the root
|
||||
directory of a Bluelib library installation.
|
||||
#]=======================================================================]
|
||||
|
||||
set (Bluelib_SEARCH_PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr/local/share
|
||||
/usr
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
${Bluelib_PREFIX}
|
||||
$ENV{Bluelib_PREFIX})
|
||||
|
||||
if (Bluelib_STATIC)
|
||||
set(_lib_suffix "-s")
|
||||
endif ()
|
||||
|
||||
set(supported_components Core Ds Term Cmd Io Serial Compress)
|
||||
set(components ${Bluelib_FIND_COMPONENTS})
|
||||
string(REPLACE ";" ", " supported_components_string_list "${supported_components}")
|
||||
|
||||
if (NOT components)
|
||||
set(components ${supported_components})
|
||||
endif ()
|
||||
|
||||
set(required_vars)
|
||||
|
||||
foreach (component ${components})
|
||||
if (NOT "${component}" IN_LIST supported_components)
|
||||
message(FATAL_ERROR "'${component}' is not a valid Bluelib module.\nSupported modules: ${supported_components_string_list}")
|
||||
endif ()
|
||||
|
||||
string(TOLOWER ${component} header_name)
|
||||
set(lib_name ${header_name}${_lib_suffix})
|
||||
|
||||
if (NOT Bluelib_${component}_INCLUDE_DIR)
|
||||
find_path(Bluelib_${component}_INCLUDE_DIR
|
||||
NAMES blue/${header_name}.h ${Bluelib_FIND_ARGS}
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${Bluelib_SEARCH_PATHS})
|
||||
endif ()
|
||||
|
||||
if (NOT Bluelib_${component}_LIBRARY)
|
||||
find_library(Bluelib_${component}_LIBRARY
|
||||
NAMES blue-${lib_name} ${Bluelib_FIND_ARGS}
|
||||
PATH_SUFFIXES lib
|
||||
PATHS ${Bluelib_SEARCH_PATHS})
|
||||
else ()
|
||||
# on Windows, ensure paths are in canonical format (forward slahes):
|
||||
file(TO_CMAKE_PATH "${Bluelib_${component}_LIBRARY}" Bluelib_${component}_LIBRARY)
|
||||
endif()
|
||||
|
||||
list(APPEND required_vars Bluelib_${component}_INCLUDE_DIR Bluelib_${component}_LIBRARY)
|
||||
endforeach (component)
|
||||
|
||||
unset(Bluelib_FIND_ARGS)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(Bluelib
|
||||
REQUIRED_VARS ${required_vars})
|
||||
|
||||
if (Bluelib_FOUND)
|
||||
set(created_targets)
|
||||
foreach (component ${components})
|
||||
string(TOLOWER ${component} header_name)
|
||||
set(lib_name ${header_name}${_lib_suffix})
|
||||
|
||||
if(NOT TARGET Bluelib::${component})
|
||||
add_library(Bluelib::${component} UNKNOWN IMPORTED)
|
||||
set_target_properties(Bluelib::${component} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Bluelib_${component}_INCLUDE_DIR}")
|
||||
target_compile_definitions(Bluelib::${component} INTERFACE _CRT_SECURE_NO_WARNINGS=1)
|
||||
|
||||
if (Bluelib_STATIC)
|
||||
target_compile_definitions(Bluelib::${component} INTERFACE BLUELIB_STATIC=1)
|
||||
endif ()
|
||||
|
||||
set_target_properties(Bluelib::${component} PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${Bluelib_${component}_LIBRARY}")
|
||||
set(created_targets ${created_targets} ${component})
|
||||
endif ()
|
||||
endforeach (component)
|
||||
|
||||
foreach (component ${created_targets})
|
||||
if ("${component}" STREQUAL "Ds")
|
||||
if (NOT TARGET Bluelib::Core)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Ds' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Bluelib::Ds INTERFACE Bluelib::Core)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Term")
|
||||
if (NOT TARGET Bluelib::Core)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET Bluelib::Ds)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Bluelib::Term INTERFACE Bluelib::Core Bluelib::Ds)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Serial")
|
||||
if (NOT TARGET Bluelib::Core)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Serial' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET Bluelib::Ds)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Serial' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Bluelib::Serial INTERFACE Bluelib::Core Bluelib::Ds)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Cmd")
|
||||
if (NOT TARGET Bluelib::Core)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET Bluelib::Ds)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET Bluelib::Term)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Term', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Bluelib::Cmd INTERFACE Bluelib::Core Bluelib::Ds Bluelib::Term)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Io")
|
||||
if (NOT TARGET Bluelib::Core)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Io' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET Bluelib::Ds)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Io' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Bluelib::Io INTERFACE Bluelib::Core Bluelib::Ds)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Compress")
|
||||
if (NOT TARGET Bluelib::Core)
|
||||
message(FATAL_ERROR "Bluelib: Module 'Compress' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(Bluelib::Compress INTERFACE Bluelib::Core Bluelib::Ds)
|
||||
endif ()
|
||||
endforeach (component)
|
||||
endif()
|
||||
189
cmake/FindFX.cmake
Normal file
189
cmake/FindFX.cmake
Normal file
@@ -0,0 +1,189 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindFX
|
||||
------------
|
||||
|
||||
Find the FX library and header directories
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` target:
|
||||
|
||||
``FX::FX``
|
||||
The FX library, if found
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``FX_FOUND``
|
||||
true if the FX C headers and libraries were found
|
||||
``FX_INCLUDE_DIR``
|
||||
directories containing the FX C headers.
|
||||
|
||||
``FX_LIBRARY``
|
||||
the C library to link against
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
The user may set the environment variable ``FX_PREFIX`` to the root
|
||||
directory of a FX library installation.
|
||||
#]=======================================================================]
|
||||
|
||||
set (FX_SEARCH_PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr/local/share
|
||||
/usr
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
${FX_PREFIX}
|
||||
$ENV{FX_PREFIX})
|
||||
|
||||
if (FX_STATIC)
|
||||
set(_lib_suffix "-s")
|
||||
endif ()
|
||||
|
||||
set(supported_components Core Ds Term Cmd Io Serial Compress)
|
||||
set(components ${FX_FIND_COMPONENTS})
|
||||
string(REPLACE ";" ", " supported_components_string_list "${supported_components}")
|
||||
|
||||
if (NOT components)
|
||||
set(components ${supported_components})
|
||||
endif ()
|
||||
|
||||
set(required_vars)
|
||||
|
||||
foreach (component ${components})
|
||||
if (NOT "${component}" IN_LIST supported_components)
|
||||
message(FATAL_ERROR "'${component}' is not a valid FX module.\nSupported modules: ${supported_components_string_list}")
|
||||
endif ()
|
||||
|
||||
string(TOLOWER ${component} header_name)
|
||||
set(lib_name ${header_name}${_lib_suffix})
|
||||
|
||||
if (NOT FX_${component}_INCLUDE_DIR)
|
||||
find_path(FX_${component}_INCLUDE_DIR
|
||||
NAMES fx/${header_name}.h ${FX_FIND_ARGS}
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${FX_SEARCH_PATHS})
|
||||
endif ()
|
||||
|
||||
if (NOT FX_${component}_LIBRARY)
|
||||
find_library(FX_${component}_LIBRARY
|
||||
NAMES fx-${lib_name} ${FX_FIND_ARGS}
|
||||
PATH_SUFFIXES lib
|
||||
PATHS ${FX_SEARCH_PATHS})
|
||||
else ()
|
||||
# on Windows, ensure paths are in canonical format (forward slahes):
|
||||
file(TO_CMAKE_PATH "${FX_${component}_LIBRARY}" FX_${component}_LIBRARY)
|
||||
endif()
|
||||
|
||||
list(APPEND required_vars FX_${component}_INCLUDE_DIR FX_${component}_LIBRARY)
|
||||
endforeach (component)
|
||||
|
||||
unset(FX_FIND_ARGS)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(FX
|
||||
REQUIRED_VARS ${required_vars})
|
||||
|
||||
if (FX_FOUND)
|
||||
set(created_targets)
|
||||
foreach (component ${components})
|
||||
string(TOLOWER ${component} header_name)
|
||||
set(lib_name ${header_name}${_lib_suffix})
|
||||
|
||||
if(NOT TARGET FX::${component})
|
||||
add_library(FX::${component} UNKNOWN IMPORTED)
|
||||
set_target_properties(FX::${component} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FX_${component}_INCLUDE_DIR}")
|
||||
target_compile_definitions(FX::${component} INTERFACE _CRT_SECURE_NO_WARNINGS=1)
|
||||
|
||||
if (FX_STATIC)
|
||||
target_compile_definitions(FX::${component} INTERFACE FX_STATIC=1)
|
||||
endif ()
|
||||
|
||||
set_target_properties(FX::${component} PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${FX_${component}_LIBRARY}")
|
||||
set(created_targets ${created_targets} ${component})
|
||||
endif ()
|
||||
endforeach (component)
|
||||
|
||||
foreach (component ${created_targets})
|
||||
if ("${component}" STREQUAL "Ds")
|
||||
if (NOT TARGET FX::Core)
|
||||
message(FATAL_ERROR "FX: Module 'Ds' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(FX::Ds INTERFACE FX::Core)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Term")
|
||||
if (NOT TARGET FX::Core)
|
||||
message(FATAL_ERROR "FX: Module 'Term' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET FX::Ds)
|
||||
message(FATAL_ERROR "FX: Module 'Term' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(FX::Term INTERFACE FX::Core FX::Ds)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Serial")
|
||||
if (NOT TARGET FX::Core)
|
||||
message(FATAL_ERROR "FX: Module 'Serial' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET FX::Ds)
|
||||
message(FATAL_ERROR "FX: Module 'Serial' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(FX::Serial INTERFACE FX::Core FX::Ds)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Cmd")
|
||||
if (NOT TARGET FX::Core)
|
||||
message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET FX::Ds)
|
||||
message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET FX::Term)
|
||||
message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Term', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(FX::Cmd INTERFACE FX::Core FX::Ds FX::Term)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Io")
|
||||
if (NOT TARGET FX::Core)
|
||||
message(FATAL_ERROR "FX: Module 'Io' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET FX::Ds)
|
||||
message(FATAL_ERROR "FX: Module 'Io' depends on 'Ds', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(FX::Io INTERFACE FX::Core FX::Ds)
|
||||
endif ()
|
||||
|
||||
if ("${component}" STREQUAL "Compress")
|
||||
if (NOT TARGET FX::Core)
|
||||
message(FATAL_ERROR "FX: Module 'Compress' depends on 'Core', which was not specified in find_package()")
|
||||
endif ()
|
||||
|
||||
target_link_libraries(FX::Compress INTERFACE FX::Core FX::Ds)
|
||||
endif ()
|
||||
endforeach (component)
|
||||
endif()
|
||||
@@ -11,5 +11,5 @@ else ()
|
||||
endif ()
|
||||
|
||||
target_include_directories(mie PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
||||
target_link_libraries(mie Bluelib::Core Bluelib::Ds Bluelib::Io)
|
||||
target_link_libraries(mie FX::Core FX::Ds FX::Io)
|
||||
target_compile_definitions(mie PRIVATE MIE_EXPORT=1 MIE_STATIC=${MIE_STATIC})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
|
||||
@@ -12,7 +12,7 @@ struct mie_attribute_definition *mie_attribute_definition_create(
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->a_name = b_strdup(name);
|
||||
out->a_name = fx_strdup(name);
|
||||
if (!out->a_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -20,7 +20,7 @@ struct mie_attribute_definition *mie_attribute_definition_create(
|
||||
|
||||
out->a_parent = parent;
|
||||
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id_map_put(&parent->d_attributes, &out->a_id, &name_rope);
|
||||
|
||||
return out;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/hash.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/attribute/attribute-map.h>
|
||||
|
||||
enum attribute_map_entry_type {
|
||||
@@ -13,14 +13,14 @@ struct attribute_map_entry {
|
||||
enum attribute_map_entry_type e_type;
|
||||
uint64_t e_hash;
|
||||
union {
|
||||
b_btree_node e_node;
|
||||
b_queue_entry e_entry;
|
||||
fx_bst_node e_node;
|
||||
fx_queue_entry e_entry;
|
||||
};
|
||||
};
|
||||
|
||||
struct attribute_map_bucket {
|
||||
struct attribute_map_entry b_base;
|
||||
b_queue b_items;
|
||||
fx_queue b_items;
|
||||
};
|
||||
|
||||
struct attribute_map_item {
|
||||
@@ -29,9 +29,9 @@ struct attribute_map_item {
|
||||
const struct mie_attribute *i_value;
|
||||
};
|
||||
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct attribute_map_entry, e_node, e_hash, put_entry);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct attribute_map_entry, uint64_t, e_node, e_hash, get_entry);
|
||||
|
||||
void mie_attribute_map_init(struct mie_attribute_map *map)
|
||||
@@ -57,16 +57,16 @@ static const struct mie_attribute *get_attribute_from_item(
|
||||
static const struct mie_attribute *get_attribute_from_bucket(
|
||||
const struct attribute_map_bucket *bucket, const char *name)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(&bucket->b_items);
|
||||
fx_queue_entry *cur = fx_queue_first(&bucket->b_items);
|
||||
while (cur) {
|
||||
const struct attribute_map_item *item = b_unbox(
|
||||
const struct attribute_map_item *item = fx_unbox(
|
||||
const struct attribute_map_item, cur, i_base.e_entry);
|
||||
|
||||
if (!strcmp(item->i_name, name)) {
|
||||
return item->i_value;
|
||||
}
|
||||
|
||||
cur = b_queue_next(cur);
|
||||
cur = fx_queue_next(cur);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -90,7 +90,7 @@ static const struct mie_attribute *get_attribute_from_entry(
|
||||
const struct mie_attribute *mie_attribute_map_get(
|
||||
const struct mie_attribute_map *map, const char *name)
|
||||
{
|
||||
uint64_t name_hash = b_hash_cstr(name);
|
||||
uint64_t name_hash = fx_hash_cstr(name);
|
||||
struct attribute_map_entry *entry = get_entry(&map->m_entries, name_hash);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
@@ -107,13 +107,13 @@ static struct attribute_map_bucket *convert_item_to_bucket(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_btree_delete(&map->m_entries, &item->i_base.e_node);
|
||||
fx_bst_delete(&map->m_entries, &item->i_base.e_node);
|
||||
memset(bucket, 0x0, sizeof *bucket);
|
||||
|
||||
bucket->b_base.e_type = ATTRMAP_ENTRY_BUCKET;
|
||||
bucket->b_base.e_hash = item->i_base.e_hash;
|
||||
|
||||
b_queue_push_back(&bucket->b_items, &item->i_base.e_entry);
|
||||
fx_queue_push_back(&bucket->b_items, &item->i_base.e_entry);
|
||||
put_entry(&map->m_entries, &bucket->b_base);
|
||||
|
||||
return bucket;
|
||||
@@ -132,7 +132,7 @@ static struct attribute_map_item *create_item(
|
||||
out->i_value = attrib;
|
||||
out->i_base.e_type = ATTRMAP_ENTRY_ITEM;
|
||||
out->i_base.e_hash = name_hash;
|
||||
out->i_name = b_strdup(name);
|
||||
out->i_name = fx_strdup(name);
|
||||
if (!out->i_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -145,7 +145,7 @@ enum mie_status mie_attribute_map_put(
|
||||
struct mie_attribute_map *map, const char *name,
|
||||
const struct mie_attribute *value, enum mie_attribute_map_flags flags)
|
||||
{
|
||||
uint64_t name_hash = b_hash_cstr(name);
|
||||
uint64_t name_hash = fx_hash_cstr(name);
|
||||
struct attribute_map_entry *entry = get_entry(&map->m_entries, name_hash);
|
||||
struct attribute_map_item *item = NULL;
|
||||
struct attribute_map_bucket *bucket = NULL;
|
||||
@@ -184,7 +184,7 @@ enum mie_status mie_attribute_map_put(
|
||||
return MIE_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
b_queue_push_back(&bucket->b_items, &item->i_base.e_entry);
|
||||
fx_queue_push_back(&bucket->b_items, &item->i_base.e_entry);
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -192,13 +192,13 @@ enum mie_status mie_attribute_map_iterator_begin(
|
||||
struct mie_attribute_map_iterator *it, const struct mie_attribute_map *map)
|
||||
{
|
||||
memset(it, 0x0, sizeof *it);
|
||||
it->_n = b_btree_first(&map->m_entries);
|
||||
it->_n = fx_bst_first(&map->m_entries);
|
||||
if (!it->_n) {
|
||||
return MIE_ERR_NO_DATA;
|
||||
}
|
||||
|
||||
struct attribute_map_entry *entry
|
||||
= b_unbox(struct attribute_map_entry, it->_n, e_node);
|
||||
= fx_unbox(struct attribute_map_entry, it->_n, e_node);
|
||||
struct attribute_map_item *item = NULL;
|
||||
struct attribute_map_bucket *bucket = NULL;
|
||||
|
||||
@@ -210,8 +210,8 @@ enum mie_status mie_attribute_map_iterator_begin(
|
||||
return MIE_SUCCESS;
|
||||
case ATTRMAP_ENTRY_BUCKET:
|
||||
bucket = (struct attribute_map_bucket *)entry;
|
||||
it->_e = b_queue_first(&bucket->b_items);
|
||||
item = b_unbox(struct attribute_map_item, it->_e, i_base.e_entry);
|
||||
it->_e = fx_queue_first(&bucket->b_items);
|
||||
item = fx_unbox(struct attribute_map_item, it->_e, i_base.e_entry);
|
||||
it->it_name = item->i_name;
|
||||
it->it_value = item->i_value;
|
||||
return MIE_SUCCESS;
|
||||
@@ -228,11 +228,11 @@ enum mie_status mie_attribute_map_iterator_move_next(
|
||||
struct attribute_map_bucket *next_bucket = NULL;
|
||||
|
||||
if (it->_e) {
|
||||
it->_e = b_queue_next(it->_e);
|
||||
next_entry = b_unbox(struct attribute_map_entry, it->_e, e_entry);
|
||||
it->_e = fx_queue_next(it->_e);
|
||||
next_entry = fx_unbox(struct attribute_map_entry, it->_e, e_entry);
|
||||
} else if (it->_n) {
|
||||
it->_n = b_btree_next(it->_n);
|
||||
next_entry = b_unbox(struct attribute_map_entry, it->_n, e_node);
|
||||
it->_n = fx_bst_next(it->_n);
|
||||
next_entry = fx_unbox(struct attribute_map_entry, it->_n, e_node);
|
||||
} else {
|
||||
memset(it, 0x0, sizeof *it);
|
||||
return MIE_ERR_NO_DATA;
|
||||
@@ -249,8 +249,8 @@ enum mie_status mie_attribute_map_iterator_move_next(
|
||||
break;
|
||||
case ATTRMAP_ENTRY_BUCKET:
|
||||
next_bucket = (struct attribute_map_bucket *)next_item;
|
||||
it->_e = b_queue_first(&next_bucket->b_items);
|
||||
next_item = b_unbox(
|
||||
it->_e = fx_queue_first(&next_bucket->b_items);
|
||||
next_item = fx_unbox(
|
||||
struct attribute_map_item, it->_e, i_base.e_entry);
|
||||
break;
|
||||
default:
|
||||
|
||||
76
mie/ctx.c
76
mie/ctx.c
@@ -1,7 +1,7 @@
|
||||
#include <blue/core/bstr.h>
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <blue/ds/list.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <fx/ds/hashmap.h>
|
||||
#include <fx/ds/list.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/diag/class.h>
|
||||
@@ -140,123 +140,123 @@ bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op)
|
||||
|
||||
struct mie_dialect *mie_ctx_get_dialect(const struct mie_ctx *ctx, const char *name)
|
||||
{
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&ctx->ctx_dialects), &name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_dialects, &id);
|
||||
return b_unbox(struct mie_dialect, target, d_id);
|
||||
return fx_unbox(struct mie_dialect, target, d_id);
|
||||
}
|
||||
|
||||
const struct mie_op_definition *mie_ctx_get_op_definition(
|
||||
const struct mie_ctx *ctx, const char *dialect_name, const char *op_name)
|
||||
{
|
||||
b_rope dialect_name_rope = B_ROPE_CSTR(dialect_name);
|
||||
fx_rope dialect_name_rope = FX_ROPE_CSTR(dialect_name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&ctx->ctx_dialects), &dialect_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_dialects, &id);
|
||||
struct mie_dialect *dialect = b_unbox(struct mie_dialect, target, d_id);
|
||||
struct mie_dialect *dialect = fx_unbox(struct mie_dialect, target, d_id);
|
||||
if (!dialect) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope op_name_rope = B_ROPE_CSTR(op_name);
|
||||
fx_rope op_name_rope = FX_ROPE_CSTR(op_name);
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_ops), &op_name_rope);
|
||||
target = mie_id_map_get(&dialect->d_ops, &id);
|
||||
|
||||
return b_unbox(struct mie_op_definition, target, op_id);
|
||||
return fx_unbox(struct mie_op_definition, target, op_id);
|
||||
}
|
||||
|
||||
struct mie_type_definition *mie_ctx_get_type_definition(
|
||||
const struct mie_ctx *ctx, const char *dialect_name, const char *type_name)
|
||||
{
|
||||
b_rope dialect_name_rope = B_ROPE_CSTR(dialect_name);
|
||||
fx_rope dialect_name_rope = FX_ROPE_CSTR(dialect_name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&ctx->ctx_dialects), &dialect_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_dialects, &id);
|
||||
struct mie_dialect *dialect = b_unbox(struct mie_dialect, target, d_id);
|
||||
struct mie_dialect *dialect = fx_unbox(struct mie_dialect, target, d_id);
|
||||
if (!dialect) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope type_name_rope = B_ROPE_CSTR(type_name);
|
||||
fx_rope type_name_rope = FX_ROPE_CSTR(type_name);
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_types), &type_name_rope);
|
||||
target = mie_id_map_get(&dialect->d_types, &id);
|
||||
|
||||
return b_unbox(struct mie_type_definition, target, ty_id);
|
||||
return fx_unbox(struct mie_type_definition, target, ty_id);
|
||||
}
|
||||
|
||||
const struct mie_trait_definition *mie_ctx_get_trait_definition(
|
||||
const struct mie_ctx *ctx, const char *dialect_name, const char *trait_name)
|
||||
{
|
||||
b_rope dialect_name_rope = B_ROPE_CSTR(dialect_name);
|
||||
fx_rope dialect_name_rope = FX_ROPE_CSTR(dialect_name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&ctx->ctx_dialects), &dialect_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_dialects, &id);
|
||||
struct mie_dialect *dialect = b_unbox(struct mie_dialect, target, d_id);
|
||||
struct mie_dialect *dialect = fx_unbox(struct mie_dialect, target, d_id);
|
||||
if (!dialect) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope trait_name_rope = B_ROPE_CSTR(trait_name);
|
||||
fx_rope trait_name_rope = FX_ROPE_CSTR(trait_name);
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_traits), &trait_name_rope);
|
||||
target = mie_id_map_get(&dialect->d_traits, &id);
|
||||
|
||||
return b_unbox(struct mie_trait_definition, target, tr_id);
|
||||
return fx_unbox(struct mie_trait_definition, target, tr_id);
|
||||
}
|
||||
|
||||
const struct mie_attribute_definition *mie_ctx_get_attribute_definition(
|
||||
const struct mie_ctx *ctx, const char *dialect_name,
|
||||
const char *attribute_name)
|
||||
{
|
||||
b_rope dialect_name_rope = B_ROPE_CSTR(dialect_name);
|
||||
fx_rope dialect_name_rope = FX_ROPE_CSTR(dialect_name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&ctx->ctx_dialects), &dialect_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_dialects, &id);
|
||||
struct mie_dialect *dialect = b_unbox(struct mie_dialect, target, d_id);
|
||||
struct mie_dialect *dialect = fx_unbox(struct mie_dialect, target, d_id);
|
||||
if (!dialect) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope attribute_name_rope = B_ROPE_CSTR(attribute_name);
|
||||
fx_rope attribute_name_rope = FX_ROPE_CSTR(attribute_name);
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&dialect->d_attributes),
|
||||
&attribute_name_rope);
|
||||
target = mie_id_map_get(&dialect->d_attributes, &id);
|
||||
|
||||
return b_unbox(struct mie_attribute_definition, target, a_id);
|
||||
return fx_unbox(struct mie_attribute_definition, target, a_id);
|
||||
}
|
||||
|
||||
const struct mie_interface_definition *mie_ctx_get_interface_definition(
|
||||
const struct mie_ctx *ctx, const char *dialect_name,
|
||||
const char *interface_name)
|
||||
{
|
||||
b_rope dialect_name_rope = B_ROPE_CSTR(dialect_name);
|
||||
fx_rope dialect_name_rope = FX_ROPE_CSTR(dialect_name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&ctx->ctx_dialects), &dialect_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_dialects, &id);
|
||||
struct mie_dialect *dialect = b_unbox(struct mie_dialect, target, d_id);
|
||||
struct mie_dialect *dialect = fx_unbox(struct mie_dialect, target, d_id);
|
||||
if (!dialect) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope interface_name_rope = B_ROPE_CSTR(interface_name);
|
||||
fx_rope interface_name_rope = FX_ROPE_CSTR(interface_name);
|
||||
mie_id_init_ns(
|
||||
&id, mie_id_map_get_ns(&dialect->d_interfaces),
|
||||
&interface_name_rope);
|
||||
target = mie_id_map_get(&dialect->d_interfaces, &id);
|
||||
|
||||
return b_unbox(struct mie_interface_definition, target, if_id);
|
||||
return fx_unbox(struct mie_interface_definition, target, if_id);
|
||||
}
|
||||
|
||||
struct mie_type *mie_ctx_get_type(
|
||||
@@ -264,13 +264,13 @@ struct mie_type *mie_ctx_get_type(
|
||||
{
|
||||
char full_name[256];
|
||||
snprintf(full_name, sizeof full_name, "%s.%s", dialect_name, type_name);
|
||||
b_rope full_name_rope = B_ROPE_CSTR(full_name);
|
||||
fx_rope full_name_rope = FX_ROPE_CSTR(full_name);
|
||||
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&ctx->ctx_types), &full_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_types, &id);
|
||||
struct mie_type *type = b_unbox(struct mie_type, target, ty_id);
|
||||
struct mie_type *type = fx_unbox(struct mie_type, target, ty_id);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ struct mie_type *mie_ctx_get_type(
|
||||
memset(type, 0x0, sizeof *type);
|
||||
|
||||
type->ty_def = type_info;
|
||||
type->ty_name = b_bstr_fmt(NULL, "%s.%s", dialect_name, type_name);
|
||||
type->ty_name = fx_bstr_fmt(NULL, "%s.%s", dialect_name, type_name);
|
||||
|
||||
if (type_info->ty_init) {
|
||||
type_info->ty_init(type_info, type);
|
||||
@@ -311,13 +311,13 @@ const struct mie_trait *mie_ctx_get_trait(
|
||||
{
|
||||
char full_name[256];
|
||||
snprintf(full_name, sizeof full_name, "%s.%s", dialect_name, trait_name);
|
||||
b_rope full_name_rope = B_ROPE_CSTR(full_name);
|
||||
fx_rope full_name_rope = FX_ROPE_CSTR(full_name);
|
||||
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&ctx->ctx_traits), &full_name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_traits, &id);
|
||||
struct mie_trait *trait = b_unbox(struct mie_trait, target, tr_id);
|
||||
struct mie_trait *trait = fx_unbox(struct mie_trait, target, tr_id);
|
||||
if (trait) {
|
||||
return trait;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ const struct mie_trait *mie_ctx_get_trait(
|
||||
memset(trait, 0x0, sizeof trait_info->tr_data_size);
|
||||
|
||||
trait->tr_def = trait_info;
|
||||
trait->tr_name = b_bstr_fmt(NULL, "%s.%s", dialect_name, trait_name);
|
||||
trait->tr_name = fx_bstr_fmt(NULL, "%s.%s", dialect_name, trait_name);
|
||||
|
||||
if (trait_info->tr_init) {
|
||||
trait_info->tr_init(trait_info, trait);
|
||||
@@ -363,7 +363,7 @@ struct mie_type *mie_ctx_get_storage_type(
|
||||
mie_id_builder_end(&id_builder, &id);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_types, &id);
|
||||
struct mie_type *type = b_unbox(struct mie_type, target, ty_id);
|
||||
struct mie_type *type = fx_unbox(struct mie_type, target, ty_id);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
@@ -389,7 +389,7 @@ struct mie_type *mie_ctx_get_function_type(
|
||||
mie_id_builder_end(&id_builder, &id);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_types, &id);
|
||||
struct mie_type *type = b_unbox(struct mie_type, target, ty_id);
|
||||
struct mie_type *type = fx_unbox(struct mie_type, target, ty_id);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ enum mie_status mie_ctx_get_pass(
|
||||
}
|
||||
|
||||
struct mie_pass_definition *pass_def
|
||||
= b_unbox(struct mie_pass_definition, target, p_id);
|
||||
= fx_unbox(struct mie_pass_definition, target, p_id);
|
||||
|
||||
if (pass_def->p_data_size < sizeof(struct mie_pass)) {
|
||||
return MIE_ERR_BAD_STATE;
|
||||
@@ -511,17 +511,17 @@ struct mie_diag *mie_ctx_push_diag(
|
||||
diag->diag_parent = dialect;
|
||||
diag->diag_class = &dialect->d_diag_classes[diag_class];
|
||||
|
||||
b_queue_push_back(&ctx->ctx_diag, &diag->diag_entry);
|
||||
fx_queue_push_back(&ctx->ctx_diag, &diag->diag_entry);
|
||||
|
||||
return diag;
|
||||
}
|
||||
|
||||
struct mie_diag *mie_ctx_pop_diag(struct mie_ctx *ctx)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_pop_front(&ctx->ctx_diag);
|
||||
fx_queue_entry *entry = fx_queue_pop_front(&ctx->ctx_diag);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_diag, entry, diag_entry);
|
||||
return fx_unbox(struct mie_diag, entry, diag_entry);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/diag/amendment.h>
|
||||
#include <mie/diag/component.h>
|
||||
@@ -19,7 +19,7 @@ struct mie_diag_c_msg *diag_msg_create(const struct mie_diag_msg *content)
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->msg_base.c_type = MIE_DIAG_COMPONENT_MSG;
|
||||
out->msg_content = b_strdup(content->msg_content);
|
||||
out->msg_content = fx_strdup(content->msg_content);
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ void mie_diag_push_msg(
|
||||
return;
|
||||
}
|
||||
|
||||
b_queue_push_back(&diag->diag_components, &c_msg->msg_base.c_entry);
|
||||
fx_queue_push_back(&diag->diag_components, &c_msg->msg_base.c_entry);
|
||||
}
|
||||
|
||||
void mie_diag_push_string(struct mie_diag *diag, const char *str)
|
||||
@@ -103,9 +103,9 @@ void mie_diag_push_string(struct mie_diag *diag, const char *str)
|
||||
|
||||
memset(c_msg, 0x0, sizeof *c_msg);
|
||||
c_msg->msg_base.c_type = MIE_DIAG_COMPONENT_MSG;
|
||||
c_msg->msg_content = b_strdup(str);
|
||||
c_msg->msg_content = fx_strdup(str);
|
||||
|
||||
b_queue_push_back(&diag->diag_components, &c_msg->msg_base.c_entry);
|
||||
fx_queue_push_back(&diag->diag_components, &c_msg->msg_base.c_entry);
|
||||
}
|
||||
|
||||
void mie_diag_push_snippet(
|
||||
@@ -120,5 +120,5 @@ void mie_diag_push_snippet(
|
||||
return;
|
||||
}
|
||||
|
||||
b_queue_push_back(&diag->diag_components, &c_snippet->s_base.c_entry);
|
||||
fx_queue_push_back(&diag->diag_components, &c_snippet->s_base.c_entry);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef _DIAG_DIAG_H_
|
||||
#define _DIAG_DIAG_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/core/btree.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <stdlib.h>
|
||||
@@ -10,19 +10,19 @@ typedef union float_key {
|
||||
} float_key;
|
||||
|
||||
struct float_width_cache_entry {
|
||||
b_btree_node e_node;
|
||||
fx_bst_node e_node;
|
||||
float_key e_key;
|
||||
struct mie_float e_value;
|
||||
};
|
||||
|
||||
struct float_width_cache {
|
||||
b_btree_node c_node;
|
||||
fx_bst_node c_node;
|
||||
size_t c_width;
|
||||
b_btree c_floats;
|
||||
fx_bst c_floats;
|
||||
};
|
||||
|
||||
struct mie_float_cache {
|
||||
b_btree c_widths;
|
||||
fx_bst c_widths;
|
||||
};
|
||||
|
||||
static int float_key_compare(const float_key *a, const float_key *b)
|
||||
@@ -30,38 +30,38 @@ static int float_key_compare(const float_key *a, const float_key *b)
|
||||
return memcmp(a->i, b->i, sizeof a->i);
|
||||
}
|
||||
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct float_width_cache, c_node, c_width, put_width_cache);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct float_width_cache, size_t, c_node, c_width, get_width_cache);
|
||||
|
||||
void put_float(b_btree *tree, struct float_width_cache_entry *node)
|
||||
void put_float(fx_bst *tree, struct float_width_cache_entry *node)
|
||||
{
|
||||
if (!tree->b_root) {
|
||||
tree->b_root = &node->e_node;
|
||||
b_btree_insert_fixup(tree, &node->e_node);
|
||||
if (!tree->bst_root) {
|
||||
tree->bst_root = &node->e_node;
|
||||
fx_bst_insert_fixup(tree, &node->e_node);
|
||||
return;
|
||||
}
|
||||
|
||||
b_btree_node *cur = tree->b_root;
|
||||
fx_bst_node *cur = tree->bst_root;
|
||||
while (1) {
|
||||
struct float_width_cache_entry *cur_node
|
||||
= b_unbox(struct float_width_cache_entry, cur, e_node);
|
||||
b_btree_node *next = NULL;
|
||||
= fx_unbox(struct float_width_cache_entry, cur, e_node);
|
||||
fx_bst_node *next = NULL;
|
||||
int cmp = float_key_compare(&node->e_key, &cur_node->e_key);
|
||||
|
||||
if (cmp >= 0) {
|
||||
next = b_btree_right(cur);
|
||||
next = fx_bst_right(cur);
|
||||
|
||||
if (!next) {
|
||||
b_btree_put_right(cur, &node->e_node);
|
||||
fx_bst_put_right(cur, &node->e_node);
|
||||
break;
|
||||
}
|
||||
} else if (cmp < 0) {
|
||||
next = b_btree_left(cur);
|
||||
next = fx_bst_left(cur);
|
||||
|
||||
if (!next) {
|
||||
b_btree_put_left(cur, &node->e_node);
|
||||
fx_bst_put_left(cur, &node->e_node);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -71,20 +71,20 @@ void put_float(b_btree *tree, struct float_width_cache_entry *node)
|
||||
cur = next;
|
||||
}
|
||||
|
||||
b_btree_insert_fixup(tree, &node->e_node);
|
||||
fx_bst_insert_fixup(tree, &node->e_node);
|
||||
}
|
||||
|
||||
static struct float_width_cache_entry *get_float(const b_btree *tree, float_key key)
|
||||
static struct float_width_cache_entry *get_float(const fx_bst *tree, float_key key)
|
||||
{
|
||||
b_btree_node *cur = tree->b_root;
|
||||
fx_bst_node *cur = tree->bst_root;
|
||||
while (cur) {
|
||||
struct float_width_cache_entry *cur_node
|
||||
= b_unbox(struct float_width_cache_entry, cur, e_node);
|
||||
= fx_unbox(struct float_width_cache_entry, cur, e_node);
|
||||
int cmp = float_key_compare(&key, &cur_node->e_key);
|
||||
if (cmp > 0) {
|
||||
cur = b_btree_right(cur);
|
||||
cur = fx_bst_right(cur);
|
||||
} else if (cmp < 0) {
|
||||
cur = b_btree_left(cur);
|
||||
cur = fx_bst_left(cur);
|
||||
} else {
|
||||
return cur_node;
|
||||
}
|
||||
@@ -109,13 +109,13 @@ static struct float_width_cache *float_width_cache_create(size_t width)
|
||||
|
||||
static void float_width_cache_destroy(struct float_width_cache *cache)
|
||||
{
|
||||
b_btree_node *cur = b_btree_first(&cache->c_floats);
|
||||
fx_bst_node *cur = fx_bst_first(&cache->c_floats);
|
||||
while (cur) {
|
||||
b_btree_node *next = b_btree_next(cur);
|
||||
b_btree_delete(&cache->c_floats, cur);
|
||||
fx_bst_node *next = fx_bst_next(cur);
|
||||
fx_bst_delete(&cache->c_floats, cur);
|
||||
|
||||
struct float_width_cache_entry *entry
|
||||
= b_unbox(struct float_width_cache_entry, cur, e_node);
|
||||
= fx_unbox(struct float_width_cache_entry, cur, e_node);
|
||||
free(entry);
|
||||
|
||||
cur = next;
|
||||
@@ -170,13 +170,13 @@ struct mie_float_cache *mie_float_cache_create(void)
|
||||
|
||||
void mie_float_cache_destroy(struct mie_float_cache *cache)
|
||||
{
|
||||
b_btree_node *cur = b_btree_first(&cache->c_widths);
|
||||
fx_bst_node *cur = fx_bst_first(&cache->c_widths);
|
||||
while (cur) {
|
||||
b_btree_node *next = b_btree_next(cur);
|
||||
b_btree_delete(&cache->c_widths, cur);
|
||||
fx_bst_node *next = fx_bst_next(cur);
|
||||
fx_bst_delete(&cache->c_widths, cur);
|
||||
|
||||
struct float_width_cache *width_cache
|
||||
= b_unbox(struct float_width_cache, cur, c_node);
|
||||
= fx_unbox(struct float_width_cache, cur, c_node);
|
||||
float_width_cache_destroy(width_cache);
|
||||
|
||||
cur = next;
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
#include <blue/core/btree.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct int_width_cache_entry {
|
||||
b_btree_node e_node;
|
||||
fx_bst_node e_node;
|
||||
struct mie_int e_value;
|
||||
};
|
||||
|
||||
struct int_width_cache {
|
||||
b_btree_node c_node;
|
||||
fx_bst_node c_node;
|
||||
size_t c_width;
|
||||
b_btree c_ints;
|
||||
fx_bst c_ints;
|
||||
};
|
||||
|
||||
struct mie_int_cache {
|
||||
b_btree c_widths;
|
||||
fx_bst c_widths;
|
||||
};
|
||||
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct int_width_cache, c_node, c_width, put_width_cache);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct int_width_cache, size_t, c_node, c_width, get_width_cache);
|
||||
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct int_width_cache_entry, e_node, e_value.i_val.v_small, put_int);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct int_width_cache_entry, uint64_t, e_node, e_value.i_val.v_small,
|
||||
get_int);
|
||||
|
||||
@@ -46,13 +46,13 @@ static struct int_width_cache *int_width_cache_create(size_t width)
|
||||
|
||||
static void int_width_cache_destroy(struct int_width_cache *cache)
|
||||
{
|
||||
b_btree_node *cur = b_btree_first(&cache->c_ints);
|
||||
fx_bst_node *cur = fx_bst_first(&cache->c_ints);
|
||||
while (cur) {
|
||||
b_btree_node *next = b_btree_next(cur);
|
||||
b_btree_delete(&cache->c_ints, cur);
|
||||
fx_bst_node *next = fx_bst_next(cur);
|
||||
fx_bst_delete(&cache->c_ints, cur);
|
||||
|
||||
struct int_width_cache_entry *entry
|
||||
= b_unbox(struct int_width_cache_entry, cur, e_node);
|
||||
= fx_unbox(struct int_width_cache_entry, cur, e_node);
|
||||
free(entry);
|
||||
|
||||
cur = next;
|
||||
@@ -96,13 +96,13 @@ struct mie_int_cache *mie_int_cache_create(void)
|
||||
|
||||
void mie_int_cache_destroy(struct mie_int_cache *cache)
|
||||
{
|
||||
b_btree_node *cur = b_btree_first(&cache->c_widths);
|
||||
fx_bst_node *cur = fx_bst_first(&cache->c_widths);
|
||||
while (cur) {
|
||||
b_btree_node *next = b_btree_next(cur);
|
||||
b_btree_delete(&cache->c_widths, cur);
|
||||
fx_bst_node *next = fx_bst_next(cur);
|
||||
fx_bst_delete(&cache->c_widths, cur);
|
||||
|
||||
struct int_width_cache *width_cache
|
||||
= b_unbox(struct int_width_cache, cur, c_node);
|
||||
= fx_unbox(struct int_width_cache, cur, c_node);
|
||||
int_width_cache_destroy(width_cache);
|
||||
|
||||
cur = next;
|
||||
|
||||
@@ -17,11 +17,11 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
const struct mie_op_arg *left = &op->op_args.items[0];
|
||||
const struct mie_op_arg *right = &op->op_args.items[1];
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_op_arg(printer, left, false);
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
mie_printer_print_op_arg(printer, right, false);
|
||||
b_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
mie_printer_print_type(printer, mie_op_arg_get_type(left));
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -19,11 +19,11 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
const struct mie_op_arg *left = &op->op_args.items[0];
|
||||
const struct mie_op_arg *right = &op->op_args.items[1];
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_op_arg(printer, left, false);
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
mie_printer_print_op_arg(printer, right, false);
|
||||
b_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
mie_printer_print_type(printer, mie_op_arg_get_type(left));
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -47,19 +47,19 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
|
||||
if (pred < 0 || pred >= nr_predicates) {
|
||||
return MIE_ERR_BAD_STATE;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, predicates[pred], NULL);
|
||||
fx_stream_write_string(printer->p_stream, predicates[pred], NULL);
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_op_arg(printer, left, false);
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
mie_printer_print_op_arg(printer, right, false);
|
||||
b_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
mie_printer_print_type(printer, mie_op_arg_get_type(left));
|
||||
|
||||
return MIE_SUCCESS;
|
||||
@@ -79,14 +79,14 @@ static enum mie_status parse(
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
b_string *tmp = mie_parser_get_tempstr(parser);
|
||||
fx_string *tmp = mie_parser_get_tempstr(parser);
|
||||
if (!mie_parser_parse_word(parser, tmp, &span)) {
|
||||
mie_parser_report_unexpected_token_s(
|
||||
parser, "predicate word", "comparison operation");
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
int pred = find_predicate(b_string_ptr(tmp));
|
||||
int pred = find_predicate(fx_string_ptr(tmp));
|
||||
if (pred == -1) {
|
||||
struct mie_diag *diag = mie_parser_report_error_simple(
|
||||
parser, "arith", MIE_ARITH_E_INVALID_COMPARISON_PREDICATE,
|
||||
|
||||
@@ -21,14 +21,14 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
const struct mie_type *type = NULL;
|
||||
if (mie_attribute_check_name(value, "builtin", "int")) {
|
||||
const struct mie_int *i = (const struct mie_int *)value;
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
printer->p_stream, NULL, " %lld : ", i->i_val.v_small);
|
||||
type = i->i_type;
|
||||
} else if (mie_attribute_check_name(value, "builtin", "float")) {
|
||||
const struct mie_float *f = (const struct mie_float *)value;
|
||||
double d;
|
||||
mie_float_get_value(value, &d);
|
||||
b_stream_write_fmt(printer->p_stream, NULL, " %g : ", d);
|
||||
fx_stream_write_fmt(printer->p_stream, NULL, " %g : ", d);
|
||||
type = f->f_type;
|
||||
} else {
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -13,27 +13,27 @@ static enum mie_status print(
|
||||
const struct mie_array *array = (const struct mie_array *)value;
|
||||
|
||||
if (!(out->p_flags & MIE_PRINT_F_ABBREVIATED)) {
|
||||
b_stream_write_string(out->p_stream, "#builtin.array<", NULL);
|
||||
fx_stream_write_string(out->p_stream, "#builtin.array<", NULL);
|
||||
}
|
||||
|
||||
b_stream_write_char(out->p_stream, '[');
|
||||
fx_stream_write_char(out->p_stream, '[');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(array->a_items); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_char(out->p_stream, ',');
|
||||
fx_stream_write_char(out->p_stream, ',');
|
||||
}
|
||||
|
||||
b_stream_write_char(out->p_stream, ' ');
|
||||
fx_stream_write_char(out->p_stream, ' ');
|
||||
mie_printer_print_attribute(out, array->a_items.items[i]);
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(array->a_items) != 0) {
|
||||
b_stream_write_char(out->p_stream, ' ');
|
||||
fx_stream_write_char(out->p_stream, ' ');
|
||||
}
|
||||
b_stream_write_char(out->p_stream, ']');
|
||||
fx_stream_write_char(out->p_stream, ']');
|
||||
|
||||
if (!(out->p_flags & MIE_PRINT_F_ABBREVIATED)) {
|
||||
b_stream_write_char(out->p_stream, '>');
|
||||
fx_stream_write_char(out->p_stream, '>');
|
||||
}
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../float.h"
|
||||
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/attribute/attribute.h>
|
||||
#include <mie/ctx.h>
|
||||
@@ -17,28 +17,28 @@ static enum mie_status print(
|
||||
const struct float_type *float_ty
|
||||
= (const struct float_type *)float_val->f_type;
|
||||
if (!(out->p_flags & MIE_PRINT_F_ABBREVIATED)) {
|
||||
b_stream_write_string(out->p_stream, "#builtin.float<", NULL);
|
||||
fx_stream_write_string(out->p_stream, "#builtin.float<", NULL);
|
||||
}
|
||||
|
||||
switch (float_ty->f_width) {
|
||||
case MIE_FLOAT_32:
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "%f : f%zu", float_val->f_val.v_32,
|
||||
float_ty->f_width);
|
||||
break;
|
||||
case MIE_FLOAT_64:
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "%lf : f%zu",
|
||||
float_val->f_val.v_64, float_ty->f_width);
|
||||
break;
|
||||
default:
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "NaN : f%zu", float_ty->f_width);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(out->p_flags & MIE_PRINT_F_ABBREVIATED)) {
|
||||
b_stream_write_string(out->p_stream, ">", NULL);
|
||||
fx_stream_write_string(out->p_stream, ">", NULL);
|
||||
}
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../int.h"
|
||||
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/attribute/attribute.h>
|
||||
#include <mie/ctx.h>
|
||||
@@ -18,32 +18,32 @@ static enum mie_status print(
|
||||
bool abbrev = ((out->p_flags & MIE_PRINT_F_ABBREVIATED) != 0);
|
||||
|
||||
if (!abbrev) {
|
||||
b_stream_write_string(out->p_stream, "#builtin.int<", NULL);
|
||||
fx_stream_write_string(out->p_stream, "#builtin.int<", NULL);
|
||||
}
|
||||
|
||||
if (int_ty->i_width <= 64) {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "%zu", int_val->i_val.v_small,
|
||||
int_ty->i_width);
|
||||
} else {
|
||||
b_stream_write_fmt(out->p_stream, NULL, "INF", int_ty->i_width);
|
||||
fx_stream_write_fmt(out->p_stream, NULL, "INF", int_ty->i_width);
|
||||
}
|
||||
|
||||
if (int_ty->i_width != 64 || !abbrev) {
|
||||
b_stream_write_string(out->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(out->p_stream, " : ", NULL);
|
||||
|
||||
if (abbrev) {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "i%zu", int_ty->i_width);
|
||||
} else {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "!builtin.int<%zu>",
|
||||
int_ty->i_width);
|
||||
}
|
||||
}
|
||||
|
||||
if (!abbrev) {
|
||||
b_stream_write_string(out->p_stream, ">", NULL);
|
||||
fx_stream_write_string(out->p_stream, ">", NULL);
|
||||
}
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -11,9 +11,9 @@ static enum mie_status print(
|
||||
{
|
||||
const struct mie_string *str = (const struct mie_string *)value;
|
||||
if (out->p_flags & MIE_PRINT_F_ABBREVIATED) {
|
||||
b_stream_write_fmt(out->p_stream, NULL, "\"%s\"", str->str_val);
|
||||
fx_stream_write_fmt(out->p_stream, NULL, "\"%s\"", str->str_val);
|
||||
} else {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "#builtin.string<\"%s\">",
|
||||
str->str_val);
|
||||
}
|
||||
@@ -23,14 +23,14 @@ static enum mie_status print(
|
||||
static enum mie_status parse(
|
||||
struct mie_parser *ctx, const struct mie_attribute **out)
|
||||
{
|
||||
b_string *str = mie_parser_get_tempstr(ctx);
|
||||
fx_string *str = mie_parser_get_tempstr(ctx);
|
||||
struct mie_file_span span;
|
||||
if (!mie_parser_parse_string(ctx, str, &span)) {
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
struct mie_attribute *v = mie_ctx_get_string(
|
||||
mie_parser_get_mie_ctx(ctx), b_string_ptr(str));
|
||||
mie_parser_get_mie_ctx(ctx), fx_string_ptr(str));
|
||||
|
||||
if (!v) {
|
||||
return MIE_ERR_NO_MEMORY;
|
||||
|
||||
@@ -30,13 +30,13 @@ static enum mie_status print(
|
||||
const struct mie_type_attr *ty = (const struct mie_type_attr *)value;
|
||||
|
||||
if (!(out->p_flags & MIE_PRINT_F_ABBREVIATED)) {
|
||||
b_stream_write_string(out->p_stream, "#builtin.type<", NULL);
|
||||
fx_stream_write_string(out->p_stream, "#builtin.type<", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(out, ty->ty_value);
|
||||
|
||||
if (!(out->p_flags & MIE_PRINT_F_ABBREVIATED)) {
|
||||
b_stream_write_char(out->p_stream, '>');
|
||||
fx_stream_write_char(out->p_stream, '>');
|
||||
}
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -31,6 +31,7 @@ MIE_DIAG_CLASS_LIST_END(mie_builtin_diag)
|
||||
|
||||
MIE_DIAG_MSG_LIST_BEGIN(mie_builtin_msg)
|
||||
MIE_DIAG_MSG(UNRECOGNISED_TOKEN, "encountered an unrecognised token.")
|
||||
MIE_DIAG_MSG(UNEXPECTED_TOKEN, "encountered an unexpected token.")
|
||||
MIE_DIAG_MSG(UNRESOLVED_VALUE, "cannot resolve this value reference.")
|
||||
MIE_DIAG_MSG(
|
||||
UNRESOLVED_BUILTIN_TYPE,
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include <blue/core/btree.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct index_cache_entry {
|
||||
b_btree_node e_node;
|
||||
fx_bst_node e_node;
|
||||
struct mie_index e_value;
|
||||
};
|
||||
|
||||
struct mie_index_cache {
|
||||
b_btree c_entries;
|
||||
fx_bst c_entries;
|
||||
};
|
||||
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct index_cache_entry, e_node, e_value.i_value, put_index);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct index_cache_entry, size_t, e_node, e_value.i_value, get_index);
|
||||
|
||||
static struct index_cache_entry *index_cache_entry_create(
|
||||
@@ -48,13 +48,13 @@ struct mie_index_cache *mie_index_cache_create(void)
|
||||
|
||||
void mie_index_cache_destroy(struct mie_index_cache *cache)
|
||||
{
|
||||
b_btree_node *cur = b_btree_first(&cache->c_entries);
|
||||
fx_bst_node *cur = fx_bst_first(&cache->c_entries);
|
||||
while (cur) {
|
||||
b_btree_node *next = b_btree_next(cur);
|
||||
b_btree_delete(&cache->c_entries, cur);
|
||||
fx_bst_node *next = fx_bst_next(cur);
|
||||
fx_bst_delete(&cache->c_entries, cur);
|
||||
|
||||
struct index_cache_entry *entry
|
||||
= b_unbox(struct index_cache_entry, cur, e_node);
|
||||
= fx_unbox(struct index_cache_entry, cur, e_node);
|
||||
free(entry);
|
||||
|
||||
cur = next;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
static enum mie_status print(struct mie_printer *out, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(out->p_stream, ' ');
|
||||
fx_stream_write_char(out->p_stream, ' ');
|
||||
|
||||
struct mie_region *region = mie_op_get_first_region(op);
|
||||
if (region) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/ds/hashmap.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct mie_string_cache {
|
||||
b_hashmap *c_entries;
|
||||
fx_hashmap *c_entries;
|
||||
};
|
||||
|
||||
static struct mie_string *mie_string_create(
|
||||
@@ -19,7 +19,7 @@ static struct mie_string *mie_string_create(
|
||||
|
||||
out->str_base.a_def
|
||||
= mie_ctx_get_attribute_definition(ctx, "builtin", "string");
|
||||
out->str_val = b_strdup(s);
|
||||
out->str_val = fx_strdup(s);
|
||||
if (!out->str_val) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -42,8 +42,8 @@ struct mie_string_cache *mie_string_cache_create(void)
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->c_entries = b_hashmap_create(
|
||||
NULL, (b_hashmap_value_destructor)mie_string_destroy);
|
||||
out->c_entries = fx_hashmap_create(
|
||||
NULL, (fx_hashmap_value_destructor)mie_string_destroy);
|
||||
if (!out->c_entries) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -54,7 +54,7 @@ struct mie_string_cache *mie_string_cache_create(void)
|
||||
|
||||
void mie_string_cache_destroy(struct mie_string_cache *cache)
|
||||
{
|
||||
b_hashmap_unref(cache->c_entries);
|
||||
fx_hashmap_unref(cache->c_entries);
|
||||
free(cache);
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ struct mie_string *mie_string_cache_get(
|
||||
struct mie_string_cache *cache, struct mie_ctx *ctx, const char *s)
|
||||
{
|
||||
size_t s_len = strlen(s);
|
||||
b_hashmap_key key = {.key_data = s, .key_size = s_len};
|
||||
const b_hashmap_value *value = b_hashmap_get(cache->c_entries, &key);
|
||||
fx_hashmap_key key = {.key_data = s, .key_size = s_len};
|
||||
const fx_hashmap_value *value = fx_hashmap_get(cache->c_entries, &key);
|
||||
if (value) {
|
||||
return value->value_data;
|
||||
}
|
||||
@@ -73,8 +73,8 @@ struct mie_string *mie_string_cache_get(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_hashmap_value new_val = {.value_data = str, .value_size = sizeof *str};
|
||||
b_hashmap_put(cache->c_entries, &key, &new_val);
|
||||
fx_hashmap_value new_val = {.value_data = str, .value_size = sizeof *str};
|
||||
fx_hashmap_put(cache->c_entries, &key, &new_val);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../float.h"
|
||||
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
@@ -17,16 +17,16 @@ struct mie_type *mie_ctx_get_float_type(struct mie_ctx *ctx, size_t bit_width)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope rope_i = B_ROPE_CHAR('f'), rope_width = B_ROPE_UINT(bit_width);
|
||||
b_rope type_name;
|
||||
b_rope_concat(&type_name, &rope_i, &rope_width);
|
||||
fx_rope rope_i = FX_ROPE_CHAR('f'), rope_width = FX_ROPE_UINT(bit_width);
|
||||
fx_rope type_name;
|
||||
fx_rope_concat(&type_name, &rope_i, &rope_width);
|
||||
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&ctx->ctx_types), &type_name);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_types, &id);
|
||||
if (target) {
|
||||
return b_unbox(struct mie_type, target, ty_id);
|
||||
return fx_unbox(struct mie_type, target, ty_id);
|
||||
}
|
||||
|
||||
struct float_type *type = (struct float_type *)mie_type_create(type_info);
|
||||
@@ -34,7 +34,7 @@ struct mie_type *mie_ctx_get_float_type(struct mie_ctx *ctx, size_t bit_width)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
type->f_base.ty_name = b_bstr_fmt(NULL, "builtin.float<%zu>", bit_width);
|
||||
type->f_base.ty_name = fx_bstr_fmt(NULL, "builtin.float<%zu>", bit_width);
|
||||
type->f_base.ty_instance_size = sizeof(struct mie_float);
|
||||
type->f_width = bit_width;
|
||||
|
||||
@@ -59,7 +59,7 @@ size_t mie_float_type_get_width(const struct mie_type *type)
|
||||
static enum mie_status print(const struct mie_type *ty, struct mie_printer *out)
|
||||
{
|
||||
const struct float_type *float_type = (const struct float_type *)ty;
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL,
|
||||
(out->p_flags & MIE_PRINT_F_ABBREVIATED) ? "f%zu" : "!builtin.float<%zu>",
|
||||
float_type->f_width);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../int.h"
|
||||
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
@@ -17,16 +17,16 @@ struct mie_type *mie_ctx_get_int_type(struct mie_ctx *ctx, size_t bit_width)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_rope rope_i = B_ROPE_CHAR('i'), rope_width = B_ROPE_UINT(bit_width);
|
||||
b_rope type_name;
|
||||
b_rope_concat(&type_name, &rope_i, &rope_width);
|
||||
fx_rope rope_i = FX_ROPE_CHAR('i'), rope_width = FX_ROPE_UINT(bit_width);
|
||||
fx_rope type_name;
|
||||
fx_rope_concat(&type_name, &rope_i, &rope_width);
|
||||
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&ctx->ctx_types), &type_name);
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_types, &id);
|
||||
if (target) {
|
||||
return b_unbox(struct mie_type, target, ty_id);
|
||||
return fx_unbox(struct mie_type, target, ty_id);
|
||||
}
|
||||
|
||||
struct int_type *type = (struct int_type *)mie_type_create(type_info);
|
||||
@@ -34,7 +34,7 @@ struct mie_type *mie_ctx_get_int_type(struct mie_ctx *ctx, size_t bit_width)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
type->i_base.ty_name = b_bstr_fmt(NULL, "builtin.int<%zu>", bit_width);
|
||||
type->i_base.ty_name = fx_bstr_fmt(NULL, "builtin.int<%zu>", bit_width);
|
||||
type->i_base.ty_instance_size = sizeof(struct mie_int);
|
||||
type->i_width = bit_width;
|
||||
|
||||
@@ -59,7 +59,7 @@ size_t mie_int_type_get_width(const struct mie_type *type)
|
||||
static enum mie_status print(const struct mie_type *ty, struct mie_printer *out)
|
||||
{
|
||||
const struct int_type *int_type = (const struct int_type *)ty;
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL,
|
||||
(out->p_flags & MIE_PRINT_F_ABBREVIATED) ? "i%zu"
|
||||
: "!builtin.int<%zu>",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
@@ -48,7 +48,7 @@ struct mie_type *mie_ctx_get_memref_type(
|
||||
|
||||
mie_id *target = mie_id_map_get(&ctx->ctx_types, &id);
|
||||
if (target) {
|
||||
return b_unbox(struct mie_type, target, ty_id);
|
||||
return fx_unbox(struct mie_type, target, ty_id);
|
||||
}
|
||||
|
||||
struct memref_type *type
|
||||
@@ -57,40 +57,40 @@ struct mie_type *mie_ctx_get_memref_type(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_bstr type_name;
|
||||
b_bstr_begin_dynamic(&type_name);
|
||||
b_bstr_write_cstr(&type_name, "builtin.memref<", NULL);
|
||||
fx_bstr type_name;
|
||||
fx_bstr_begin_dynamic(&type_name);
|
||||
fx_bstr_write_cstr(&type_name, "builtin.memref<", NULL);
|
||||
|
||||
struct mie_printer printer;
|
||||
mie_printer_init(
|
||||
&printer, ctx, (b_stream *)&type_name, MIE_PRINT_F_ABBREVIATED);
|
||||
&printer, ctx, (fx_stream *)&type_name, MIE_PRINT_F_ABBREVIATED);
|
||||
|
||||
for (size_t i = 0; i < nr_ranks; i++) {
|
||||
mie_vector_push_back(type->m_rank, &ranks[i], NULL);
|
||||
|
||||
if (i > 0) {
|
||||
b_bstr_write_char(&type_name, '*');
|
||||
fx_bstr_write_char(&type_name, '*');
|
||||
}
|
||||
|
||||
switch (ranks[i].r_ranktype) {
|
||||
case MIE_MEMREF_RANK_UNKNOWN:
|
||||
b_bstr_write_char(&type_name, '?');
|
||||
fx_bstr_write_char(&type_name, '?');
|
||||
break;
|
||||
case MIE_MEMREF_RANK_TYPE:
|
||||
mie_printer_print_type(&printer, ranks[i].r_type);
|
||||
break;
|
||||
case MIE_MEMREF_RANK_STATIC:
|
||||
b_bstr_write_fmt(&type_name, NULL, "%zu", ranks[i].r_static);
|
||||
fx_bstr_write_fmt(&type_name, NULL, "%zu", ranks[i].r_static);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
b_bstr_write_char(&type_name, '>');
|
||||
type->m_base.ty_name = b_bstr_end(&type_name);
|
||||
fx_bstr_write_char(&type_name, '>');
|
||||
type->m_base.ty_name = fx_bstr_end(&type_name);
|
||||
type->m_base.ty_instance_size = 0;
|
||||
b_rope name_rope = B_ROPE_CSTR(type->m_base.ty_name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(type->m_base.ty_name);
|
||||
|
||||
mie_id_map_put(&ctx->ctx_types, &type->m_base.ty_id, &name_rope);
|
||||
return (struct mie_type *)type;
|
||||
@@ -104,36 +104,36 @@ static void type_init(
|
||||
static enum mie_status print(const struct mie_type *ty, struct mie_printer *out)
|
||||
{
|
||||
const struct memref_type *memref_ty = (const struct memref_type *)ty;
|
||||
b_stream_write_string(
|
||||
fx_stream_write_string(
|
||||
out->p_stream,
|
||||
(out->p_flags & MIE_PRINT_F_ABBREVIATED) ? "memref"
|
||||
: "builtin.memref",
|
||||
NULL);
|
||||
|
||||
b_stream_write_char(out->p_stream, '<');
|
||||
fx_stream_write_char(out->p_stream, '<');
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(memref_ty->m_rank); i++) {
|
||||
const struct mie_memref_rank *rank = &memref_ty->m_rank.items[i];
|
||||
|
||||
if (i > 0) {
|
||||
b_stream_write_char(out->p_stream, '*');
|
||||
fx_stream_write_char(out->p_stream, '*');
|
||||
}
|
||||
|
||||
switch (rank->r_ranktype) {
|
||||
case MIE_MEMREF_RANK_UNKNOWN:
|
||||
b_stream_write_char(out->p_stream, '?');
|
||||
fx_stream_write_char(out->p_stream, '?');
|
||||
break;
|
||||
case MIE_MEMREF_RANK_TYPE:
|
||||
mie_printer_print_type(out, rank->r_type);
|
||||
break;
|
||||
case MIE_MEMREF_RANK_STATIC:
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
out->p_stream, NULL, "%zu", rank->r_static);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
b_stream_write_char(out->p_stream, '>');
|
||||
fx_stream_write_char(out->p_stream, '>');
|
||||
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
@@ -15,7 +15,7 @@ static void type_init(
|
||||
|
||||
static enum mie_status print(const struct mie_type *ty, struct mie_printer *out)
|
||||
{
|
||||
b_stream_write_string(
|
||||
fx_stream_write_string(
|
||||
out->p_stream,
|
||||
(out->p_flags & MIE_PRINT_F_ABBREVIATED) ? "str" : "!builtin.string",
|
||||
NULL);
|
||||
|
||||
@@ -21,11 +21,11 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
const struct mie_op_successor *if_true = &op->op_successors.items[0];
|
||||
const struct mie_op_successor *if_false = &op->op_successors.items[1];
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_op_arg(printer, cond, false);
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
mie_printer_print_op_successor(printer, if_true, true);
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
mie_printer_print_op_successor(printer, if_false, true);
|
||||
|
||||
return MIE_SUCCESS;
|
||||
@@ -34,7 +34,7 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
static bool parse_successor(struct mie_parser *ctx, struct mie_op_successor *out)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_string *str = mie_parser_get_tempstr(ctx);
|
||||
fx_string *str = mie_parser_get_tempstr(ctx);
|
||||
bool result = false;
|
||||
|
||||
if (!mie_parser_parse_blockname(ctx, str, &out->s_name_span)) {
|
||||
@@ -43,7 +43,7 @@ static bool parse_successor(struct mie_parser *ctx, struct mie_op_successor *out
|
||||
return false;
|
||||
}
|
||||
|
||||
out->s_block_name = b_string_steal(str);
|
||||
out->s_block_name = fx_string_steal(str);
|
||||
|
||||
if (mie_parser_peek_type(ctx) == MIE_TOK_LINEFEED
|
||||
|| mie_parser_peek_symbol(ctx) == MIE_SYM_COMMA) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
static enum mie_status print(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
const struct mie_op_successor *successor = &op->op_successors.items[0];
|
||||
|
||||
mie_printer_print_op_successor(printer, successor, true);
|
||||
@@ -20,7 +20,7 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
static bool parse_successor(struct mie_parser *ctx, struct mie_op_successor *out)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_string *str = mie_parser_get_tempstr(ctx);
|
||||
fx_string *str = mie_parser_get_tempstr(ctx);
|
||||
bool result = false;
|
||||
|
||||
if (!mie_parser_parse_blockname(ctx, str, &out->s_name_span)) {
|
||||
@@ -29,7 +29,7 @@ static bool parse_successor(struct mie_parser *ctx, struct mie_op_successor *out
|
||||
return false;
|
||||
}
|
||||
|
||||
out->s_block_name = b_string_steal(str);
|
||||
out->s_block_name = fx_string_steal(str);
|
||||
|
||||
if (mie_parser_peek_type(ctx) == MIE_TOK_LINEFEED) {
|
||||
goto ok;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/ir/op-definition.h>
|
||||
@@ -37,7 +37,7 @@ struct mie_dialect *mie_dialect_create(
|
||||
|
||||
memset(out, 0x0, size);
|
||||
|
||||
out->d_name = b_strdup(name);
|
||||
out->d_name = fx_strdup(name);
|
||||
if (!out->d_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -58,7 +58,7 @@ struct mie_dialect *mie_dialect_create(
|
||||
mie_id interface_ns = INTERFACE_NS_ID;
|
||||
mie_id_map_init(&out->d_interfaces, &interface_ns);
|
||||
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id_map_put(&ctx->ctx_dialects, &out->d_id, &name_rope);
|
||||
|
||||
return out;
|
||||
@@ -67,21 +67,21 @@ struct mie_dialect *mie_dialect_create(
|
||||
const struct mie_op_definition *mie_dialect_get_op(
|
||||
const struct mie_dialect *dialect, const char *name)
|
||||
{
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_ops), &name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&dialect->d_ops, &id);
|
||||
return b_unbox(struct mie_op_definition, target, op_id);
|
||||
return fx_unbox(struct mie_op_definition, target, op_id);
|
||||
}
|
||||
|
||||
const struct mie_type_definition *mie_dialect_get_type(
|
||||
const struct mie_dialect *dialect, const char *name)
|
||||
{
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id id;
|
||||
mie_id_init_ns(&id, mie_id_map_get_ns(&dialect->d_types), &name_rope);
|
||||
|
||||
mie_id *target = mie_id_map_get(&dialect->d_types, &id);
|
||||
return b_unbox(struct mie_type_definition, target, ty_id);
|
||||
return fx_unbox(struct mie_type_definition, target, ty_id);
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
const struct mie_function_type *function_ty
|
||||
= (const struct mie_function_type *)function_type_g;
|
||||
|
||||
b_stream_write_fmt(printer->p_stream, NULL, " @%s(", sym_name_cstr);
|
||||
fx_stream_write_fmt(printer->p_stream, NULL, " @%s(", sym_name_cstr);
|
||||
|
||||
const struct mie_region *code = mie_op_get_first_region(op);
|
||||
const struct mie_block *entry = mie_region_get_first_block(code);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(entry->b_params); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
const struct mie_register *param = &entry->b_params.items[i];
|
||||
@@ -43,15 +43,15 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
mie_printer_print_register(printer, param, MIE_PRINT_F_INCLUDE_TYPE);
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, ") -> ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ") -> ", NULL);
|
||||
|
||||
if (MIE_VECTOR_COUNT(function_ty->func_out) != 1) {
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(function_ty->func_out); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
const struct mie_type *ty = function_ty->func_out.items[i];
|
||||
@@ -60,10 +60,10 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(function_ty->func_out) != 1) {
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
|
||||
mie_printer_print_region(
|
||||
printer, code, MIE_PRINT_F_EXCLUDE_FIRST_BLOCK_HEADER);
|
||||
@@ -107,7 +107,7 @@ static enum mie_status parse(
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
b_string *temp = mie_parser_get_tempstr(parser);
|
||||
fx_string *temp = mie_parser_get_tempstr(parser);
|
||||
if (!mie_parser_parse_symname(parser, temp, NULL)) {
|
||||
mie_parser_report_unexpected_token(
|
||||
parser, MIE_TOK_SYMNAME, "function signature");
|
||||
@@ -115,7 +115,7 @@ static enum mie_status parse(
|
||||
}
|
||||
|
||||
struct mie_attribute *sym_name = mie_ctx_get_string(
|
||||
mie_parser_get_mie_ctx(parser), b_string_ptr(temp));
|
||||
mie_parser_get_mie_ctx(parser), fx_string_ptr(temp));
|
||||
|
||||
if (!mie_parser_parse_symbol(parser, MIE_SYM_LEFT_PAREN)) {
|
||||
mie_parser_report_unexpected_token(
|
||||
|
||||
@@ -15,21 +15,21 @@
|
||||
|
||||
static enum mie_status print(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_op_arg(printer, &op->op_args.items[i], false);
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(
|
||||
|
||||
@@ -13,26 +13,26 @@
|
||||
|
||||
static enum mie_status print(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
const struct mie_type *memref_type = NULL;
|
||||
if (MIE_VECTOR_COUNT(op->op_args) > 0) {
|
||||
mie_printer_print_op_arg(printer, &op->op_args.items[0], false);
|
||||
memref_type = mie_op_arg_get_type(&op->op_args.items[0]);
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, '[');
|
||||
fx_stream_write_char(printer->p_stream, '[');
|
||||
|
||||
for (size_t i = 1; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 1) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_op_arg(printer, &op->op_args.items[i], false);
|
||||
}
|
||||
b_stream_write_char(printer->p_stream, ']');
|
||||
fx_stream_write_char(printer->p_stream, ']');
|
||||
|
||||
if (memref_type) {
|
||||
b_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
mie_printer_print_type(printer, memref_type);
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ static bool parse_param_name(
|
||||
struct mie_parser *ctx, struct mie_op_arg *out, const char *context)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_string *str = mie_parser_get_tempstr(ctx);
|
||||
fx_string *str = mie_parser_get_tempstr(ctx);
|
||||
|
||||
struct mie_file_span loc;
|
||||
if (mie_parser_parse_vregname(ctx, str, &loc)) {
|
||||
out->arg_unresolved.reg_name = b_string_steal(str);
|
||||
out->arg_unresolved.reg_name = fx_string_steal(str);
|
||||
out->arg_unresolved.reg_flags = MIE_REGISTER_F_VIRTUAL;
|
||||
} else if (mie_parser_parse_mregname(ctx, str, &loc)) {
|
||||
out->arg_unresolved.reg_name = b_string_steal(str);
|
||||
out->arg_unresolved.reg_name = fx_string_steal(str);
|
||||
out->arg_unresolved.reg_flags = MIE_REGISTER_F_MACHINE;
|
||||
} else {
|
||||
struct mie_parser_item required[] = {
|
||||
|
||||
@@ -40,35 +40,35 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
ub = &op->op_args.items[1];
|
||||
step = &op->op_args.items[2];
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_register(printer, iv, 0);
|
||||
b_stream_write_string(printer->p_stream, " = ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " = ", NULL);
|
||||
mie_printer_print_op_arg(printer, lb, 0);
|
||||
b_stream_write_string(printer->p_stream, " to ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " to ", NULL);
|
||||
mie_printer_print_op_arg(printer, ub, 0);
|
||||
b_stream_write_string(printer->p_stream, " step ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " step ", NULL);
|
||||
mie_printer_print_op_arg(printer, step, 0);
|
||||
|
||||
if (MIE_VECTOR_COUNT(entry->b_params) > 1) {
|
||||
b_stream_write_string(printer->p_stream, " iter-args(", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " iter-args(", NULL);
|
||||
for (size_t i = 1; i < MIE_VECTOR_COUNT(entry->b_params); i++) {
|
||||
if (i > 1) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_register(
|
||||
printer, &entry->b_params.items[i], 0);
|
||||
b_stream_write_string(printer->p_stream, " = ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " = ", NULL);
|
||||
mie_printer_print_op_arg(
|
||||
printer, &op->op_args.items[i + 2], false);
|
||||
}
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 0) {
|
||||
b_stream_write_string(printer->p_stream, " -> ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " -> ", NULL);
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 1) {
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_result); i++) {
|
||||
@@ -77,11 +77,11 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 1) {
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
}
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_region(
|
||||
printer, body, MIE_PRINT_F_EXCLUDE_FIRST_BLOCK_HEADER);
|
||||
|
||||
|
||||
@@ -8,30 +8,30 @@
|
||||
|
||||
static enum mie_status print(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
mie_printer_print_op_arg(printer, &op->op_args.items[0], false);
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 0) {
|
||||
b_stream_write_string(printer->p_stream, " -> ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " -> ", NULL);
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 1) {
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_result); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(printer, op->op_result.items[i].reg_type);
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 1) {
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
|
||||
struct mie_region *if_region = mie_op_get_first_region(op);
|
||||
struct mie_region *else_region = mie_op_get_next_region(op, if_region);
|
||||
@@ -39,7 +39,7 @@ static enum mie_status print(struct mie_printer *printer, const struct mie_op *o
|
||||
mie_printer_print_region(printer, if_region, 0);
|
||||
|
||||
if (else_region) {
|
||||
b_stream_write_string(printer->p_stream, " else ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " else ", NULL);
|
||||
mie_printer_print_region(printer, else_region, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,20 +9,20 @@
|
||||
|
||||
static enum mie_status print(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, ' ');
|
||||
fx_stream_write_char(printer->p_stream, ' ');
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_op_arg(printer, &op->op_args.items[i], false);
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : ", NULL);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(
|
||||
|
||||
90
mie/id.c
90
mie/id.c
@@ -1,7 +1,7 @@
|
||||
#include <blue/core/bstr.h>
|
||||
#include <blue/core/endian.h>
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/core/random.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <fx/core/endian.h>
|
||||
#include <fx/core/hash.h>
|
||||
#include <fx/core/random.h>
|
||||
#include <mie/id.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -10,18 +10,18 @@ static inline int id_memcmp(const uint8_t *a, const uint8_t *b)
|
||||
return memcmp(a, b, MIE_ID_NR_BYTES);
|
||||
}
|
||||
|
||||
static mie_id *get_id(const b_btree *tree, mie_id *key)
|
||||
static mie_id *get_id(const fx_bst *tree, mie_id *key)
|
||||
{
|
||||
b_btree_node *cur = tree->b_root;
|
||||
fx_bst_node *cur = tree->bst_root;
|
||||
while (cur) {
|
||||
mie_id *cur_node = b_unbox(mie_id, cur, e_node);
|
||||
mie_id *cur_node = fx_unbox(mie_id, cur, e_node);
|
||||
int cmp = memcmp(
|
||||
key->id_bytes, cur_node->id_bytes, sizeof key->id_bytes);
|
||||
|
||||
if (cmp > 0) {
|
||||
cur = b_btree_right(cur);
|
||||
cur = fx_bst_right(cur);
|
||||
} else if (cmp < 0) {
|
||||
cur = b_btree_left(cur);
|
||||
cur = fx_bst_left(cur);
|
||||
} else {
|
||||
return cur_node;
|
||||
}
|
||||
@@ -30,33 +30,33 @@ static mie_id *get_id(const b_btree *tree, mie_id *key)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void put_id(b_btree *tree, mie_id *node)
|
||||
void put_id(fx_bst *tree, mie_id *node)
|
||||
{
|
||||
if (!tree->b_root) {
|
||||
tree->b_root = &node->e_node;
|
||||
b_btree_insert_fixup(tree, &node->e_node);
|
||||
if (!tree->bst_root) {
|
||||
tree->bst_root = &node->e_node;
|
||||
fx_bst_insert_fixup(tree, &node->e_node);
|
||||
return;
|
||||
}
|
||||
|
||||
b_btree_node *cur = tree->b_root;
|
||||
fx_bst_node *cur = tree->bst_root;
|
||||
while (1) {
|
||||
mie_id *cur_node = b_unbox(mie_id, cur, e_node);
|
||||
b_btree_node *next = NULL;
|
||||
mie_id *cur_node = fx_unbox(mie_id, cur, e_node);
|
||||
fx_bst_node *next = NULL;
|
||||
int cmp = memcmp(
|
||||
node->id_bytes, cur_node->id_bytes, sizeof node->id_bytes);
|
||||
|
||||
if (cmp > 0) {
|
||||
next = b_btree_right(cur);
|
||||
next = fx_bst_right(cur);
|
||||
|
||||
if (!next) {
|
||||
b_btree_put_right(cur, &node->e_node);
|
||||
fx_bst_put_right(cur, &node->e_node);
|
||||
break;
|
||||
}
|
||||
} else if (cmp < 0) {
|
||||
next = b_btree_left(cur);
|
||||
next = fx_bst_left(cur);
|
||||
|
||||
if (!next) {
|
||||
b_btree_put_left(cur, &node->e_node);
|
||||
fx_bst_put_left(cur, &node->e_node);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -66,17 +66,17 @@ void put_id(b_btree *tree, mie_id *node)
|
||||
cur = next;
|
||||
}
|
||||
|
||||
b_btree_insert_fixup(tree, &node->e_node);
|
||||
fx_bst_insert_fixup(tree, &node->e_node);
|
||||
}
|
||||
|
||||
void mie_id_init(
|
||||
mie_id *out, uint32_t a, uint16_t b, uint16_t c, uint16_t d, uint64_t e)
|
||||
{
|
||||
b_i32 x_a = b_i32_htob(a);
|
||||
b_i16 x_b = b_i16_htob(b);
|
||||
b_i16 x_c = b_i16_htob(c);
|
||||
b_i16 x_d = b_i16_htob(d);
|
||||
b_i64 x_e = b_i64_htob(e);
|
||||
fx_i32 x_a = fx_i32_htob(a);
|
||||
fx_i16 x_b = fx_i16_htob(b);
|
||||
fx_i16 x_c = fx_i16_htob(c);
|
||||
fx_i16 x_d = fx_i16_htob(d);
|
||||
fx_i64 x_e = fx_i64_htob(e);
|
||||
|
||||
memcpy(&out->id_bytes[0], x_a.i_bytes, sizeof x_a.i_bytes);
|
||||
memcpy(&out->id_bytes[4], x_b.i_bytes, sizeof x_b.i_bytes);
|
||||
@@ -92,12 +92,12 @@ void mie_id_init_zero(mie_id *out)
|
||||
|
||||
void mie_id_init_random(mie_id *out)
|
||||
{
|
||||
b_random_ctx *random = b_random_global_ctx();
|
||||
b_random_next_bytes(
|
||||
fx_random_ctx *random = fx_random_global_ctx();
|
||||
fx_random_next_bytes(
|
||||
random, (unsigned char *)out->id_bytes, sizeof out->id_bytes);
|
||||
}
|
||||
|
||||
void mie_id_init_ns(mie_id *out, const mie_id *ns, const b_rope *name)
|
||||
void mie_id_init_ns(mie_id *out, const mie_id *ns, const fx_rope *name)
|
||||
{
|
||||
struct mie_id_builder ctx;
|
||||
mie_id_builder_begin(&ctx, ns);
|
||||
@@ -107,45 +107,45 @@ void mie_id_init_ns(mie_id *out, const mie_id *ns, const b_rope *name)
|
||||
|
||||
void mie_id_to_string(const mie_id *id, char *out, size_t max)
|
||||
{
|
||||
b_bstr str;
|
||||
b_bstr_begin(&str, out, max);
|
||||
fx_bstr str;
|
||||
fx_bstr_begin(&str, out, max);
|
||||
for (size_t i = 0; i < sizeof id->id_bytes; i++) {
|
||||
if (i == 4 || i == 6 || i == 8 || i == 10) {
|
||||
b_bstr_write_char(&str, '-');
|
||||
fx_bstr_write_char(&str, '-');
|
||||
}
|
||||
|
||||
b_bstr_write_fmt(&str, NULL, "%02x", id->id_bytes[i]);
|
||||
fx_bstr_write_fmt(&str, NULL, "%02x", id->id_bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void mie_id_builder_begin(struct mie_id_builder *builder, const mie_id *ns)
|
||||
{
|
||||
memset(builder, 0x0, sizeof *builder);
|
||||
b_hash_ctx_init(&builder->b_hash, B_HASH_SHA1);
|
||||
b_hash_ctx_update(&builder->b_hash, ns->id_bytes, sizeof ns->id_bytes);
|
||||
fx_hash_ctx_init(&builder->b_hash, FX_HASH_SHA1);
|
||||
fx_hash_ctx_update(&builder->b_hash, ns->id_bytes, sizeof ns->id_bytes);
|
||||
}
|
||||
|
||||
void mie_id_builder_add(struct mie_id_builder *builder, const void *p, size_t len)
|
||||
{
|
||||
b_hash_ctx_update(&builder->b_hash, p, len);
|
||||
fx_hash_ctx_update(&builder->b_hash, p, len);
|
||||
}
|
||||
|
||||
void mie_id_builder_add_rope(struct mie_id_builder *builder, const b_rope *rope)
|
||||
void mie_id_builder_add_rope(struct mie_id_builder *builder, const fx_rope *rope)
|
||||
{
|
||||
b_hash_ctx_update_rope(&builder->b_hash, rope);
|
||||
fx_hash_ctx_update_rope(&builder->b_hash, rope);
|
||||
}
|
||||
|
||||
void mie_id_builder_add_marker(
|
||||
struct mie_id_builder *builder, enum mie_id_builder_marker marker)
|
||||
{
|
||||
unsigned char c = marker;
|
||||
b_hash_ctx_update(&builder->b_hash, &c, sizeof c);
|
||||
fx_hash_ctx_update(&builder->b_hash, &c, sizeof c);
|
||||
}
|
||||
|
||||
void mie_id_builder_end(struct mie_id_builder *builder, mie_id *out)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_hash_ctx_finish(&builder->b_hash, out->id_bytes, sizeof out->id_bytes);
|
||||
fx_hash_ctx_finish(&builder->b_hash, out->id_bytes, sizeof out->id_bytes);
|
||||
|
||||
out->id_bytes[6] &= 0x0F;
|
||||
out->id_bytes[6] |= 0x50;
|
||||
@@ -166,7 +166,7 @@ const mie_id *mie_id_map_get_ns(const struct mie_id_map *map)
|
||||
return &map->map_ns_id;
|
||||
}
|
||||
|
||||
void mie_id_map_put(struct mie_id_map *map, mie_id *id, const b_rope *name)
|
||||
void mie_id_map_put(struct mie_id_map *map, mie_id *id, const fx_rope *name)
|
||||
{
|
||||
mie_id_init_ns(id, &map->map_ns_id, name);
|
||||
put_id(&map->map_entries, id);
|
||||
@@ -187,13 +187,13 @@ enum mie_status mie_id_map_iterator_begin(
|
||||
{
|
||||
memset(it, 0x0, sizeof *it);
|
||||
|
||||
it->_n = b_btree_first(&map->map_entries);
|
||||
it->_n = fx_bst_first(&map->map_entries);
|
||||
|
||||
if (!it->_n) {
|
||||
return MIE_ERR_NO_DATA;
|
||||
}
|
||||
|
||||
it->it_id = b_unbox(mie_id, it->_n, e_node);
|
||||
it->it_id = fx_unbox(mie_id, it->_n, e_node);
|
||||
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
@@ -205,13 +205,13 @@ enum mie_status mie_id_map_iterator_move_next(struct mie_id_map_iterator *it)
|
||||
return MIE_ERR_NO_DATA;
|
||||
}
|
||||
|
||||
it->_n = b_btree_next(it->_n);
|
||||
it->_n = fx_bst_next(it->_n);
|
||||
if (!it->_n) {
|
||||
it->it_id = NULL;
|
||||
return MIE_ERR_NO_DATA;
|
||||
}
|
||||
|
||||
it->it_id = b_unbox(mie_id, it->_n, e_node);
|
||||
it->it_id = fx_unbox(mie_id, it->_n, e_node);
|
||||
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef MIE_ATTRIBUTE_ATTRIBUTE_MAP_H_
|
||||
#define MIE_ATTRIBUTE_ATTRIBUTE_MAP_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
struct b_queue_entry;
|
||||
struct fx_queue_entry;
|
||||
|
||||
struct mie_attribute_map {
|
||||
b_btree m_entries;
|
||||
fx_bst m_entries;
|
||||
};
|
||||
|
||||
enum mie_attribute_map_flags {
|
||||
@@ -18,8 +18,8 @@ enum mie_attribute_map_flags {
|
||||
struct mie_attribute_map_iterator {
|
||||
const char *it_name;
|
||||
const struct mie_attribute *it_value;
|
||||
b_btree_node *_n;
|
||||
struct b_queue_entry *_e;
|
||||
fx_bst_node *_n;
|
||||
struct fx_queue_entry *_e;
|
||||
};
|
||||
|
||||
MIE_API void mie_attribute_map_init(struct mie_attribute_map *map);
|
||||
@@ -27,7 +27,7 @@ MIE_API void mie_attribute_map_cleanup(struct mie_attribute_map *map);
|
||||
|
||||
static inline bool mie_attribute_map_empty(const struct mie_attribute_map *map)
|
||||
{
|
||||
return b_btree_empty(&map->m_entries);
|
||||
return fx_bst_empty(&map->m_entries);
|
||||
}
|
||||
|
||||
MIE_API const struct mie_attribute *mie_attribute_map_get(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_CTX_H_
|
||||
#define MIE_CTX_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/ds/hashmap.h>
|
||||
#include <mie/id.h>
|
||||
|
||||
struct mie_op;
|
||||
@@ -21,8 +21,8 @@ struct mie_ctx {
|
||||
struct mie_const *ctx_true, *ctx_false;
|
||||
struct mie_value *ctx_null;
|
||||
struct mie_type *ctx_types[__MIE_TYPE_COUNT];
|
||||
b_hashmap *ctx_sel_cache;
|
||||
b_hashmap *ctx_string_cache;
|
||||
fx_hashmap *ctx_sel_cache;
|
||||
fx_hashmap *ctx_string_cache;
|
||||
#endif
|
||||
/* map of struct mie_dialect */
|
||||
struct mie_id_map ctx_dialects;
|
||||
@@ -35,7 +35,7 @@ struct mie_ctx {
|
||||
/* map of struct mie_pass_definition */
|
||||
struct mie_id_map ctx_passes;
|
||||
/* queue of struct mie_diag */
|
||||
b_queue ctx_diag;
|
||||
fx_queue ctx_diag;
|
||||
};
|
||||
|
||||
MIE_API struct mie_ctx *mie_ctx_create(void);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_DIAG_COMPONENT_H_
|
||||
#define MIE_DIAG_COMPONENT_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <stddef.h>
|
||||
|
||||
enum mie_diag_component_type {
|
||||
@@ -12,7 +12,7 @@ enum mie_diag_component_type {
|
||||
|
||||
struct mie_diag_component {
|
||||
enum mie_diag_component_type c_type;
|
||||
b_queue_entry c_entry;
|
||||
fx_queue_entry c_entry;
|
||||
};
|
||||
|
||||
struct mie_diag_c_snippet {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_DIAG_DIAG_H_
|
||||
#define MIE_DIAG_DIAG_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/parse/file-span.h>
|
||||
|
||||
#define MIE_DIAG_HL(type, span) \
|
||||
@@ -55,8 +55,8 @@ struct mie_diag {
|
||||
|
||||
struct mie_line_source *diag_src;
|
||||
struct mie_file_cell diag_loc;
|
||||
b_queue_entry diag_entry;
|
||||
b_queue diag_components;
|
||||
fx_queue_entry diag_entry;
|
||||
fx_queue diag_components;
|
||||
};
|
||||
|
||||
MIE_API void mie_diag_set_location(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_DIALECT_BUILTIN_H_
|
||||
#define MIE_DIALECT_BUILTIN_H_
|
||||
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/attribute/attribute.h>
|
||||
#include <mie/interface/interface.h>
|
||||
#include <mie/misc.h>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_DIALECT_DIALECT_H_
|
||||
#define MIE_DIALECT_DIALECT_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/id.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/vector.h>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef MIE_ID_H_
|
||||
#define MIE_ID_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/core/rope.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/core/rope.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/status.h>
|
||||
#include <stddef.h>
|
||||
@@ -42,30 +42,30 @@ typedef struct mie_id {
|
||||
};
|
||||
|
||||
union {
|
||||
b_btree_node e_node;
|
||||
b_queue_entry e_entry;
|
||||
fx_bst_node e_node;
|
||||
fx_queue_entry e_entry;
|
||||
};
|
||||
} mie_id;
|
||||
|
||||
struct mie_id_builder {
|
||||
b_hash_ctx b_hash;
|
||||
fx_hash_ctx b_hash;
|
||||
};
|
||||
|
||||
struct mie_id_map {
|
||||
mie_id map_ns_id;
|
||||
b_btree map_entries;
|
||||
fx_bst map_entries;
|
||||
};
|
||||
|
||||
struct mie_id_map_iterator {
|
||||
mie_id *it_id;
|
||||
b_btree_node *_n;
|
||||
fx_bst_node *_n;
|
||||
};
|
||||
|
||||
MIE_API void mie_id_init(
|
||||
mie_id *out, uint32_t a, uint16_t b, uint16_t c, uint16_t d, uint64_t e);
|
||||
MIE_API void mie_id_init_zero(mie_id *out);
|
||||
MIE_API void mie_id_init_random(mie_id *out);
|
||||
MIE_API void mie_id_init_ns(mie_id *out, const mie_id *ns, const b_rope *name);
|
||||
MIE_API void mie_id_init_ns(mie_id *out, const mie_id *ns, const fx_rope *name);
|
||||
|
||||
static inline int mie_id_compare(const mie_id *a, const mie_id *b)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ static inline void mie_id_builder_add_int(
|
||||
mie_id_builder_add(builder, s, len);
|
||||
}
|
||||
MIE_API void mie_id_builder_add_rope(
|
||||
struct mie_id_builder *builder, const b_rope *rope);
|
||||
struct mie_id_builder *builder, const fx_rope *rope);
|
||||
MIE_API void mie_id_builder_add_marker(
|
||||
struct mie_id_builder *builder, enum mie_id_builder_marker marker);
|
||||
MIE_API void mie_id_builder_end(struct mie_id_builder *builder, mie_id *out);
|
||||
@@ -107,12 +107,12 @@ MIE_API void mie_id_builder_end(struct mie_id_builder *builder, mie_id *out);
|
||||
MIE_API void mie_id_map_init(struct mie_id_map *map, const mie_id *ns);
|
||||
static inline bool mie_id_map_empty(const struct mie_id_map *map)
|
||||
{
|
||||
return b_btree_empty(&map->map_entries);
|
||||
return fx_bst_empty(&map->map_entries);
|
||||
}
|
||||
|
||||
MIE_API const mie_id *mie_id_map_get_ns(const struct mie_id_map *map);
|
||||
MIE_API void mie_id_map_put(
|
||||
struct mie_id_map *map, mie_id *node, const b_rope *name);
|
||||
struct mie_id_map *map, mie_id *node, const fx_rope *name);
|
||||
MIE_API void mie_id_map_put_id(struct mie_id_map *map, mie_id *node);
|
||||
MIE_API mie_id *mie_id_map_get(const struct mie_id_map *map, mie_id *id);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_IR_BLOCK_H_
|
||||
#define MIE_IR_BLOCK_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/name.h>
|
||||
#include <mie/vector.h>
|
||||
@@ -26,11 +26,11 @@ struct mie_block {
|
||||
unsigned int b_id;
|
||||
struct mie_block *b_idom;
|
||||
// struct mie_block *b_sdom, *b_dfs_parent;
|
||||
b_queue_entry b_entry;
|
||||
fx_queue_entry b_entry;
|
||||
|
||||
MIE_VECTOR_DECLARE(struct mie_register, b_params);
|
||||
/* queue of struct mie_op */
|
||||
b_queue b_ops;
|
||||
fx_queue b_ops;
|
||||
};
|
||||
|
||||
extern struct mie_vector_ops mie_block_vector_ops;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_IR_OP_DEFINITION_H_
|
||||
#define MIE_IR_OP_DEFINITION_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/core/stream.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <mie/id.h>
|
||||
#include <mie/interface/interface-map.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
@@ -52,7 +52,7 @@ struct mie_op_successor {
|
||||
struct mie_op {
|
||||
enum mie_op_flags op_flags;
|
||||
/* used by struct mie_block */
|
||||
b_queue_entry op_entry;
|
||||
fx_queue_entry op_entry;
|
||||
|
||||
struct mie_line_source *op_src;
|
||||
/* this pointer is only valid if the F_OP_RESOLVED flag is set */
|
||||
@@ -63,7 +63,7 @@ struct mie_op {
|
||||
/* only valid if the F_RESOLVED flag is NOT set */
|
||||
char *op_name;
|
||||
|
||||
b_queue op_regions;
|
||||
fx_queue op_regions;
|
||||
|
||||
MIE_VECTOR_DECLARE(struct mie_op_successor, op_successors);
|
||||
struct mie_attribute_map op_attrib;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_IR_REGION_H_
|
||||
#define MIE_IR_REGION_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/vector.h>
|
||||
#include <stddef.h>
|
||||
@@ -15,12 +15,12 @@ struct mie_region {
|
||||
struct mie_name_map *r_names;
|
||||
struct mie_op *r_parent;
|
||||
/* used by struct mie_op */
|
||||
b_queue_entry r_entry;
|
||||
fx_queue_entry r_entry;
|
||||
/* queue of struct mie_block */
|
||||
b_queue r_blocks;
|
||||
fx_queue r_blocks;
|
||||
/* bst of struct mie_block, as numbered by a depth-first search.
|
||||
* this ordering is recalculated by mie_region_refresh_dominance */
|
||||
b_btree r_blocks_s;
|
||||
fx_bst r_blocks_s;
|
||||
};
|
||||
|
||||
MIE_API struct mie_block *mie_region_get_first_block(
|
||||
@@ -45,8 +45,8 @@ MIE_API struct mie_register *mie_region_find_register(
|
||||
* this function populates the following attributes of every block in the
|
||||
* region:
|
||||
* b_id
|
||||
* b_node
|
||||
* b_parent
|
||||
* fx_node
|
||||
* fx_parent
|
||||
* as well as the following attributes of the region itself:
|
||||
* r_blocks_s
|
||||
* only top-level blocks and ops are considered by this function. if an op
|
||||
|
||||
@@ -30,7 +30,7 @@ struct mie_register_ref {
|
||||
|
||||
/* represents a use of/resolved reference to a mie_register */
|
||||
struct mie_register_use {
|
||||
b_queue_entry u_entry;
|
||||
fx_queue_entry u_entry;
|
||||
struct mie_op *u_user;
|
||||
struct mie_register *u_reg;
|
||||
};
|
||||
@@ -59,7 +59,7 @@ struct mie_register {
|
||||
struct mie_op *reg_op;
|
||||
/* list of struct mie_register_use, representing all the places
|
||||
* where this register is used. */
|
||||
b_queue reg_use;
|
||||
fx_queue reg_use;
|
||||
};
|
||||
|
||||
extern struct mie_vector_ops mie_register_vector_ops;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_IR_WALK_H_
|
||||
#define MIE_IR_WALK_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/status.h>
|
||||
#include <stddef.h>
|
||||
@@ -35,7 +35,7 @@ enum mie_walk_item_type {
|
||||
|
||||
struct mie_walk_item {
|
||||
int _f;
|
||||
b_queue_entry _e;
|
||||
fx_queue_entry _e;
|
||||
enum mie_walk_item_type i_type;
|
||||
// size_t i_index;
|
||||
size_t i_depth;
|
||||
@@ -50,7 +50,7 @@ struct mie_walker {
|
||||
enum mie_walker_flags w_flags;
|
||||
union {
|
||||
/* used for recursive walks */
|
||||
b_queue w_stack;
|
||||
fx_queue w_stack;
|
||||
/* used for non-recursive walks */
|
||||
struct {
|
||||
struct mie_walk_item w_region, w_block, w_op;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_NAME_H_
|
||||
#define MIE_NAME_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/parse/file-span.h>
|
||||
|
||||
@@ -30,14 +30,14 @@ struct mie_name_map_entry {
|
||||
enum mie_name_map_entry_type e_type;
|
||||
uint64_t e_hash;
|
||||
union {
|
||||
b_queue_entry e_entry;
|
||||
b_btree_node e_node;
|
||||
fx_queue_entry e_entry;
|
||||
fx_bst_node e_node;
|
||||
};
|
||||
};
|
||||
|
||||
struct mie_name_bucket {
|
||||
struct mie_name_map_entry b_base;
|
||||
b_queue b_names;
|
||||
fx_queue b_names;
|
||||
};
|
||||
|
||||
/* stores a unique name, and forms a binary tree of similar entries.
|
||||
@@ -64,7 +64,7 @@ struct mie_name {
|
||||
|
||||
struct mie_name_map {
|
||||
const struct mie_name_map *m_parent;
|
||||
b_btree m_entries;
|
||||
fx_bst m_entries;
|
||||
size_t m_next_id;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_PARSE_LEX_H_
|
||||
#define MIE_PARSE_LEX_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/core/stream.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
#ifndef MIE_PARSE_LINE_SOURCE_H_
|
||||
#define MIE_PARSE_LINE_SOURCE_H_
|
||||
|
||||
#include <blue/core/stream.h>
|
||||
#include <blue/ds/array.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <fx/ds/array.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/parse/file-span.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
struct mie_line_source {
|
||||
b_stream *s_stream;
|
||||
fx_stream *s_stream;
|
||||
const char *s_path;
|
||||
b_string *s_linebuf;
|
||||
b_iterator *s_linebuf_ptr;
|
||||
b_array *s_lines;
|
||||
fx_string *s_linebuf;
|
||||
fx_iterator *s_linebuf_ptr;
|
||||
fx_array *s_lines;
|
||||
|
||||
struct mie_file_cell s_cursor;
|
||||
};
|
||||
|
||||
MIE_API enum mie_status mie_line_source_init(
|
||||
struct mie_line_source *src, const char *path, b_stream *stream);
|
||||
struct mie_line_source *src, const char *path, fx_stream *stream);
|
||||
MIE_API void mie_line_source_cleanup(struct mie_line_source *src);
|
||||
|
||||
MIE_API const char *mie_line_source_get_path(const struct mie_line_source *src);
|
||||
MIE_API const struct mie_file_cell *mie_line_source_get_cursor(
|
||||
const struct mie_line_source *src);
|
||||
MIE_API b_wchar mie_line_source_peekc(struct mie_line_source *src);
|
||||
MIE_API b_wchar mie_line_source_getc(struct mie_line_source *src);
|
||||
MIE_API fx_wchar mie_line_source_peekc(struct mie_line_source *src);
|
||||
MIE_API fx_wchar mie_line_source_getc(struct mie_line_source *src);
|
||||
MIE_API enum mie_status mie_line_source_get_row(
|
||||
struct mie_line_source *src, size_t row, const b_string **out);
|
||||
struct mie_line_source *src, size_t row, const fx_string **out);
|
||||
|
||||
MIE_API bool mie_line_source_input_available(struct mie_line_source *src);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_PARSE_PARSER_H_
|
||||
#define MIE_PARSE_PARSER_H_
|
||||
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/ir/register.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/parse/token.h>
|
||||
@@ -57,7 +57,7 @@ MIE_API struct mie_ctx *mie_parser_get_mie_ctx(struct mie_parser *ctx);
|
||||
MIE_API struct mie_lex *mie_parser_get_lexer(struct mie_parser *ctx);
|
||||
MIE_API enum mie_status mie_parser_get_status(const struct mie_parser *ctx);
|
||||
MIE_API void mie_parser_set_status(struct mie_parser *ctx, enum mie_status status);
|
||||
MIE_API b_string *mie_parser_get_tempstr(struct mie_parser *ctx);
|
||||
MIE_API fx_string *mie_parser_get_tempstr(struct mie_parser *ctx);
|
||||
|
||||
MIE_API struct mie_token *mie_parser_peek(struct mie_parser *ctx);
|
||||
MIE_API enum mie_token_type mie_parser_peek_type(struct mie_parser *ctx);
|
||||
@@ -74,29 +74,29 @@ MIE_API bool mie_parser_parse_int(
|
||||
MIE_API bool mie_parser_parse_float(
|
||||
struct mie_parser *ctx, double *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_word(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_name(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_instname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_graphname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_opname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_vregname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_mregname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_blockname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_attribname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_typename(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_symname(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_string(
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc);
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_keyword(
|
||||
struct mie_parser *ctx, const char *kw, struct mie_file_span *loc);
|
||||
MIE_API bool mie_parser_parse_symbol(
|
||||
@@ -126,7 +126,7 @@ MIE_API bool mie_parser_parse_parameter_list(
|
||||
struct mie_parser *ctx, bool include_type,
|
||||
MIE_VECTOR_REF_PARAM(struct mie_op_arg, out), const char *context);
|
||||
|
||||
MIE_API bool mie_parser_parse_unknown_keyword(struct mie_parser *ctx, b_string *out);
|
||||
MIE_API bool mie_parser_parse_unknown_keyword(struct mie_parser *ctx, fx_string *out);
|
||||
MIE_API bool mie_parser_parse_unknown_symbol(
|
||||
struct mie_parser *ctx, enum mie_token_symbol sym);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_PARSE_TOKEN_H_
|
||||
#define MIE_PARSE_TOKEN_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/parse/file-span.h>
|
||||
|
||||
@@ -82,7 +82,7 @@ struct mie_token {
|
||||
struct mie_file_span tok_location;
|
||||
enum mie_token_type tok_type;
|
||||
enum mie_token_value_type tok_value_type;
|
||||
b_queue_entry tok_entry;
|
||||
fx_queue_entry tok_entry;
|
||||
|
||||
union {
|
||||
char *tok_str;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_PRINT_PRINTER_H_
|
||||
#define MIE_PRINT_PRINTER_H_
|
||||
|
||||
#include <blue/core/stream.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
@@ -30,11 +30,11 @@ enum mie_print_flags {
|
||||
struct mie_printer {
|
||||
enum mie_print_flags p_flags;
|
||||
struct mie_ctx *p_mie;
|
||||
b_stream *p_stream;
|
||||
fx_stream *p_stream;
|
||||
};
|
||||
|
||||
MIE_API enum mie_status mie_printer_init(
|
||||
struct mie_printer *printer, struct mie_ctx *ctx, b_stream *out,
|
||||
struct mie_printer *printer, struct mie_ctx *ctx, fx_stream *out,
|
||||
enum mie_print_flags flags);
|
||||
|
||||
MIE_API void mie_printer_print_module(
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#define MIE_ERROR_VENDOR (ivy_error_vendor())
|
||||
|
||||
struct b_error_vendor;
|
||||
struct fx_error_vendor;
|
||||
|
||||
enum mie_status {
|
||||
MIE_SUCCESS = 0,
|
||||
@@ -23,6 +23,6 @@ enum mie_status {
|
||||
MIE_ERR_INTERNAL_FAILURE,
|
||||
};
|
||||
|
||||
MIE_API const struct b_error_vendor *mie_error_vendor(void);
|
||||
MIE_API const struct fx_error_vendor *mie_error_vendor(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_TRAIT_TRAIT_DEFINITION_H_
|
||||
#define MIE_TRAIT_TRAIT_DEFINITION_H_
|
||||
|
||||
#include <blue/core/stream.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <mie/id.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
@@ -50,7 +50,7 @@ struct mie_trait_definition {
|
||||
struct mie_id_builder *);
|
||||
enum mie_status (*tr_print)(
|
||||
const struct mie_trait_definition *, const struct mie_trait *,
|
||||
b_stream *);
|
||||
fx_stream *);
|
||||
enum mie_status (*tr_cleanup)(
|
||||
const struct mie_trait_definition *, struct mie_trait *);
|
||||
enum mie_status (*tr_validate)(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_TRAIT_TRAIT_TABLE_H_
|
||||
#define MIE_TRAIT_TRAIT_TABLE_H_
|
||||
|
||||
#include <blue/core/btree.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <mie/id.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/status.h>
|
||||
@@ -18,7 +18,7 @@ struct mie_trait_table_iterator {
|
||||
int _f;
|
||||
struct mie_id_map_iterator _n;
|
||||
const struct mie_trait_table *_m;
|
||||
b_queue_entry *_e;
|
||||
fx_queue_entry *_e;
|
||||
};
|
||||
|
||||
MIE_API void mie_trait_table_init(struct mie_trait_table *out);
|
||||
|
||||
@@ -15,6 +15,6 @@ struct mie_trait {
|
||||
const struct mie_trait_definition *tr_def;
|
||||
};
|
||||
|
||||
MIE_API void mie_trait_print(const struct mie_trait *type, b_stream *out);
|
||||
MIE_API void mie_trait_print(const struct mie_trait *type, fx_stream *out);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_TYPE_FUNCTION_H_
|
||||
#define MIE_TYPE_FUNCTION_H_
|
||||
|
||||
#include <blue/core/stream.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <mie/type/type.h>
|
||||
#include <mie/vector.h>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MIE_TYPE_STORAGE_H_
|
||||
#define MIE_TYPE_STORAGE_H_
|
||||
|
||||
#include <blue/core/stream.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <mie/type/type.h>
|
||||
#include <mie/vector.h>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef MIE_TYPE_TYPE_H_
|
||||
#define MIE_TYPE_TYPE_H_
|
||||
|
||||
#include <blue/core/stream.h>
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <fx/core/stream.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <mie/id.h>
|
||||
#include <mie/misc.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/interface/interface-definition.h>
|
||||
|
||||
@@ -12,7 +12,7 @@ struct mie_interface_definition *mie_interface_definition_create(
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->if_name = b_strdup(name);
|
||||
out->if_name = fx_strdup(name);
|
||||
if (!out->if_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -21,7 +21,7 @@ struct mie_interface_definition *mie_interface_definition_create(
|
||||
out->if_parent = parent;
|
||||
out->if_size = 0;
|
||||
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id_map_put(&parent->d_interfaces, &out->if_id, &name_rope);
|
||||
|
||||
return out;
|
||||
|
||||
@@ -49,6 +49,6 @@ const struct mie_interface *mie_interface_map_get(
|
||||
|
||||
const mie_id *result = mie_id_map_get(&map->m_entries, &id);
|
||||
const struct mie_interface *iface
|
||||
= b_unbox(const struct mie_interface, result, if_id);
|
||||
= fx_unbox(const struct mie_interface, result, if_id);
|
||||
return iface;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
struct mie_op *mie_block_get_first_op(const struct mie_block *block)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&block->b_ops);
|
||||
fx_queue_entry *entry = fx_queue_first(&block->b_ops);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_op, entry, op_entry);
|
||||
return fx_unbox(struct mie_op, entry, op_entry);
|
||||
}
|
||||
|
||||
struct mie_op *mie_block_get_prev_op(
|
||||
@@ -19,12 +19,12 @@ struct mie_op *mie_block_get_prev_op(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_prev(&before->op_entry);
|
||||
fx_queue_entry *entry = fx_queue_prev(&before->op_entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_op, entry, op_entry);
|
||||
return fx_unbox(struct mie_op, entry, op_entry);
|
||||
}
|
||||
|
||||
struct mie_op *mie_block_get_next_op(
|
||||
@@ -34,28 +34,28 @@ struct mie_op *mie_block_get_next_op(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_next(&after->op_entry);
|
||||
fx_queue_entry *entry = fx_queue_next(&after->op_entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_op, entry, op_entry);
|
||||
return fx_unbox(struct mie_op, entry, op_entry);
|
||||
}
|
||||
|
||||
struct mie_op *mie_block_get_last_op(const struct mie_block *block)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&block->b_ops);
|
||||
fx_queue_entry *entry = fx_queue_last(&block->b_ops);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_op, entry, op_entry);
|
||||
return fx_unbox(struct mie_op, entry, op_entry);
|
||||
}
|
||||
|
||||
struct mie_op *mie_block_get_terminator(const struct mie_block *block)
|
||||
{
|
||||
b_queue_entry *op_entry = b_queue_last(&block->b_ops);
|
||||
return b_unbox(struct mie_op, op_entry, op_entry);
|
||||
fx_queue_entry *op_entry = fx_queue_last(&block->b_ops);
|
||||
return fx_unbox(struct mie_op, op_entry, op_entry);
|
||||
}
|
||||
|
||||
struct mie_op_successor *mie_block_get_first_successor(const struct mie_block *block)
|
||||
@@ -200,7 +200,7 @@ struct mie_op *mie_block_add_op(struct mie_block *block)
|
||||
mie_op_init(op);
|
||||
op->op_container = block;
|
||||
|
||||
b_queue_push_back(&block->b_ops, &op->op_entry);
|
||||
fx_queue_push_back(&block->b_ops, &op->op_entry);
|
||||
|
||||
return op;
|
||||
}
|
||||
@@ -220,9 +220,9 @@ struct mie_op *mie_block_add_op_after(struct mie_block *block, struct mie_op *af
|
||||
op->op_container = block;
|
||||
|
||||
if (after) {
|
||||
b_queue_insert_after(&block->b_ops, &op->op_entry, &after->op_entry);
|
||||
fx_queue_insert_after(&block->b_ops, &op->op_entry, &after->op_entry);
|
||||
} else {
|
||||
b_queue_push_back(&block->b_ops, &op->op_entry);
|
||||
fx_queue_push_back(&block->b_ops, &op->op_entry);
|
||||
}
|
||||
|
||||
return op;
|
||||
@@ -243,7 +243,7 @@ struct mie_register *mie_block_find_register(
|
||||
const struct mie_block *block, const char *name,
|
||||
const struct mie_op *start_point)
|
||||
{
|
||||
const b_queue_entry *entry = b_queue_last(&block->b_ops);
|
||||
const fx_queue_entry *entry = fx_queue_last(&block->b_ops);
|
||||
if (start_point) {
|
||||
entry = &start_point->op_entry;
|
||||
}
|
||||
@@ -255,13 +255,13 @@ struct mie_register *mie_block_find_register(
|
||||
}
|
||||
|
||||
while (entry) {
|
||||
struct mie_op *op = b_unbox(struct mie_op, entry, op_entry);
|
||||
struct mie_op *op = fx_unbox(struct mie_op, entry, op_entry);
|
||||
struct mie_register *reg = mie_op_get_result_with_name(op, name);
|
||||
if (reg) {
|
||||
return reg;
|
||||
}
|
||||
|
||||
entry = b_queue_prev(entry);
|
||||
entry = fx_queue_prev(entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <mie/ir/region.h>
|
||||
|
||||
struct builder_scope {
|
||||
b_queue_entry s_entry;
|
||||
fx_queue_entry s_entry;
|
||||
struct mie_op *s_op;
|
||||
struct mie_region *s_region;
|
||||
struct mie_block *s_block;
|
||||
@@ -16,7 +16,7 @@ struct builder_scope {
|
||||
struct mie_builder {
|
||||
struct mie_emitter b_base;
|
||||
struct mie_ctx *b_ctx;
|
||||
b_queue b_scope_stack;
|
||||
fx_queue b_scope_stack;
|
||||
struct mie_op *b_root;
|
||||
struct mie_op *b_prev_op;
|
||||
};
|
||||
@@ -50,16 +50,16 @@ struct mie_ctx *mie_builder_get_ctx(struct mie_builder *builder)
|
||||
|
||||
static struct mie_name_map *get_current_name_map(struct mie_builder *builder)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_last(&builder->b_scope_stack);
|
||||
fx_queue_entry *cur = fx_queue_last(&builder->b_scope_stack);
|
||||
while (cur) {
|
||||
struct builder_scope *scope
|
||||
= b_unbox(struct builder_scope, cur, s_entry);
|
||||
= fx_unbox(struct builder_scope, cur, s_entry);
|
||||
|
||||
if (scope->s_region && scope->s_region->r_names) {
|
||||
return scope->s_region->r_names;
|
||||
}
|
||||
|
||||
cur = b_queue_prev(cur);
|
||||
cur = fx_queue_prev(cur);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -67,13 +67,13 @@ static struct mie_name_map *get_current_name_map(struct mie_builder *builder)
|
||||
|
||||
struct mie_block *mie_builder_get_current_block(struct mie_builder *builder)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&builder->b_scope_stack);
|
||||
fx_queue_entry *entry = fx_queue_last(&builder->b_scope_stack);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct builder_scope *scope
|
||||
= b_unbox(struct builder_scope, entry, s_entry);
|
||||
= fx_unbox(struct builder_scope, entry, s_entry);
|
||||
|
||||
return scope->s_block;
|
||||
}
|
||||
@@ -114,19 +114,19 @@ void mie_builder_step_into_block(struct mie_builder *builder, struct mie_block *
|
||||
scope->s_region = block->b_parent;
|
||||
scope->s_op = scope->s_region->r_parent;
|
||||
|
||||
b_queue_push_back(&builder->b_scope_stack, &scope->s_entry);
|
||||
fx_queue_push_back(&builder->b_scope_stack, &scope->s_entry);
|
||||
}
|
||||
|
||||
void mie_builder_step_out(struct mie_builder *builder)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&builder->b_scope_stack);
|
||||
fx_queue_entry *entry = fx_queue_last(&builder->b_scope_stack);
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct builder_scope *scope
|
||||
= b_unbox(struct builder_scope, entry, s_entry);
|
||||
b_queue_delete(&builder->b_scope_stack, entry);
|
||||
= fx_unbox(struct builder_scope, entry, s_entry);
|
||||
fx_queue_delete(&builder->b_scope_stack, entry);
|
||||
free(scope);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ struct mie_op *mie_builder_put_op(
|
||||
arg->arg_flags = MIE_OP_F_ARG_RESOLVED;
|
||||
arg->arg_value.u_reg = args[i];
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(&args[i]->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&args[i]->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
|
||||
return op;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/ir/op-definition.h>
|
||||
|
||||
@@ -10,7 +10,7 @@ struct mie_op_definition *mie_op_definition_create(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
out->op_name = b_strdup(name);
|
||||
out->op_name = fx_strdup(name);
|
||||
if (!out->op_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -20,7 +20,7 @@ struct mie_op_definition *mie_op_definition_create(
|
||||
mie_trait_table_init(&out->op_traits);
|
||||
mie_interface_map_init(&out->op_iface);
|
||||
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id_map_put(&parent->d_ops, &out->op_id, &name_rope);
|
||||
|
||||
return out;
|
||||
|
||||
22
mie/ir/op.c
22
mie/ir/op.c
@@ -15,7 +15,7 @@ static enum mie_status op_arg_cleanup(void *p)
|
||||
struct mie_op_arg *arg = p;
|
||||
|
||||
if (arg->arg_flags & MIE_OP_F_ARG_RESOLVED) {
|
||||
b_queue_delete(
|
||||
fx_queue_delete(
|
||||
&arg->arg_value.u_reg->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ struct mie_op_successor *mie_op_add_successor(
|
||||
arg->arg_flags = MIE_OP_F_ARG_RESOLVED;
|
||||
arg->arg_value.u_reg = args[i];
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(&args[i]->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&args[i]->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
|
||||
return s;
|
||||
@@ -147,7 +147,7 @@ struct mie_region *mie_op_add_region(struct mie_op *op)
|
||||
region->r_names = mie_name_map_create(NULL);
|
||||
}
|
||||
|
||||
b_queue_push_back(&op->op_regions, ®ion->r_entry);
|
||||
fx_queue_push_back(&op->op_regions, ®ion->r_entry);
|
||||
|
||||
return region;
|
||||
}
|
||||
@@ -202,12 +202,12 @@ bool mie_op_has_interface(
|
||||
|
||||
struct mie_region *mie_op_get_first_region(const struct mie_op *op)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&op->op_regions);
|
||||
fx_queue_entry *entry = fx_queue_first(&op->op_regions);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_region, entry, r_entry);
|
||||
return fx_unbox(struct mie_region, entry, r_entry);
|
||||
}
|
||||
|
||||
struct mie_region *mie_op_get_prev_region(
|
||||
@@ -217,12 +217,12 @@ struct mie_region *mie_op_get_prev_region(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_prev(&before->r_entry);
|
||||
fx_queue_entry *entry = fx_queue_prev(&before->r_entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_region, entry, r_entry);
|
||||
return fx_unbox(struct mie_region, entry, r_entry);
|
||||
}
|
||||
|
||||
struct mie_region *mie_op_get_next_region(
|
||||
@@ -232,22 +232,22 @@ struct mie_region *mie_op_get_next_region(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_next(&after->r_entry);
|
||||
fx_queue_entry *entry = fx_queue_next(&after->r_entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_region, entry, r_entry);
|
||||
return fx_unbox(struct mie_region, entry, r_entry);
|
||||
}
|
||||
|
||||
struct mie_region *mie_op_get_last_region(const struct mie_op *op)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&op->op_regions);
|
||||
fx_queue_entry *entry = fx_queue_last(&op->op_regions);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_region, entry, r_entry);
|
||||
return fx_unbox(struct mie_region, entry, r_entry);
|
||||
}
|
||||
|
||||
struct mie_register *mie_op_get_arg(const struct mie_op *op, size_t index)
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
struct mie_block *mie_region_get_first_block(const struct mie_region *region)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(®ion->r_blocks);
|
||||
fx_queue_entry *entry = fx_queue_first(®ion->r_blocks);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_block, entry, b_entry);
|
||||
return fx_unbox(struct mie_block, entry, b_entry);
|
||||
}
|
||||
|
||||
struct mie_block *mie_region_get_prev_block(
|
||||
@@ -25,12 +25,12 @@ struct mie_block *mie_region_get_prev_block(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_prev(&before->b_entry);
|
||||
fx_queue_entry *entry = fx_queue_prev(&before->b_entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_block, entry, b_entry);
|
||||
return fx_unbox(struct mie_block, entry, b_entry);
|
||||
}
|
||||
|
||||
struct mie_block *mie_region_get_next_block(
|
||||
@@ -40,22 +40,22 @@ struct mie_block *mie_region_get_next_block(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_next(&after->b_entry);
|
||||
fx_queue_entry *entry = fx_queue_next(&after->b_entry);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_block, entry, b_entry);
|
||||
return fx_unbox(struct mie_block, entry, b_entry);
|
||||
}
|
||||
|
||||
struct mie_block *mie_region_get_last_block(const struct mie_region *region)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(®ion->r_blocks);
|
||||
fx_queue_entry *entry = fx_queue_last(®ion->r_blocks);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct mie_block, entry, b_entry);
|
||||
return fx_unbox(struct mie_block, entry, b_entry);
|
||||
}
|
||||
|
||||
struct mie_block *mie_region_add_block(struct mie_region *region)
|
||||
@@ -70,7 +70,7 @@ struct mie_block *mie_region_add_block(struct mie_region *region)
|
||||
block->b_parent = region;
|
||||
block->b_id = MIE_BLOCK_ID_INVALID;
|
||||
|
||||
b_queue_push_back(®ion->r_blocks, &block->b_entry);
|
||||
fx_queue_push_back(®ion->r_blocks, &block->b_entry);
|
||||
|
||||
return block;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ struct mie_block *mie_region_add_block_before(
|
||||
memset(block, 0x0, sizeof *block);
|
||||
block->b_parent = region;
|
||||
|
||||
b_queue_insert_before(®ion->r_blocks, &block->b_entry, &before->b_entry);
|
||||
fx_queue_insert_before(®ion->r_blocks, &block->b_entry, &before->b_entry);
|
||||
|
||||
return block;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ struct mie_block *mie_region_add_block_after(
|
||||
memset(block, 0x0, sizeof *block);
|
||||
block->b_parent = region;
|
||||
|
||||
b_queue_insert_after(®ion->r_blocks, &block->b_entry, &after->b_entry);
|
||||
fx_queue_insert_after(®ion->r_blocks, &block->b_entry, &after->b_entry);
|
||||
|
||||
return block;
|
||||
}
|
||||
@@ -120,15 +120,15 @@ struct mie_block *mie_region_add_block_after(
|
||||
struct mie_block *mie_region_find_block(
|
||||
const struct mie_region *region, const char *name)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(®ion->r_blocks);
|
||||
fx_queue_entry *cur = fx_queue_first(®ion->r_blocks);
|
||||
while (cur) {
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
const char *block_name = block->b_name.n_str;
|
||||
if (block_name && !strcmp(block_name, name)) {
|
||||
return block;
|
||||
}
|
||||
|
||||
cur = b_queue_next(cur);
|
||||
cur = fx_queue_next(cur);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -137,17 +137,17 @@ struct mie_block *mie_region_find_block(
|
||||
struct mie_register *mie_region_find_register(
|
||||
const struct mie_region *region, const char *name)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(®ion->r_blocks);
|
||||
fx_queue_entry *cur = fx_queue_first(®ion->r_blocks);
|
||||
|
||||
while (cur) {
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
struct mie_register *reg
|
||||
= mie_block_find_register(block, name, NULL);
|
||||
if (reg) {
|
||||
return reg;
|
||||
}
|
||||
|
||||
cur = b_queue_next(cur);
|
||||
cur = fx_queue_next(cur);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <assert.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/ir/register.h>
|
||||
|
||||
static enum mie_status reg_cleanup(void *p)
|
||||
@@ -57,13 +57,13 @@ void mie_register_use_move(
|
||||
memmove(dest, src, sizeof *dest);
|
||||
|
||||
if (src->u_reg) {
|
||||
b_queue_move(&src->u_reg->reg_use, &src->u_entry, &dest->u_entry);
|
||||
fx_queue_move(&src->u_reg->reg_use, &src->u_entry, &dest->u_entry);
|
||||
}
|
||||
}
|
||||
|
||||
void mie_register_use_cleanup(struct mie_register_use *use)
|
||||
{
|
||||
if (use->u_reg) {
|
||||
b_queue_delete(&use->u_reg->reg_use, &use->u_entry);
|
||||
fx_queue_delete(&use->u_reg->reg_use, &use->u_entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ static bool resolve_arg(
|
||||
memset(&arg->arg_value, 0x0, sizeof arg->arg_value);
|
||||
arg->arg_value.u_reg = reg;
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(®->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(®->reg_use, &arg->arg_value.u_entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ static bool resolve_arg(
|
||||
memset(&arg->arg_value, 0x0, sizeof arg->arg_value);
|
||||
arg->arg_value.u_reg = reg;
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(®->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(®->reg_use, &arg->arg_value.u_entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,15 +35,15 @@ static void push_walk_item(
|
||||
}
|
||||
|
||||
memcpy(i, item, sizeof *i);
|
||||
b_queue_push_back(&walker->w_stack, &i->_e);
|
||||
fx_queue_push_back(&walker->w_stack, &i->_e);
|
||||
}
|
||||
|
||||
static void pop_walk_item(struct mie_walker *walker)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_pop_back(&walker->w_stack);
|
||||
fx_queue_entry *entry = fx_queue_pop_back(&walker->w_stack);
|
||||
if (entry) {
|
||||
struct mie_walk_item *item
|
||||
= b_unbox(struct mie_walk_item, entry, _e);
|
||||
= fx_unbox(struct mie_walk_item, entry, _e);
|
||||
free(item);
|
||||
}
|
||||
}
|
||||
@@ -65,12 +65,12 @@ static struct mie_walk_item *current_item(struct mie_walker *walker)
|
||||
return eof ? item : NULL;
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_last(&walker->w_stack);
|
||||
fx_queue_entry *entry = fx_queue_last(&walker->w_stack);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = b_unbox(struct mie_walk_item, entry, _e);
|
||||
item = fx_unbox(struct mie_walk_item, entry, _e);
|
||||
return item->i_type != MIE_WALK_ITEM_NONE ? item : NULL;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ static bool walk_item_get_first_child(
|
||||
struct mie_walk_item *child)
|
||||
{
|
||||
bool ok = false;
|
||||
b_queue_entry *entry = NULL;
|
||||
fx_queue_entry *entry = NULL;
|
||||
|
||||
switch (item->i_type) {
|
||||
case MIE_WALK_ITEM_OP:
|
||||
@@ -184,7 +184,7 @@ static bool walk_item_get_last_child(
|
||||
struct mie_walk_item *child)
|
||||
{
|
||||
bool ok = false;
|
||||
b_queue_entry *entry = NULL;
|
||||
fx_queue_entry *entry = NULL;
|
||||
|
||||
switch (item->i_type) {
|
||||
case MIE_WALK_ITEM_OP:
|
||||
@@ -230,7 +230,7 @@ static bool walk_item_get_next_sibling(
|
||||
sibling->i_type = item->i_type;
|
||||
|
||||
size_t index = 0;
|
||||
b_queue_entry *entry = NULL;
|
||||
fx_queue_entry *entry = NULL;
|
||||
struct mie_region *parent_r = NULL;
|
||||
struct mie_block *parent_b = NULL;
|
||||
struct mie_op *parent_o = NULL;
|
||||
@@ -316,11 +316,11 @@ static bool walk_item_get_prev_sibling(
|
||||
|
||||
static void print_stack(struct mie_walker *walker)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&walker->w_stack);
|
||||
fx_queue_entry *entry = fx_queue_last(&walker->w_stack);
|
||||
|
||||
while (entry) {
|
||||
struct mie_walk_item *item
|
||||
= b_unbox(struct mie_walk_item, entry, _e);
|
||||
= fx_unbox(struct mie_walk_item, entry, _e);
|
||||
|
||||
switch (item->i_type) {
|
||||
case MIE_WALK_ITEM_OP:
|
||||
@@ -347,7 +347,7 @@ static void print_stack(struct mie_walker *walker)
|
||||
|
||||
printf("\n");
|
||||
|
||||
entry = b_queue_prev(entry);
|
||||
entry = fx_queue_prev(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ struct lt_ctx {
|
||||
};
|
||||
|
||||
#if 0
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(struct mie_block, b_node, b_id, put_block_by_id);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
struct mie_block, size_t, b_node, b_id, get_block_by_id);
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(struct mie_block, fx_node, b_id, put_block_by_id);
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct mie_block, size_t, fx_node, b_id, get_block_by_id);
|
||||
#endif
|
||||
|
||||
static void set_add(struct set *set, unsigned int val)
|
||||
@@ -148,16 +148,16 @@ static unsigned int eval(struct lt_ctx *ctx, unsigned int v)
|
||||
|
||||
static void reset_block_relationship_metadata(struct mie_region *region)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(®ion->r_blocks);
|
||||
fx_queue_entry *cur = fx_queue_first(®ion->r_blocks);
|
||||
while (cur) {
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
|
||||
block->b_id = MIE_BLOCK_ID_INVALID;
|
||||
block->b_idom = NULL;
|
||||
// block->b_sdom = block->b_dfs_parent = NULL;
|
||||
mie_vector_destroy(block->b_ipred, NULL);
|
||||
|
||||
cur = b_queue_next(cur);
|
||||
cur = fx_queue_next(cur);
|
||||
}
|
||||
|
||||
memset(®ion->r_blocks_s, 0x0, sizeof region->r_blocks_s);
|
||||
@@ -191,7 +191,7 @@ static void lt_ctx_cleanup(struct lt_ctx *ctx)
|
||||
void mie_region_refresh_dominance(struct mie_region *region)
|
||||
{
|
||||
struct lt_ctx ctx;
|
||||
size_t nr_nodes = b_queue_length(®ion->r_blocks);
|
||||
size_t nr_nodes = fx_queue_length(®ion->r_blocks);
|
||||
lt_ctx_init(&ctx, nr_nodes);
|
||||
|
||||
struct mie_block *root = mie_region_get_first_block(region);
|
||||
|
||||
110
mie/name.c
110
mie/name.c
@@ -1,12 +1,12 @@
|
||||
#include <blue/core/rope.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/rope.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/name.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||
struct mie_name_map_entry, e_node, e_hash, put_entry);
|
||||
static B_BTREE_DEFINE_SIMPLE_GET(
|
||||
static FX_BST_DEFINE_SIMPLE_GET(
|
||||
struct mie_name_map_entry, uint64_t, e_node, e_hash, get_entry);
|
||||
|
||||
static struct mie_name_bucket *create_bucket(void)
|
||||
@@ -26,11 +26,11 @@ static struct mie_name_bucket *create_bucket(void)
|
||||
|
||||
static void destroy_bucket(struct mie_name_bucket *bucket)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&bucket->b_names);
|
||||
fx_queue_entry *entry = fx_queue_first(&bucket->b_names);
|
||||
|
||||
while (entry) {
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&bucket->b_names, entry);
|
||||
fx_queue_entry *next = fx_queue_next(entry);
|
||||
fx_queue_delete(&bucket->b_names, entry);
|
||||
entry = next;
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ struct mie_name_map *mie_name_map_create(const struct mie_name_map *parent)
|
||||
|
||||
void mie_name_map_destroy(struct mie_name_map *map)
|
||||
{
|
||||
b_btree_node *node = b_btree_first(&map->m_entries);
|
||||
fx_bst_node *node = fx_bst_first(&map->m_entries);
|
||||
|
||||
while (node) {
|
||||
struct mie_name_map_entry *entry
|
||||
= b_unbox(struct mie_name_map_entry, node, e_node);
|
||||
b_btree_node *next = b_btree_next(node);
|
||||
b_btree_delete(&map->m_entries, node);
|
||||
= fx_unbox(struct mie_name_map_entry, node, e_node);
|
||||
fx_bst_node *next = fx_bst_next(node);
|
||||
fx_bst_delete(&map->m_entries, node);
|
||||
if (entry->e_type == MIE_NAME_MAP_E_BUCKET) {
|
||||
struct mie_name_bucket *bucket
|
||||
= (struct mie_name_bucket *)entry;
|
||||
@@ -71,36 +71,36 @@ void mie_name_map_destroy(struct mie_name_map *map)
|
||||
free(map);
|
||||
}
|
||||
|
||||
static b_status put_name_in_bucket(
|
||||
static fx_status put_name_in_bucket(
|
||||
struct mie_name_bucket *bucket, struct mie_name *name)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&bucket->b_names);
|
||||
fx_queue_entry *entry = fx_queue_first(&bucket->b_names);
|
||||
|
||||
while (entry) {
|
||||
struct mie_name *cur = (struct mie_name *)b_unbox(
|
||||
struct mie_name *cur = (struct mie_name *)fx_unbox(
|
||||
struct mie_name_map_entry, entry, e_entry);
|
||||
|
||||
if (!strcmp(cur->n_str, name->n_str)) {
|
||||
return B_ERR_NAME_EXISTS;
|
||||
return FX_ERR_NAME_EXISTS;
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
b_queue_push_back(&bucket->b_names, &name->n_base.e_entry);
|
||||
fx_queue_push_back(&bucket->b_names, &name->n_base.e_entry);
|
||||
name->n_bucket = bucket;
|
||||
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static b_status put_name(struct mie_name_map *map, struct mie_name *name)
|
||||
static fx_status put_name(struct mie_name_map *map, struct mie_name *name)
|
||||
{
|
||||
struct mie_name_map_entry *entry
|
||||
= get_entry(&map->m_entries, name->n_base.e_hash);
|
||||
|
||||
if (!entry) {
|
||||
put_entry(&map->m_entries, &name->n_base);
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
if (entry->e_type == MIE_NAME_MAP_E_BUCKET) {
|
||||
@@ -111,26 +111,26 @@ static b_status put_name(struct mie_name_map *map, struct mie_name *name)
|
||||
struct mie_name *existing_name = (struct mie_name *)entry;
|
||||
|
||||
if (!strcmp(existing_name->n_str, name->n_str)) {
|
||||
return B_ERR_NAME_EXISTS;
|
||||
return FX_ERR_NAME_EXISTS;
|
||||
}
|
||||
|
||||
struct mie_name_bucket *bucket = create_bucket();
|
||||
if (!bucket) {
|
||||
return B_ERR_NO_MEMORY;
|
||||
return FX_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
b_btree_delete(&map->m_entries, &entry->e_node);
|
||||
entry->e_entry = B_QUEUE_ENTRY_INIT;
|
||||
fx_bst_delete(&map->m_entries, &entry->e_node);
|
||||
entry->e_entry = FX_QUEUE_ENTRY_INIT;
|
||||
|
||||
bucket->b_base.e_hash = name->n_base.e_hash;
|
||||
b_queue_push_back(&bucket->b_names, &existing_name->n_base.e_entry);
|
||||
b_queue_push_back(&bucket->b_names, &name->n_base.e_entry);
|
||||
fx_queue_push_back(&bucket->b_names, &existing_name->n_base.e_entry);
|
||||
fx_queue_push_back(&bucket->b_names, &name->n_base.e_entry);
|
||||
|
||||
existing_name->n_bucket = name->n_bucket = bucket;
|
||||
|
||||
put_entry(&map->m_entries, &bucket->b_base);
|
||||
|
||||
return B_SUCCESS;
|
||||
return FX_SUCCESS;
|
||||
}
|
||||
|
||||
static bool check_name(const struct mie_name *name, const char *s, uint64_t hash)
|
||||
@@ -141,16 +141,16 @@ static bool check_name(const struct mie_name *name, const char *s, uint64_t hash
|
||||
static const struct mie_name *find_name_in_bucket(
|
||||
const struct mie_name_bucket *bucket, const char *s, uint64_t hash)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&bucket->b_names);
|
||||
fx_queue_entry *entry = fx_queue_first(&bucket->b_names);
|
||||
while (entry) {
|
||||
struct mie_name_map_entry *map_entry
|
||||
= b_unbox(struct mie_name_map_entry, entry, e_entry);
|
||||
= fx_unbox(struct mie_name_map_entry, entry, e_entry);
|
||||
struct mie_name *name = (struct mie_name *)map_entry;
|
||||
if (check_name(name, s, hash)) {
|
||||
return name;
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -194,7 +194,7 @@ const struct mie_name *mie_name_map_get(
|
||||
const struct mie_name_map *map, const char *name,
|
||||
enum mie_name_map_flags flags)
|
||||
{
|
||||
uint64_t name_hash = b_hash_cstr(name);
|
||||
uint64_t name_hash = fx_hash_cstr(name);
|
||||
while (map) {
|
||||
const struct mie_name *result = name_map_get(map, name, name_hash);
|
||||
if (result) {
|
||||
@@ -214,24 +214,24 @@ struct mie_name *mie_name_map_put(
|
||||
memset(entry, 0x0, sizeof *entry);
|
||||
entry->n_base.e_type = MIE_NAME_MAP_E_NAME;
|
||||
|
||||
b_rope base = {};
|
||||
fx_rope base = {};
|
||||
|
||||
if (hint) {
|
||||
b_rope_init_cstr_borrowed(&base, hint);
|
||||
fx_rope_init_cstr_borrowed(&base, hint);
|
||||
}
|
||||
|
||||
char str[256];
|
||||
|
||||
if (hint) {
|
||||
/* first try just the hint on its own */
|
||||
b_rope_to_cstr(&base, str, sizeof str);
|
||||
fx_rope_to_cstr(&base, str, sizeof str);
|
||||
entry->n_str = str;
|
||||
entry->n_base.e_hash = base.r_v.v_cstr.hash;
|
||||
b_status status = put_name(map, entry);
|
||||
fx_status status = put_name(map, entry);
|
||||
|
||||
if (B_OK(status)) {
|
||||
if (FX_OK(status)) {
|
||||
entry->n_parent = map;
|
||||
entry->n_str = b_strdup(str);
|
||||
entry->n_str = fx_strdup(str);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
@@ -244,15 +244,15 @@ struct mie_name *mie_name_map_put(
|
||||
|
||||
/* that name already exists, use a suffix to make the name unique.
|
||||
* alternately, no hint was specified, so it's up to us to generate the name */
|
||||
b_rope dot = B_ROPE_CHAR('.');
|
||||
b_rope suffix = B_ROPE_UINT(0);
|
||||
b_rope unique_name;
|
||||
fx_rope dot = FX_ROPE_CHAR('.');
|
||||
fx_rope suffix = FX_ROPE_UINT(0);
|
||||
fx_rope unique_name;
|
||||
|
||||
if (hint) {
|
||||
const b_rope *parts[] = {&base, &dot, &suffix};
|
||||
b_rope_join(&unique_name, parts, sizeof parts / sizeof parts[0]);
|
||||
const fx_rope *parts[] = {&base, &dot, &suffix};
|
||||
fx_rope_join(&unique_name, parts, sizeof parts / sizeof parts[0]);
|
||||
} else {
|
||||
b_rope_concat(&unique_name, &base, &suffix);
|
||||
fx_rope_concat(&unique_name, &base, &suffix);
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
@@ -263,21 +263,21 @@ struct mie_name *mie_name_map_put(
|
||||
for (;; i++) {
|
||||
suffix.r_v.v_uint = i;
|
||||
|
||||
b_rope_to_cstr(&unique_name, str, sizeof str);
|
||||
fx_rope_to_cstr(&unique_name, str, sizeof str);
|
||||
|
||||
entry->n_str = str;
|
||||
entry->n_base.e_hash = b_hash_cstr(str);
|
||||
b_status status = put_name(map, entry);
|
||||
entry->n_base.e_hash = fx_hash_cstr(str);
|
||||
fx_status status = put_name(map, entry);
|
||||
|
||||
if (B_OK(status)) {
|
||||
if (FX_OK(status)) {
|
||||
entry->n_parent = map;
|
||||
entry->n_str = b_strdup(str);
|
||||
b_rope_destroy(&unique_name);
|
||||
entry->n_str = fx_strdup(str);
|
||||
fx_rope_destroy(&unique_name);
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
b_rope_destroy(&unique_name);
|
||||
fx_rope_destroy(&unique_name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -292,11 +292,11 @@ void mie_name_move(struct mie_name *dst, struct mie_name *src)
|
||||
memmove(dst, src, sizeof *src);
|
||||
|
||||
if (src->n_bucket) {
|
||||
b_queue_move(
|
||||
fx_queue_move(
|
||||
&src->n_bucket->b_names, &dst->n_base.e_entry,
|
||||
&src->n_base.e_entry);
|
||||
} else {
|
||||
b_btree_move(
|
||||
fx_bst_move(
|
||||
&src->n_parent->m_entries, &dst->n_base.e_node,
|
||||
&src->n_base.e_node);
|
||||
}
|
||||
@@ -318,11 +318,11 @@ void mie_name_destroy(struct mie_name *name)
|
||||
|
||||
switch (entry->e_type) {
|
||||
case MIE_NAME_MAP_E_NAME:
|
||||
b_btree_delete(&parent->m_entries, &entry->e_node);
|
||||
fx_bst_delete(&parent->m_entries, &entry->e_node);
|
||||
break;
|
||||
case MIE_NAME_MAP_E_BUCKET:
|
||||
bucket = b_unbox(struct mie_name_bucket, entry, b_base);
|
||||
b_queue_delete(&bucket->b_names, &name->n_base.e_entry);
|
||||
bucket = fx_unbox(struct mie_name_bucket, entry, b_base);
|
||||
fx_queue_delete(&bucket->b_names, &name->n_base.e_entry);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
|
||||
122
mie/parse/lex.c
122
mie/parse/lex.c
@@ -1,11 +1,11 @@
|
||||
#include "lex.h"
|
||||
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/ds/dict.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/hash.h>
|
||||
#include <fx/core/misc.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/ds/dict.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <ctype.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/diag/diag.h>
|
||||
@@ -22,10 +22,10 @@
|
||||
#define LEX_TOKEN_DEF(i, n) {.id = (i), .name = (n)}
|
||||
|
||||
#define IS_VALID_IDENT_CHAR(c) \
|
||||
(b_wchar_is_alnum(c) || c == '.' || c == '-' || c == '_')
|
||||
(fx_wchar_is_alnum(c) || c == '.' || c == '-' || c == '_')
|
||||
#define IS_VALID_IDENT_START_CHAR(c) \
|
||||
(b_wchar_is_alpha(c) || c == '.' || c == '_')
|
||||
#define IS_VALID_REG_START_CHAR(c) (b_wchar_is_alnum(c) || c == '.' || c == '_')
|
||||
(fx_wchar_is_alpha(c) || c == '.' || c == '_')
|
||||
#define IS_VALID_REG_START_CHAR(c) (fx_wchar_is_alnum(c) || c == '.' || c == '_')
|
||||
|
||||
static struct lex_token_def symbols[] = {
|
||||
LEX_TOKEN_DEF(MIE_SYM_COLON, ":"),
|
||||
@@ -57,15 +57,15 @@ static const size_t nr_symbols = sizeof symbols / sizeof symbols[0];
|
||||
static struct mie_lex_symbol_node *get_symbol_node(
|
||||
struct mie_lex_symbol_node *node, char c)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&node->s_children);
|
||||
fx_queue_entry *entry = fx_queue_first(&node->s_children);
|
||||
while (entry) {
|
||||
struct mie_lex_symbol_node *child
|
||||
= b_unbox(struct mie_lex_symbol_node, entry, s_entry);
|
||||
= fx_unbox(struct mie_lex_symbol_node, entry, s_entry);
|
||||
if (child->s_char == c) {
|
||||
return child;
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -79,13 +79,13 @@ static struct mie_diag *push_diag(struct mie_lex *lex, unsigned long diag_class)
|
||||
diag_class);
|
||||
}
|
||||
|
||||
static b_string *get_temp_string(struct mie_lex *lex)
|
||||
static fx_string *get_temp_string(struct mie_lex *lex)
|
||||
{
|
||||
if (!lex->lex_temp) {
|
||||
lex->lex_temp = b_string_create();
|
||||
lex->lex_temp = fx_string_create();
|
||||
}
|
||||
|
||||
b_string_clear(lex->lex_temp);
|
||||
fx_string_clear(lex->lex_temp);
|
||||
return lex->lex_temp;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ static enum mie_status put_symbol(
|
||||
child->s_def = NULL;
|
||||
child->s_char = c;
|
||||
|
||||
b_queue_push_back(&tree->s_children, &child->s_entry);
|
||||
fx_queue_push_back(&tree->s_children, &child->s_entry);
|
||||
tree = child;
|
||||
}
|
||||
|
||||
@@ -120,12 +120,12 @@ static enum mie_status put_symbol(
|
||||
|
||||
static void destroy_symbol_tree(struct mie_lex_symbol_node *tree)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&tree->s_children);
|
||||
fx_queue_entry *entry = fx_queue_first(&tree->s_children);
|
||||
while (entry) {
|
||||
struct mie_lex_symbol_node *node
|
||||
= b_unbox(struct mie_lex_symbol_node, entry, s_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&tree->s_children, entry);
|
||||
= fx_unbox(struct mie_lex_symbol_node, entry, s_entry);
|
||||
fx_queue_entry *next = fx_queue_next(entry);
|
||||
fx_queue_delete(&tree->s_children, entry);
|
||||
|
||||
destroy_symbol_tree(node);
|
||||
|
||||
@@ -183,13 +183,13 @@ struct mie_lex *mie_lex_create(struct mie_line_source *src, struct mie_ctx *ctx)
|
||||
|
||||
void mie_lex_destroy(struct mie_lex *lex)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
|
||||
fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
|
||||
|
||||
while (entry) {
|
||||
struct mie_token *tok
|
||||
= b_unbox(struct mie_token, entry, tok_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&lex->lex_queue, entry);
|
||||
= fx_unbox(struct mie_token, entry, tok_entry);
|
||||
fx_queue_entry *next = fx_queue_next(entry);
|
||||
fx_queue_delete(&lex->lex_queue, entry);
|
||||
|
||||
mie_token_destroy(tok);
|
||||
|
||||
@@ -201,7 +201,7 @@ void mie_lex_destroy(struct mie_lex *lex)
|
||||
}
|
||||
|
||||
if (lex->lex_temp) {
|
||||
b_string_unref(lex->lex_temp);
|
||||
fx_string_unref(lex->lex_temp);
|
||||
}
|
||||
|
||||
free(lex);
|
||||
@@ -261,7 +261,7 @@ static enum mie_status push_token(struct mie_lex *lex, struct mie_token *tok)
|
||||
tok->tok_location.s_start = lex->lex_token_start;
|
||||
tok->tok_location.s_end = lex->lex_token_end;
|
||||
|
||||
b_queue_push_back(&lex->lex_queue, &tok->tok_entry);
|
||||
fx_queue_push_back(&lex->lex_queue, &tok->tok_entry);
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ static enum mie_status push_float(struct mie_lex *lex, double v)
|
||||
static enum mie_status read_line_comment(struct mie_lex *lex)
|
||||
{
|
||||
while (true) {
|
||||
b_wchar c = mie_line_source_getc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_getc(lex->lex_source);
|
||||
|
||||
if (c == -MIE_ERR_EOF || c == '\n') {
|
||||
break;
|
||||
@@ -373,14 +373,14 @@ static enum mie_status read_number(struct mie_lex *lex, bool negate)
|
||||
int token_len = 0;
|
||||
int base = 10;
|
||||
int dots = 0;
|
||||
b_string *str = get_temp_string(lex);
|
||||
fx_string *str = get_temp_string(lex);
|
||||
|
||||
if (!negate) {
|
||||
set_token_start(lex);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
if (c == -MIE_ERR_EOF) {
|
||||
break;
|
||||
}
|
||||
@@ -408,13 +408,13 @@ static enum mie_status read_number(struct mie_lex *lex, bool negate)
|
||||
token_len++;
|
||||
dots++;
|
||||
char s[] = {c, 0};
|
||||
b_string_append_cstr(str, s);
|
||||
fx_string_append_cstr(str, s);
|
||||
set_token_end(lex);
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (b_wchar_is_space(c) || b_wchar_is_punct(c)) {
|
||||
if (fx_wchar_is_space(c) || fx_wchar_is_punct(c)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ static enum mie_status read_number(struct mie_lex *lex, bool negate)
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
b_string_append_wc(str, c);
|
||||
fx_string_append_wc(str, c);
|
||||
set_token_end(lex);
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
token_len++;
|
||||
@@ -456,7 +456,7 @@ static enum mie_status read_number(struct mie_lex *lex, bool negate)
|
||||
return push_int(lex, 0);
|
||||
}
|
||||
|
||||
const char *s = b_string_ptr(str);
|
||||
const char *s = fx_string_ptr(str);
|
||||
char *ep = NULL;
|
||||
|
||||
/* negative numbers will be lexed as a hyphen followed by a positive
|
||||
@@ -492,15 +492,15 @@ static enum mie_status read_number(struct mie_lex *lex, bool negate)
|
||||
static enum mie_status read_ident(struct mie_lex *lex, enum mie_token_type type)
|
||||
{
|
||||
int dots = 0;
|
||||
b_string *str = get_temp_string(lex);
|
||||
b_wchar prev = 0;
|
||||
fx_string *str = get_temp_string(lex);
|
||||
fx_wchar prev = 0;
|
||||
|
||||
if (type == MIE_TOK_NONE) {
|
||||
set_token_start(lex);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
|
||||
if ((c == '.' || c == '-') && prev == c) {
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
@@ -515,7 +515,7 @@ static enum mie_status read_ident(struct mie_lex *lex, enum mie_token_type type)
|
||||
}
|
||||
|
||||
prev = c;
|
||||
b_string_append_wc(str, c);
|
||||
fx_string_append_wc(str, c);
|
||||
set_token_end(lex);
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
}
|
||||
@@ -524,7 +524,7 @@ static enum mie_status read_ident(struct mie_lex *lex, enum mie_token_type type)
|
||||
type = dots > 0 ? MIE_TOK_NAME : MIE_TOK_WORD;
|
||||
}
|
||||
|
||||
char *s = b_string_steal(str);
|
||||
char *s = fx_string_steal(str);
|
||||
|
||||
switch (type) {
|
||||
case MIE_TOK_INSTNAME:
|
||||
@@ -543,9 +543,9 @@ static enum mie_status read_ident(struct mie_lex *lex, enum mie_token_type type)
|
||||
|
||||
static enum mie_status read_string(struct mie_lex *lex)
|
||||
{
|
||||
b_string *str = get_temp_string(lex);
|
||||
fx_string *str = get_temp_string(lex);
|
||||
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
bool esc = false;
|
||||
|
||||
if (c != '"') {
|
||||
@@ -555,13 +555,13 @@ static enum mie_status read_string(struct mie_lex *lex)
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
|
||||
while (1) {
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
|
||||
if (esc) {
|
||||
switch (c) {
|
||||
case '\\':
|
||||
case '"':
|
||||
b_string_append_wc(str, c);
|
||||
fx_string_append_wc(str, c);
|
||||
break;
|
||||
default:
|
||||
return MIE_ERR_BAD_SYNTAX;
|
||||
@@ -583,11 +583,11 @@ static enum mie_status read_string(struct mie_lex *lex)
|
||||
break;
|
||||
}
|
||||
|
||||
b_string_append_wc(str, c);
|
||||
fx_string_append_wc(str, c);
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
}
|
||||
|
||||
char *s = b_string_steal(str);
|
||||
char *s = fx_string_steal(str);
|
||||
return push_string_token(lex, MIE_TOK_STRING, s);
|
||||
}
|
||||
|
||||
@@ -595,10 +595,10 @@ static enum mie_status read_symbol(struct mie_lex *lex)
|
||||
{
|
||||
struct mie_lex_symbol_node *node = lex->lex_sym_tree;
|
||||
set_token_start(lex);
|
||||
b_wchar prev = 0;
|
||||
fx_wchar prev = 0;
|
||||
|
||||
while (true) {
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
if (c < 0) {
|
||||
break;
|
||||
}
|
||||
@@ -667,17 +667,17 @@ static enum mie_status read_symbol(struct mie_lex *lex)
|
||||
|
||||
static void skip_whitespace(struct mie_lex *lex)
|
||||
{
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
|
||||
while (b_wchar_is_space(c)) {
|
||||
while (fx_wchar_is_space(c)) {
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
c = mie_line_source_peekc(lex->lex_source);
|
||||
}
|
||||
}
|
||||
|
||||
static bool should_skip(b_wchar c, bool skip_linefeeds)
|
||||
static bool should_skip(fx_wchar c, bool skip_linefeeds)
|
||||
{
|
||||
bool skip = b_wchar_is_space(c);
|
||||
bool skip = fx_wchar_is_space(c);
|
||||
|
||||
if (!skip_linefeeds) {
|
||||
skip = (skip && c != '\n');
|
||||
@@ -688,7 +688,7 @@ static bool should_skip(b_wchar c, bool skip_linefeeds)
|
||||
|
||||
static void skip_ignored_chars(struct mie_lex *lex, bool include_linefeeds)
|
||||
{
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
|
||||
while (1) {
|
||||
while (should_skip(c, include_linefeeds)) {
|
||||
@@ -715,14 +715,14 @@ static void skip_ignored_chars(struct mie_lex *lex, bool include_linefeeds)
|
||||
|
||||
static enum mie_status pump_tokens(struct mie_lex *lex)
|
||||
{
|
||||
b_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
fx_wchar c = mie_line_source_peekc(lex->lex_source);
|
||||
|
||||
if (c < 0) {
|
||||
return -c;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (c == ';' || (b_wchar_is_space(c) && c != '\n')) {
|
||||
if (c == ';' || (fx_wchar_is_space(c) && c != '\n')) {
|
||||
skip_ignored_chars(lex, false);
|
||||
} else {
|
||||
break;
|
||||
@@ -758,7 +758,7 @@ static enum mie_status pump_tokens(struct mie_lex *lex)
|
||||
return push_linefeed(lex);
|
||||
}
|
||||
|
||||
while (b_wchar_is_space(c) && c != '\n') {
|
||||
while (fx_wchar_is_space(c) && c != '\n') {
|
||||
mie_line_source_getc(lex->lex_source);
|
||||
c = mie_line_source_peekc(lex->lex_source);
|
||||
}
|
||||
@@ -800,7 +800,7 @@ struct mie_token *mie_lex_peek(struct mie_lex *lex)
|
||||
{
|
||||
enum mie_status status = MIE_SUCCESS;
|
||||
|
||||
while (b_queue_empty(&lex->lex_queue)) {
|
||||
while (fx_queue_empty(&lex->lex_queue)) {
|
||||
status = pump_tokens(lex);
|
||||
|
||||
if (status != MIE_SUCCESS) {
|
||||
@@ -811,8 +811,8 @@ struct mie_token *mie_lex_peek(struct mie_lex *lex)
|
||||
|
||||
lex->lex_status = status;
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
|
||||
struct mie_token *tok = b_unbox(struct mie_token, entry, tok_entry);
|
||||
fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
|
||||
struct mie_token *tok = fx_unbox(struct mie_token, entry, tok_entry);
|
||||
return tok;
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ void mie_lex_advance(struct mie_lex *lex)
|
||||
{
|
||||
enum mie_status status = MIE_SUCCESS;
|
||||
|
||||
while (b_queue_empty(&lex->lex_queue)) {
|
||||
while (fx_queue_empty(&lex->lex_queue)) {
|
||||
status = pump_tokens(lex);
|
||||
|
||||
if (status != MIE_SUCCESS) {
|
||||
@@ -829,14 +829,14 @@ void mie_lex_advance(struct mie_lex *lex)
|
||||
}
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_pop_front(&lex->lex_queue);
|
||||
struct mie_token *tok = b_unbox(struct mie_token, entry, tok_entry);
|
||||
fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue);
|
||||
struct mie_token *tok = fx_unbox(struct mie_token, entry, tok_entry);
|
||||
mie_token_destroy(tok);
|
||||
}
|
||||
|
||||
bool mie_lex_tokens_available(struct mie_lex *lex)
|
||||
{
|
||||
if (!b_queue_empty(&lex->lex_queue)) {
|
||||
if (!fx_queue_empty(&lex->lex_queue)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef _PARSE_LEX_H_
|
||||
#define _PARSE_LEX_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/ds/dict.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <fx/ds/dict.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/parse/lex.h>
|
||||
#include <mie/parse/line-source.h>
|
||||
#include <mie/parse/token.h>
|
||||
@@ -16,10 +16,10 @@ struct mie_lex {
|
||||
enum mie_status lex_status;
|
||||
|
||||
struct mie_ctx *lex_ctx;
|
||||
b_queue lex_queue;
|
||||
fx_queue lex_queue;
|
||||
|
||||
b_string *lex_temp;
|
||||
b_queue lex_state;
|
||||
fx_string *lex_temp;
|
||||
fx_queue lex_state;
|
||||
unsigned int lex_brace_depth;
|
||||
|
||||
struct mie_file_cell lex_token_start, lex_token_end;
|
||||
@@ -29,8 +29,8 @@ struct mie_lex_symbol_node {
|
||||
char s_char;
|
||||
struct lex_token_def *s_def;
|
||||
|
||||
b_queue_entry s_entry;
|
||||
b_queue s_children;
|
||||
fx_queue_entry s_entry;
|
||||
fx_queue s_children;
|
||||
};
|
||||
|
||||
struct lex_token_def {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <mie/parse/line-source.h>
|
||||
|
||||
enum mie_status mie_line_source_init(
|
||||
struct mie_line_source *src, const char *path, b_stream *stream)
|
||||
struct mie_line_source *src, const char *path, fx_stream *stream)
|
||||
{
|
||||
memset(src, 0x0, sizeof *src);
|
||||
|
||||
src->s_lines = b_array_create();
|
||||
src->s_lines = fx_array_create();
|
||||
|
||||
if (!src->s_lines) {
|
||||
return MIE_ERR_NO_MEMORY;
|
||||
@@ -22,11 +22,11 @@ enum mie_status mie_line_source_init(
|
||||
void mie_line_source_cleanup(struct mie_line_source *src)
|
||||
{
|
||||
if (src->s_linebuf_ptr) {
|
||||
b_iterator_unref(src->s_linebuf_ptr);
|
||||
fx_iterator_unref(src->s_linebuf_ptr);
|
||||
}
|
||||
|
||||
if (src->s_lines) {
|
||||
b_array_unref(src->s_lines);
|
||||
fx_array_unref(src->s_lines);
|
||||
}
|
||||
|
||||
memset(src, 0x0, sizeof *src);
|
||||
@@ -50,31 +50,31 @@ static enum mie_status refill_linebuf(struct mie_line_source *src)
|
||||
}
|
||||
|
||||
if (src->s_linebuf_ptr) {
|
||||
b_iterator_unref(src->s_linebuf_ptr);
|
||||
fx_iterator_unref(src->s_linebuf_ptr);
|
||||
src->s_linebuf_ptr = NULL;
|
||||
}
|
||||
|
||||
b_stringstream *s = b_stringstream_create();
|
||||
fx_stringstream *s = fx_stringstream_create();
|
||||
|
||||
b_status status = b_stream_read_line_s(src->s_stream, s);
|
||||
fx_status status = fx_stream_read_line_s(src->s_stream, s);
|
||||
|
||||
if (status == B_ERR_NO_DATA) {
|
||||
if (status == FX_ERR_NO_DATA) {
|
||||
return MIE_ERR_EOF;
|
||||
}
|
||||
|
||||
if (!B_OK(status)) {
|
||||
if (!FX_OK(status)) {
|
||||
return MIE_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
b_string *line = b_string_create();
|
||||
b_string_replace_all_with_stringstream(line, s);
|
||||
b_stringstream_unref(s);
|
||||
fx_string *line = fx_string_create();
|
||||
fx_string_replace_all_with_stringstream(line, s);
|
||||
fx_stringstream_unref(s);
|
||||
|
||||
b_array_append(src->s_lines, line);
|
||||
b_string_unref(line);
|
||||
fx_array_append(src->s_lines, line);
|
||||
fx_string_unref(line);
|
||||
|
||||
src->s_linebuf = line;
|
||||
src->s_linebuf_ptr = b_iterator_begin(src->s_linebuf);
|
||||
src->s_linebuf_ptr = fx_iterator_begin(src->s_linebuf);
|
||||
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ static int peek(struct mie_line_source *src)
|
||||
{
|
||||
enum mie_status status = MIE_SUCCESS;
|
||||
|
||||
if (!src->s_linebuf_ptr || !b_iterator_is_valid(src->s_linebuf_ptr)) {
|
||||
if (!src->s_linebuf_ptr || !fx_iterator_is_valid(src->s_linebuf_ptr)) {
|
||||
status = refill_linebuf(src);
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ static int peek(struct mie_line_source *src)
|
||||
return -status;
|
||||
}
|
||||
|
||||
if (b_string_get_size(src->s_linebuf, B_STRLEN_NORMAL) == 0) {
|
||||
if (fx_string_get_size(src->s_linebuf, FX_STRLEN_NORMAL) == 0) {
|
||||
return -MIE_ERR_EOF;
|
||||
}
|
||||
|
||||
b_wchar c = b_iterator_get_value(src->s_linebuf_ptr).v_int;
|
||||
fx_wchar c = fx_iterator_get_value(src->s_linebuf_ptr).v_int;
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ static int advance(struct mie_line_source *src)
|
||||
{
|
||||
enum mie_status status = MIE_SUCCESS;
|
||||
|
||||
if (!b_iterator_is_valid(src->s_linebuf_ptr)) {
|
||||
if (!fx_iterator_is_valid(src->s_linebuf_ptr)) {
|
||||
status = refill_linebuf(src);
|
||||
}
|
||||
|
||||
@@ -111,12 +111,12 @@ static int advance(struct mie_line_source *src)
|
||||
return -status;
|
||||
}
|
||||
|
||||
if (b_string_get_size(src->s_linebuf, B_STRLEN_NORMAL) == 0) {
|
||||
if (fx_string_get_size(src->s_linebuf, FX_STRLEN_NORMAL) == 0) {
|
||||
return -MIE_ERR_EOF;
|
||||
}
|
||||
|
||||
b_wchar c = b_iterator_get_value(src->s_linebuf_ptr).v_int;
|
||||
b_iterator_move_next(src->s_linebuf_ptr);
|
||||
fx_wchar c = fx_iterator_get_value(src->s_linebuf_ptr).v_int;
|
||||
fx_iterator_move_next(src->s_linebuf_ptr);
|
||||
|
||||
src->s_cursor.c_col++;
|
||||
if (c == '\n') {
|
||||
@@ -126,18 +126,18 @@ static int advance(struct mie_line_source *src)
|
||||
return c;
|
||||
}
|
||||
|
||||
b_wchar mie_line_source_peekc(struct mie_line_source *src)
|
||||
fx_wchar mie_line_source_peekc(struct mie_line_source *src)
|
||||
{
|
||||
return peek(src);
|
||||
}
|
||||
|
||||
b_wchar mie_line_source_getc(struct mie_line_source *src)
|
||||
fx_wchar mie_line_source_getc(struct mie_line_source *src)
|
||||
{
|
||||
return advance(src);
|
||||
}
|
||||
|
||||
enum mie_status mie_line_source_get_row(
|
||||
struct mie_line_source *src, size_t row, const b_string **out)
|
||||
struct mie_line_source *src, size_t row, const fx_string **out)
|
||||
{
|
||||
if (row == 0) {
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
@@ -145,11 +145,11 @@ enum mie_status mie_line_source_get_row(
|
||||
|
||||
row--;
|
||||
|
||||
if (row >= b_array_size(src->s_lines)) {
|
||||
if (row >= fx_array_size(src->s_lines)) {
|
||||
return MIE_ERR_EOF;
|
||||
}
|
||||
|
||||
b_string *line = b_array_at(src->s_lines, row);
|
||||
fx_string *line = fx_array_at(src->s_lines, row);
|
||||
*out = line;
|
||||
|
||||
return MIE_SUCCESS;
|
||||
@@ -157,5 +157,5 @@ enum mie_status mie_line_source_get_row(
|
||||
|
||||
bool mie_line_source_input_available(struct mie_line_source *src)
|
||||
{
|
||||
return src->s_linebuf_ptr && b_iterator_is_valid(src->s_linebuf_ptr);
|
||||
return src->s_linebuf_ptr && fx_iterator_is_valid(src->s_linebuf_ptr);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/core/bstr.h>
|
||||
#include <fx/core/bstr.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/attribute/attribute-map.h>
|
||||
#include <mie/ctx.h>
|
||||
@@ -25,49 +25,49 @@ struct mie_parser {
|
||||
struct mie_ctx *p_ctx;
|
||||
struct mie_lex *p_lex;
|
||||
enum mie_status p_status;
|
||||
b_string *s_tmp;
|
||||
fx_string *s_tmp;
|
||||
};
|
||||
|
||||
static b_string *get_temp_string(struct mie_parser *parser)
|
||||
static fx_string *get_temp_string(struct mie_parser *parser)
|
||||
{
|
||||
b_string_clear(parser->s_tmp);
|
||||
fx_string_clear(parser->s_tmp);
|
||||
return parser->s_tmp;
|
||||
}
|
||||
|
||||
#define GET_SOMETHING_BY_FULL_NAME(thing) \
|
||||
static const struct mie_##thing##_definition *get_##thing##_by_full_name( \
|
||||
struct mie_parser *ctx, b_string *name) \
|
||||
struct mie_parser *ctx, fx_string *name) \
|
||||
{ \
|
||||
b_string *dialect = b_string_create(); \
|
||||
b_string *item = b_string_create(); \
|
||||
fx_string *dialect = fx_string_create(); \
|
||||
fx_string *item = fx_string_create(); \
|
||||
const char *delim[] = {"."}; \
|
||||
size_t i = 0; \
|
||||
b_iterator *it = b_string_tokenise( \
|
||||
name, delim, 1, B_STRING_TOK_F_NORMAL); \
|
||||
while (b_iterator_is_valid(it)) { \
|
||||
const char *tok = b_iterator_get_cvalue(it).v_cptr; \
|
||||
fx_iterator *it = fx_string_tokenise( \
|
||||
name, delim, 1, FX_STRING_TOK_F_NORMAL); \
|
||||
while (fx_iterator_is_valid(it)) { \
|
||||
const char *tok = fx_iterator_get_cvalue(it).v_cptr; \
|
||||
switch (i) { \
|
||||
case 0: \
|
||||
b_string_append_cstr(dialect, tok); \
|
||||
fx_string_append_cstr(dialect, tok); \
|
||||
break; \
|
||||
case 1: \
|
||||
b_string_append_cstr(item, tok); \
|
||||
fx_string_append_cstr(item, tok); \
|
||||
break; \
|
||||
default: \
|
||||
b_string_append_c(item, '.'); \
|
||||
b_string_append_cstr(item, tok); \
|
||||
fx_string_append_c(item, '.'); \
|
||||
fx_string_append_cstr(item, tok); \
|
||||
break; \
|
||||
} \
|
||||
b_iterator_move_next(it); \
|
||||
fx_iterator_move_next(it); \
|
||||
i++; \
|
||||
} \
|
||||
b_iterator_unref(it); \
|
||||
fx_iterator_unref(it); \
|
||||
const struct mie_##thing##_definition *def \
|
||||
= mie_ctx_get_##thing##_definition( \
|
||||
ctx->p_ctx, b_string_ptr(dialect), \
|
||||
b_string_ptr(item)); \
|
||||
b_string_unref(dialect); \
|
||||
b_string_unref(item); \
|
||||
ctx->p_ctx, fx_string_ptr(dialect), \
|
||||
fx_string_ptr(item)); \
|
||||
fx_string_unref(dialect); \
|
||||
fx_string_unref(item); \
|
||||
return def; \
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ struct mie_parser *mie_parser_create(struct mie_ctx *ctx, struct mie_lex *lex)
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->s_tmp = b_string_create();
|
||||
out->s_tmp = fx_string_create();
|
||||
if (!out->s_tmp) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -100,7 +100,7 @@ struct mie_parser *mie_parser_create(struct mie_ctx *ctx, struct mie_lex *lex)
|
||||
void mie_parser_destroy(struct mie_parser *ctx)
|
||||
{
|
||||
if (ctx->s_tmp) {
|
||||
b_string_unref(ctx->s_tmp);
|
||||
fx_string_unref(ctx->s_tmp);
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
@@ -126,7 +126,7 @@ void mie_parser_set_status(struct mie_parser *ctx, enum mie_status status)
|
||||
ctx->p_status = status;
|
||||
}
|
||||
|
||||
b_string *mie_parser_get_tempstr(struct mie_parser *ctx)
|
||||
fx_string *mie_parser_get_tempstr(struct mie_parser *ctx)
|
||||
{
|
||||
return get_temp_string(ctx);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ bool mie_parser_parse_float(
|
||||
|
||||
#define TOKEN_PARSER(name, id) \
|
||||
bool mie_parser_parse_##name( \
|
||||
struct mie_parser *ctx, b_string *out, struct mie_file_span *loc) \
|
||||
struct mie_parser *ctx, fx_string *out, struct mie_file_span *loc) \
|
||||
{ \
|
||||
if (!mie_parser_check_type(ctx, id)) { \
|
||||
return false; \
|
||||
@@ -225,10 +225,10 @@ bool mie_parser_parse_float(
|
||||
struct mie_token *tok = mie_lex_peek(ctx->p_lex); \
|
||||
switch (tok->tok_value_type) { \
|
||||
case MIE_TOK_V_STRING: \
|
||||
b_string_append_cstr(out, tok->tok_str); \
|
||||
fx_string_append_cstr(out, tok->tok_str); \
|
||||
break; \
|
||||
case MIE_TOK_V_INT: \
|
||||
b_string_append_cstrf(out, "%lld", tok->tok_int); \
|
||||
fx_string_append_cstrf(out, "%lld", tok->tok_int); \
|
||||
break; \
|
||||
default: \
|
||||
return false; \
|
||||
@@ -256,12 +256,12 @@ TOKEN_PARSER(string, MIE_TOK_STRING);
|
||||
bool mie_parser_parse_keyword(
|
||||
struct mie_parser *ctx, const char *kw, struct mie_file_span *loc)
|
||||
{
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
if (!mie_parser_parse_word(ctx, str, loc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strcmp(b_string_ptr(str), kw) == 0;
|
||||
return strcmp(fx_string_ptr(str), kw) == 0;
|
||||
}
|
||||
|
||||
bool mie_parser_parse_symbol(struct mie_parser *ctx, enum mie_token_symbol sym)
|
||||
@@ -294,7 +294,7 @@ static bool parse_builtin_type_name(
|
||||
struct mie_parser *ctx, const char *context,
|
||||
const struct mie_type **out, struct mie_file_span *out_span)
|
||||
{
|
||||
b_string *name = get_temp_string(ctx);
|
||||
fx_string *name = get_temp_string(ctx);
|
||||
struct mie_file_span loc;
|
||||
if (!mie_parser_parse_word(ctx, name, &loc)) {
|
||||
return false;
|
||||
@@ -315,7 +315,7 @@ static bool parse_builtin_type_name(
|
||||
FLOAT
|
||||
} base_type = NONE;
|
||||
|
||||
const char *name_cstr = b_string_ptr(name);
|
||||
const char *name_cstr = fx_string_ptr(name);
|
||||
|
||||
if (!strcmp(name_cstr, "memref")) {
|
||||
type_info = mie_ctx_get_type_definition(
|
||||
@@ -381,7 +381,7 @@ static bool parse_type_name(
|
||||
struct mie_parser *ctx, const char *context,
|
||||
const struct mie_type **out, struct mie_file_span *out_span)
|
||||
{
|
||||
b_string *name = get_temp_string(ctx);
|
||||
fx_string *name = get_temp_string(ctx);
|
||||
struct mie_file_span loc;
|
||||
if (!mie_parser_parse_typename(ctx, name, &loc)) {
|
||||
return false;
|
||||
@@ -625,16 +625,16 @@ MIE_API bool mie_parser_parse_function_type(
|
||||
bool mie_parser_parse_operand(struct mie_parser *ctx, struct mie_op_arg *out)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
bool result = false;
|
||||
|
||||
struct mie_file_span loc;
|
||||
if (mie_parser_parse_vregname(ctx, str, &loc)) {
|
||||
out->arg_unresolved.reg_name = b_string_steal(str);
|
||||
out->arg_unresolved.reg_name = fx_string_steal(str);
|
||||
out->arg_unresolved.reg_flags = MIE_REGISTER_F_VIRTUAL;
|
||||
result = true;
|
||||
} else if (mie_parser_parse_mregname(ctx, str, &loc)) {
|
||||
out->arg_unresolved.reg_name = b_string_steal(str);
|
||||
out->arg_unresolved.reg_name = fx_string_steal(str);
|
||||
out->arg_unresolved.reg_flags = MIE_REGISTER_F_MACHINE;
|
||||
result = true;
|
||||
}
|
||||
@@ -698,14 +698,14 @@ bool mie_parser_parse_parameter(
|
||||
const char *context)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
|
||||
struct mie_file_span loc;
|
||||
if (mie_parser_parse_vregname(ctx, str, &loc)) {
|
||||
out->arg_unresolved.reg_name = b_string_steal(str);
|
||||
out->arg_unresolved.reg_name = fx_string_steal(str);
|
||||
out->arg_unresolved.reg_flags = MIE_REGISTER_F_VIRTUAL;
|
||||
} else if (mie_parser_parse_mregname(ctx, str, &loc)) {
|
||||
out->arg_unresolved.reg_name = b_string_steal(str);
|
||||
out->arg_unresolved.reg_name = fx_string_steal(str);
|
||||
out->arg_unresolved.reg_flags = MIE_REGISTER_F_MACHINE;
|
||||
} else {
|
||||
struct mie_parser_item required[] = {
|
||||
@@ -823,16 +823,16 @@ bool mie_parser_parse_register(
|
||||
}
|
||||
|
||||
struct mie_name *name = NULL;
|
||||
b_string *tmp = get_temp_string(ctx);
|
||||
fx_string *tmp = get_temp_string(ctx);
|
||||
switch (tok->tok_value_type) {
|
||||
case MIE_TOK_V_STRING:
|
||||
name = mie_parser_scope_put_name(
|
||||
scope, &out->reg_name, tok->tok_str, MIE_NAME_MAP_F_STRICT);
|
||||
break;
|
||||
case MIE_TOK_V_INT:
|
||||
b_string_append_cstrf(tmp, "%lld", tok->tok_int);
|
||||
fx_string_append_cstrf(tmp, "%lld", tok->tok_int);
|
||||
name = mie_parser_scope_put_name(
|
||||
scope, &out->reg_name, b_string_ptr(tmp),
|
||||
scope, &out->reg_name, fx_string_ptr(tmp),
|
||||
MIE_NAME_MAP_F_STRICT);
|
||||
break;
|
||||
default:
|
||||
@@ -1070,7 +1070,7 @@ bool mie_parser_parse_block(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
struct mie_file_span span;
|
||||
|
||||
if (!mie_parser_parse_blockname(ctx, str, &span)) {
|
||||
@@ -1078,7 +1078,7 @@ bool mie_parser_parse_block(
|
||||
}
|
||||
|
||||
if (!mie_parser_scope_put_name(
|
||||
scope, &block->b_name, b_string_ptr(str),
|
||||
scope, &block->b_name, fx_string_ptr(str),
|
||||
MIE_NAME_MAP_F_STRICT)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1120,14 +1120,14 @@ bool mie_parser_parse_block(
|
||||
bool mie_parser_parse_successor(struct mie_parser *ctx, struct mie_op_successor *out)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
bool result = false;
|
||||
|
||||
if (!mie_parser_parse_blockname(ctx, str, &out->s_name_span)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
out->s_block_name = b_string_steal(str);
|
||||
out->s_block_name = fx_string_steal(str);
|
||||
|
||||
if (!mie_parser_parse_symbol(ctx, MIE_SYM_COLON)) {
|
||||
return true;
|
||||
@@ -1203,13 +1203,13 @@ bool mie_parser_parse_successor_list(
|
||||
static bool parse_custom_op(
|
||||
struct mie_parser *ctx, struct mie_parser_scope *scope, struct mie_op *dest)
|
||||
{
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
struct mie_file_span loc;
|
||||
if (!mie_parser_parse_name(ctx, str, &dest->op_name_span)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dest->op_name = b_string_steal(str);
|
||||
dest->op_name = fx_string_steal(str);
|
||||
|
||||
if (!mie_resolve_op_self(dest, ctx->p_ctx)) {
|
||||
struct mie_diag *diag = mie_ctx_push_diag(
|
||||
@@ -1267,13 +1267,13 @@ static bool parse_custom_op(
|
||||
static bool parse_builtin_op(
|
||||
struct mie_parser *ctx, struct mie_parser_scope *scope, struct mie_op *dest)
|
||||
{
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
struct mie_file_span loc;
|
||||
if (!mie_parser_parse_word(ctx, str, &loc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dest->op_name = b_bstr_fmt(NULL, "builtin.%s", b_string_ptr(str));
|
||||
dest->op_name = fx_bstr_fmt(NULL, "builtin.%s", fx_string_ptr(str));
|
||||
|
||||
if (!mie_resolve_op_self(dest, ctx->p_ctx)) {
|
||||
struct mie_diag *diag = mie_ctx_push_diag(
|
||||
@@ -1331,13 +1331,13 @@ static bool parse_builtin_op(
|
||||
static bool parse_generic_op(
|
||||
struct mie_parser *ctx, struct mie_parser_scope *scope, struct mie_op *dest)
|
||||
{
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
struct mie_file_span loc;
|
||||
if (!mie_parser_parse_opname(ctx, str, &loc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dest->op_name = b_string_steal(str);
|
||||
dest->op_name = fx_string_steal(str);
|
||||
|
||||
/* resolve the op now. we need to know if the op is isolated-from-above
|
||||
* in order to add register/block names to the correct region name maps. */
|
||||
@@ -1479,7 +1479,7 @@ bool mie_parser_parse_attribute(
|
||||
{
|
||||
enum mie_token_type type = mie_parser_peek_type(ctx);
|
||||
const struct mie_attribute_definition *attribute = NULL;
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
struct mie_file_span span;
|
||||
bool need_angle_delim = false;
|
||||
|
||||
@@ -1554,13 +1554,13 @@ static bool parse_attribute_map_entry(
|
||||
struct mie_parser *ctx, char **out_name,
|
||||
const struct mie_attribute **out_value)
|
||||
{
|
||||
b_string *str = get_temp_string(ctx);
|
||||
fx_string *str = get_temp_string(ctx);
|
||||
struct mie_file_span span;
|
||||
if (!mie_parser_parse_word(ctx, str, &span)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *name = b_string_steal(str);
|
||||
char *name = fx_string_steal(str);
|
||||
|
||||
if (!mie_parser_parse_symbol(ctx, MIE_SYM_EQUAL)) {
|
||||
free(name);
|
||||
@@ -1691,29 +1691,29 @@ void mie_parser_report_unexpected_token_v(
|
||||
struct mie_parser *parser,
|
||||
const struct mie_parser_item expected_tokens[], const char *context)
|
||||
{
|
||||
b_bstr str;
|
||||
b_bstr_begin_dynamic(&str);
|
||||
fx_bstr str;
|
||||
fx_bstr_begin_dynamic(&str);
|
||||
struct mie_token *tok = mie_lex_peek(parser->p_lex);
|
||||
|
||||
b_bstr_write_cstr(&str, "expected ", NULL);
|
||||
fx_bstr_write_cstr(&str, "expected ", NULL);
|
||||
|
||||
for (size_t i = 0; expected_tokens[i].i_type != MIE_PARSER_ITEM_NONE; i++) {
|
||||
bool end = expected_tokens[i + 1].i_type == MIE_PARSER_ITEM_NONE;
|
||||
|
||||
if (end && i > 0) {
|
||||
b_bstr_write_cstr(&str, " or ", NULL);
|
||||
fx_bstr_write_cstr(&str, " or ", NULL);
|
||||
} else if (i > 0) {
|
||||
b_bstr_write_cstr(&str, ", ", NULL);
|
||||
fx_bstr_write_cstr(&str, ", ", NULL);
|
||||
}
|
||||
|
||||
switch (expected_tokens[i].i_type) {
|
||||
case MIE_PARSER_ITEM_TOK:
|
||||
b_bstr_write_fmt(
|
||||
fx_bstr_write_fmt(
|
||||
&str, NULL, "[blue]%s[reset]",
|
||||
token_diag_string(expected_tokens[i].i_tok));
|
||||
break;
|
||||
case MIE_PARSER_ITEM_CSTR:
|
||||
b_bstr_write_fmt(
|
||||
fx_bstr_write_fmt(
|
||||
&str, NULL, "[blue]%s[reset]",
|
||||
expected_tokens[i].i_cstr);
|
||||
break;
|
||||
@@ -1723,22 +1723,22 @@ void mie_parser_report_unexpected_token_v(
|
||||
}
|
||||
|
||||
if (context) {
|
||||
b_bstr_write_fmt(
|
||||
fx_bstr_write_fmt(
|
||||
&str, NULL, " while parsing [cyan]%s[reset]", context);
|
||||
}
|
||||
|
||||
b_bstr_write_cstr(&str, "; found [red]", NULL);
|
||||
fx_bstr_write_cstr(&str, "; found [red]", NULL);
|
||||
if (MIE_TOKEN_TYPE(tok) == MIE_TOK_SYMBOL) {
|
||||
b_bstr_write_cstr(&str, token_diag_string(tok->tok_sym), NULL);
|
||||
fx_bstr_write_cstr(&str, token_diag_string(tok->tok_sym), NULL);
|
||||
} else if (tok != NULL) {
|
||||
b_bstr_write_cstr(&str, token_diag_string(tok->tok_type), NULL);
|
||||
fx_bstr_write_cstr(&str, token_diag_string(tok->tok_type), NULL);
|
||||
} else {
|
||||
b_bstr_write_cstr(&str, "end of file", NULL);
|
||||
fx_bstr_write_cstr(&str, "end of file", NULL);
|
||||
}
|
||||
b_bstr_write_cstr(&str, "[reset]", NULL);
|
||||
b_bstr_write_cstr(&str, ".", NULL);
|
||||
fx_bstr_write_cstr(&str, "[reset]", NULL);
|
||||
fx_bstr_write_cstr(&str, ".", NULL);
|
||||
|
||||
char *s = b_bstr_end(&str);
|
||||
char *s = fx_bstr_end(&str);
|
||||
|
||||
const struct mie_file_cell *loc = tok ? &tok->tok_location.s_start
|
||||
: mie_lex_get_cursor(parser->p_lex);
|
||||
@@ -1766,28 +1766,28 @@ void mie_parser_report_unexpected_token_v(
|
||||
void mie_parser_report_unexpected_token_s(
|
||||
struct mie_parser *parser, const char *expected_token, const char *context)
|
||||
{
|
||||
b_bstr str;
|
||||
b_bstr_begin_dynamic(&str);
|
||||
fx_bstr str;
|
||||
fx_bstr_begin_dynamic(&str);
|
||||
struct mie_token *tok = mie_lex_peek(parser->p_lex);
|
||||
|
||||
b_bstr_write_fmt(&str, NULL, "expected [blue]%s[reset]", expected_token);
|
||||
fx_bstr_write_fmt(&str, NULL, "expected [blue]%s[reset]", expected_token);
|
||||
if (context) {
|
||||
b_bstr_write_fmt(
|
||||
fx_bstr_write_fmt(
|
||||
&str, NULL, " while parsing [cyan]%s[reset]", context);
|
||||
}
|
||||
|
||||
b_bstr_write_cstr(&str, "; found [red]", NULL);
|
||||
fx_bstr_write_cstr(&str, "; found [red]", NULL);
|
||||
|
||||
if (MIE_TOKEN_TYPE(tok) == MIE_TOK_SYMBOL) {
|
||||
b_bstr_write_cstr(&str, token_diag_string(tok->tok_sym), NULL);
|
||||
fx_bstr_write_cstr(&str, token_diag_string(tok->tok_sym), NULL);
|
||||
} else if (tok != NULL) {
|
||||
b_bstr_write_cstr(&str, token_diag_string(tok->tok_type), NULL);
|
||||
fx_bstr_write_cstr(&str, token_diag_string(tok->tok_type), NULL);
|
||||
} else {
|
||||
b_bstr_write_cstr(&str, "end of file", NULL);
|
||||
fx_bstr_write_cstr(&str, "end of file", NULL);
|
||||
}
|
||||
b_bstr_write_cstr(&str, "[reset].", NULL);
|
||||
fx_bstr_write_cstr(&str, "[reset].", NULL);
|
||||
|
||||
char *s = b_bstr_end(&str);
|
||||
char *s = fx_bstr_end(&str);
|
||||
|
||||
const struct mie_file_cell *loc = tok ? &tok->tok_location.s_start
|
||||
: mie_lex_get_cursor(parser->p_lex);
|
||||
|
||||
@@ -52,7 +52,7 @@ static struct mie_rewrite_result if_rewrite(
|
||||
struct mie_register *old_reg = &op->op_result.items[i];
|
||||
struct mie_register *new_reg = mie_block_add_param(end_block);
|
||||
new_reg->reg_type = old_reg->reg_type;
|
||||
char *name = b_strdup(old_reg->reg_name.n_str);
|
||||
char *name = fx_strdup(old_reg->reg_name.n_str);
|
||||
|
||||
mie_name_destroy(&old_reg->reg_name);
|
||||
mie_rewriter_rename_register(rewriter, new_reg, name);
|
||||
@@ -163,7 +163,7 @@ static struct mie_rewrite_result for_rewrite(
|
||||
struct mie_register *old_reg = &op->op_result.items[i];
|
||||
struct mie_register *new_reg = mie_block_add_param(end_block);
|
||||
new_reg->reg_type = old_reg->reg_type;
|
||||
char *name = b_strdup(old_reg->reg_name.n_str);
|
||||
char *name = fx_strdup(old_reg->reg_name.n_str);
|
||||
|
||||
mie_name_destroy(&old_reg->reg_name);
|
||||
mie_rewriter_rename_register(rewriter, new_reg, name);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/interface/interface-definition.h>
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
struct pass_sched {
|
||||
struct mie_op *s_op;
|
||||
b_queue_entry s_entry;
|
||||
fx_queue_entry s_entry;
|
||||
/* queue of struct pass_sched_item */
|
||||
b_queue s_items;
|
||||
fx_queue s_items;
|
||||
};
|
||||
|
||||
struct pass_sched_item {
|
||||
b_queue_entry i_entry;
|
||||
fx_queue_entry i_entry;
|
||||
struct mie_pass *i_pass;
|
||||
};
|
||||
|
||||
@@ -181,10 +181,10 @@ void mie_pass_manager_add_pass(struct mie_pass_manager *pm, struct mie_pass *pas
|
||||
}
|
||||
|
||||
static void schedule_passes(
|
||||
struct mie_pass_manager *pm, b_queue *schedule, struct mie_op *op,
|
||||
struct mie_pass_manager *pm, fx_queue *schedule, struct mie_op *op,
|
||||
size_t depth)
|
||||
{
|
||||
b_queue passes = B_QUEUE_INIT;
|
||||
fx_queue passes = FX_QUEUE_INIT;
|
||||
if (!filter_check_op(&pm->pm_filter, op) || depth > pm->pm_depth) {
|
||||
return;
|
||||
}
|
||||
@@ -196,13 +196,13 @@ static void schedule_passes(
|
||||
}
|
||||
|
||||
struct pass_sched_item *item = pass_sched_item_create(pass);
|
||||
b_queue_push_back(&passes, &item->i_entry);
|
||||
fx_queue_push_back(&passes, &item->i_entry);
|
||||
}
|
||||
|
||||
if (!b_queue_empty(&passes)) {
|
||||
if (!fx_queue_empty(&passes)) {
|
||||
struct pass_sched *sched = pass_sched_create(op);
|
||||
sched->s_items = passes;
|
||||
b_queue_push_back(schedule, &sched->s_entry);
|
||||
fx_queue_push_back(schedule, &sched->s_entry);
|
||||
}
|
||||
|
||||
struct mie_walker walker;
|
||||
@@ -236,14 +236,14 @@ static void sched_execute(
|
||||
struct pass_sched *sched, struct mie_pass_args *args,
|
||||
struct mie_pass_result *result)
|
||||
{
|
||||
b_queue_entry *cur_item = NULL, *next_item = NULL;
|
||||
fx_queue_entry *cur_item = NULL, *next_item = NULL;
|
||||
struct pass_sched_item *sched_item = NULL;
|
||||
|
||||
cur_item = b_queue_first(&sched->s_items);
|
||||
cur_item = fx_queue_first(&sched->s_items);
|
||||
while (cur_item) {
|
||||
sched_item = b_unbox(struct pass_sched_item, cur_item, i_entry);
|
||||
next_item = b_queue_next(cur_item);
|
||||
b_queue_delete(&sched->s_items, cur_item);
|
||||
sched_item = fx_unbox(struct pass_sched_item, cur_item, i_entry);
|
||||
next_item = fx_queue_next(cur_item);
|
||||
fx_queue_delete(&sched->s_items, cur_item);
|
||||
|
||||
sched_item_execute(sched_item, sched->s_op, args, result);
|
||||
|
||||
@@ -255,10 +255,10 @@ static void sched_execute(
|
||||
struct mie_pass_result mie_pass_manager_run(
|
||||
struct mie_pass_manager *pm, struct mie_op *target)
|
||||
{
|
||||
b_queue schedule = B_QUEUE_INIT;
|
||||
fx_queue schedule = FX_QUEUE_INIT;
|
||||
schedule_passes(pm, &schedule, target, 0);
|
||||
|
||||
b_queue_entry *cur_sched = b_queue_first(&schedule), *next_sched = NULL;
|
||||
fx_queue_entry *cur_sched = fx_queue_first(&schedule), *next_sched = NULL;
|
||||
struct pass_sched *sched = NULL;
|
||||
struct mie_pass_result result = MIE_PASS_CONTINUE;
|
||||
|
||||
@@ -267,9 +267,9 @@ struct mie_pass_result mie_pass_manager_run(
|
||||
};
|
||||
|
||||
while (cur_sched) {
|
||||
sched = b_unbox(struct pass_sched, cur_sched, s_entry);
|
||||
next_sched = b_queue_next(cur_sched);
|
||||
b_queue_delete(&schedule, cur_sched);
|
||||
sched = fx_unbox(struct pass_sched, cur_sched, s_entry);
|
||||
next_sched = fx_queue_next(cur_sched);
|
||||
fx_queue_delete(&schedule, cur_sched);
|
||||
|
||||
sched_execute(sched, &args, &result);
|
||||
|
||||
|
||||
@@ -31,42 +31,42 @@ static void print_block_header_params(
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(block->b_params); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_register(printer, &block->b_params.items[i], 0);
|
||||
|
||||
b_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
|
||||
mie_printer_print_type(printer, block->b_params.items[i].reg_type);
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
}
|
||||
|
||||
static void print_block_header(
|
||||
struct mie_printer *printer, const struct mie_block *block)
|
||||
{
|
||||
bool first_block = b_queue_prev(&block->b_entry) == NULL;
|
||||
bool first_block = fx_queue_prev(&block->b_entry) == NULL;
|
||||
if (first_block && !block->b_name.n_str) {
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, '^');
|
||||
fx_stream_write_char(printer->p_stream, '^');
|
||||
|
||||
if (block->b_name.n_str) {
|
||||
b_stream_write_string(printer->p_stream, block->b_name.n_str, NULL);
|
||||
fx_stream_write_string(printer->p_stream, block->b_name.n_str, NULL);
|
||||
} else {
|
||||
b_stream_write_string(printer->p_stream, "<UNNAMED>", NULL);
|
||||
fx_stream_write_string(printer->p_stream, "<UNNAMED>", NULL);
|
||||
}
|
||||
|
||||
print_block_header_params(printer, block);
|
||||
|
||||
b_stream_write_string(printer->p_stream, ":\n", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ":\n", NULL);
|
||||
}
|
||||
|
||||
void mie_printer_print_block(
|
||||
@@ -77,16 +77,16 @@ void mie_printer_print_block(
|
||||
print_block_header(printer, block);
|
||||
}
|
||||
|
||||
b_stream_push_indent(printer->p_stream, 4);
|
||||
fx_stream_push_indent(printer->p_stream, 4);
|
||||
|
||||
struct mie_op *op = mie_block_get_first_op(block);
|
||||
while (op) {
|
||||
mie_printer_print_op(printer, op);
|
||||
b_stream_write_char(printer->p_stream, '\n');
|
||||
fx_stream_write_char(printer->p_stream, '\n');
|
||||
op = mie_block_get_next_op(block, op);
|
||||
}
|
||||
|
||||
b_stream_pop_indent(printer->p_stream);
|
||||
fx_stream_pop_indent(printer->p_stream);
|
||||
}
|
||||
|
||||
void mie_printer_print_block_ref(
|
||||
|
||||
@@ -33,28 +33,28 @@ void mie_printer_print_op_arg(
|
||||
}
|
||||
|
||||
if (arg_flags & MIE_REGISTER_F_MACHINE) {
|
||||
b_stream_write_char(printer->p_stream, '$');
|
||||
fx_stream_write_char(printer->p_stream, '$');
|
||||
} else {
|
||||
b_stream_write_char(printer->p_stream, '%');
|
||||
fx_stream_write_char(printer->p_stream, '%');
|
||||
}
|
||||
|
||||
if (!arg_name) {
|
||||
arg_name = "<NO-NAME>";
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, arg_name, NULL);
|
||||
fx_stream_write_string(printer->p_stream, arg_name, NULL);
|
||||
|
||||
if (!resolved
|
||||
&& MIE_TEST_FLAGS(
|
||||
printer->p_flags, MIE_PRINT_F_MARK_UNRESOLVED_ELEMENTS)) {
|
||||
b_stream_write_char(printer->p_stream, '?');
|
||||
fx_stream_write_char(printer->p_stream, '?');
|
||||
}
|
||||
|
||||
if (!include_type || !arg_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
|
||||
mie_printer_print_type(printer, arg_type);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void mie_printer_print_op_successor(
|
||||
struct mie_printer *printer, const struct mie_op_successor *successor,
|
||||
bool compact)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, '^');
|
||||
fx_stream_write_char(printer->p_stream, '^');
|
||||
bool resolved = false;
|
||||
|
||||
const char *name = NULL;
|
||||
@@ -78,12 +78,12 @@ void mie_printer_print_op_successor(
|
||||
name = "<NO-NAME>";
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, name, NULL);
|
||||
fx_stream_write_string(printer->p_stream, name, NULL);
|
||||
|
||||
if (!resolved
|
||||
&& MIE_TEST_FLAGS(
|
||||
printer->p_flags, MIE_PRINT_F_MARK_UNRESOLVED_ELEMENTS)) {
|
||||
b_stream_write_char(printer->p_stream, '?');
|
||||
fx_stream_write_char(printer->p_stream, '?');
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(successor->s_args) == 0) {
|
||||
@@ -91,20 +91,20 @@ void mie_printer_print_op_successor(
|
||||
}
|
||||
|
||||
if (!compact) {
|
||||
b_stream_write_char(printer->p_stream, ':');
|
||||
fx_stream_write_char(printer->p_stream, ':');
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(successor->s_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_op_arg(printer, &successor->s_args.items[i], true);
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
}
|
||||
|
||||
static void print_successor_list(
|
||||
@@ -114,34 +114,34 @@ static void print_successor_list(
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " [ ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " [ ", NULL);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_successors); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_op_successor(
|
||||
printer, &op->op_successors.items[i], false);
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " ]", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " ]", NULL);
|
||||
}
|
||||
|
||||
static void print_region_list(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
if (b_queue_empty(&op->op_regions)) {
|
||||
if (fx_queue_empty(&op->op_regions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " (", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " (", NULL);
|
||||
|
||||
struct mie_region *region = mie_op_get_first_region(op);
|
||||
size_t i = 0;
|
||||
|
||||
while (region) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_region(printer, region, 0);
|
||||
@@ -150,13 +150,13 @@ static void print_region_list(struct mie_printer *printer, const struct mie_op *
|
||||
i++;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, ")", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ")", NULL);
|
||||
}
|
||||
|
||||
static void print_attribute(
|
||||
struct mie_printer *printer, const struct mie_attribute_map_iterator *attrib)
|
||||
{
|
||||
b_stream_write_fmt(printer->p_stream, NULL, "%s = ", attrib->it_name);
|
||||
fx_stream_write_fmt(printer->p_stream, NULL, "%s = ", attrib->it_name);
|
||||
mie_printer_print_attribute(printer, attrib->it_value);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ static void print_attribute_list(
|
||||
return;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " { ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " { ", NULL);
|
||||
|
||||
struct mie_attribute_map_iterator it;
|
||||
enum mie_status status
|
||||
@@ -176,7 +176,7 @@ static void print_attribute_list(
|
||||
|
||||
while (status == MIE_SUCCESS) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
print_attribute(printer, &it);
|
||||
@@ -184,18 +184,18 @@ static void print_attribute_list(
|
||||
i++;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, " }", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " }", NULL);
|
||||
}
|
||||
|
||||
static void print_type_signature(
|
||||
struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
const struct mie_type *type = NULL;
|
||||
b_stream_write_string(printer->p_stream, " : (", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " : (", NULL);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
const struct mie_op_arg *arg = &op->op_args.items[i];
|
||||
@@ -208,15 +208,15 @@ static void print_type_signature(
|
||||
mie_printer_print_type(printer, type);
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, ") -> ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ") -> ", NULL);
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) != 1) {
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_result); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
type = op->op_result.items[i].reg_type;
|
||||
@@ -224,38 +224,38 @@ static void print_type_signature(
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) != 1) {
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
}
|
||||
}
|
||||
|
||||
static void print_generic_op(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
b_stream_write_char(printer->p_stream, '~');
|
||||
fx_stream_write_char(printer->p_stream, '~');
|
||||
|
||||
if (op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
printer->p_stream, NULL, "%s.%s",
|
||||
op->op_info->op_parent->d_name, op->op_info->op_name);
|
||||
} else {
|
||||
b_stream_write_string(printer->p_stream, op->op_name, NULL);
|
||||
fx_stream_write_string(printer->p_stream, op->op_name, NULL);
|
||||
|
||||
if (MIE_TEST_FLAGS(
|
||||
printer->p_flags, MIE_PRINT_F_MARK_UNRESOLVED_ELEMENTS)) {
|
||||
b_stream_write_char(printer->p_stream, '?');
|
||||
fx_stream_write_char(printer->p_stream, '?');
|
||||
}
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, '(');
|
||||
fx_stream_write_char(printer->p_stream, '(');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_args); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_op_arg(printer, &op->op_args.items[i], false);
|
||||
}
|
||||
|
||||
b_stream_write_char(printer->p_stream, ')');
|
||||
fx_stream_write_char(printer->p_stream, ')');
|
||||
|
||||
print_successor_list(printer, op);
|
||||
print_region_list(printer, op);
|
||||
@@ -267,14 +267,14 @@ void mie_printer_print_op(struct mie_printer *printer, const struct mie_op *op)
|
||||
{
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_result); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_register(printer, &op->op_result.items[i], 0);
|
||||
}
|
||||
|
||||
if (MIE_VECTOR_COUNT(op->op_result) > 0) {
|
||||
b_stream_write_string(printer->p_stream, " = ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, " = ", NULL);
|
||||
}
|
||||
|
||||
bool use_generic = !op->op_info || !op->op_info->op_print
|
||||
@@ -307,23 +307,23 @@ void mie_printer_print_op_name(struct mie_printer *printer, const struct mie_op
|
||||
|
||||
if (printer->p_flags & MIE_PRINT_F_GENERIC) {
|
||||
generic = true;
|
||||
b_stream_write_char(printer->p_stream, '~');
|
||||
fx_stream_write_char(printer->p_stream, '~');
|
||||
} else if (!strcmp(op->op_info->op_parent->d_name, "builtin")) {
|
||||
builtin = true;
|
||||
}
|
||||
|
||||
if (!resolved) {
|
||||
b_stream_write_string(printer->p_stream, op->op_name, NULL);
|
||||
fx_stream_write_string(printer->p_stream, op->op_name, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (generic || !builtin || !abbreviate) {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
printer->p_stream, NULL, "%s.",
|
||||
op->op_info->op_parent->d_name);
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, op->op_info->op_name, NULL);
|
||||
fx_stream_write_string(printer->p_stream, op->op_info->op_name, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <mie/print/printer.h>
|
||||
|
||||
enum mie_status mie_printer_init(
|
||||
struct mie_printer *printer, struct mie_ctx *ctx, b_stream *out,
|
||||
struct mie_printer *printer, struct mie_ctx *ctx, fx_stream *out,
|
||||
enum mie_print_flags flags)
|
||||
{
|
||||
memset(printer, 0x0, sizeof *printer);
|
||||
|
||||
@@ -6,7 +6,7 @@ void mie_printer_print_region(
|
||||
struct mie_printer *printer, const struct mie_region *region,
|
||||
enum mie_print_flags flags)
|
||||
{
|
||||
b_stream_write_string(printer->p_stream, "{\n", NULL);
|
||||
fx_stream_write_string(printer->p_stream, "{\n", NULL);
|
||||
|
||||
struct mie_block *block = mie_region_get_first_block(region);
|
||||
size_t i = 0;
|
||||
@@ -24,5 +24,5 @@ void mie_printer_print_region(
|
||||
i++;
|
||||
}
|
||||
|
||||
b_stream_write_string(printer->p_stream, "}", NULL);
|
||||
fx_stream_write_string(printer->p_stream, "}", NULL);
|
||||
}
|
||||
|
||||
@@ -6,18 +6,18 @@ void mie_printer_print_register(
|
||||
enum mie_print_flags flags)
|
||||
{
|
||||
if (reg->reg_flags & MIE_REGISTER_F_VIRTUAL) {
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
printer->p_stream, NULL, "%%%s", reg->reg_name.n_str);
|
||||
} else if (reg->reg_flags & MIE_REGISTER_F_MACHINE) {
|
||||
// TODO this shouldnt use reg_name
|
||||
b_stream_write_fmt(
|
||||
fx_stream_write_fmt(
|
||||
printer->p_stream, NULL, "$%s", reg->reg_name.n_str);
|
||||
} else {
|
||||
b_stream_write_string(printer->p_stream, "?REG", NULL);
|
||||
fx_stream_write_string(printer->p_stream, "?REG", NULL);
|
||||
}
|
||||
|
||||
if (flags & MIE_PRINT_F_INCLUDE_TYPE) {
|
||||
b_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
fx_stream_write_string(printer->p_stream, ": ", NULL);
|
||||
mie_printer_print_type(printer, reg->reg_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,23 +13,23 @@
|
||||
void mie_printer_print_type(struct mie_printer *printer, const struct mie_type *type)
|
||||
{
|
||||
if (!type) {
|
||||
b_stream_write_string(printer->p_stream, "<NULL-TYPE>", NULL);
|
||||
fx_stream_write_string(printer->p_stream, "<NULL-TYPE>", NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TYPE_HAS_PRINT_CALLBACK(type)) {
|
||||
type->ty_def->ty_print(type, printer);
|
||||
} else if (TYPE_IS_BUILTIN(type)) {
|
||||
b_stream_write_string(
|
||||
fx_stream_write_string(
|
||||
printer->p_stream, type->ty_def->ty_name, NULL);
|
||||
} else if (TYPE_HAS_NAME(type)) {
|
||||
b_stream_write_char(printer->p_stream, '!');
|
||||
b_stream_write_string(printer->p_stream, type->ty_name, NULL);
|
||||
fx_stream_write_char(printer->p_stream, '!');
|
||||
fx_stream_write_string(printer->p_stream, type->ty_name, NULL);
|
||||
} else if (TYPE_DEF_HAS_NAME(type)) {
|
||||
b_stream_write_char(printer->p_stream, '!');
|
||||
b_stream_write_string(
|
||||
fx_stream_write_char(printer->p_stream, '!');
|
||||
fx_stream_write_string(
|
||||
printer->p_stream, type->ty_def->ty_name, NULL);
|
||||
} else {
|
||||
b_stream_write_string(printer->p_stream, "<UNNAMED-TYPE>", NULL);
|
||||
fx_stream_write_string(printer->p_stream, "<UNNAMED-TYPE>", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ struct mie_block *mie_rewriter_split_block(
|
||||
struct mie_block *new_block = mie_region_add_block_after(region, block);
|
||||
mie_name_map_put(names, &new_block->b_name, name, 0);
|
||||
|
||||
b_queue_entry *cur = &before->op_entry;
|
||||
fx_queue_entry *cur = &before->op_entry;
|
||||
while (cur) {
|
||||
struct mie_op *cur_op = b_unbox(struct mie_op, cur, op_entry);
|
||||
b_queue_entry *next = b_queue_next(cur);
|
||||
b_queue_delete(&block->b_ops, cur);
|
||||
b_queue_push_back(&new_block->b_ops, cur);
|
||||
struct mie_op *cur_op = fx_unbox(struct mie_op, cur, op_entry);
|
||||
fx_queue_entry *next = fx_queue_next(cur);
|
||||
fx_queue_delete(&block->b_ops, cur);
|
||||
fx_queue_push_back(&new_block->b_ops, cur);
|
||||
|
||||
cur_op->op_container = new_block;
|
||||
cur = next;
|
||||
@@ -142,8 +142,8 @@ enum mie_status mie_rewriter_move_block_to_start(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
b_queue_push_front(&to->r_blocks, &block->b_entry);
|
||||
fx_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
fx_queue_push_front(&to->r_blocks, &block->b_entry);
|
||||
|
||||
block->b_parent = to;
|
||||
|
||||
@@ -158,8 +158,8 @@ enum mie_status mie_rewriter_move_block_to_end(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
b_queue_push_back(&to->r_blocks, &block->b_entry);
|
||||
fx_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
fx_queue_push_back(&to->r_blocks, &block->b_entry);
|
||||
|
||||
block->b_parent = to;
|
||||
|
||||
@@ -178,8 +178,8 @@ enum mie_status mie_rewriter_move_block_before(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
b_queue_insert_before(&to->r_blocks, &block->b_entry, &before->b_entry);
|
||||
fx_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
fx_queue_insert_before(&to->r_blocks, &block->b_entry, &before->b_entry);
|
||||
|
||||
block->b_parent = to;
|
||||
|
||||
@@ -198,8 +198,8 @@ enum mie_status mie_rewriter_move_block_after(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
b_queue_insert_after(&to->r_blocks, &block->b_entry, &after->b_entry);
|
||||
fx_queue_delete(&from->r_blocks, &block->b_entry);
|
||||
fx_queue_insert_after(&to->r_blocks, &block->b_entry, &after->b_entry);
|
||||
|
||||
block->b_parent = to;
|
||||
|
||||
@@ -221,18 +221,18 @@ enum mie_status mie_rewriter_rename_block(
|
||||
enum mie_status mie_rewriter_move_blocks_to_start(
|
||||
struct mie_rewriter *rw, struct mie_region *from, struct mie_region *to)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(&from->r_blocks);
|
||||
b_queue_entry *insert_point = NULL;
|
||||
fx_queue_entry *cur = fx_queue_first(&from->r_blocks);
|
||||
fx_queue_entry *insert_point = NULL;
|
||||
while (cur) {
|
||||
b_queue_entry *next = b_queue_next(cur);
|
||||
fx_queue_entry *next = fx_queue_next(cur);
|
||||
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
b_queue_delete(&from->r_blocks, cur);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
fx_queue_delete(&from->r_blocks, cur);
|
||||
|
||||
if (insert_point) {
|
||||
b_queue_insert_after(&to->r_blocks, cur, insert_point);
|
||||
fx_queue_insert_after(&to->r_blocks, cur, insert_point);
|
||||
} else {
|
||||
b_queue_push_front(&to->r_blocks, cur);
|
||||
fx_queue_push_front(&to->r_blocks, cur);
|
||||
}
|
||||
|
||||
block->b_parent = to;
|
||||
@@ -246,13 +246,13 @@ enum mie_status mie_rewriter_move_blocks_to_start(
|
||||
enum mie_status mie_rewriter_move_blocks_to_end(
|
||||
struct mie_rewriter *rw, struct mie_region *from, struct mie_region *to)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(&from->r_blocks);
|
||||
fx_queue_entry *cur = fx_queue_first(&from->r_blocks);
|
||||
while (cur) {
|
||||
b_queue_entry *next = b_queue_next(cur);
|
||||
fx_queue_entry *next = fx_queue_next(cur);
|
||||
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
b_queue_delete(&from->r_blocks, cur);
|
||||
b_queue_push_back(&to->r_blocks, cur);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
fx_queue_delete(&from->r_blocks, cur);
|
||||
fx_queue_push_back(&to->r_blocks, cur);
|
||||
|
||||
block->b_parent = to;
|
||||
cur = next;
|
||||
@@ -269,13 +269,13 @@ enum mie_status mie_rewriter_move_blocks_before(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_entry *cur = b_queue_last(&from->r_blocks);
|
||||
fx_queue_entry *cur = fx_queue_last(&from->r_blocks);
|
||||
while (cur) {
|
||||
b_queue_entry *next = b_queue_prev(cur);
|
||||
fx_queue_entry *next = fx_queue_prev(cur);
|
||||
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
b_queue_delete(&from->r_blocks, cur);
|
||||
b_queue_insert_before(&to->r_blocks, cur, &before->b_entry);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
fx_queue_delete(&from->r_blocks, cur);
|
||||
fx_queue_insert_before(&to->r_blocks, cur, &before->b_entry);
|
||||
|
||||
block->b_parent = to;
|
||||
cur = next;
|
||||
@@ -292,15 +292,15 @@ enum mie_status mie_rewriter_move_blocks_after(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_entry *cur = b_queue_first(&from->r_blocks);
|
||||
b_queue_entry *insert_point = &after->b_entry;
|
||||
fx_queue_entry *cur = fx_queue_first(&from->r_blocks);
|
||||
fx_queue_entry *insert_point = &after->b_entry;
|
||||
|
||||
while (cur) {
|
||||
b_queue_entry *next = b_queue_next(cur);
|
||||
fx_queue_entry *next = fx_queue_next(cur);
|
||||
|
||||
struct mie_block *block = b_unbox(struct mie_block, cur, b_entry);
|
||||
b_queue_delete(&from->r_blocks, cur);
|
||||
b_queue_insert_after(&to->r_blocks, cur, insert_point);
|
||||
struct mie_block *block = fx_unbox(struct mie_block, cur, b_entry);
|
||||
fx_queue_delete(&from->r_blocks, cur);
|
||||
fx_queue_insert_after(&to->r_blocks, cur, insert_point);
|
||||
|
||||
block->b_parent = to;
|
||||
insert_point = cur;
|
||||
@@ -318,8 +318,8 @@ enum mie_status mie_rewriter_move_region_to_start(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
b_queue_push_front(&to->op_regions, ®ion->r_entry);
|
||||
fx_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
fx_queue_push_front(&to->op_regions, ®ion->r_entry);
|
||||
|
||||
region->r_parent = to;
|
||||
|
||||
@@ -334,8 +334,8 @@ enum mie_status mie_rewriter_move_region_to_end(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
b_queue_push_back(&to->op_regions, ®ion->r_entry);
|
||||
fx_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
fx_queue_push_back(&to->op_regions, ®ion->r_entry);
|
||||
|
||||
region->r_parent = to;
|
||||
|
||||
@@ -354,8 +354,8 @@ enum mie_status mie_rewriter_move_region_before(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
b_queue_insert_before(&to->op_regions, ®ion->r_entry, &before->r_entry);
|
||||
fx_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
fx_queue_insert_before(&to->op_regions, ®ion->r_entry, &before->r_entry);
|
||||
|
||||
region->r_parent = to;
|
||||
|
||||
@@ -374,8 +374,8 @@ enum mie_status mie_rewriter_move_region_after(
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
b_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
b_queue_insert_after(&to->op_regions, ®ion->r_entry, &after->r_entry);
|
||||
fx_queue_delete(&from->op_regions, ®ion->r_entry);
|
||||
fx_queue_insert_after(&to->op_regions, ®ion->r_entry, &after->r_entry);
|
||||
|
||||
region->r_parent = to;
|
||||
|
||||
@@ -410,7 +410,7 @@ struct mie_op *mie_rewriter_put_op(
|
||||
arg->arg_flags = MIE_OP_F_ARG_RESOLVED;
|
||||
arg->arg_value.u_reg = args[i];
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(&args[i]->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&args[i]->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
|
||||
return op;
|
||||
@@ -439,7 +439,7 @@ struct mie_op_arg *mie_rewriter_add_op_arg(
|
||||
arg->arg_flags = MIE_OP_F_ARG_RESOLVED;
|
||||
arg->arg_value.u_reg = value;
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(&value->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&value->reg_use, &arg->arg_value.u_entry);
|
||||
|
||||
return arg;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ MIE_API struct mie_op_arg *mie_rewriter_add_op_successor_arg(
|
||||
arg->arg_flags = MIE_OP_F_ARG_RESOLVED;
|
||||
arg->arg_value.u_reg = value;
|
||||
arg->arg_value.u_user = op;
|
||||
b_queue_push_back(&value->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&value->reg_use, &arg->arg_value.u_entry);
|
||||
|
||||
return arg;
|
||||
}
|
||||
@@ -471,7 +471,7 @@ enum mie_status mie_rewriter_erase_op(struct mie_rewriter *rw, struct mie_op *op
|
||||
return MIE_ERR_BAD_STATE;
|
||||
}
|
||||
|
||||
b_queue_delete(&parent->b_ops, &op->op_entry);
|
||||
fx_queue_delete(&parent->b_ops, &op->op_entry);
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_successors); i++) {
|
||||
struct mie_op_successor *s = &op->op_successors.items[i];
|
||||
@@ -481,7 +481,7 @@ enum mie_status mie_rewriter_erase_op(struct mie_rewriter *rw, struct mie_op *op
|
||||
continue;
|
||||
}
|
||||
|
||||
b_queue_delete(
|
||||
fx_queue_delete(
|
||||
&arg->arg_value.u_reg->reg_use,
|
||||
&arg->arg_value.u_entry);
|
||||
}
|
||||
@@ -493,21 +493,21 @@ enum mie_status mie_rewriter_erase_op(struct mie_rewriter *rw, struct mie_op *op
|
||||
continue;
|
||||
}
|
||||
|
||||
b_queue_delete(
|
||||
fx_queue_delete(
|
||||
&arg->arg_value.u_reg->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_result); i++) {
|
||||
struct mie_register *reg = &op->op_result.items[i];
|
||||
|
||||
b_queue_entry *cur = b_queue_first(®->reg_use);
|
||||
fx_queue_entry *cur = fx_queue_first(®->reg_use);
|
||||
while (cur) {
|
||||
b_queue_entry *next = b_queue_next(cur);
|
||||
fx_queue_entry *next = fx_queue_next(cur);
|
||||
|
||||
struct mie_register_use *use
|
||||
= b_unbox(struct mie_register_use, cur, u_entry);
|
||||
= fx_unbox(struct mie_register_use, cur, u_entry);
|
||||
|
||||
b_queue_delete(®->reg_use, &use->u_entry);
|
||||
fx_queue_delete(®->reg_use, &use->u_entry);
|
||||
use->u_reg = NULL;
|
||||
cur = next;
|
||||
}
|
||||
@@ -529,14 +529,14 @@ enum mie_status mie_rewriter_move_op_args_to_successor(
|
||||
struct mie_register *reg = NULL;
|
||||
if (src->arg_flags & MIE_OP_F_ARG_RESOLVED) {
|
||||
reg = src->arg_value.u_reg;
|
||||
b_queue_delete(®->reg_use, &src->arg_value.u_entry);
|
||||
fx_queue_delete(®->reg_use, &src->arg_value.u_entry);
|
||||
}
|
||||
|
||||
memcpy(dest, src, sizeof *src);
|
||||
if (reg) {
|
||||
memset(&dest->arg_value.u_entry, 0x0,
|
||||
sizeof dest->arg_value.u_entry);
|
||||
b_queue_push_back(®->reg_use, &dest->arg_value.u_entry);
|
||||
fx_queue_push_back(®->reg_use, &dest->arg_value.u_entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,9 +558,9 @@ static enum mie_status replace_register_usage(
|
||||
continue;
|
||||
}
|
||||
|
||||
b_queue_delete(&old->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_delete(&old->reg_use, &arg->arg_value.u_entry);
|
||||
arg->arg_value.u_reg = new;
|
||||
b_queue_push_back(&new->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&new->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(op->op_successors); i++) {
|
||||
@@ -575,9 +575,9 @@ static enum mie_status replace_register_usage(
|
||||
continue;
|
||||
}
|
||||
|
||||
b_queue_delete(&old->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_delete(&old->reg_use, &arg->arg_value.u_entry);
|
||||
arg->arg_value.u_reg = new;
|
||||
b_queue_push_back(&new->reg_use, &arg->arg_value.u_entry);
|
||||
fx_queue_push_back(&new->reg_use, &arg->arg_value.u_entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,17 +587,17 @@ static enum mie_status replace_register_usage(
|
||||
enum mie_status mie_rewriter_replace_register(
|
||||
struct mie_rewriter *rw, struct mie_register *old, struct mie_register *new)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(&old->reg_use);
|
||||
fx_queue_entry *cur = fx_queue_first(&old->reg_use);
|
||||
while (cur) {
|
||||
struct mie_register_use *use
|
||||
= b_unbox(struct mie_register_use, cur, u_entry);
|
||||
= fx_unbox(struct mie_register_use, cur, u_entry);
|
||||
struct mie_op *op = use->u_user;
|
||||
|
||||
if (use->u_reg == old) {
|
||||
replace_register_usage(op, old, new);
|
||||
}
|
||||
|
||||
cur = b_queue_next(cur);
|
||||
cur = fx_queue_next(cur);
|
||||
}
|
||||
|
||||
return MIE_SUCCESS;
|
||||
|
||||
26
mie/status.c
26
mie/status.c
@@ -1,31 +1,31 @@
|
||||
#include <blue/core/error.h>
|
||||
#include <fx/core/error.h>
|
||||
#include <errno.h>
|
||||
#include <mie/status.h>
|
||||
|
||||
static const b_error_definition error_defs[] = {
|
||||
B_ERROR_DEFINITION(MIE_SUCCESS, "SUCCESS", "Success"),
|
||||
B_ERROR_DEFINITION(MIE_ERR_EOF, "EOF", "Unexpected end of file"),
|
||||
B_ERROR_DEFINITION(MIE_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"),
|
||||
B_ERROR_DEFINITION(MIE_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
|
||||
B_ERROR_DEFINITION(
|
||||
static const fx_error_definition error_defs[] = {
|
||||
FX_ERROR_DEFINITION(MIE_SUCCESS, "SUCCESS", "Success"),
|
||||
FX_ERROR_DEFINITION(MIE_ERR_EOF, "EOF", "Unexpected end of file"),
|
||||
FX_ERROR_DEFINITION(MIE_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"),
|
||||
FX_ERROR_DEFINITION(MIE_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
|
||||
FX_ERROR_DEFINITION(
|
||||
MIE_ERR_NOT_SUPPORTED, "NOT_SUPPORTED",
|
||||
"Operation not supported"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(
|
||||
MIE_ERR_INTERNAL_FAILURE, "INTERNAL_FAILURE",
|
||||
"Internal failure"),
|
||||
B_ERROR_DEFINITION(
|
||||
FX_ERROR_DEFINITION(
|
||||
MIE_ERR_INVALID_VALUE, "INVALID_VALUE", "Invalid value"),
|
||||
B_ERROR_DEFINITION(MIE_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"),
|
||||
B_ERROR_DEFINITION(MIE_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"),
|
||||
FX_ERROR_DEFINITION(MIE_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"),
|
||||
FX_ERROR_DEFINITION(MIE_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"),
|
||||
};
|
||||
|
||||
static const b_error_vendor error_vendor = {
|
||||
static const fx_error_vendor error_vendor = {
|
||||
.v_name = "Mie",
|
||||
.v_error_definitions = error_defs,
|
||||
.v_error_definitions_length = sizeof error_defs,
|
||||
};
|
||||
|
||||
const struct b_error_vendor *mie_error_vendor(void)
|
||||
const struct fx_error_vendor *mie_error_vendor(void)
|
||||
{
|
||||
return &error_vendor;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/trait/trait-definition.h>
|
||||
|
||||
@@ -12,7 +12,7 @@ struct mie_trait_definition *mie_trait_definition_create(
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->tr_name = b_strdup(name);
|
||||
out->tr_name = fx_strdup(name);
|
||||
if (!out->tr_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -20,7 +20,7 @@ struct mie_trait_definition *mie_trait_definition_create(
|
||||
|
||||
out->tr_parent = parent;
|
||||
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id_map_put(&parent->d_traits, &out->tr_id, &name_rope);
|
||||
|
||||
return out;
|
||||
|
||||
@@ -20,7 +20,7 @@ struct generic_trait {
|
||||
/* generic trait ID. */
|
||||
mie_id g_id;
|
||||
/* list of struct unique_trait */
|
||||
b_queue g_traits;
|
||||
fx_queue g_traits;
|
||||
};
|
||||
|
||||
static struct unique_trait *unique_trait_create(const struct mie_trait *trait)
|
||||
@@ -56,19 +56,19 @@ static struct generic_trait *generic_trait_create(const struct mie_trait *trait)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
b_queue_push_back(&out->g_traits, &entry->u_id.e_entry);
|
||||
fx_queue_push_back(&out->g_traits, &entry->u_id.e_entry);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static void generic_trait_destroy(struct generic_trait *trait)
|
||||
{
|
||||
b_queue_entry *cur = b_queue_first(&trait->g_traits);
|
||||
fx_queue_entry *cur = fx_queue_first(&trait->g_traits);
|
||||
while (cur) {
|
||||
b_queue_entry *next = b_queue_next(cur);
|
||||
b_queue_delete(&trait->g_traits, cur);
|
||||
fx_queue_entry *next = fx_queue_next(cur);
|
||||
fx_queue_delete(&trait->g_traits, cur);
|
||||
struct unique_trait *u
|
||||
= b_unbox(struct unique_trait, cur, u_id.e_entry);
|
||||
= fx_unbox(struct unique_trait, cur, u_id.e_entry);
|
||||
unique_trait_destroy(u);
|
||||
cur = next;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ const struct mie_trait *mie_trait_table_get_unique(
|
||||
|
||||
const mie_id *result = mie_id_map_get(&table->tr_unique, &id);
|
||||
const struct unique_trait *entry
|
||||
= b_unbox(struct unique_trait, result, u_id);
|
||||
= fx_unbox(struct unique_trait, result, u_id);
|
||||
return entry ? entry->u_trait : NULL;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ static enum mie_status put_generic_trait(
|
||||
|
||||
mie_id *target = mie_id_map_get(&table->tr_generic, &id);
|
||||
struct generic_trait *generic
|
||||
= b_unbox(struct generic_trait, target, g_id);
|
||||
= fx_unbox(struct generic_trait, target, g_id);
|
||||
if (!generic) {
|
||||
generic = generic_trait_create(trait);
|
||||
|
||||
@@ -160,7 +160,7 @@ static enum mie_status put_generic_trait(
|
||||
return MIE_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
b_queue_push_back(&generic->g_traits, &unique->u_id.e_entry);
|
||||
fx_queue_push_back(&generic->g_traits, &unique->u_id.e_entry);
|
||||
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
@@ -189,17 +189,17 @@ enum mie_status mie_trait_table_get_generic(
|
||||
|
||||
const mie_id *result = mie_id_map_get(&table->tr_unique, &id);
|
||||
const struct generic_trait *entry
|
||||
= b_unbox(struct generic_trait, entry, g_id);
|
||||
= fx_unbox(struct generic_trait, entry, g_id);
|
||||
|
||||
if (!entry || b_queue_empty(&entry->g_traits)) {
|
||||
if (!entry || fx_queue_empty(&entry->g_traits)) {
|
||||
return MIE_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
memset(it, 0x0, sizeof *it);
|
||||
|
||||
it->_e = b_queue_first(&entry->g_traits);
|
||||
it->_e = fx_queue_first(&entry->g_traits);
|
||||
struct unique_trait *trait
|
||||
= b_unbox(struct unique_trait, it->_e, u_id.e_entry);
|
||||
= fx_unbox(struct unique_trait, it->_e, u_id.e_entry);
|
||||
|
||||
it->it_trait = trait->u_trait;
|
||||
|
||||
@@ -216,7 +216,7 @@ enum mie_status mie_trait_table_iterate(
|
||||
|
||||
while (it.it_id) {
|
||||
const struct unique_trait *trait
|
||||
= b_unbox(struct unique_trait, it.it_id, u_id);
|
||||
= fx_unbox(struct unique_trait, it.it_id, u_id);
|
||||
ret = func(trait->u_trait, arg);
|
||||
|
||||
if (ret != 0) {
|
||||
@@ -230,19 +230,19 @@ enum mie_status mie_trait_table_iterate(
|
||||
|
||||
while (it.it_id) {
|
||||
const struct generic_trait *trait_group
|
||||
= b_unbox(struct generic_trait, it.it_id, g_id);
|
||||
= fx_unbox(struct generic_trait, it.it_id, g_id);
|
||||
|
||||
const b_queue_entry *cur = b_queue_first(&trait_group->g_traits);
|
||||
const fx_queue_entry *cur = fx_queue_first(&trait_group->g_traits);
|
||||
while (cur) {
|
||||
const struct unique_trait *trait
|
||||
= b_unbox(struct unique_trait, cur, u_id.e_entry);
|
||||
= fx_unbox(struct unique_trait, cur, u_id.e_entry);
|
||||
ret = func(trait->u_trait, arg);
|
||||
|
||||
if (ret != 0) {
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
cur = b_queue_next(cur);
|
||||
cur = fx_queue_next(cur);
|
||||
}
|
||||
|
||||
mie_id_map_iterator_move_next(&it);
|
||||
@@ -258,13 +258,13 @@ enum mie_status mie_trait_table_iterator_move_next(
|
||||
return MIE_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
it->_e = b_queue_next(it->_e);
|
||||
it->_e = fx_queue_next(it->_e);
|
||||
if (!it->_e) {
|
||||
return MIE_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
struct unique_trait *trait
|
||||
= b_unbox(struct unique_trait, it->_e, u_id.e_entry);
|
||||
= fx_unbox(struct unique_trait, it->_e, u_id.e_entry);
|
||||
|
||||
it->it_trait = trait->u_trait;
|
||||
return MIE_SUCCESS;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#include <mie/trait/trait-definition.h>
|
||||
#include <mie/trait/trait.h>
|
||||
|
||||
void mie_trait_print(const struct mie_trait *trait, b_stream *out)
|
||||
void mie_trait_print(const struct mie_trait *trait, fx_stream *out)
|
||||
{
|
||||
if (trait->tr_name) {
|
||||
b_stream_write_string(out, trait->tr_name, NULL);
|
||||
fx_stream_write_string(out, trait->tr_name, NULL);
|
||||
} else if (trait->tr_def && trait->tr_def->tr_print) {
|
||||
trait->tr_def->tr_print(trait->tr_def, trait, out);
|
||||
} else if (trait->tr_def->tr_name) {
|
||||
b_stream_write_string(out, trait->tr_def->tr_name, NULL);
|
||||
fx_stream_write_string(out, trait->tr_def->tr_name, NULL);
|
||||
} else {
|
||||
b_stream_write_string(out, "<UNNAMED-TRAIT>", NULL);
|
||||
fx_stream_write_string(out, "<UNNAMED-TRAIT>", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,34 +21,34 @@ static enum mie_status type_print(
|
||||
const struct mie_function_type *func
|
||||
= (const struct mie_function_type *)type;
|
||||
|
||||
b_stream_write_char(out->p_stream, '(');
|
||||
fx_stream_write_char(out->p_stream, '(');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(func->func_in); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(out->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(out->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(out, MIE_VECTOR_ITEM(func->func_in, i));
|
||||
}
|
||||
|
||||
b_stream_write_string(out->p_stream, ") -> ", NULL);
|
||||
fx_stream_write_string(out->p_stream, ") -> ", NULL);
|
||||
|
||||
if (MIE_VECTOR_COUNT(func->func_out) == 1) {
|
||||
mie_printer_print_type(out, MIE_VECTOR_ITEM(func->func_out, 0));
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
b_stream_write_char(out->p_stream, '(');
|
||||
fx_stream_write_char(out->p_stream, '(');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(func->func_out); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(out->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(out->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(out, MIE_VECTOR_ITEM(func->func_out, i));
|
||||
}
|
||||
|
||||
b_stream_write_char(out->p_stream, ')');
|
||||
fx_stream_write_char(out->p_stream, ')');
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,17 @@ static enum mie_status type_print(
|
||||
{
|
||||
const struct mie_storage_type *storage
|
||||
= (const struct mie_storage_type *)type;
|
||||
b_stream_write_char(out->p_stream, '(');
|
||||
fx_stream_write_char(out->p_stream, '(');
|
||||
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(storage->st_parts); i++) {
|
||||
if (i > 0) {
|
||||
b_stream_write_string(out->p_stream, ", ", NULL);
|
||||
fx_stream_write_string(out->p_stream, ", ", NULL);
|
||||
}
|
||||
|
||||
mie_printer_print_type(out, storage->st_parts.items[i]);
|
||||
}
|
||||
|
||||
b_stream_write_char(out->p_stream, ')');
|
||||
fx_stream_write_char(out->p_stream, ')');
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/type/type-definition.h>
|
||||
|
||||
@@ -12,7 +12,7 @@ struct mie_type_definition *mie_type_definition_create(
|
||||
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
out->ty_name = b_strdup(name);
|
||||
out->ty_name = fx_strdup(name);
|
||||
if (!out->ty_name) {
|
||||
free(out);
|
||||
return NULL;
|
||||
@@ -21,7 +21,7 @@ struct mie_type_definition *mie_type_definition_create(
|
||||
out->ty_parent = parent;
|
||||
mie_trait_table_init(&out->ty_traits);
|
||||
|
||||
b_rope name_rope = B_ROPE_CSTR(name);
|
||||
fx_rope name_rope = FX_ROPE_CSTR(name);
|
||||
mie_id_map_put(&parent->d_types, &out->ty_id, &name_rope);
|
||||
|
||||
return out;
|
||||
|
||||
@@ -12,9 +12,9 @@ add_executable(mie-tool ${tool_sources} ${rc_file})
|
||||
target_link_libraries(
|
||||
mie-tool
|
||||
mie
|
||||
Bluelib::Core
|
||||
Bluelib::Ds
|
||||
Bluelib::Cmd)
|
||||
FX::Core
|
||||
FX::Ds
|
||||
FX::Cmd)
|
||||
|
||||
set_target_properties(mie-tool PROPERTIES OUTPUT_NAME "mie")
|
||||
target_compile_definitions(mie-tool PRIVATE MIE_STATIC=${MIE_STATIC})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/term.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/arith.h>
|
||||
@@ -27,7 +27,7 @@ enum {
|
||||
};
|
||||
|
||||
static int builder_test(
|
||||
const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
struct mie_ctx *ctx = mie_ctx_create();
|
||||
mie_builtin_dialect_create(ctx);
|
||||
@@ -94,19 +94,20 @@ static int builder_test(
|
||||
struct mie_pass_manager *func_pm = mie_pass_manager_nest(pm);
|
||||
mie_pass_manager_filter_op(module_pm, "func", "func");
|
||||
|
||||
b_arglist_iterator it;
|
||||
b_arglist_foreach(&it, args)
|
||||
fx_arglist_iterator it;
|
||||
fx_arglist_foreach(&it, args)
|
||||
{
|
||||
if (it.opt_id < OPT_PASS_OFFSET) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const b_command_option *opt = b_command_get_option(cmd, it.opt_id);
|
||||
const fx_command_option *opt
|
||||
= fx_command_get_option(cmd, it.opt_id);
|
||||
if (!opt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *pass_name = b_command_option_get_long_name(opt);
|
||||
const char *pass_name = fx_command_option_get_long_name(opt);
|
||||
struct mie_pass *pass = NULL;
|
||||
enum mie_status status
|
||||
= mie_ctx_get_pass(ctx, pass_name, NULL, &pass);
|
||||
@@ -121,62 +122,62 @@ static int builder_test(
|
||||
mie_pass_manager_run(pm, module);
|
||||
|
||||
enum mie_print_flags flags = 0;
|
||||
if (b_arglist_get_count(args, OPT_GENERIC, B_COMMAND_INVALID_ID) > 0) {
|
||||
if (fx_arglist_get_count(args, OPT_GENERIC, FX_COMMAND_INVALID_ID) > 0) {
|
||||
flags |= MIE_PRINT_F_GENERIC;
|
||||
}
|
||||
|
||||
if (b_arglist_get_count(args, OPT_NO_ABBREV, B_COMMAND_INVALID_ID) == 0) {
|
||||
if (fx_arglist_get_count(args, OPT_NO_ABBREV, FX_COMMAND_INVALID_ID) == 0) {
|
||||
flags |= MIE_PRINT_F_ABBREVIATED;
|
||||
}
|
||||
|
||||
struct mie_printer printer;
|
||||
mie_printer_init(&printer, ctx, b_stdout, flags);
|
||||
mie_printer_init(&printer, ctx, fx_stdout, flags);
|
||||
mie_printer_print_op(&printer, module);
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL_BUILDER_TEST, CMD_INTERNAL)
|
||||
FX_COMMAND(CMD_INTERNAL_BUILDER_TEST, CMD_INTERNAL)
|
||||
{
|
||||
B_COMMAND_NAME("builder-test");
|
||||
B_COMMAND_DESC("mie_builder test");
|
||||
B_COMMAND_FUNCTION(builder_test);
|
||||
FX_COMMAND_NAME("builder-test");
|
||||
FX_COMMAND_DESC("mie_builder test");
|
||||
FX_COMMAND_FUNCTION(builder_test);
|
||||
|
||||
B_COMMAND_OPTION(OPT_GENERIC)
|
||||
FX_COMMAND_OPTION(OPT_GENERIC)
|
||||
{
|
||||
B_OPTION_LONG_NAME("generic");
|
||||
B_OPTION_SHORT_NAME('g');
|
||||
B_OPTION_DESC("print operations in generic format.");
|
||||
FX_OPTION_LONG_NAME("generic");
|
||||
FX_OPTION_SHORT_NAME('g');
|
||||
FX_OPTION_DESC("print operations in generic format.");
|
||||
}
|
||||
|
||||
B_COMMAND_OPTION(OPT_NO_ABBREV)
|
||||
FX_COMMAND_OPTION(OPT_NO_ABBREV)
|
||||
{
|
||||
B_OPTION_LONG_NAME("no-abbrev");
|
||||
B_OPTION_SHORT_NAME('n');
|
||||
B_OPTION_DESC(
|
||||
FX_OPTION_LONG_NAME("no-abbrev");
|
||||
FX_OPTION_SHORT_NAME('n');
|
||||
FX_OPTION_DESC(
|
||||
"don't use abbreviations for builtin types and ops.");
|
||||
}
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
|
||||
struct mie_ctx *ctx = mie_ctx_create();
|
||||
mie_builtin_passes_register(ctx);
|
||||
|
||||
size_t i = 0;
|
||||
b_btree_node *node = b_btree_first(&ctx->ctx_passes.map_entries);
|
||||
fx_bst_node *node = fx_bst_first(&ctx->ctx_passes.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_pass_definition *pass
|
||||
= b_unbox(struct mie_pass_definition, id, p_id);
|
||||
= fx_unbox(struct mie_pass_definition, id, p_id);
|
||||
|
||||
B_COMMAND_OPTION_GEN(OPT_PASS_OFFSET + i)
|
||||
FX_COMMAND_OPTION_GEN(OPT_PASS_OFFSET + i)
|
||||
{
|
||||
B_OPTION_LONG_NAME(pass->p_name);
|
||||
B_OPTION_DESC(pass->p_description);
|
||||
FX_OPTION_LONG_NAME(pass->p_name);
|
||||
FX_OPTION_DESC(pass->p_description);
|
||||
}
|
||||
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "../cmd.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/term.h>
|
||||
#include <mie/attribute/attribute-definition.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/diag/class.h>
|
||||
@@ -35,7 +35,7 @@ static void mie_op_definition_print(const struct mie_op_definition *op)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&op->op_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,red]Op:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
op->op_name, id_str);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ static void mie_type_definition_print(const struct mie_type_definition *type)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&type->ty_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,blue]Ty:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
type->ty_name, id_str);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ static void mie_trait_definition_print(const struct mie_trait_definition *trait)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&trait->tr_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,yellow]Tr:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
trait->tr_name, id_str);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ static void mie_attribute_definition_print(
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&attribute->a_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,magenta]At:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
attribute->a_name, id_str);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ static void mie_interface_definition_print(
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&interface->if_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,cyan]If:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
interface->if_name, id_str);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ static void mie_pass_definition_print(const struct mie_pass_definition *interfac
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&interface->p_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
" [bold,cyan]Ps:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
interface->p_name, id_str);
|
||||
}
|
||||
@@ -92,19 +92,19 @@ static void mie_diag_class_print(
|
||||
{
|
||||
switch (c->c_type) {
|
||||
case MIE_DIAG_CLASS_HINT:
|
||||
b_printf(" [bold,cyan]Hint:[reset]");
|
||||
fx_printf(" [bold,cyan]Hint:[reset]");
|
||||
break;
|
||||
case MIE_DIAG_CLASS_WARNING:
|
||||
b_printf(" [bold,yellow]Warn:[reset]");
|
||||
fx_printf(" [bold,yellow]Warn:[reset]");
|
||||
break;
|
||||
case MIE_DIAG_CLASS_ERROR:
|
||||
b_printf(" [bold,red]Err: [reset]");
|
||||
fx_printf(" [bold,red]Err: [reset]");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
b_printf(
|
||||
fx_printf(
|
||||
"%s.%-25s [green]%s[reset]\n", dialect->d_name,
|
||||
c->c_id_str_short, c->c_title);
|
||||
}
|
||||
@@ -112,7 +112,11 @@ static void mie_diag_class_print(
|
||||
static void mie_diag_msg_print(
|
||||
const struct mie_dialect *dialect, const struct mie_diag_msg *msg)
|
||||
{
|
||||
b_printf(
|
||||
if (!msg->msg_id_str_short || !msg->msg_content) {
|
||||
return;
|
||||
}
|
||||
|
||||
fx_printf(
|
||||
" [bold,blue]Msg: [reset]%s.%-25s [green]%s[reset]\n",
|
||||
dialect->d_name, msg->msg_id_str_short, msg->msg_content);
|
||||
}
|
||||
@@ -121,105 +125,110 @@ static void mie_dialect_print(const struct mie_dialect *dialect)
|
||||
{
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&dialect->d_id, id_str, sizeof id_str);
|
||||
b_printf(
|
||||
fx_printf(
|
||||
"[bold,green]D:[reset]%-20s [dark_grey]{%s}[reset]\n",
|
||||
dialect->d_name, id_str);
|
||||
|
||||
b_btree_node *node = b_btree_first(&dialect->d_ops.map_entries);
|
||||
fx_bst_node *node = fx_bst_first(&dialect->d_ops.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_op_definition *op
|
||||
= b_unbox(struct mie_op_definition, id, op_id);
|
||||
= fx_unbox(struct mie_op_definition, id, op_id);
|
||||
|
||||
mie_op_definition_print(op);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_types.map_entries);
|
||||
node = fx_bst_first(&dialect->d_types.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_type_definition *type
|
||||
= b_unbox(struct mie_type_definition, id, ty_id);
|
||||
= fx_unbox(struct mie_type_definition, id, ty_id);
|
||||
|
||||
mie_type_definition_print(type);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_traits.map_entries);
|
||||
node = fx_bst_first(&dialect->d_traits.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_trait_definition *trait
|
||||
= b_unbox(struct mie_trait_definition, id, tr_id);
|
||||
= fx_unbox(struct mie_trait_definition, id, tr_id);
|
||||
|
||||
mie_trait_definition_print(trait);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_attributes.map_entries);
|
||||
node = fx_bst_first(&dialect->d_attributes.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_attribute_definition *attribute
|
||||
= b_unbox(struct mie_attribute_definition, id, a_id);
|
||||
= fx_unbox(struct mie_attribute_definition, id, a_id);
|
||||
|
||||
mie_attribute_definition_print(attribute);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
node = b_btree_first(&dialect->d_interfaces.map_entries);
|
||||
node = fx_bst_first(&dialect->d_interfaces.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
struct mie_interface_definition *interface = b_unbox(
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_interface_definition *interface = fx_unbox(
|
||||
struct mie_interface_definition, id, if_id);
|
||||
|
||||
mie_interface_definition_print(interface);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
}
|
||||
|
||||
static void mie_ctx_print(const struct mie_ctx *ctx)
|
||||
{
|
||||
printf("Dialects:\n");
|
||||
b_btree_node *node = b_btree_first(&ctx->ctx_dialects.map_entries);
|
||||
fx_bst_node *node = fx_bst_first(&ctx->ctx_dialects.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_dialect *dialect
|
||||
= b_unbox(struct mie_dialect, id, d_id);
|
||||
= fx_unbox(struct mie_dialect, id, d_id);
|
||||
|
||||
mie_dialect_print(dialect);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
printf("\nPasses:\n");
|
||||
node = b_btree_first(&ctx->ctx_passes.map_entries);
|
||||
node = fx_bst_first(&ctx->ctx_passes.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_pass_definition *pass
|
||||
= b_unbox(struct mie_pass_definition, id, p_id);
|
||||
= fx_unbox(struct mie_pass_definition, id, p_id);
|
||||
|
||||
mie_pass_definition_print(pass);
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
|
||||
printf("\nDiagnostics:\n");
|
||||
node = b_btree_first(&ctx->ctx_dialects.map_entries);
|
||||
node = fx_bst_first(&ctx->ctx_dialects.map_entries);
|
||||
while (node) {
|
||||
mie_id *id = b_unbox(mie_id, node, e_node);
|
||||
mie_id *id = fx_unbox(mie_id, node, e_node);
|
||||
struct mie_dialect *dialect
|
||||
= b_unbox(struct mie_dialect, id, d_id);
|
||||
= fx_unbox(struct mie_dialect, id, d_id);
|
||||
|
||||
for (size_t i = 0; i < dialect->d_nr_diag_classes; i++) {
|
||||
mie_diag_class_print(dialect, &dialect->d_diag_classes[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < dialect->d_nr_diag_msgs; i++) {
|
||||
if (!dialect->d_diag_msgs[i].msg_content) {
|
||||
printf(" [%zu] NULL\n", i);
|
||||
}
|
||||
|
||||
mie_diag_msg_print(dialect, &dialect->d_diag_msgs[i]);
|
||||
}
|
||||
|
||||
node = b_btree_next(node);
|
||||
node = fx_bst_next(node);
|
||||
}
|
||||
}
|
||||
|
||||
static int ctx_dump(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
static int ctx_dump(
|
||||
const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
struct mie_ctx *ctx = mie_ctx_create();
|
||||
mie_builtin_dialect_create(ctx);
|
||||
@@ -267,7 +276,7 @@ static int ctx_dump(const b_command *cmd, const b_arglist *args, const b_array *
|
||||
sizeof func_out_parts / sizeof *func_out_parts));
|
||||
|
||||
struct mie_printer printer;
|
||||
mie_printer_init(&printer, ctx, b_stdout, MIE_PRINT_F_ABBREVIATED);
|
||||
mie_printer_init(&printer, ctx, fx_stdout, MIE_PRINT_F_ABBREVIATED);
|
||||
|
||||
char id_str[MIE_ID_STRING_MAX];
|
||||
mie_id_to_string(&i32->ty_id, id_str, sizeof id_str);
|
||||
@@ -304,11 +313,11 @@ static int ctx_dump(const b_command *cmd, const b_arglist *args, const b_array *
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL_CTX_DUMP, CMD_INTERNAL)
|
||||
FX_COMMAND(CMD_INTERNAL_CTX_DUMP, CMD_INTERNAL)
|
||||
{
|
||||
B_COMMAND_NAME("ctx-dump");
|
||||
B_COMMAND_DESC("mie_ctx dump");
|
||||
B_COMMAND_FUNCTION(ctx_dump);
|
||||
FX_COMMAND_NAME("ctx-dump");
|
||||
FX_COMMAND_DESC("mie_ctx dump");
|
||||
FX_COMMAND_FUNCTION(ctx_dump);
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
#include "../cmd.h"
|
||||
|
||||
#include <blue/cmd.h>
|
||||
#include <blue/term.h>
|
||||
#include <fx/cmd.h>
|
||||
#include <fx/term.h>
|
||||
|
||||
static int internal(const b_command *cmd, const b_arglist *args, const b_array *_)
|
||||
static int internal(
|
||||
const fx_command *cmd, const fx_arglist *args, const fx_array *_)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
B_COMMAND(CMD_INTERNAL, CMD_ROOT)
|
||||
FX_COMMAND(CMD_INTERNAL, CMD_ROOT)
|
||||
{
|
||||
B_COMMAND_SHORT_NAME('X');
|
||||
B_COMMAND_DESC("internal frontend debugging tools.");
|
||||
B_COMMAND_FUNCTION(internal);
|
||||
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
FX_COMMAND_SHORT_NAME('X');
|
||||
FX_COMMAND_DESC("internal frontend debugging tools.");
|
||||
FX_COMMAND_FUNCTION(internal);
|
||||
FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
|
||||
|
||||
B_COMMAND_HELP_OPTION();
|
||||
FX_COMMAND_HELP_OPTION();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user