Implemented the attribute operator, using a period

This commit is contained in:
2026-04-24 11:31:54 +10:00
parent d2ac1eeb8e
commit 9a75226491
7 changed files with 94 additions and 1 deletions
+20
View File
@@ -1080,6 +1080,22 @@ static unsigned int writeInstructionFnInvoke(Toy_Bytecode** mb, Toy_AstFnInvoke
return 0;
}
static unsigned int writeInstructionAttribute(Toy_Bytecode** mb, Toy_AstAttribute ast) {
//write the lhs normally
unsigned int result = writeBytecodeFromAst(mb, ast.left);
//write the attribute's identifier
result += writeBytecodeFromAst(mb, ast.right);
//exactly what this results in is type-dependant
EMIT_BYTE(mb, code,TOY_OPCODE_ATTRIBUTE);
EMIT_BYTE(mb, code, 0);
EMIT_BYTE(mb, code, 0);
EMIT_BYTE(mb, code, 0);
return 1;
}
static unsigned int writeInstructionStackPop(Toy_Bytecode** mb, Toy_AstStackPop ast) {
unsigned int result = writeBytecodeFromAst(mb, ast.child);
@@ -1211,6 +1227,10 @@ static unsigned int writeBytecodeFromAst(Toy_Bytecode** mb, Toy_Ast* ast) {
result += writeInstructionFnInvoke(mb, ast->fnInvoke);
break;
case TOY_AST_ATTRIBUTE:
result += writeInstructionAttribute(mb, ast->attribute);
break;
case TOY_AST_STACK_POP:
result += writeInstructionStackPop(mb, ast->stackPop);
break;