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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
8 | 8 |
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 ClassElement defaultSuperclass(ClassElement element) { | 1494 ClassElement defaultSuperclass(ClassElement element) { |
1495 // Native classes inherit from Interceptor. | 1495 // Native classes inherit from Interceptor. |
1496 return element.isNative ? jsInterceptorClass : compiler.objectClass; | 1496 return element.isNative ? jsInterceptorClass : compiler.objectClass; |
1497 } | 1497 } |
1498 | 1498 |
1499 /** | 1499 /** |
1500 * Unit test hook that returns code of an element as a String. | 1500 * Unit test hook that returns code of an element as a String. |
1501 * | 1501 * |
1502 * Invariant: [element] must be a declaration element. | 1502 * Invariant: [element] must be a declaration element. |
1503 */ | 1503 */ |
1504 String assembleCode(Element element) { | 1504 String getGeneratedCode(Element element) { |
1505 assert(invariant(element, element.isDeclaration)); | 1505 assert(invariant(element, element.isDeclaration)); |
1506 var code = generatedCode[element]; | |
1507 if (namer is jsAst.TokenFinalizer) { | |
1508 jsAst.TokenCounter counter = new jsAst.TokenCounter(); | |
1509 counter.countTokens(code); | |
1510 // Avoid a warning. | |
1511 var finalizer = namer; | |
1512 finalizer.finalizeTokens(); | |
1513 } | |
1514 return jsAst.prettyPrint(generatedCode[element], compiler).getText(); | 1506 return jsAst.prettyPrint(generatedCode[element], compiler).getText(); |
1515 } | 1507 } |
1516 | 1508 |
1517 int assembleProgram() { | 1509 int assembleProgram() { |
1518 int programSize = emitter.assembleProgram(); | 1510 int programSize = emitter.assembleProgram(); |
1519 noSuchMethodRegistry.emitDiagnostic(); | 1511 noSuchMethodRegistry.emitDiagnostic(); |
1520 int totalMethodCount = generatedCode.length; | 1512 int totalMethodCount = generatedCode.length; |
1521 if (totalMethodCount != preMirrorsMethodCount) { | 1513 if (totalMethodCount != preMirrorsMethodCount) { |
1522 int mirrorCount = totalMethodCount - preMirrorsMethodCount; | 1514 int mirrorCount = totalMethodCount - preMirrorsMethodCount; |
1523 double percentage = (mirrorCount / totalMethodCount) * 100; | 1515 double percentage = (mirrorCount / totalMethodCount) * 100; |
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3134 } | 3126 } |
3135 } | 3127 } |
3136 | 3128 |
3137 /// Records that [constant] is used by the element behind [registry]. | 3129 /// Records that [constant] is used by the element behind [registry]. |
3138 class Dependency { | 3130 class Dependency { |
3139 final ConstantValue constant; | 3131 final ConstantValue constant; |
3140 final Element annotatedElement; | 3132 final Element annotatedElement; |
3141 | 3133 |
3142 const Dependency(this.constant, this.annotatedElement); | 3134 const Dependency(this.constant, this.annotatedElement); |
3143 } | 3135 } |
OLD | NEW |