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

Complete bytecode structure. More...

#include <CodeGen.hpp>

Public Member Functions

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, int32_t op4=0, int32_t op5=0)
 Emit an instruction with operands.

Public Attributes

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

Detailed Description

Complete bytecode structure.

Definition at line 200 of file CodeGen.hpp.

Member Function Documentation

◆ addConstant()

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

Add a constant to the pool and return its index.

Definition at line 213 of file CodeGen.hpp.

◆ emit()

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

Emit an instruction with operands.

Definition at line 233 of file CodeGen.hpp.

◆ getOrCreateVar()

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

Get or create a variable index.

Definition at line 220 of file CodeGen.hpp.

Member Data Documentation

◆ constants

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

Constant pool.

Definition at line 203 of file CodeGen.hpp.

◆ functionEntries

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

Function name -> instruction index mapping.

Definition at line 205 of file CodeGen.hpp.

◆ instructions

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

List of instructions.

Definition at line 202 of file CodeGen.hpp.

◆ nextVarIndex

int Phasor::Bytecode::nextVarIndex = 0

Next available variable index.

Definition at line 206 of file CodeGen.hpp.

◆ structEntries

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

Struct name -> index in structs.

Definition at line 210 of file CodeGen.hpp.

◆ structs

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

List of struct descriptors.

Definition at line 209 of file CodeGen.hpp.

◆ variables

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

Variable name -> index mapping.

Definition at line 204 of file CodeGen.hpp.


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