MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
mxvm Namespace Reference

Classes

class  ASTNode
 Abstract base class for all AST nodes. More...
class  SectionNode
 Represents a program section (.data, .code, .module, .object). More...
class  ProgramNode
 Root AST node representing an entire program or object. More...
class  VariableNode
 AST node for a variable declaration in a .data section. More...
class  ModuleNode
 AST node for a module import declaration. More...
class  ObjectNode
 AST node for an object import declaration. More...
class  InstructionNode
 AST node representing a single MXVM instruction with its operands. More...
class  LabelNode
 AST node for a label (or function entry point) in the code section. More...
class  ExpressionNode
 AST node for a literal expression value. More...
class  CommentNode
 AST node for a source-level comment. More...
class  ASTVisitor
 Visitor interface for traversing the AST node hierarchy. More...
class  Function
class  Function< R(Args...)>
 RAII wrapper for dynamically loaded functions via dlopen/dlsym. More...
class  HTMLGen
 Generates syntax-highlighted HTML output from MXVM source code. More...
class  PasHTMLGen
 Generates syntax-highlighted HTML output from Pascal (.pas) source code. More...
class  Stack
 Runtime operand stack for the MXVM interpreter. More...
class  RuntimeFunction
 Wraps a dynamically loaded native function from a shared library module. More...
class  Base
 Base class for instruction storage, variables, labels, and external function registrations. More...
class  Program
 Complete MXVM program: instruction interpreter and native x64 code generator. More...
struct  Operand
 A single instruction operand (constant value or variable reference). More...
struct  Instruction
 A complete MXVM instruction with opcode, operands, and optional label. More...
struct  Variable_Value
 Runtime value storage for a variable. More...
struct  Variable
 A named variable with type, value, and optional object association. More...
class  Parser
 Main MXVM parser — tokenizes source, builds AST, and generates intermediate code. More...
struct  ExternalFunction
 Describes an external function imported from a module or object. More...
class  ModuleParser
 Parser for MXVM module definition files (.mxvm). More...
struct  ParsedOp
 A parsed operand with its kind, text, and source location. More...
struct  UseVar
 Records a variable usage site for validation. More...
struct  UseLabel
 Records a label usage site for validation. More...
struct  OpSpec
 Specification of valid operand patterns for an instruction. More...
class  Validator
 Validates MXVM source for correct variable/label usage and instruction operands. More...

Typedefs

using StackValue = std::variant<int64_t, void *, double, std::string>
 Stack element: integer, pointer, double, or string.
using runtime_call = std::function<void(Program *program, std::vector<Operand> &operands)>
 Callback type for runtime-registered native functions.

Enumerations

enum class  OperandType { OP_CONSTANT , OP_VARIABLE }
 Discriminates whether an operand is a compile-time constant or a variable reference. More...
enum class  VarType {
  VAR_NULL = 0 , VAR_INTEGER , VAR_FLOAT , VAR_STRING ,
  VAR_POINTER , VAR_LABEL , VAR_ARRAY , VAR_EXTERN ,
  VAR_BYTE
}
 MXVM variable type discriminator. More...
enum class  Keywords {
  KEY_PROGRAM , KEY_OBJECT , KEY_MODULE , KEY_DATA ,
  KEY_CODE , KEY_SECTION
}
 MXVM language keywords. More...
enum class  Mode { MODE_INTERPRET , MODE_COMPILE }
 Execution mode: interpretation or native compilation. More...
enum class  Platform { LINUX , DARWIN , WINX64 }
 Target platform for native code generation. More...
enum class  OpKind {
  Num , Hex , Str , Id ,
  Member , Label , Any
}
 Classification of operand kinds for validation. More...
enum class  VArity { None , AnyTail , ArgsTail }
 Variadic arity policy for instruction operand specs. More...

Functions

void except_assert (std::string reason, bool value)
 Assert a condition, throwing an Exception with the given reason on failure.
bool isFunctionReturningOwnedPtr (const std::string &funcName)
 Check whether a named function returns an owned (heap-allocated) pointer.
static std::unordered_set< std::string > buildInstructionSet ()
static std::unordered_set< std::string > buildKeywordSet ()
static void releaseOwnedPointer (Variable &v)
std::string toStringFromVarType (const VarType &v)
static bool is_stdio_name (const std::string &s)
static int stdio_index (const std::string &s)
static std::string join_lines (const std::vector< std::string > &v)
static bool is_label (const std::string &line)
static std::vector< std::string > opt_core_lines (const std::vector< std::string > &lines)
static std::vector< std::string > x64_opt_core_lines (const std::vector< std::string > &lines)
static std::string darwin_prefix_calls (const std::string &line, const std::unordered_set< std::string > &macos_functions)
static std::vector< std::string > opt_darwin_lines (const std::vector< std::string > &lines)
static std::vector< std::string > opt_x64_windows_lines (const std::vector< std::string > &lines)
static std::vector< std::string > opt_linux_lines (const std::vector< std::string > &lines)
static bool isImmediate (const OpKind k)
static bool has_semicolon (const std::string &s)
static bool isIdLike (OpKind k)

Variables

std::vector< std::string > keywords {"program", "object", "module", "data", "code", "section"}
 String representations of Keywords enum values.
bool debug_mode = false
 enable verbose debug output during parsing
bool instruct_mode = false
 enable instruction trace mode
bool html_mode = false
 enable HTML debug output
static const std::unordered_set< std::string > kInstructions = buildInstructionSet()
static const std::unordered_set< std::string > kKeywords = buildKeywordSet()
static const std::unordered_set< std::string > kTypes
static int error_label_count = 0
static unsigned x64_sp_mod16 = 0
size_t xmm_offset
static int error_label_count = 0
static const std::unordered_map< std::string, OpSpeckOpSpecs

Typedef Documentation

◆ runtime_call

using mxvm::runtime_call = std::function<void(Program *program, std::vector<Operand> &operands)>

Callback type for runtime-registered native functions.

Definition at line 70 of file icode.hpp.

◆ StackValue

using mxvm::StackValue = std::variant<int64_t, void *, double, std::string>

Stack element: integer, pointer, double, or string.

Definition at line 20 of file icode.hpp.

Enumeration Type Documentation

◆ Keywords

enum class mxvm::Keywords
strong

MXVM language keywords.

Enumerator
KEY_PROGRAM 
KEY_OBJECT 
KEY_MODULE 
KEY_DATA 
KEY_CODE 
KEY_SECTION 

Definition at line 192 of file instruct.hpp.

◆ Mode

enum class mxvm::Mode
strong

Execution mode: interpretation or native compilation.

Enumerator
MODE_INTERPRET 
MODE_COMPILE 

Definition at line 36 of file parser.hpp.

◆ OperandType

enum class mxvm::OperandType
strong

Discriminates whether an operand is a compile-time constant or a variable reference.

Enumerator
OP_CONSTANT 
OP_VARIABLE 

Definition at line 153 of file instruct.hpp.

◆ OpKind

enum class mxvm::OpKind
strong

Classification of operand kinds for validation.

Enumerator
Num 
Hex 
Str 
Id 
Member 
Label 
Any 

Definition at line 19 of file valid.hpp.

◆ Platform

enum class mxvm::Platform
strong

Target platform for native code generation.

Enumerator
LINUX 
DARWIN 
WINX64 

Definition at line 42 of file parser.hpp.

◆ VArity

enum class mxvm::VArity
strong

Variadic arity policy for instruction operand specs.

Enumerator
None 

exact fixed operand count required

AnyTail 

fixed operands followed by any number of trailing operands

ArgsTail 

fixed operands followed by argument-typed trailing operands

Definition at line 48 of file valid.hpp.

◆ VarType

enum class mxvm::VarType
strong

MXVM variable type discriminator.

Enumerator
VAR_NULL 
VAR_INTEGER 
VAR_FLOAT 
VAR_STRING 
VAR_POINTER 
VAR_LABEL 
VAR_ARRAY 
VAR_EXTERN 
VAR_BYTE 

Definition at line 180 of file instruct.hpp.

Function Documentation

◆ buildInstructionSet()

std::unordered_set< std::string > mxvm::buildInstructionSet ( )
static

Definition at line 56 of file html_gen.cpp.

References IncType.

◆ buildKeywordSet()

std::unordered_set< std::string > mxvm::buildKeywordSet ( )
static

Definition at line 66 of file html_gen.cpp.

References keywords.

◆ darwin_prefix_calls()

std::string mxvm::darwin_prefix_calls ( const std::string & line,
const std::unordered_set< std::string > & macos_functions )
static

Definition at line 329 of file icode_opt.cpp.

References pos().

Referenced by opt_darwin_lines().

◆ except_assert()

void mxvm::except_assert ( std::string reason,
bool value )

Assert a condition, throwing an Exception with the given reason on failure.

Parameters
reasonError message
valueCondition to assert (true = pass)

Definition at line 436 of file icode.cpp.

Referenced by asReadPtr(), asWritePtr(), getStringFromVar(), mxvm_std_memcmp(), mxvm_std_memcpy(), mxvm_std_memmove(), mxvm_std_memset(), mxvm_string_snprintf(), mxvm_string_strcmp(), mxvm_string_strlen(), and mxvm_string_substr().

◆ has_semicolon()

bool mxvm::has_semicolon ( const std::string & s)
static

Definition at line 20 of file valid.cpp.

Referenced by mxvm::Validator::validate().

◆ is_label()

bool mxvm::is_label ( const std::string & line)
static

Definition at line 33 of file icode_opt.cpp.

Referenced by opt_core_lines(), and mxvm::HTMLGen::output().

◆ is_stdio_name()

bool mxvm::is_stdio_name ( const std::string & s)
inlinestatic

◆ isFunctionReturningOwnedPtr()

bool mxvm::isFunctionReturningOwnedPtr ( const std::string & funcName)

Check whether a named function returns an owned (heap-allocated) pointer.

Parameters
funcNameFunction name to check
Returns
true if the function returns an owned pointer

Definition at line 249 of file icode_gen_x64.cpp.

Referenced by mxvm::Program::generateInvokeCall(), and mxvm::Program::x64_generateInvokeCall().

◆ isIdLike()

bool mxvm::isIdLike ( OpKind k)
static

Definition at line 140 of file valid.cpp.

References Id, and Member.

Referenced by mxvm::Validator::validateAgainstSpec().

◆ isImmediate()

bool mxvm::isImmediate ( const OpKind k)
inlinestatic

Definition at line 16 of file valid.cpp.

References Hex, Num, and Str.

Referenced by mxvm::Validator::validateAgainstSpec().

◆ join_lines()

std::string mxvm::join_lines ( const std::vector< std::string > & v)
static

Definition at line 16 of file icode_opt.cpp.

Referenced by mxvm::Program::gen_optimize().

◆ opt_core_lines()

std::vector< std::string > mxvm::opt_core_lines ( const std::vector< std::string > & lines)
static

Definition at line 38 of file icode_opt.cpp.

References is_label().

Referenced by mxvm::Program::gen_optimize().

◆ opt_darwin_lines()

std::vector< std::string > mxvm::opt_darwin_lines ( const std::vector< std::string > & lines)
static

Definition at line 358 of file icode_opt.cpp.

References darwin_prefix_calls().

Referenced by mxvm::Program::gen_optimize().

◆ opt_linux_lines()

std::vector< std::string > mxvm::opt_linux_lines ( const std::vector< std::string > & lines)
static

Definition at line 492 of file icode_opt.cpp.

Referenced by mxvm::Program::gen_optimize().

◆ opt_x64_windows_lines()

std::vector< std::string > mxvm::opt_x64_windows_lines ( const std::vector< std::string > & lines)
static

Definition at line 452 of file icode_opt.cpp.

Referenced by mxvm::Program::gen_optimize().

◆ releaseOwnedPointer()

◆ stdio_index()

int mxvm::stdio_index ( const std::string & s)
inlinestatic

◆ toStringFromVarType()

std::string mxvm::toStringFromVarType ( const VarType & v)

Definition at line 1852 of file icode_exec.cpp.

References VAR_BYTE, VAR_EXTERN, VAR_FLOAT, VAR_INTEGER, VAR_POINTER, and VAR_STRING.

◆ x64_opt_core_lines()

std::vector< std::string > mxvm::x64_opt_core_lines ( const std::vector< std::string > & lines)
static

Definition at line 159 of file icode_opt.cpp.

Referenced by mxvm::Program::gen_optimize().

Variable Documentation

◆ debug_mode

bool mxvm::debug_mode = false

enable verbose debug output during parsing

Definition at line 96 of file parser.cpp.

Referenced by mxvm::Program::~Program(), action_interpret(), proc_args(), signal_action(), and translate_x64().

◆ error_label_count [1/2]

◆ error_label_count [2/2]

int mxvm::error_label_count = 0
static

Definition at line 18 of file icode_gen_x64.cpp.

◆ html_mode

bool mxvm::html_mode = false

enable HTML debug output

Definition at line 98 of file parser.cpp.

Referenced by action_interpret(), mxvm::Parser::generateProgramCode(), proc_args(), and translate_x64().

◆ instruct_mode

bool mxvm::instruct_mode = false

enable instruction trace mode

Definition at line 97 of file parser.cpp.

Referenced by mxvm::Program::exec(), and proc_args().

◆ keywords

std::vector< std::string > mxvm::keywords {"program", "object", "module", "data", "code", "section"}

String representations of Keywords enum values.

Definition at line 10 of file instruct.cpp.

Referenced by buildKeywordSet(), and operator<<().

◆ kInstructions

const std::unordered_set<std::string> mxvm::kInstructions = buildInstructionSet()
static

Definition at line 78 of file html_gen.cpp.

Referenced by mxvm::HTMLGen::output().

◆ kKeywords

const std::unordered_set<std::string> mxvm::kKeywords = buildKeywordSet()
static

Definition at line 79 of file html_gen.cpp.

Referenced by mxvm::HTMLGen::output().

◆ kOpSpecs

const std::unordered_map<std::string, OpSpec> mxvm::kOpSpecs
static

Definition at line 92 of file valid.cpp.

Referenced by mxvm::Validator::validateAgainstSpec().

◆ kTypes

const std::unordered_set<std::string> mxvm::kTypes
static
Initial value:
= [] {
return std::unordered_set<std::string>{"string", "int", "byte", "float", "ptr"};
}()

Definition at line 80 of file html_gen.cpp.

Referenced by mxvm::HTMLGen::output().

◆ x64_sp_mod16

◆ xmm_offset

size_t mxvm::xmm_offset
extern