|
MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
|
Base class for instruction storage, variables, labels, and external function registrations. More...
#include <icode.hpp>

Public Member Functions | |
| Base ()=default | |
| Base (Base &&other) noexcept | |
| Move constructor. | |
| ~Base ()=default | |
| Base & | operator= (Base &&other) noexcept |
| Move-assignment operator. | |
| void | setMainBase (Base *b) |
| Set the root program base pointer (used for global variable lookup). | |
| void | add_instruction (const Instruction &i) |
| Append an instruction to the instruction stream. | |
| void | add_label (const std::string &name, uint64_t address, bool f) |
| Register a label at the given instruction address. | |
| void | add_variable (const std::string &name, const Variable &v) |
| Declare a local variable in the symbol table. | |
| void | add_global (const std::string &objname, const std::string &name, const Variable &v) |
| Declare a global variable scoped to an object. | |
| void | add_extern (const std::string &mod, const std::string &name, bool module) |
| Register an external function import. | |
| void | add_runtime_extern (const std::string &mod_name, const std::string &mod, const std::string &func_name, const std::string &name) |
| Register and resolve a runtime-loaded external function. | |
| void | add_filename (const std::string &fname) |
| Record a source filename for debug/error reporting. | |
| void | add_allocated (const std::string &name, Variable &v) |
| Track a heap-allocated variable for cleanup. | |
| void | add_object (const std::string &name, Program *prog) |
| Register a child object program. | |
Public Attributes | |
| std::string | name |
| std::vector< Instruction > | inc |
| instruction stream | |
| std::unordered_map< std::string, Variable > | vars |
| variable symbol table | |
| std::unordered_map< std::string, std::pair< uint64_t, bool > > | labels |
| label -> (address, is_function) | |
| std::vector< ExternalFunction > | external |
| declared external function imports | |
| std::unordered_map< std::string, RuntimeFunction > | external_functions |
| resolved runtime function bindings | |
| std::string | assembly_code |
| generated assembly output for objects | |
Static Public Attributes | |
| static Base * | base = nullptr |
| pointer to the main program base | |
| static std::string | root_name |
| static std::vector< std::string > | filenames |
| static std::unordered_map< std::string, Variable > | allocated |
| heap-allocated variables | |
| static std::unordered_map< std::string, Program * > | object_map |
| object name -> Program mapping | |
Base class for instruction storage, variables, labels, and external function registrations.
Provides the shared data structures used by both interpreted and compiled programs: instruction list, variable table, label map, external function bindings, and object references.
|
default |
References Base().
Referenced by Base(), Base(), ~Base(), operator=(), and setMainBase().
|
noexcept |
|
default |
References Base().
| void mxvm::Base::add_allocated | ( | const std::string & | name, |
| Variable & | v ) |
| void mxvm::Base::add_extern | ( | const std::string & | mod, |
| const std::string & | name, | ||
| bool | module ) |
| void mxvm::Base::add_filename | ( | const std::string & | fname | ) |
| void mxvm::Base::add_global | ( | const std::string & | objname, |
| const std::string & | name, | ||
| const Variable & | v ) |
| void mxvm::Base::add_instruction | ( | const Instruction & | i | ) |
Append an instruction to the instruction stream.
| i | Instruction to add |
Definition at line 237 of file icode.cpp.
References inc.
Referenced by mxvm::Program::flatten_inc().
| void mxvm::Base::add_label | ( | const std::string & | name, |
| uint64_t | address, | ||
| bool | f ) |
Register a label at the given instruction address.
| name | Label identifier |
| address | Instruction index the label points to |
| f | true if the label marks a function entry |
Definition at line 241 of file icode.cpp.
Referenced by mxvm::Program::flatten_label().
| void mxvm::Base::add_object | ( | const std::string & | name, |
| Program * | prog ) |
| void mxvm::Base::add_runtime_extern | ( | const std::string & | mod_name, |
| const std::string & | mod, | ||
| const std::string & | func_name, | ||
| const std::string & | name ) |
| void mxvm::Base::add_variable | ( | const std::string & | name, |
| const Variable & | v ) |
Move-assignment operator.
Definition at line 76 of file icode.cpp.
References Base(), external, external_functions, inc, labels, name, and vars.
Referenced by mxvm::Program::operator=().
|
inline |
|
static |
| std::string mxvm::Base::assembly_code |
|
static |
pointer to the main program base
Definition at line 197 of file icode.hpp.
Referenced by action_interpret(), add_filename(), add_object(), add_runtime_extern(), mxvm::Program::addVariables(), collectAndRegisterAllExterns(), mxvm::Program::exec_load(), mxvm::Program::exec_store(), mxvm::Program::generateCode(), mxvm::Parser::generateProgramCode(), mxvm::Program::getMangledName(), mxvm::Program::getVariable(), mxvm::Program::isVariable(), process_arguments(), mxvm::Parser::processObjectFile(), setMainBase(), mxvm::Program::subVariables(), translate_x64(), and mxvm::Program::x64_generateCode().
| std::vector<ExternalFunction> mxvm::Base::external |
declared external function imports
Definition at line 195 of file icode.hpp.
Referenced by Base(), add_extern(), mxvm::Program::gen_done(), mxvm::Program::gen_exit(), mxvm::Program::generateCode(), operator=(), mxvm::Program::x64_gen_done(), mxvm::Program::x64_gen_exit(), and mxvm::Program::x64_generateCode().
| std::unordered_map<std::string, RuntimeFunction> mxvm::Base::external_functions |
resolved runtime function bindings
Definition at line 196 of file icode.hpp.
Referenced by Base(), mxvm::Program::exec_invoke(), mxvm::Program::flatten(), mxvm::Program::flatten_external(), and operator=().
| std::vector<Instruction> mxvm::Base::inc |
instruction stream
Definition at line 192 of file icode.hpp.
Referenced by Base(), add_instruction(), mxvm::Program::exec(), mxvm::Program::flatten(), mxvm::Program::generateCode(), operator=(), mxvm::Program::print(), mxvm::Program::sysv_analyzeRegAlloc(), mxvm::Program::x64_analyzeRegAlloc(), and mxvm::Program::x64_generateCode().
| std::unordered_map<std::string, std::pair<uint64_t, bool> > mxvm::Base::labels |
label -> (address, is_function)
Definition at line 194 of file icode.hpp.
Referenced by Base(), add_label(), mxvm::Program::exec_call(), mxvm::Program::exec_jmp(), mxvm::Program::flatten(), mxvm::Program::flatten_inc(), mxvm::Program::gen_jmp(), mxvm::Program::generateCode(), mxvm::Program::getMangledName(), mxvm::Program::isFunctionValid(), mxvm::Program::memoryDump(), operator=(), mxvm::Program::x64_gen_jmp(), and mxvm::Program::x64_generateCode().
| std::string mxvm::Base::name |
Definition at line 191 of file icode.hpp.
Referenced by Base(), add_allocated(), add_extern(), add_global(), add_label(), add_object(), add_runtime_extern(), add_variable(), and operator=().
|
static |
object name -> Program mapping
Definition at line 201 of file icode.hpp.
Referenced by mxvm::Program::getVariable(), mxvm::Program::isFunctionValid(), and mxvm::Program::isVariable().
|
static |
Definition at line 198 of file icode.hpp.
Referenced by mxvm::Program::generateCode(), and mxvm::Program::x64_generateCode().
| std::unordered_map<std::string, Variable> mxvm::Base::vars |
variable symbol table
Definition at line 193 of file icode.hpp.
Referenced by Base(), mxvm::Program::Program(), mxvm::Program::~Program(), add_variable(), mxvm::Program::exec_free(), mxvm::Program::exec_mov(), mxvm::Program::flatten_inc(), mxvm::Program::generateCode(), mxvm::Program::getVariable(), mxvm::Program::isVariable(), mxvm::Program::memoryDump(), mxvm_io_fclose(), mxvm_io_feof(), mxvm_io_fopen(), mxvm_io_fputs(), mxvm_io_fread(), mxvm_io_fseek(), mxvm_io_fsize(), mxvm_io_fwrite(), mxvm_io_mxvm_fgets(), mxvm_io_rand_number(), mxvm_io_seed_random(), mxvm_sdl_blit_surface(), mxvm_sdl_create_render_target(), mxvm_sdl_create_renderer(), mxvm_sdl_create_rgb_surface(), mxvm_sdl_create_texture(), mxvm_sdl_create_window(), mxvm_sdl_get_clipboard_text(), mxvm_sdl_get_event_type(), mxvm_sdl_get_key_code(), mxvm_sdl_get_keyboard_state(), mxvm_sdl_get_mouse_button(), mxvm_sdl_get_mouse_buttons(), mxvm_sdl_get_mouse_state(), mxvm_sdl_get_mouse_x(), mxvm_sdl_get_mouse_y(), mxvm_sdl_get_num_keys(), mxvm_sdl_get_queued_audio_size(), mxvm_sdl_get_relative_mouse_buttons(), mxvm_sdl_get_relative_mouse_state(), mxvm_sdl_get_relative_mouse_x(), mxvm_sdl_get_relative_mouse_y(), mxvm_sdl_get_ticks(), mxvm_sdl_init(), mxvm_sdl_init_text(), mxvm_sdl_is_key_pressed(), mxvm_sdl_load_font(), mxvm_sdl_load_texture(), mxvm_sdl_load_texture_color_key(), mxvm_sdl_load_texture_color_key_rgb(), mxvm_sdl_load_wav(), mxvm_sdl_lock_texture(), mxvm_sdl_open_audio(), mxvm_sdl_poll_event(), mxvm_sdl_queue_audio(), mxvm_sdl_update_texture(), mxvm_std_abs(), mxvm_std_acos(), mxvm_std_argc(), mxvm_std_argv(), mxvm_std_asin(), mxvm_std_atan(), mxvm_std_atan2(), mxvm_std_atof(), mxvm_std_atoi(), mxvm_std_calloc(), mxvm_std_ceil(), mxvm_std_cos(), mxvm_std_cosh(), mxvm_std_exp(), mxvm_std_exp2(), mxvm_std_fabs(), mxvm_std_float_to_int(), mxvm_std_floor(), mxvm_std_fmod(), mxvm_std_hypot(), mxvm_std_int_to_float(), mxvm_std_isalpha(), mxvm_std_isdigit(), mxvm_std_isspace(), mxvm_std_log(), mxvm_std_log10(), mxvm_std_log2(), mxvm_std_malloc(), mxvm_std_memcmp(), mxvm_std_memcpy(), mxvm_std_memmove(), mxvm_std_memset(), mxvm_std_pow(), mxvm_std_rand(), mxvm_std_round(), mxvm_std_sin(), mxvm_std_sinh(), mxvm_std_sqrt(), mxvm_std_system(), mxvm_std_tan(), mxvm_std_tanh(), mxvm_std_tolower(), mxvm_std_toupper(), mxvm_std_trunc(), mxvm_string_copy(), mxvm_string_delete(), mxvm_string_insert(), mxvm_string_inttostr(), mxvm_string_pos(), mxvm_string_snprintf(), mxvm_string_strat(), mxvm_string_strcmp(), mxvm_string_strfind(), mxvm_string_strlen(), mxvm_string_strncat(), mxvm_string_strncpy(), mxvm_string_strtoint(), mxvm_string_substr(), operator=(), mxvm::Program::operator=(), mxvm::Program::validateNames(), and mxvm::Program::x64_generateCode().