mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
All leaks plugged for the time being
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
fn capture(count: int) {
|
|
||||||
print count;
|
|
||||||
print capture;
|
|
||||||
|
|
||||||
if (count > 5) {
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return capture(count + 1);
|
fn panic() {
|
||||||
|
assert false, "This should only be seen once";
|
||||||
}
|
}
|
||||||
|
|
||||||
print capture(0);
|
panic();
|
||||||
|
panic();
|
||||||
|
|||||||
@@ -550,6 +550,7 @@ static bool execAssert(Interpreter* interpreter) {
|
|||||||
|
|
||||||
if (IS_NULL(lhs) || !IS_TRUTHY(lhs)) {
|
if (IS_NULL(lhs) || !IS_TRUTHY(lhs)) {
|
||||||
(*interpreter->assertOutput)(AS_STRING(rhs));
|
(*interpreter->assertOutput)(AS_STRING(rhs));
|
||||||
|
freeLiteral(rhs);
|
||||||
interpreter->panic = true;
|
interpreter->panic = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -569,6 +570,7 @@ static bool execPrint(Interpreter* interpreter) {
|
|||||||
if (!parseIdentifierToValue(interpreter, &lit)) {
|
if (!parseIdentifierToValue(interpreter, &lit)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
|
|
||||||
printLiteralCustom(lit, interpreter->printOutput);
|
printLiteralCustom(lit, interpreter->printOutput);
|
||||||
@@ -657,7 +659,7 @@ static bool execInvert(Interpreter* interpreter) {
|
|||||||
if (!parseIdentifierToValue(interpreter, &lit)) {
|
if (!parseIdentifierToValue(interpreter, &lit)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
freeLitreral(idn);
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_BOOLEAN(lit)) {
|
if (IS_BOOLEAN(lit)) {
|
||||||
@@ -849,7 +851,12 @@ static bool execVarDecl(Interpreter* interpreter, bool lng) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Literal val = popLiteralArray(&interpreter->stack);
|
Literal val = popLiteralArray(&interpreter->stack);
|
||||||
|
|
||||||
|
if (IS_IDENTIFIER(val)) {
|
||||||
|
Literal idn = val;
|
||||||
parseIdentifierToValue(interpreter, &val);
|
parseIdentifierToValue(interpreter, &val);
|
||||||
|
freeLiteral(idn);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IS_NULL(val) && !setScopeVariable(interpreter->scope, identifier, val, false)) {
|
if (!IS_NULL(val) && !setScopeVariable(interpreter->scope, identifier, val, false)) {
|
||||||
printf(ERROR "ERROR: Incorrect type assigned to variable \"");
|
printf(ERROR "ERROR: Incorrect type assigned to variable \"");
|
||||||
@@ -919,7 +926,11 @@ static bool execVarAssign(Interpreter* interpreter) {
|
|||||||
Literal rhs = popLiteralArray(&interpreter->stack);
|
Literal rhs = popLiteralArray(&interpreter->stack);
|
||||||
Literal lhs = popLiteralArray(&interpreter->stack);
|
Literal lhs = popLiteralArray(&interpreter->stack);
|
||||||
|
|
||||||
|
if (IS_IDENTIFIER(rhs)) {
|
||||||
|
Literal idn = rhs;
|
||||||
parseIdentifierToValue(interpreter, &rhs);
|
parseIdentifierToValue(interpreter, &rhs);
|
||||||
|
freeLiteral(idn);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IS_IDENTIFIER(lhs)) {
|
if (!IS_IDENTIFIER(lhs)) {
|
||||||
printf(ERROR "ERROR: Can't assign to a non-variable \"");
|
printf(ERROR "ERROR: Can't assign to a non-variable \"");
|
||||||
@@ -932,6 +943,9 @@ static bool execVarAssign(Interpreter* interpreter) {
|
|||||||
printf(ERROR "ERROR: Undeclared variable \"");
|
printf(ERROR "ERROR: Undeclared variable \"");
|
||||||
printLiteral(lhs);
|
printLiteral(lhs);
|
||||||
printf("\"\n" RESET);
|
printf("\"\n" RESET);
|
||||||
|
|
||||||
|
freeLiteral(lhs);
|
||||||
|
freeLiteral(rhs);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -939,6 +953,9 @@ static bool execVarAssign(Interpreter* interpreter) {
|
|||||||
printf(ERROR "ERROR Incorrect type assigned to variable \"");
|
printf(ERROR "ERROR Incorrect type assigned to variable \"");
|
||||||
printLiteral(lhs);
|
printLiteral(lhs);
|
||||||
printf("\"\n" RESET);
|
printf("\"\n" RESET);
|
||||||
|
|
||||||
|
freeLiteral(lhs);
|
||||||
|
freeLiteral(rhs);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,7 +1369,9 @@ static bool execFnCall(Interpreter* interpreter) {
|
|||||||
initLiteralArray(&correct);
|
initLiteralArray(&correct);
|
||||||
|
|
||||||
while(arguments.count) {
|
while(arguments.count) {
|
||||||
pushLiteralArray(&correct, popLiteralArray(&arguments));
|
Literal lit = popLiteralArray(&arguments);
|
||||||
|
pushLiteralArray(&correct, lit);
|
||||||
|
freeLiteral(lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
freeLiteralArray(&arguments);
|
freeLiteralArray(&arguments);
|
||||||
@@ -1361,6 +1380,7 @@ static bool execFnCall(Interpreter* interpreter) {
|
|||||||
((NativeFn) AS_FUNCTION(func).bytecode )(interpreter, &correct);
|
((NativeFn) AS_FUNCTION(func).bytecode )(interpreter, &correct);
|
||||||
|
|
||||||
freeLiteralArray(&correct);
|
freeLiteralArray(&correct);
|
||||||
|
freeLiteral(identifier);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user