diff --git a/nulascript/eval/eval.cc b/nulascript/eval/eval.cc index 2318f7d..0670d06 100644 --- a/nulascript/eval/eval.cc +++ b/nulascript/eval/eval.cc @@ -289,33 +289,33 @@ Storage* runForLoop(ForLoop* fl, Environment* env) { "Incorrectly provisioned incremental boolean variable for loop"); } - if (increment->value) { - Infix* conditional = dynamic_cast(fl->definition.conditional); + Infix* conditional = dynamic_cast(fl->definition.conditional); - if (!conditional) { - return new ErrorStorage( - "Incorrectly provisioned conditional statement for loop"); - } + if (!conditional) { + return new ErrorStorage( + "Incorrectly provisioned conditional statement for loop"); + } - Identifier* identifier = dynamic_cast(conditional->left); - if (!identifier) { - // TODO: come up with better message; - return new ErrorStorage("something 1"); - } + Identifier* identifier = dynamic_cast(conditional->left); + if (!identifier) { + // TODO: come up with better message; + return new ErrorStorage("something 1"); + } - Integer* threshold = dynamic_cast(conditional->right); - if (!threshold) { - // TODO: come up with better message; - return new ErrorStorage("something 2"); - } + Integer* threshold = dynamic_cast(conditional->right); + if (!threshold) { + // TODO: come up with better message; + return new ErrorStorage("something 2"); + } - IntegerStorage* initializer = - dynamic_cast(env->get(identifier->token.literal)); - if (!initializer) { - // TODO: come up with better message; - return new ErrorStorage("something 3"); - } + IntegerStorage* initializer = + dynamic_cast(env->get(identifier->token.literal)); + if (!initializer) { + // TODO: come up with better message; + return new ErrorStorage("something 3"); + } + if (increment->value) { for (int i = initializer->value; true; i++) { if (!evaluateConditionalExpression(i, conditional->op, threshold->value)) @@ -336,6 +336,7 @@ Storage* runForLoop(ForLoop* fl, Environment* env) { return new ErrorStorage("Decremental loops are not yet implemented"); } + // TODO: delete newly created loop variable from environment return emptyStorage; }