Mercurial > repos > tabletprog
comparison interp.js @ 240:dc5f487247ee
Don't rename the symbol self in quote blocks
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 05 Jan 2014 20:53:35 -0800 |
parents | 3bfc00e4f5e5 |
children | 0ee70ac20a02 |
comparison
equal
deleted
inserted
replaced
239:6aab8a5a2be9 | 240:dc5f487247ee |
---|---|
318 return this; | 318 return this; |
319 } | 319 } |
320 }; | 320 }; |
321 | 321 |
322 symbol.prototype.makeHygienic = function(env) { | 322 symbol.prototype.makeHygienic = function(env) { |
323 if (this.dirty) { | 323 if (this.dirty && this.cleanName() != 'self') { |
324 var hygenic = env.findQuoteTrans(this.cleanName()); | 324 var hygenic = env.findQuoteTrans(this.cleanName()); |
325 if (hygenic) | 325 if (hygenic) |
326 { | 326 { |
327 return new symbol(hygenic, this.symbols); | 327 return new symbol(hygenic, this.symbols); |
328 } else { | 328 } else { |
740 } else { | 740 } else { |
741 env.syms[expr.symbol.cleanName()] = {}; | 741 env.syms[expr.symbol.cleanName()] = {}; |
742 this.expressions[i] = expr.macroexpand(env); | 742 this.expressions[i] = expr.macroexpand(env); |
743 if (this.expressions[i].expression instanceof lambda) { | 743 if (this.expressions[i].expression instanceof lambda) { |
744 env.syms[expr.symbol.cleanName()] = this.expressions[i].expression.eval(env); | 744 env.syms[expr.symbol.cleanName()] = this.expressions[i].expression.eval(env); |
745 } else { | |
746 env.syms[expr.symbol.cleanName()] = null; | |
745 } | 747 } |
746 } | 748 } |
747 } else { | 749 } else { |
748 this.expressions[i] = expr.macroexpand(env); | 750 this.expressions[i] = expr.macroexpand(env); |
749 } | 751 } |
771 var args = []; | 773 var args = []; |
772 var expressions = []; | 774 var expressions = []; |
773 var env = new environment(parentenv); | 775 var env = new environment(parentenv); |
774 for (var i = 0; i < this.args.length; i++) { | 776 for (var i = 0; i < this.args.length; i++) { |
775 env.syms[this.args[i].cleanName()] = null; | 777 env.syms[this.args[i].cleanName()] = null; |
776 if (this.args[i].dirty) { | 778 if (this.args[i].dirty && this.args[i].cleanName() != 'self') { |
777 var hygienic = '' + quote_prefix + this.args[i].cleanName(); | 779 var hygienic = '' + quote_prefix + this.args[i].cleanName(); |
778 env.quotetrans[this.args[i].cleanName()] = hygienic; | 780 env.quotetrans[this.args[i].cleanName()] = hygienic; |
779 args.push(new symbol(hygienic, this.args[i].symbols)); | 781 args.push(new symbol(hygienic, this.args[i].symbols)); |
780 } else { | 782 } else { |
781 args.push(this.args[i]); | 783 args.push(this.args[i]); |