mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Added tables to the scripts, untested
This also has a lot of bugfixing.
This commit is contained in:
@@ -266,7 +266,7 @@ static unsigned int writeInstructionCompound(Toy_Routine** rt, Toy_AstCompound a
|
||||
unsigned int result = writeRoutineCode(rt, ast.child);
|
||||
|
||||
if (ast.flag == TOY_AST_FLAG_COMPOUND_ARRAY) {
|
||||
//signal how many values to read in as an array value
|
||||
//signal how many values to read in as array elements
|
||||
EMIT_BYTE(rt, code, TOY_OPCODE_READ);
|
||||
EMIT_BYTE(rt, code, TOY_VALUE_ARRAY);
|
||||
|
||||
@@ -279,6 +279,20 @@ static unsigned int writeInstructionCompound(Toy_Routine** rt, Toy_AstCompound a
|
||||
|
||||
return 1; //leaves only 1 value on the stack
|
||||
}
|
||||
if (ast.flag == TOY_AST_FLAG_COMPOUND_TABLE) {
|
||||
//signal how many values to read in as table elements
|
||||
EMIT_BYTE(rt, code, TOY_OPCODE_READ);
|
||||
EMIT_BYTE(rt, code, TOY_VALUE_TABLE);
|
||||
|
||||
//4-byte alignment
|
||||
EMIT_BYTE(rt, code,0);
|
||||
EMIT_BYTE(rt, code,0);
|
||||
|
||||
//how many elements
|
||||
EMIT_INT(rt, code, result);
|
||||
|
||||
return 1; //leaves only 1 value on the stack
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, TOY_CC_ERROR "ERROR: Invalid AST compound flag found\n" TOY_CC_RESET);
|
||||
exit(-1);
|
||||
@@ -297,6 +311,10 @@ static unsigned int writeInstructionAggregate(Toy_Routine** rt, Toy_AstAggregate
|
||||
//collections are handled above
|
||||
return result;
|
||||
}
|
||||
else if (ast.flag == TOY_AST_FLAG_PAIR) {
|
||||
//pairs are handled above
|
||||
return result;
|
||||
}
|
||||
else if (ast.flag == TOY_AST_FLAG_INDEX) {
|
||||
//value[index, length]
|
||||
EMIT_BYTE(rt, code, TOY_OPCODE_INDEX);
|
||||
|
||||
Reference in New Issue
Block a user