| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.backend.js; | 5 package com.google.dart.compiler.backend.js; |
| 6 | 6 |
| 7 import com.google.common.collect.Lists; | 7 import com.google.common.collect.Lists; |
| 8 import com.google.dart.compiler.DartCompilationError; | 8 import com.google.dart.compiler.DartCompilationError; |
| 9 import com.google.dart.compiler.DartCompilerContext; | 9 import com.google.dart.compiler.DartCompilerContext; |
| 10 import com.google.dart.compiler.DartCompilerErrorCode; | 10 import com.google.dart.compiler.DartCompilerErrorCode; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 if (optStrategy.canEmitOptimizedClassConstructor(classElement)) { | 414 if (optStrategy.canEmitOptimizedClassConstructor(classElement)) { |
| 415 createInlinedClassConstructor(x); | 415 createInlinedClassConstructor(x); |
| 416 } else { | 416 } else { |
| 417 JsFunction jsClass = new JsFunction(globalScope, classJsName).setSourc
eRef(x); | 417 JsFunction jsClass = new JsFunction(globalScope, classJsName).setSourc
eRef(x); |
| 418 jsClass.setIsConstructor(true); | 418 jsClass.setIsConstructor(true); |
| 419 jsClass.setBody(new JsBlock()); | 419 jsClass.setBody(new JsBlock()); |
| 420 globalBlock.getStatements().add(jsClass.makeStmt()); | 420 globalBlock.getStatements().add(jsClass.makeStmt()); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 | 423 |
| 424 maybeInjectIsolateMethods(classElement); | |
| 425 | |
| 426 if (classElement.isInterface()) { | 424 if (classElement.isInterface()) { |
| 427 rtt.generateRuntimeTypeInfo(x); | 425 rtt.generateRuntimeTypeInfo(x); |
| 428 | 426 |
| 429 // Emit only static final fields for interfaces. | 427 // Emit only static final fields for interfaces. |
| 430 for (Element member : classElement.getMembers()) { | 428 for (Element member : classElement.getMembers()) { |
| 431 if (ElementKind.of(member).equals(ElementKind.FIELD)) { | 429 if (ElementKind.of(member).equals(ElementKind.FIELD)) { |
| 432 Modifiers modifiers = member.getModifiers(); | 430 Modifiers modifiers = member.getModifiers(); |
| 433 if (modifiers.isStatic() && !modifiers.isAbstractField()) { | 431 if (modifiers.isStatic() && !modifiers.isAbstractField()) { |
| 434 assert modifiers.isFinal(); | 432 assert modifiers.isFinal(); |
| 435 generateField((FieldElement) member); | 433 generateField((FieldElement) member); |
| 436 } | 434 } |
| 437 } | 435 } |
| 438 } | 436 } |
| 439 } else { | 437 } else { |
| 440 // Inherits. | 438 // Inherits. |
| 441 if (x.getSuperSymbol() != null) { | 439 if (x.getSuperSymbol() != null) { |
| 442 JsNameRef superRef = getJsName(x.getSuperSymbol()).makeRef(); | 440 JsNameRef superRef = getJsName(x.getSuperSymbol()).makeRef(); |
| 443 JsInvocation inherits = AstUtil.newInvocation( | 441 JsInvocation inherits = AstUtil.newInvocation( |
| 444 new JsNameRef("$inherits"), | 442 new JsNameRef("$inherits"), |
| 445 classJsName.makeRef(), | 443 classJsName.makeRef(), |
| 446 superRef); | 444 superRef); |
| 447 inherits.setSourceRef(x); | 445 inherits.setSourceRef(x); |
| 448 globalBlock.getStatements().add(inherits.makeStmt()); | 446 globalBlock.getStatements().add(inherits.makeStmt()); |
| 449 } | 447 } |
| 450 | 448 |
| 449 maybeInjectIsolateMethods(classElement); |
| 451 rtt.generateRuntimeTypeInfo(x); | 450 rtt.generateRuntimeTypeInfo(x); |
| 452 | 451 |
| 453 List<Element> classMembers = new ArrayList<Element>(); | 452 List<Element> classMembers = new ArrayList<Element>(); |
| 454 classMembers.addAll(classElement.getConstructors()); | 453 classMembers.addAll(classElement.getConstructors()); |
| 455 for (Element element : classElement.getMembers()) { | 454 for (Element element : classElement.getMembers()) { |
| 456 classMembers.add(element); | 455 classMembers.add(element); |
| 457 } | 456 } |
| 458 | 457 |
| 459 if (Elements.needsImplicitDefaultConstructor(classElement)) { | 458 if (Elements.needsImplicitDefaultConstructor(classElement)) { |
| 460 addImplicitDefaultConstructor(x, classElement, classMembers); | 459 addImplicitDefaultConstructor(x, classElement, classMembers); |
| (...skipping 3317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3778 JsBlock blockStatics) { | 3777 JsBlock blockStatics) { |
| 3779 GenerateJavascriptVisitor generator = | 3778 GenerateJavascriptVisitor generator = |
| 3780 new GenerateJavascriptVisitor(unit, context, translationContext, | 3779 new GenerateJavascriptVisitor(unit, context, translationContext, |
| 3781 optStrategy, typeProvider, generateClosureCompatibleCode); | 3780 optStrategy, typeProvider, generateClosureCompatibleCode); |
| 3782 // Generate the Javascript AST. | 3781 // Generate the Javascript AST. |
| 3783 node.accept(generator); | 3782 node.accept(generator); |
| 3784 // Set aside the static initializations | 3783 // Set aside the static initializations |
| 3785 generator.addStaticInitsToBlock(blockStatics); | 3784 generator.addStaticInitsToBlock(blockStatics); |
| 3786 } | 3785 } |
| 3787 } | 3786 } |
| OLD | NEW |