Mercurial > repos > tabletprog
changeset 156:d6e79885bd3b
Fix compiler bug involving referencing a self method in a method defined before the referenced method
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 10 Aug 2013 14:50:38 -0700 |
parents | 9de2572a34a7 |
children | 55e0dca7d3d7 |
files | cbackend.js compiler.js |
diffstat | 2 files changed, 21 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/cbackend.js Sat Aug 10 14:19:38 2013 -0700 +++ b/cbackend.js Sat Aug 10 14:50:38 2013 -0700 @@ -982,7 +982,7 @@ for (var key in this.symbols.closedover) { print(key, ": ", this.symbols.closedover[key]); } - throw new Error('this.symbols.closedover is not empty, but it was when compilation of "' + assignPaths + '" started'); + throw new Error('this.symbols.closedover is not empty, but it was when compilation of ' + this.name + ' "' + assignPath + '" started'); } forwarddec += 'struct ' + this.name + '_env {\n'; if (this.symbols.needsParentEnv) { @@ -1093,11 +1093,13 @@ }; assignment.prototype.toCObject = function(cobj) { debugprint('//message definition', this.symbol.name); + assignNames.push('#' + this.symbol.name); if (this.expression.toCObject) { var val = this.expression.toCObject(cobj.name); } else { var val = this.expression.toC(); } + assignNames.pop(); if (val === null) { return; }
--- a/compiler.js Sat Aug 10 14:19:38 2013 -0700 +++ b/compiler.js Sat Aug 10 14:50:38 2013 -0700 @@ -230,9 +230,12 @@ }; } else { if (nestedcall) { - this.closedover[name] = true; - this.passthruenv = false; - } + if (!(name in this.closedover)) { + debugprint('//' + name + ' is now closed over'); + this.closedover[name] = true; + this.passthruenv = false; + } + } if (name in this.closedover) { var ret = { type: 'closedover', @@ -414,13 +417,19 @@ } } +funcall.prototype.predefSymbolsObject = function(symbols) { +}; + funcall.prototype.populateSymbolsObject = function(symbols) { this.populateSymbols(symbols); -} +}; object.prototype.populateSymbols = function(symbols) { var symbols = new osymbols(symbols); for (var i in this.messages) { + this.messages[i].predefSymbolsObject(symbols); + } + for (var i in this.messages) { this.messages[i].populateSymbolsObject(symbols); } this.symbols = symbols; @@ -456,14 +465,17 @@ this.expression.populateSymbols(symbols); this.symbols = symbols; }; -assignment.prototype.populateSymbolsObject = function(symbols) { - debugprint('//messagedef', this.symbol.name, 'populateSymbols'); +assignment.prototype.predefSymbolsObject = function(symbols) { + debugprint('//messagedef', this.symbol.name, 'predefSymbolsObject'); if (this.expression instanceof lambda || (this.expression instanceof funcall & this.expression.name == 'foreign:')) { symbols.defineMsg(this.symbol.name, this.expression); } else { symbols.defineMsg(this.symbol.name, new getter(null)); symbols.defineMsg(this.symbol.name + '!', new setter(null)); } +}; +assignment.prototype.populateSymbolsObject = function(symbols) { + debugprint('//messagedef', this.symbol.name, 'populateSymbols'); this.symbol.populateSymbols(symbols); this.expression.populateSymbols(symbols, true); this.symbols = symbols;