Mercurial > repos > tabletprog
comparison compiler.js @ 20:bf03c9f0dd55
Initial work on proper property support
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 25 Mar 2012 16:52:11 -0700 |
parents | 59e83296e331 |
children | 068d63627b16 |
comparison
equal
deleted
inserted
replaced
19:132c7756860e | 20:bf03c9f0dd55 |
---|---|
140 | 140 |
141 strlit.prototype.populateSymbols = function(symbols) { | 141 strlit.prototype.populateSymbols = function(symbols) { |
142 } | 142 } |
143 | 143 |
144 funcall.prototype.populateSymbols = function(symbols) { | 144 funcall.prototype.populateSymbols = function(symbols) { |
145 if(this.name == 'q:') { console.log('populateSymbols', this); } | |
145 if (this.name == 'foreign:') { | 146 if (this.name == 'foreign:') { |
146 if ((this.args[0] instanceof lambda) || (this.args[0] instanceof object) || (this.args[0] instanceof symbol)) { | 147 if ((this.args[0] instanceof lambda) || (this.args[0] instanceof object) || (this.args[0] instanceof symbol)) { |
147 return; | 148 return; |
148 } else { | 149 } else { |
149 throw new Error("Unexpected AST type for foreign:"); | 150 throw new Error("Unexpected AST type for foreign:"); |
150 } | 151 } |
151 } | 152 } |
153 this.symbols = symbols; | |
152 for (var i in this.args) { | 154 for (var i in this.args) { |
153 this.args[i].populateSymbols(symbols); | 155 this.args[i].populateSymbols(symbols); |
156 } | |
157 if (this.receiver) { | |
158 this.receiver.populateSymbols(symbols); | |
154 } | 159 } |
155 } | 160 } |
156 | 161 |
157 object.prototype.populateSymbols = function(symbols) { | 162 object.prototype.populateSymbols = function(symbols) { |
158 symbols = new osymbols(symbols); | 163 symbols = new osymbols(symbols); |
184 if (!existing) { | 189 if (!existing) { |
185 symbols.defineVar(this.symbol.name, this.expression); | 190 symbols.defineVar(this.symbol.name, this.expression); |
186 } | 191 } |
187 this.symbol.populateSymbols(symbols); | 192 this.symbol.populateSymbols(symbols); |
188 this.expression.populateSymbols(symbols); | 193 this.expression.populateSymbols(symbols); |
194 this.symbols = symbols; | |
189 }; | 195 }; |
190 assignment.prototype.populateSymbolsObject = function(symbols) { | 196 assignment.prototype.populateSymbolsObject = function(symbols) { |
197 console.log('populateSymbolsObject for assignment to ' + this.symbol.name) | |
191 symbols.defineMsg(this.symbol.name, this.expression); | 198 symbols.defineMsg(this.symbol.name, this.expression); |
199 if (!(this.expression instanceof lambda)) { | |
200 symbols.defineMsg(this.symbol.name + '!', new setter(null)); | |
201 } | |
192 this.symbol.populateSymbols(symbols); | 202 this.symbol.populateSymbols(symbols); |
193 this.expression.populateSymbols(symbols); | 203 this.expression.populateSymbols(symbols); |
194 }; | 204 this.symbols = symbols; |
195 | 205 }; |
206 | |
207 function setter(fun) | |
208 { | |
209 this.fun = fun; | |
210 } | |
211 | |
212 function getter(fun) | |
213 { | |
214 this.fun = fun; | |
215 } | |
216 |