comparison compiler.js @ 57:08ae75d90dc2

Add != operator. Fix more closure bugs.
author Mike Pavone <pavone@retrodev.com>
date Sat, 14 Jul 2012 00:00:24 -0700
parents 93ddb4ad6fcb
children 0fd06e077afe
comparison
equal deleted inserted replaced
56:a9bf3ffb6379 57:08ae75d90dc2
64 function osymbols(parent) 64 function osymbols(parent)
65 { 65 {
66 this.parent = parent; 66 this.parent = parent;
67 this.names = {}; 67 this.names = {};
68 this.needsenv = false; 68 this.needsenv = false;
69 this.typename = null;
69 } 70 }
70 osymbols.prototype.find = function(name, nestedcall) { 71 osymbols.prototype.find = function(name, nestedcall) {
71 debugprint('//osymbols.find', name + ', exists?:', name in this.names, ', nested?:', nestedcall); 72 debugprint('//osymbols.find', name + ', exists?:', name in this.names, ', nested?:', nestedcall);
72 if (name in this.names) { 73 if (name in this.names) {
73 if (this.names[name] instanceof funcall && this.names[name].name == 'foreign:') { 74 if (this.names[name] instanceof funcall && this.names[name].name == 'foreign:') {
77 }; 78 };
78 } 79 }
79 var ret = { 80 var ret = {
80 type: 'self', 81 type: 'self',
81 def: this.names[name], 82 def: this.names[name],
83 selftype: this.typename
82 }; 84 };
83 } else if(this.parent) { 85 } else if(this.parent) {
84 var ret = this.parent.find(name, nestedcall); 86 var ret = this.parent.find(name, nestedcall);
85 if (ret) { 87 if (ret) {
86 if(ret.type == 'self') { 88 if(ret.type == 'self') {
138 this.closedover = {}; 140 this.closedover = {};
139 this.declared = {}; 141 this.declared = {};
140 this.needsSelfVar = false; 142 this.needsSelfVar = false;
141 this.passthruenv = false; 143 this.passthruenv = false;
142 this.envtype = 'void'; 144 this.envtype = 'void';
145 this.needsParentEnv = false;
143 } 146 }
144 lsymbols.prototype.find = function(name, nestedcall) { 147 lsymbols.prototype.find = function(name, nestedcall) {
145 debugprint('//lsymbols.find', name + ', exists?:', name in this.names, ', nested?:', nestedcall); 148 debugprint('//lsymbols.find', name + ', exists?:', name in this.names, ', nested?:', nestedcall);
146 if (name in this.names) { 149 if (name in this.names) {
147 if (this.names[name] instanceof funcall && this.names[name].name == 'foreign:') { 150 if (this.names[name] instanceof funcall && this.names[name].name == 'foreign:') {
175 ret.depth = 0; 178 ret.depth = 0;
176 } 179 }
177 if (ret.type == 'upvar') { 180 if (ret.type == 'upvar') {
178 if (Object.keys(this.closedover).length) { 181 if (Object.keys(this.closedover).length) {
179 ret.depth++; 182 ret.depth++;
183 ret.startdepth = 1;
184 this.needsParentEnv = true;
180 } else { 185 } else {
181 this.passthruenv = true; 186 this.passthruenv = true;
182 if (ret.depth == 0) { 187 ret.startdepth = 0;
188 /*if (ret.depth == 0) {
183 ret.depth = 1; 189 ret.depth = 1;
184 } 190 }*/
185 } 191 }
186 } 192 }
187 } 193 }
188 } else { 194 } else {
189 return null; 195 return null;
190 } 196 }
191 debugprint('\t//symbol type:', ret ? ret.type : 'null'); 197 var type = ret ? ret.type : 'null';
198 debugprint('\t//symbol type:', type , type == 'upvar' ? 'depth: ' + ret.depth : '');
192 return ret; 199 return ret;
193 }; 200 };
194 lsymbols.prototype.defineVar = function(name, def) { 201 lsymbols.prototype.defineVar = function(name, def) {
195 this.names[name] = def; 202 this.names[name] = def;
196 }; 203 };
259 }; 266 };
260 267
261 symbol.prototype.populateSymbols = function(symbols) { 268 symbol.prototype.populateSymbols = function(symbols) {
262 this.symbols = symbols; 269 this.symbols = symbols;
263 var ret = symbols.find(this.cleanName()); 270 var ret = symbols.find(this.cleanName());
264 if (ret.type == 'self') { 271 if (ret && ret.type == 'self') {
265 symbols.find('self'); 272 symbols.find('self');
266 } 273 }
267 } 274 }
268 275
269 intlit.prototype.populateSymbols = function(symbols) { 276 intlit.prototype.populateSymbols = function(symbols) {