Mercurial > repos > tabletprog
comparison compiler.js @ 35:bf5e88f6419d
Use a function/method call strategy that actually works
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 09 Jul 2012 21:32:28 -0700 |
parents | a10f1b049193 |
children | 3b0503a67165 |
comparison
equal
deleted
inserted
replaced
34:a10f1b049193 | 35:bf5e88f6419d |
---|---|
7 function topsymbols() | 7 function topsymbols() |
8 { | 8 { |
9 this.names = null; | 9 this.names = null; |
10 var self = this; | 10 var self = this; |
11 get('/src/', function(data) { | 11 get('/src/', function(data) { |
12 console.log(data); | |
13 self.names = {}; | 12 self.names = {}; |
14 var fakeEl = newEl("div", { | 13 var fakeEl = newEl("div", { |
15 innerHTML: data.response | 14 innerHTML: data.response |
16 }); | 15 }); |
17 console.log(fakeEl); | |
18 each(qall('a', fakeEl), function(idx, a) { | 16 each(qall('a', fakeEl), function(idx, a) { |
19 var tpidx = a.textContent.indexOf('.tp'); | 17 var tpidx = a.textContent.indexOf('.tp'); |
20 if (tpidx > -1) { | 18 if (tpidx > -1) { |
21 self.names[a.textContent.substr(0, tpidx)] = true; | 19 self.names[a.textContent.substr(0, tpidx)] = true; |
22 } | 20 } |
23 }); | 21 }); |
24 }); | 22 }); |
25 } | 23 } |
26 topsymbols.prototype.find = function(name) { | 24 topsymbols.prototype.find = function(name) { |
27 console.log(this.names); | |
28 if (!this.names) { | 25 if (!this.names) { |
29 throw new Error('data not ready'); | 26 throw new Error('data not ready'); |
30 } | 27 } |
31 console.log('toplevel', name); | |
32 if (name in this.names) { | 28 if (name in this.names) { |
33 return { | 29 return { |
34 type: 'toplevel', | 30 type: 'toplevel', |
35 def: null | 31 def: null |
36 }; | 32 }; |
97 return this.parent.allSymbols(curlist, cursyms); | 93 return this.parent.allSymbols(curlist, cursyms); |
98 } | 94 } |
99 return curlist; | 95 return curlist; |
100 } | 96 } |
101 osymbols.prototype.getEnvType = function() { | 97 osymbols.prototype.getEnvType = function() { |
102 console.log('osymbol parent', this.parent); | |
103 return this.parent.getEnvType(); | 98 return this.parent.getEnvType(); |
104 } | 99 } |
105 | 100 |
106 function lsymbols(parent) | 101 function lsymbols(parent) |
107 { | 102 { |
111 this.needsSelfVar = false; | 106 this.needsSelfVar = false; |
112 this.passthruenv = false; | 107 this.passthruenv = false; |
113 this.envtype = 'void'; | 108 this.envtype = 'void'; |
114 } | 109 } |
115 lsymbols.prototype.find = function(name, nestedcall) { | 110 lsymbols.prototype.find = function(name, nestedcall) { |
116 console.log('find', name, nestedcall); | |
117 if (name in this.names) { | 111 if (name in this.names) { |
118 if (this.names[name] instanceof funcall && this.names[name].name == 'foreign:') { | 112 if (this.names[name] instanceof funcall && this.names[name].name == 'foreign:') { |
119 return { | 113 return { |
120 type: 'foreign', | 114 type: 'foreign', |
121 def: this.names[name] | 115 def: this.names[name] |
122 }; | 116 }; |
123 } | 117 } |
124 if (nestedcall) { | 118 if (nestedcall) { |
125 console.log('closedover', name); | |
126 this.closedover[name] = true; | 119 this.closedover[name] = true; |
127 } | 120 } |
128 if (name in this.closedover) { | 121 if (name in this.closedover) { |
129 return { | 122 return { |
130 type: 'closedover', | 123 type: 'closedover', |
178 } | 171 } |
179 return this.parent.getEnvType(); | 172 return this.parent.getEnvType(); |
180 }; | 173 }; |
181 lsymbols.prototype.getEnvType = function() { | 174 lsymbols.prototype.getEnvType = function() { |
182 if (this.passthruenv) { | 175 if (this.passthruenv) { |
183 console.log('lsymbol parent', this.parent); | |
184 return this.parent.getEnvType(); | 176 return this.parent.getEnvType(); |
185 } else { | 177 } else { |
186 return this.envtype; | 178 return this.envtype; |
187 } | 179 } |
188 } | 180 } |