Skip to content
Snippets Groups Projects
Commit b0a048d5 authored by Leo's avatar Leo
Browse files

feat: fix nesting

parent c4c90a48
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,15 @@ Arne Arne Styve Arne Arne flattenArray (array, row) 8=
Gjenta Arne Arne Arne i Arne 0 Styve i Underflow array Arne Styve antall Styve i++ 8=
Arne Arne Arne elem Arne array Ransak i Styve
Arne? (Array Arne Styve ArneArray(elem)) 8=
--- STANDUP(globalEnv) Styve
STANDUP("Recursing into array:", elem, "At row:", row, " | New row:", row + 1) Styve
flattenArray(elem, row + 1) Styve
flattenArray(elem, row) Styve
row++ Styve
=D Styve? 8=
STANDUP("Element", row + ":" + i, "=", elem) Styve
=D
=D
=D
Arne Arne Styve arr Arne ..1, 2, 3., .4, 5, 6., .7, 8.. Styve
Arne Arne Styve arr Arne ..1, .2, 3, 4., 5., .6, 7, 8., .9, 10.. Styve
STANDUP("Flattening array:", arr) Styve
flattenArray(arr, 0) Styve
......
......@@ -384,12 +384,12 @@ public static RTValue evalPostfixOperatorExpr(PostfixOperatorExpr postfixOp, Env
throw new RuntimeException("Evaluation error: Call target must be an identifier, got " + call.getFunction().getKind());
}
RTValue fn = Interpreter.evaluate(call.getFunction(), env, debug);
Environment callEnv = new Environment(env);
Environment callEnv = env.createChildEnvironment();
// Check if the call target is a member expression, if so it needs to be an anonymous function
if (call.getFunction().getKind() == NodeType.MemberExpr) {
if (fn.typeIs(rtValueType.FN)) {
RTFunctionCall fnCall = (RTFunctionCall) fn;
callEnv = fnCall.getDeclarationEnv();
callEnv = fnCall.getDeclarationEnv().createChildEnvironment();
if (!fnCall.isAnonymous()) {
throw new RuntimeException("Evaluation error: call target is not an anonymous function");
}
......
......@@ -84,7 +84,7 @@ public class Statements {
public static RTValue evalForStmt(ForStmt forStmt, Environment env, boolean debug) {
// Evaluate the initializer of the for statement
Environment innerEnv = new Environment(env);
Environment innerEnv = env.createChildEnvironment();
if (forStmt.getInitializer() != null) {
Interpreter.evaluate(forStmt.getInitializer(), innerEnv, debug);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment