mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-05-01 22:40:10 +10:00
Implemented the attribute operator, using a period
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user