Mercurial > repos > tabletprog
comparison compiler.js @ 55:93ddb4ad6fcb
Fix some nested closure bugs
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 13 Jul 2012 21:05:52 -0700 |
parents | 976a0924e1d4 |
children | 08ae75d90dc2 |
comparison
equal
deleted
inserted
replaced
54:976a0924e1d4 | 55:93ddb4ad6fcb |
---|---|
150 def: this.names[name] | 150 def: this.names[name] |
151 }; | 151 }; |
152 } else { | 152 } else { |
153 if (nestedcall) { | 153 if (nestedcall) { |
154 this.closedover[name] = true; | 154 this.closedover[name] = true; |
155 this.passthruenv = false; | |
155 } | 156 } |
156 if (name in this.closedover) { | 157 if (name in this.closedover) { |
157 var ret = { | 158 var ret = { |
158 type: 'closedover', | 159 type: 'closedover', |
159 def: this.names[name] | 160 def: this.names[name] |
169 } else if(this.parent) { | 170 } else if(this.parent) { |
170 var ret = this.parent.find(name, true); | 171 var ret = this.parent.find(name, true); |
171 if (ret) { | 172 if (ret) { |
172 if (ret.type == 'closedover') { | 173 if (ret.type == 'closedover') { |
173 ret.type = 'upvar'; | 174 ret.type = 'upvar'; |
174 ret.depth = 1; | 175 ret.depth = 0; |
175 } else if (ret.type == 'upvar') { | 176 } |
176 if (Object(this.closedover).keys.length) { | 177 if (ret.type == 'upvar') { |
178 if (Object.keys(this.closedover).length) { | |
177 ret.depth++; | 179 ret.depth++; |
178 } else { | 180 } else { |
179 this.passthruenv = true; | 181 this.passthruenv = true; |
182 if (ret.depth == 0) { | |
183 ret.depth = 1; | |
184 } | |
180 } | 185 } |
181 } | 186 } |
182 } | 187 } |
183 } else { | 188 } else { |
184 return null; | 189 return null; |