mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
picking up the tab
This commit is contained in:
@@ -83,9 +83,9 @@ Opcodes within the bytecode are 1 byte in length, and specify a single action to
|
|||||||
The interpeter is stack-based; most, if not all of the actions are preformed on literals within a specially designated array called `stack`. for example:
|
The interpeter is stack-based; most, if not all of the actions are preformed on literals within a specially designated array called `stack`. for example:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
case TOY_OP_PRINT:
|
case TOY_OP_PRINT:
|
||||||
if (!execPrint(interpreter)) {
|
if (!execPrint(interpreter)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
```
|
```
|
||||||
@@ -97,19 +97,19 @@ static bool execPrint(Toy_Interpreter* interpreter) {
|
|||||||
//get the top literal
|
//get the top literal
|
||||||
Toy_Literal lit = Toy_popLiteralArray(&interpreter->stack);
|
Toy_Literal lit = Toy_popLiteralArray(&interpreter->stack);
|
||||||
|
|
||||||
//if the top literal is an identifier, get it's value
|
//if the top literal is an identifier, get it's value
|
||||||
Toy_Literal idn = lit;
|
Toy_Literal idn = lit;
|
||||||
if (TOY_IS_IDENTIFIER(lit) && Toy_parseIdentifierToValue(interpreter, &lit)) {
|
if (TOY_IS_IDENTIFIER(lit) && Toy_parseIdentifierToValue(interpreter, &lit)) {
|
||||||
Toy_freeLiteral(idn);
|
Toy_freeLiteral(idn);
|
||||||
}
|
}
|
||||||
|
|
||||||
//print as a string to the current print method
|
//print as a string to the current print method
|
||||||
Toy_printLiteralCustom(lit, interpreter->printOutput);
|
Toy_printLiteralCustom(lit, interpreter->printOutput);
|
||||||
|
|
||||||
//free the literal
|
//free the literal
|
||||||
Toy_freeLiteral(lit);
|
Toy_freeLiteral(lit);
|
||||||
|
|
||||||
//continue the loop
|
//continue the loop
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user