diff --git a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/EvaluationVisitor.kt b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/EvaluationVisitor.kt index 1d5d096..699dfcc 100644 --- a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/EvaluationVisitor.kt +++ b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/EvaluationVisitor.kt @@ -4,7 +4,6 @@ import gay.pizza.pork.ast.* class EvaluationVisitor(root: Scope) : NodeVisitor { private var currentScope: Scope = root - private var insideFastCachePreservation = false override fun visitIntLiteral(node: IntLiteral): Any = node.value override fun visitStringLiteral(node: StringLiteral): Any = node.text @@ -29,7 +28,7 @@ class EvaluationVisitor(root: Scope) : NodeVisitor { override fun visitLambda(node: Lambda): CallableFunction { return CallableFunction { arguments -> - currentScope = currentScope.fork(inheritFastCache = insideFastCachePreservation) + currentScope = currentScope.fork() for ((index, argumentSymbol) in node.arguments.withIndex()) { currentScope.define(argumentSymbol.id, arguments.values[index]) } @@ -105,7 +104,7 @@ class EvaluationVisitor(root: Scope) : NodeVisitor { override fun visitFunctionDefinition(node: FunctionDefinition): Any { val blockFunction = visitBlock(node.block) as BlockFunction val function = CallableFunction { arguments -> - currentScope = currentScope.fork(inheritFastCache = insideFastCachePreservation) + currentScope = currentScope.fork(inheritFastCache = true) currentScope.fastVariableCache.put(node.symbol.id, currentScope.value(node.symbol.id)) for ((index, argumentSymbol) in node.arguments.withIndex()) { currentScope.define(argumentSymbol.id, arguments.values[index])