| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class ClosureFieldElement extends Element { | 5 class ClosureFieldElement extends Element { |
| 6 ClosureFieldElement(SourceString name, ClassElement enclosing) | 6 ClosureFieldElement(SourceString name, ClassElement enclosing) |
| 7 : super(name, ElementKind.FIELD, enclosing); | 7 : super(name, ElementKind.FIELD, enclosing); |
| 8 | 8 |
| 9 bool isInstanceMember() => true; | 9 bool isInstanceMember() => true; |
| 10 bool isAssignable() => false; | 10 bool isAssignable() => false; |
| 11 | 11 |
| 12 String toString() => "ClosureFieldElement($name)"; | 12 String toString() => "ClosureFieldElement($name)"; |
| 13 Token position() => enclosingElement.position(); |
| 13 } | 14 } |
| 14 | 15 |
| 15 class ClosureClassElement extends ClassElement { | 16 class ClosureClassElement extends ClassElement { |
| 16 ClosureClassElement(Compiler compiler, Element enclosingElement) | 17 Token originalPosition; |
| 18 |
| 19 ClosureClassElement(Compiler compiler, Element enclosingElement, |
| 20 this.originalPosition) |
| 17 : super(compiler.closureClass.name, enclosingElement) { | 21 : super(compiler.closureClass.name, enclosingElement) { |
| 18 isResolved = true; | 22 isResolved = true; |
| 19 compiler.closureClass.ensureResolved(compiler); | 23 compiler.closureClass.ensureResolved(compiler); |
| 20 supertype = compiler.closureClass.computeType(compiler); | 24 supertype = compiler.closureClass.computeType(compiler); |
| 21 } | 25 } |
| 26 |
| 27 Token position() => originalPosition; |
| 22 } | 28 } |
| 23 | 29 |
| 24 class BoxElement extends Element { | 30 class BoxElement extends Element { |
| 25 BoxElement(SourceString name, Element enclosingElement) | 31 BoxElement(SourceString name, Element enclosingElement) |
| 26 : super(name, ElementKind.VARIABLE, enclosingElement); | 32 : super(name, ElementKind.VARIABLE, enclosingElement); |
| 27 } | 33 } |
| 28 | 34 |
| 29 class ThisElement extends Element { | 35 class ThisElement extends Element { |
| 30 ThisElement(Element enclosing) | 36 ThisElement(Element enclosing) |
| 31 : super(const SourceString('this'), ElementKind.PARAMETER, enclosing); | 37 : super(const SourceString('this'), ElementKind.PARAMETER, enclosing); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (capturedVariableMapping.containsKey(element)) { | 317 if (capturedVariableMapping.containsKey(element)) { |
| 312 result.add(element); | 318 result.add(element); |
| 313 }; | 319 }; |
| 314 } | 320 } |
| 315 scopeData.boxedLoopVariables = result; | 321 scopeData.boxedLoopVariables = result; |
| 316 } | 322 } |
| 317 | 323 |
| 318 ClosureData globalizeClosure(FunctionExpression node) { | 324 ClosureData globalizeClosure(FunctionExpression node) { |
| 319 FunctionElement element = elements[node]; | 325 FunctionElement element = elements[node]; |
| 320 ClassElement globalizedElement = | 326 ClassElement globalizedElement = |
| 321 new ClosureClassElement(compiler, element.getCompilationUnit()); | 327 new ClosureClassElement(compiler, |
| 328 element.getCompilationUnit(), |
| 329 element.position()); |
| 322 FunctionElement callElement = | 330 FunctionElement callElement = |
| 323 new FunctionElement.from(Namer.CLOSURE_INVOCATION_NAME, | 331 new FunctionElement.from(Namer.CLOSURE_INVOCATION_NAME, |
| 324 element, | 332 element, |
| 325 globalizedElement); | 333 globalizedElement); |
| 326 globalizedElement.backendMembers = | 334 globalizedElement.backendMembers = |
| 327 const EmptyLink<Element>().prepend(callElement); | 335 const EmptyLink<Element>().prepend(callElement); |
| 328 // The nested function's 'this' is the same as the one for the outer | 336 // The nested function's 'this' is the same as the one for the outer |
| 329 // function. It could be [null] if we are inside a static method. | 337 // function. It could be [null] if we are inside a static method. |
| 330 Element thisElement = closureData.thisElement; | 338 Element thisElement = closureData.thisElement; |
| 331 return new ClosureData(element, globalizedElement, | 339 return new ClosureData(element, globalizedElement, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 declareLocal(elements[node]); | 432 declareLocal(elements[node]); |
| 425 } | 433 } |
| 426 | 434 |
| 427 visitTryStatement(TryStatement node) { | 435 visitTryStatement(TryStatement node) { |
| 428 // TODO(ngeoffray): implement finer grain state. | 436 // TODO(ngeoffray): implement finer grain state. |
| 429 inTryCatchOrFinally = true; | 437 inTryCatchOrFinally = true; |
| 430 node.visitChildren(this); | 438 node.visitChildren(this); |
| 431 inTryCatchOrFinally = false; | 439 inTryCatchOrFinally = false; |
| 432 } | 440 } |
| 433 } | 441 } |
| OLD | NEW |