Permalink
Browse files

Resolved some stack overflow issues

  • Loading branch information...
1 parent 3cae508 commit 57dac44213bafc5f942277fd999dfd1c6861021a @phyrex1an phyrex1an committed May 17, 2010
Showing with 6 additions and 6 deletions.
  1. +2 −2 haskell.ast.js
  2. +4 −4 haskell.interpreter.js
View
@@ -108,7 +108,7 @@
this.expr = expr;
this.eval = function(env) {
var newEnv = interpreter.loadDeclarations(this.declr, env.derive());
- return this.expr.eval(newEnv);
+ return new interpreter.Closure(newEnv, this.expr);
};
this.stringify = function() {
return "let {" + this.declr.map(function (d) {
@@ -127,7 +127,7 @@
for (var i in this.cases) {
var newEnv = env.derive();
if (this.cases[i][0].match(newEnv, expr)) {
- return this.cases[i][1].eval(newEnv);
+ return new interpreter.Closure(newEnv, this.cases[i][1]);
};
};
throw new Error("No matching clause");
View
@@ -228,8 +228,8 @@
this.pattern = pattern;
this.expression = expression;
this.apply = function(argument) {
- var substitution = this.env.substitute(this.pattern, argument);
- return this.expression.eval(substitution);
+ var newEnv = this.env.substitute(this.pattern, argument);
+ return new interpreter.Closure(newEnv, this.expression);
};
this.stringify = function() {
@@ -260,11 +260,11 @@
var expression = matchedFunc.expression[j][1];
var guardResult = guard.eval(newEnv);
if (guardResult.identifier == "True") {
- return expression.eval(newEnv);
+ return new interpreter.Closure(newEnv, expression);
}
}
} else {
- return matchedFunc.expression.eval(newEnv);
+ return new interpreter.Closure(newEnv, matchedFunc.expression);
}
}
}

0 comments on commit 57dac44

Please sign in to comment.