comparison interp.js @ 280:23b52d2d05a0

Don't try to replace self in a macro expansion since it's unlikely to be the desired behavior. A more explicit means of specifying what variables should be replaced in a quote expression is needed.
author Michael Pavone <pavone@retrodev.com>
date Mon, 21 Jul 2014 19:30:23 -0700
parents 0dc7322590da
children f6dfb85e80e5
comparison
equal deleted inserted replaced
279:eb83863fd33e 280:23b52d2d05a0
304 } 304 }
305 return res; 305 return res;
306 }; 306 };
307 307
308 symbol.prototype.quote = function(env) { 308 symbol.prototype.quote = function(env) {
309 var val = env.find(this.name); 309 if (this.cleanName() != 'self') {
310 if (val !== null) { 310 var val = env.find(this.name);
311 var newnode = makeASTNode(val); 311 if (val !== null) {
312 if (!newnode) { 312 var newnode = makeASTNode(val);
313 throw new Error(this.name + ' contains a value ' + val + ' that could not be converted to an AST node'); 313 if (!newnode) {
314 } 314 throw new Error(this.name + ' contains a value ' + val + ' that could not be converted to an AST node');
315 return newnode; 315 }
316 } else { 316 return newnode;
317 this.dirty = true; 317 } else {
318 return this; 318 this.dirty = true;
319 return this;
320 }
319 } 321 }
320 }; 322 };
321 323
322 symbol.prototype.makeHygienic = function(env) { 324 symbol.prototype.makeHygienic = function(env) {
323 if (this.dirty && this.cleanName() != 'self') { 325 if (this.dirty && this.cleanName() != 'self') {
345 return this; 347 return this;
346 }; 348 };
347 349
348 intlit.prototype.isconstant = 350 intlit.prototype.isconstant =
349 floatlit.prototype.isconstant = 351 floatlit.prototype.isconstant =
350 strlit.prototype.isconstant = 352 strlit.prototype.isconstant =
351 lambda.prototype.isconstant = function() { 353 lambda.prototype.isconstant = function() {
352 return true; 354 return true;
353 }; 355 };
354 356
355 object.prototype.isconstant = 357 object.prototype.isconstant =
356 symbol.prototype.isconstant = 358 symbol.prototype.isconstant =
357 funcall.prototype.isconstant = 359 funcall.prototype.isconstant =
358 op.prototype.isconstant = 360 op.prototype.isconstant =
359 assignment.prototype.isconstant = function() { 361 assignment.prototype.isconstant = function() {
360 return false; 362 return false;
361 } 363 }
362 364
363 arraylit.prototype.isconstant = 365 arraylit.prototype.isconstant =