Phasor 3.3.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
Phasor::Bytecode Struct Reference

Complete bytecode structure. More...

#include <CodeGen.hpp>

Collaboration diagram for Phasor::Bytecode:
[legend]

Public Member Functions

int addConstant (const Value &value)
 Add a constant to the pool and return its index.
int addStringConstant (const std::string &s)
 Add a string constant with deduplication.
int getOrCreateVar (const std::string &name)
 Get or create a variable index.
void emit (OpCode op, int32_t op1=0, int32_t op2=0, int32_t op3=0)
 Emit an instruction with operands.
int addConstant (const Value &value)
 Add a constant to the pool and return its index.
int getOrCreateVar (const std::string &name)
 Get or create a variable index.
void emit (OpCode op, int32_t op1=0, int32_t op2=0, int32_t op3=0)
 Emit an instruction with operands.

Public Attributes

std::vector< Instructioninstructions
 List of instructions.
std::vector< Valueconstants
 Constant pool.
std::unordered_map< std::string, int > variables
 Variable name -> index mapping.
std::unordered_map< std::string, int > functionEntries
 Function name -> instruction index mapping.
std::unordered_map< std::string, int > functionParamCounts
 Function name -> parameter count.
int nextVarIndex = 0
 Next available variable index.
std::vector< StructInfostructs
 List of struct descriptors.
std::unordered_map< std::string, int > structEntries
 Struct name -> index in structs.
std::unordered_map< std::string, int > stringConstantCache
 Dedup cache for string constants.
std::map< std::string, int > variables
 Variable name -> index mapping.
std::map< std::string, int > functionEntries
 Function name -> instruction index mapping.
std::map< std::string, int > functionParamCounts
 Function name -> parameter count.
std::map< std::string, int > structEntries
 Struct name -> index in structs.

Detailed Description

Complete bytecode structure.

Definition at line 49 of file CodeGen.hpp.

Member Function Documentation

◆ addConstant() [1/2]

int Phasor::Bytecode::addConstant ( const Value & value)
inline

Add a constant to the pool and return its index.

Definition at line 231 of file PhasorISA.hpp.

◆ addConstant() [2/2]

int Phasor::Bytecode::addConstant ( const Value & value)
inline

Add a constant to the pool and return its index.

Definition at line 63 of file CodeGen.hpp.

Here is the caller graph for this function:

◆ addStringConstant()

int Phasor::Bytecode::addStringConstant ( const std::string & s)
inline

Add a string constant with deduplication.

Definition at line 70 of file CodeGen.hpp.

Here is the call graph for this function:

◆ emit() [1/2]

void Phasor::Bytecode::emit ( OpCode op,
int32_t op1 = 0,
int32_t op2 = 0,
int32_t op3 = 0 )
inline

Emit an instruction with operands.

Definition at line 251 of file PhasorISA.hpp.

◆ emit() [2/2]

void Phasor::Bytecode::emit ( OpCode op,
int32_t op1 = 0,
int32_t op2 = 0,
int32_t op3 = 0 )
inline

Emit an instruction with operands.

Definition at line 98 of file CodeGen.hpp.

◆ getOrCreateVar() [1/2]

int Phasor::Bytecode::getOrCreateVar ( const std::string & name)
inline

Get or create a variable index.

Definition at line 238 of file PhasorISA.hpp.

◆ getOrCreateVar() [2/2]

int Phasor::Bytecode::getOrCreateVar ( const std::string & name)
inline

Get or create a variable index.

Definition at line 85 of file CodeGen.hpp.

Member Data Documentation

◆ constants

std::vector< Value > Phasor::Bytecode::constants

Constant pool.

Definition at line 52 of file CodeGen.hpp.

◆ functionEntries [1/2]

std::map<std::string, int> Phasor::Bytecode::functionEntries

Function name -> instruction index mapping.

Definition at line 222 of file PhasorISA.hpp.

◆ functionEntries [2/2]

std::unordered_map<std::string, int> Phasor::Bytecode::functionEntries

Function name -> instruction index mapping.

Definition at line 54 of file CodeGen.hpp.

◆ functionParamCounts [1/2]

std::map<std::string, int> Phasor::Bytecode::functionParamCounts

Function name -> parameter count.

Definition at line 223 of file PhasorISA.hpp.

◆ functionParamCounts [2/2]

std::unordered_map<std::string, int> Phasor::Bytecode::functionParamCounts

Function name -> parameter count.

Definition at line 55 of file CodeGen.hpp.

◆ instructions

std::vector< Instruction > Phasor::Bytecode::instructions

List of instructions.

Definition at line 51 of file CodeGen.hpp.

◆ nextVarIndex

int Phasor::Bytecode::nextVarIndex = 0

Next available variable index.

Definition at line 56 of file CodeGen.hpp.

◆ stringConstantCache

std::unordered_map<std::string, int> Phasor::Bytecode::stringConstantCache

Dedup cache for string constants.

Definition at line 82 of file CodeGen.hpp.

◆ structEntries [1/2]

std::map<std::string, int> Phasor::Bytecode::structEntries

Struct name -> index in structs.

Definition at line 228 of file PhasorISA.hpp.

◆ structEntries [2/2]

std::unordered_map<std::string, int> Phasor::Bytecode::structEntries

Struct name -> index in structs.

Definition at line 60 of file CodeGen.hpp.

◆ structs

std::vector< StructInfo > Phasor::Bytecode::structs

List of struct descriptors.

Definition at line 59 of file CodeGen.hpp.

◆ variables [1/2]

std::map<std::string, int> Phasor::Bytecode::variables

Variable name -> index mapping.

Definition at line 221 of file PhasorISA.hpp.

◆ variables [2/2]

std::unordered_map<std::string, int> Phasor::Bytecode::variables

Variable name -> index mapping.

Definition at line 53 of file CodeGen.hpp.


The documentation for this struct was generated from the following files: