mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Fixed a repl bug
This commit is contained in:
@@ -162,6 +162,7 @@ static int writeNodeCompoundToCache(Compiler* compiler, Node* node) {
|
|||||||
|
|
||||||
static int writeNodeCollectionToCache(Compiler* compiler, Node* node) {
|
static int writeNodeCollectionToCache(Compiler* compiler, Node* node) {
|
||||||
LiteralArray* store = ALLOCATE(LiteralArray, 1);
|
LiteralArray* store = ALLOCATE(LiteralArray, 1);
|
||||||
|
initLiteralArray(store);
|
||||||
|
|
||||||
//ensure each literal value is in the cache, individually
|
//ensure each literal value is in the cache, individually
|
||||||
for (int i = 0; i < node->fnCollection.count; i++) {
|
for (int i = 0; i < node->fnCollection.count; i++) {
|
||||||
|
|||||||
@@ -807,7 +807,7 @@ static bool execFnCall(Interpreter* interpreter) {
|
|||||||
pushLiteralArray(&returns, popLiteralArray(&inner.stack)); //NOTE: also reverses the order
|
pushLiteralArray(&returns, popLiteralArray(&inner.stack)); //NOTE: also reverses the order
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: remove this when multiple assignment is enabled
|
//TODO: remove this when multiple assignment is enabled - note the BUGFIX that balances the stack
|
||||||
if (returns.count > 1) {
|
if (returns.count > 1) {
|
||||||
printf(ERROR "ERROR: Too many values returned (multiple returns not yet implemented)\n" RESET);
|
printf(ERROR "ERROR: Too many values returned (multiple returns not yet implemented)\n" RESET);
|
||||||
|
|
||||||
@@ -1336,6 +1336,11 @@ void runInterpreter(Interpreter* interpreter, unsigned char* bytecode, int lengt
|
|||||||
//execute the interpreter
|
//execute the interpreter
|
||||||
execInterpreter(interpreter);
|
execInterpreter(interpreter);
|
||||||
|
|
||||||
|
//BUGFIX: clear the stack (for repl - stack must be balanced)
|
||||||
|
while(interpreter->stack.count > 0) {
|
||||||
|
popLiteralArray(&interpreter->stack);
|
||||||
|
}
|
||||||
|
|
||||||
//free the bytecode immediately after use
|
//free the bytecode immediately after use
|
||||||
FREE_ARRAY(unsigned char, interpreter->bytecode, interpreter->length);
|
FREE_ARRAY(unsigned char, interpreter->bytecode, interpreter->length);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user