Phasor 2.2.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
CodeGen.hpp
Go to the documentation of this file.
1#pragma once
2#include "../AST/AST.hpp"
4#include <cstdint>
5#include <map>
6#include <string>
7#include <vector>
8
9namespace Phasor
10{
15enum class OpCode : uint8_t
16{
17 // Stack operations
20
21 // Arithmetic operations
39
40 // Unary operations
43
44 // Logical operations
49
50 // Comparison operations
63
64 // Control flow
69
70 // Variable operations
73
74 // I/O and control
86
87 // Literal values
91
92 // String operatoins
96
100
104
105 // Register-based operations (v2.0)
106 // Data movement
115
116 // Register arithmetic (3-address code)
134
135 // Register comparisons
152
153 // Register unary operations
156
157 // Register I/O
164};
165
170{
172 int32_t operand1;
173 int32_t operand2;
174 int32_t operand3;
175 int32_t operand4;
176 int32_t operand5;
177
178 // Default constructor
180 {
181 }
182
183 // Full constructor
184 Instruction(OpCode op, int32_t op1 = 0, int32_t op2 = 0, int32_t op3 = 0, int32_t op4 = 0, int32_t op5 = 0)
185 : op(op), operand1(op1), operand2(op2), operand3(op3), operand4(op4), operand5(op5)
186 {
187 }
188};
189
192{
193 std::string name;
196 std::vector<std::string> fieldNames;
197};
198
201{
202 std::vector<Instruction> instructions;
203 std::vector<Value> constants;
204 std::map<std::string, int> variables;
205 std::map<std::string, int> functionEntries;
206 int nextVarIndex = 0;
207
208 // Struct section (planned usage by future struct codegen)
209 std::vector<StructInfo> structs;
210 std::map<std::string, int> structEntries;
211
213 int addConstant(const Value &value)
214 {
215 constants.push_back(value);
216 return static_cast<int>(constants.size()) - 1;
217 }
218
220 int getOrCreateVar(const std::string &name)
221 {
222 auto it = variables.find(name);
223 if (it != variables.end())
224 {
225 return it->second;
226 }
227 int index = nextVarIndex++;
228 variables[name] = index;
229 return index;
230 }
231
233 void emit(OpCode op, int32_t op1 = 0, int32_t op2 = 0, int32_t op3 = 0, int32_t op4 = 0, int32_t op5 = 0)
234 {
235 instructions.push_back(Instruction(op, op1, op2, op3, op4, op5));
236 }
237};
238
243{
244 public:
254 Bytecode generate(const AST::Program &program, const std::map<std::string, int> &existingVars = {}, int nextVarIdx = 0,
255 bool replMode = false);
256
257 private:
259 bool isRepl = false;
260 // Inferred types for variables (simple, flow-insensitive mapping)
261 std::map<std::string, ValueType> inferredTypes;
262
263 // Register allocation for v2.0
264 uint8_t nextRegister = 0;
265 std::vector<bool> registerInUse;
266
269 {
270 for (size_t i = 0; i < 256; i++)
271 {
272 if (i >= registerInUse.size())
273 {
274 registerInUse.resize(i + 1, false);
275 }
276 if (!registerInUse[i])
277 {
278 registerInUse[i] = true;
279 return static_cast<uint8_t>(i);
280 }
281 }
282 throw std::runtime_error("Out of registers");
283 }
284
286 void freeRegister(uint8_t reg)
287 {
288 if (reg < registerInUse.size())
289 {
290 registerInUse[reg] = false;
291 }
292 }
293
296 {
297 registerInUse.clear();
298 nextRegister = 0;
299 }
300
302 bool isLiteralExpression(const AST::Expression *expr, Value &outValue);
303
308 ValueType inferExpressionType(const AST::Expression *expr, bool &known);
309
310 void generateStatement(const AST::Statement *stmt);
311 void generateExpression(const AST::Expression *expr);
312 void generateVarDecl(const AST::VarDecl *varDecl);
313 void generateExpressionStmt(const AST::ExpressionStmt *exprStmt);
314 void generatePrintStmt(const AST::PrintStmt *printStmt);
315 void generateImportStmt(const AST::ImportStmt *importStmt);
316 void generateExportStmt(const AST::ExportStmt *exportStmt);
317 void generateNumberExpr(const AST::NumberExpr *numExpr);
318 void generateStringExpr(const AST::StringExpr *strExpr);
319 void generateIdentifierExpr(const AST::IdentifierExpr *identExpr);
320 void generateUnaryExpr(const AST::UnaryExpr *unaryExpr);
321 void generateCallExpr(const AST::CallExpr *callExpr);
322 void generateBinaryExpr(const AST::BinaryExpr *binExpr);
323 void generateBlockStmt(const AST::BlockStmt *blockStmt);
324 void generateIfStmt(const AST::IfStmt *ifStmt);
325 void generateWhileStmt(const AST::WhileStmt *whileStmt);
326 void generateForStmt(const AST::ForStmt *forStmt);
327 void generateReturnStmt(const AST::ReturnStmt *returnStmt);
329 const AST::UnsafeBlockStmt *unsafeStmt);
330 void generateFunctionDecl(const AST::FunctionDecl *funcDecl);
331 void generateBooleanExpr(const AST::BooleanExpr *boolExpr);
332 void generateNullExpr(const AST::NullExpr *nullExpr);
333 void generateAssignmentExpr(const AST::AssignmentExpr *assignExpr);
334 void generateStructDecl(const AST::StructDecl *decl);
337 void generatePostfixExpr(const AST::PostfixExpr *expr);
338 void generateBreakStmt();
340 void generateSwitchStmt(const AST::SwitchStmt *switchStmt);
341
342 // Loop context for break/continue
343 std::vector<int> loopStartStack; // Stack of loop start positions
344 std::vector<std::vector<int>> breakJumpsStack; // Stack of break jump positions to patch
345 std::vector<std::vector<int>> continueJumpsStack; // Stack of continue jump positions to patch
346};
347
348} // namespace Phasor
Code generator for Phasor VM.
Definition CodeGen.hpp:243
void generateForStmt(const AST::ForStmt *forStmt)
Generate bytecode from For Statement.
Definition CodeGen.cpp:752
Bytecode bytecode
Generated bytecode.
Definition CodeGen.hpp:258
void generateCallExpr(const AST::CallExpr *callExpr)
Generate bytecode from Call Expression.
Definition CodeGen.cpp:335
std::map< std::string, ValueType > inferredTypes
Definition CodeGen.hpp:261
void generateVarDecl(const AST::VarDecl *varDecl)
Generate bytecode from Variable Declaration.
Definition CodeGen.cpp:208
void generateIfStmt(const AST::IfStmt *ifStmt)
Generate bytecode from If Statement.
Definition CodeGen.cpp:689
std::vector< std::vector< int > > breakJumpsStack
Definition CodeGen.hpp:344
void generateUnaryExpr(const AST::UnaryExpr *unaryExpr)
Generate bytecode from Unary Expression.
Definition CodeGen.cpp:311
void generatePostfixExpr(const AST::PostfixExpr *expr)
Definition CodeGen.cpp:998
uint8_t nextRegister
Next available register.
Definition CodeGen.hpp:264
void generateStructInstanceExpr(const AST::StructInstanceExpr *expr)
Definition CodeGen.cpp:953
void generateNullExpr(const AST::NullExpr *nullExpr)
Generate bytecode from Null Expression.
Definition CodeGen.cpp:898
void generateFunctionDecl(const AST::FunctionDecl *funcDecl)
Generate bytecode from Function Declaration.
Definition CodeGen.cpp:855
void generateWhileStmt(const AST::WhileStmt *whileStmt)
Generate bytecode from While Statement.
Definition CodeGen.cpp:714
void generateSwitchStmt(const AST::SwitchStmt *switchStmt)
Definition CodeGen.cpp:1080
Bytecode generate(const AST::Program &program, const std::map< std::string, int > &existingVars={}, int nextVarIdx=0, bool replMode=false)
Generate bytecode from program.
Definition CodeGen.cpp:7
void generateBlockStmt(const AST::BlockStmt *blockStmt)
Generate bytecode from Block Statement.
Definition CodeGen.cpp:681
void generateBooleanExpr(const AST::BooleanExpr *boolExpr)
Generate bytecode from Boolean Expression.
Definition CodeGen.cpp:886
void generateStructDecl(const AST::StructDecl *decl)
Definition CodeGen.cpp:1038
uint8_t allocateRegister()
Allocate a new register.
Definition CodeGen.hpp:268
std::vector< int > loopStartStack
Definition CodeGen.hpp:343
void generatePrintStmt(const AST::PrintStmt *printStmt)
Generate bytecode from Print Statement.
Definition CodeGen.cpp:256
void generateStringExpr(const AST::StringExpr *strExpr)
Generate bytecode from String Expression.
Definition CodeGen.cpp:299
void freeRegister(uint8_t reg)
Free a register.
Definition CodeGen.hpp:286
ValueType inferExpressionType(const AST::Expression *expr, bool &known)
Simple expression type inference (conservative).
Definition CodeGen.cpp:62
void generateExpression(const AST::Expression *expr)
Generate bytecode from Expression.
Definition CodeGen.cpp:157
std::vector< std::vector< int > > continueJumpsStack
Definition CodeGen.hpp:345
void generateExportStmt(const AST::ExportStmt *exportStmt)
Generate bytecode from Export Statement.
Definition CodeGen.cpp:268
void generateUnsafeBlockStmt(const AST::UnsafeBlockStmt *unsafeStmt)
Generate bytecode from Unsafe Block Statement.
Definition CodeGen.cpp:850
void generateBinaryExpr(const AST::BinaryExpr *binExpr)
Generate bytecode from Binary Expression.
Definition CodeGen.cpp:429
void generateExpressionStmt(const AST::ExpressionStmt *exprStmt)
Generate bytecode from Expression Statement.
Definition CodeGen.cpp:243
void generateImportStmt(const AST::ImportStmt *importStmt)
Generate bytecode from Import Statement.
Definition CodeGen.cpp:262
void generateStatement(const AST::Statement *stmt)
Generate bytecode from Statement.
Definition CodeGen.cpp:88
bool isLiteralExpression(const AST::Expression *expr, Value &outValue)
Check if expression is a compile-time literal.
Definition CodeGen.cpp:23
void generateIdentifierExpr(const AST::IdentifierExpr *identExpr)
Generate bytecode from Identifier Expression.
Definition CodeGen.cpp:305
bool isRepl
REPL mode.
Definition CodeGen.hpp:259
void generateAssignmentExpr(const AST::AssignmentExpr *assignExpr)
Generate bytecode from Assignment Expression.
Definition CodeGen.cpp:903
void generateNumberExpr(const AST::NumberExpr *numExpr)
Generate bytecode from Numeral Expression.
Definition CodeGen.cpp:274
std::vector< bool > registerInUse
Track which registers are in use.
Definition CodeGen.hpp:265
void resetRegisters()
Reset register allocator.
Definition CodeGen.hpp:295
void generateFieldAccessExpr(const AST::FieldAccessExpr *expr)
Definition CodeGen.cpp:986
void generateReturnStmt(const AST::ReturnStmt *returnStmt)
Generate bytecode from Return Statement.
Definition CodeGen.cpp:837
A value in the Phasor VM.
Definition Value.hpp:33
The Phasor Programming Language and Runtime.
Definition AST.hpp:8
@ IGREATER_THAN
Pop b, pop a, push a > b.
Definition CodeGen.hpp:54
@ IEQUAL
Pop b, pop a, push a == b.
Definition CodeGen.hpp:51
@ SYSTEM_OUT
Call system function and push stdout.
Definition CodeGen.hpp:83
@ LOG_R
R[rA] = log(R[rB]).
Definition CodeGen.hpp:129
@ FLMOD_R
R[rA] = R[rB] % R[rC].
Definition CodeGen.hpp:126
@ SUBSTR
Pop len, pop start, pop s, push s.substr(start, len).
Definition CodeGen.hpp:95
@ IAND
Pop b, pop a, push a && b.
Definition CodeGen.hpp:45
@ NOT
Pop a, push !a.
Definition CodeGen.hpp:42
@ SET_FIELD_STATIC
Pop value and struct instance, set field by static offset.
Definition CodeGen.hpp:103
@ NULL_VAL
Push null.
Definition CodeGen.hpp:90
@ MOV
Copy register to register: R[rA] = R[rB].
Definition CodeGen.hpp:107
@ PRINTERROR_R
Print register to stderr: printerror(R[rA]).
Definition CodeGen.hpp:159
@ IAND_R
R[rA] = R[rB] && R[rC].
Definition CodeGen.hpp:136
@ FLMUL_R
R[rA] = R[rB] * R[rC].
Definition CodeGen.hpp:124
@ IADD
Pop b, pop a, push a + b.
Definition CodeGen.hpp:22
@ PUSH2_R
Push 2 registers to stack: push2(R[rA], R[rB]).
Definition CodeGen.hpp:112
@ FLGE_R
R[rA] = R[rB] >= R[rC].
Definition CodeGen.hpp:151
@ SYSTEM_R
Run an operating system shell command: system(R[rA]).
Definition CodeGen.hpp:161
@ PUSH_CONST
Push constant from constant pool.
Definition CodeGen.hpp:18
@ JUMP_IF_TRUE
Jump if top of stack is true (pops value).
Definition CodeGen.hpp:67
@ FLGT_R
R[rA] = R[rB] > R[rC].
Definition CodeGen.hpp:149
@ PUSH_R
Push register to stack: push(R[rA]).
Definition CodeGen.hpp:111
@ POP_R
Pop stack to register: R[rA] = pop().
Definition CodeGen.hpp:113
@ FLEQUAL
Pop b, pop a, push a == b.
Definition CodeGen.hpp:57
@ GET_FIELD_STATIC
Pop struct instance, push field by static offset (structIndex, fieldOffset).
Definition CodeGen.hpp:102
@ FLNOT_EQUAL
Pop b, pop a, push a != b.
Definition CodeGen.hpp:58
@ FLADD_R
R[rA] = R[rB] + R[rC].
Definition CodeGen.hpp:122
@ POP2_R
Pop 2 values from stack to registers: pop2(R[rA], R[rB]).
Definition CodeGen.hpp:114
@ LOAD_CONST_R
Load constant to register: R[rA] = constants[immediate].
Definition CodeGen.hpp:108
@ SQRT
sqrt()
Definition CodeGen.hpp:32
@ FLADD
Pop b, pop a, push a + b.
Definition CodeGen.hpp:27
@ JUMP
Unconditional jump to offset.
Definition CodeGen.hpp:65
@ FLLT_R
R[rA] = R[rB] < R[rC].
Definition CodeGen.hpp:148
@ SET_FIELD
Pop struct, pop field name, pop value, set field value.
Definition CodeGen.hpp:99
@ NOT_R
R[rA] = !R[rB].
Definition CodeGen.hpp:155
@ IMULTIPLY
Pop b, pop a, push a * b.
Definition CodeGen.hpp:24
@ READLINE_R
Read line into register: readline(R[rA]).
Definition CodeGen.hpp:160
@ CHAR_AT
Pop index, pop s, push s[index].
Definition CodeGen.hpp:94
@ IMUL_R
R[rA] = R[rB] * R[rC].
Definition CodeGen.hpp:119
@ FLGREATER_EQUAL
Pop b, pop a, push a >= b.
Definition CodeGen.hpp:62
@ FLLE_R
R[rA] = R[rB] <= R[rC].
Definition CodeGen.hpp:150
@ IGREATER_EQUAL
Pop b, pop a, push a >= b.
Definition CodeGen.hpp:56
@ SYSTEM_ERR
Call system function and push stderr.
Definition CodeGen.hpp:84
@ SQRT_R
R[rA] = sqrt(R[rB]).
Definition CodeGen.hpp:127
@ ISUB_R
R[rA] = R[rB] - R[rC].
Definition CodeGen.hpp:118
@ FLDIV_R
R[rA] = R[rB] / R[rC].
Definition CodeGen.hpp:125
@ COS_R
R[rA] = cos(R[rB]).
Definition CodeGen.hpp:132
@ CALL_NATIVE
Call a native function: operand is index of function name in constants.
Definition CodeGen.hpp:80
@ ISUBTRACT
Pop b, pop a, push a - b.
Definition CodeGen.hpp:23
@ LEN
Pop s, push len(s).
Definition CodeGen.hpp:93
@ FLMODULO
Pop b, pop a, push a % b.
Definition CodeGen.hpp:31
@ FALSE_P
Push false.
Definition CodeGen.hpp:89
@ NEW_STRUCT_INSTANCE_STATIC
Create new struct instance using struct section metadata (structIndex).
Definition CodeGen.hpp:101
@ NEG_R
R[rA] = -R[rB].
Definition CodeGen.hpp:154
@ IDIVIDE
Pop b, pop a, push a / b.
Definition CodeGen.hpp:25
@ FLOR
Pop b, pop a, push a || b.
Definition CodeGen.hpp:48
@ STORE_VAR
Pop top of stack, store in variable slot.
Definition CodeGen.hpp:71
@ ILE_R
R[rA] = R[rB] <= R[rC].
Definition CodeGen.hpp:142
@ FLDIVIDE
Pop b, pop a, push a / b.
Definition CodeGen.hpp:30
@ POW_R
R[rA] = pow(R[rB], R[rC]).
Definition CodeGen.hpp:128
@ IMODULO
Pop b, pop a, push a % b.
Definition CodeGen.hpp:26
@ FLAND_R
R[rA] = R[rB] && R[rC].
Definition CodeGen.hpp:144
@ JUMP_IF_FALSE
Jump if top of stack is false (pops value).
Definition CodeGen.hpp:66
@ INOT_EQUAL
Pop b, pop a, push a != b.
Definition CodeGen.hpp:52
@ FLEQ_R
R[rA] = R[rB] == R[rC].
Definition CodeGen.hpp:146
@ LOAD_VAR
Push variable value onto stack.
Definition CodeGen.hpp:72
@ IOR
Pop b, pop a, push a || b.
Definition CodeGen.hpp:46
@ EXP_R
R[rA] = exp(R[rB]).
Definition CodeGen.hpp:130
@ RETURN
Return from function.
Definition CodeGen.hpp:85
@ STORE_VAR_R
Store register to variable: variables[immediate] = R[rA].
Definition CodeGen.hpp:110
@ READLINE
Read line from input and push onto stack.
Definition CodeGen.hpp:77
@ IGT_R
R[rA] = R[rB] > R[rC].
Definition CodeGen.hpp:141
@ FLSUBTRACT
Pop b, pop a, push a - b.
Definition CodeGen.hpp:28
@ IADD_R
R[rA] = R[rB] + R[rC].
Definition CodeGen.hpp:117
@ IDIV_R
R[rA] = R[rB] / R[rC].
Definition CodeGen.hpp:120
@ FLLESS_EQUAL
Pop b, pop a, push a <= b.
Definition CodeGen.hpp:61
@ SYSTEM_ERR_R
Run shell command and get output: system_out(R[rA], R[rB]).
Definition CodeGen.hpp:163
@ FLMULTIPLY
Pop b, pop a, push a * b.
Definition CodeGen.hpp:29
@ ILESS_EQUAL
Pop b, pop a, push a <= b.
Definition CodeGen.hpp:55
@ HALT
Stop execution.
Definition CodeGen.hpp:79
@ PRINT_R
Print register: print(R[rA]).
Definition CodeGen.hpp:158
@ PRINTERROR
Pop top of stack and print to stderr.
Definition CodeGen.hpp:76
@ TAN_R
R[rA] = tan(R[rB]).
Definition CodeGen.hpp:133
@ FLSUB_R
R[rA] = R[rB] - R[rC].
Definition CodeGen.hpp:123
@ JUMP_BACK
Jump backwards (for loops).
Definition CodeGen.hpp:68
@ FLOR_R
R[rA] = R[rB] || R[rC].
Definition CodeGen.hpp:145
@ CALL
Call a user function: operand is index of function name in constants.
Definition CodeGen.hpp:81
@ INE_R
R[rA] = R[rB] != R[rC].
Definition CodeGen.hpp:139
@ NEGATE
Pop a, push -a.
Definition CodeGen.hpp:41
@ FLNE_R
R[rA] = R[rB] != R[rC].
Definition CodeGen.hpp:147
@ FLGREATER_THAN
Pop b, pop a, push a > b.
Definition CodeGen.hpp:60
@ ILESS_THAN
Pop b, pop a, push a < b.
Definition CodeGen.hpp:53
@ GET_FIELD
Pop struct, pop field name, push field value.
Definition CodeGen.hpp:98
@ SIN_R
R[rA] = sin(R[rB]).
Definition CodeGen.hpp:131
@ IMPORT
Import a module: operand is index of module path in constants.
Definition CodeGen.hpp:78
@ LOAD_VAR_R
Load variable to register: R[rA] = variables[immediate].
Definition CodeGen.hpp:109
@ FLLESS_THAN
Pop b, pop a, push a < b.
Definition CodeGen.hpp:59
@ NEW_STRUCT
Create new struct: operand is index of struct name in constants.
Definition CodeGen.hpp:97
@ IOR_R
R[rA] = R[rB] || R[rC].
Definition CodeGen.hpp:137
@ ILT_R
R[rA] = R[rB] < R[rC].
Definition CodeGen.hpp:140
@ TRUE_P
Push true.
Definition CodeGen.hpp:88
@ POP
Pop top of stack.
Definition CodeGen.hpp:19
@ FLAND
Pop b, pop a, push a && b.
Definition CodeGen.hpp:47
@ IMOD_R
R[rA] = R[rB] % R[rC].
Definition CodeGen.hpp:121
@ PRINT
Pop top of stack and print.
Definition CodeGen.hpp:75
@ SYSTEM
Call a system function: operand is index of function name in constants.
Definition CodeGen.hpp:82
@ IEQ_R
R[rA] = R[rB] == R[rC].
Definition CodeGen.hpp:138
@ IGE_R
R[rA] = R[rB] >= R[rC].
Definition CodeGen.hpp:143
ValueType
Runtime value types for the VM.
Definition Value.hpp:17
Assignment Expression Node.
Definition AST.hpp:354
Binary Expression Node.
Definition AST.hpp:223
Block Statement Node.
Definition AST.hpp:445
Boolean Expression Node.
Definition AST.hpp:109
Call Expression Node.
Definition AST.hpp:334
Export Statement Node.
Definition AST.hpp:431
Expression Node.
Definition AST.hpp:28
Expression Statement Node.
Definition AST.hpp:391
Field Access Expression Node.
Definition AST.hpp:670
For Statement Node.
Definition AST.hpp:539
Function Declaration Node.
Definition AST.hpp:580
Identifier Expression Node.
Definition AST.hpp:96
If Statement Node.
Definition AST.hpp:495
Import Statement Node.
Definition AST.hpp:418
NULL Expression Node.
Definition AST.hpp:122
Numeral Expression Node.
Definition AST.hpp:70
Postfix Expression Node.
Definition AST.hpp:165
Print Statement Node.
Definition AST.hpp:404
Program Node.
Definition AST.hpp:38
Return Statement Node.
Definition AST.hpp:462
Statement Node.
Definition AST.hpp:33
String Expression Node.
Definition AST.hpp:83
Struct Declaration Node.
Definition AST.hpp:627
Struct Instance Expression Node.
Definition AST.hpp:648
Switch Statement Node.
Definition AST.hpp:700
Unary Expression Node.
Definition AST.hpp:191
Unsafe Block Statement Node.
Definition AST.hpp:566
Variable Declaration Node.
Definition AST.hpp:375
While Statement Node.
Definition AST.hpp:520
Complete bytecode structure.
Definition CodeGen.hpp:201
std::vector< StructInfo > structs
List of struct descriptors.
Definition CodeGen.hpp:209
std::vector< Value > constants
Constant pool.
Definition CodeGen.hpp:203
std::map< std::string, int > functionEntries
Function name -> instruction index mapping.
Definition CodeGen.hpp:205
int nextVarIndex
Next available variable index.
Definition CodeGen.hpp:206
int getOrCreateVar(const std::string &name)
Get or create a variable index.
Definition CodeGen.hpp:220
std::map< std::string, int > structEntries
Struct name -> index in structs.
Definition CodeGen.hpp:210
std::map< std::string, int > variables
Variable name -> index mapping.
Definition CodeGen.hpp:204
int addConstant(const Value &value)
Add a constant to the pool and return its index.
Definition CodeGen.hpp:213
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.
Definition CodeGen.hpp:233
std::vector< Instruction > instructions
List of instructions.
Definition CodeGen.hpp:202
Instruction with up to 5 operands Format: instruction operand1, operand2, operand3,...
Definition CodeGen.hpp:170
int32_t operand1
First operand.
Definition CodeGen.hpp:172
int32_t operand2
Second operand.
Definition CodeGen.hpp:173
int32_t operand4
Fourth operand.
Definition CodeGen.hpp:175
int32_t operand3
Third operand.
Definition CodeGen.hpp:174
OpCode op
Operation code.
Definition CodeGen.hpp:171
int32_t operand5
Fifth operand.
Definition CodeGen.hpp:176
Instruction(OpCode op, int32_t op1=0, int32_t op2=0, int32_t op3=0, int32_t op4=0, int32_t op5=0)
Definition CodeGen.hpp:184
Struct metadata stored alongside bytecode (struct section).
Definition CodeGen.hpp:192
int firstConstIndex
Index into constants for the first default value.
Definition CodeGen.hpp:194
std::vector< std::string > fieldNames
Field names in declaration order.
Definition CodeGen.hpp:196
int fieldCount
Number of fields in this struct.
Definition CodeGen.hpp:195
std::string name
Struct name.
Definition CodeGen.hpp:193