Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library rasta.kernel; | 5 library rasta.kernel; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:collection' show | 10 import 'dart:collection' show |
| 11 Queue; | 11 Queue; |
| 12 | 12 |
| 13 import 'package:kernel/ast.dart' as ir; | 13 import 'package:kernel/ast.dart' as ir; |
| 14 | 14 |
| 15 import 'package:kernel/checks.dart' show | 15 import 'package:kernel/checks.dart' show |
| 16 CheckParentPointers; | 16 CheckParentPointers; |
| 17 | 17 |
| 18 import 'package:kernel/frontend/super_calls.dart' show | 18 import 'package:kernel/frontend/super_calls.dart' show |
| 19 moveSuperCallLast; | 19 moveSuperCallLast; |
| 20 | 20 |
| 21 import 'package:compiler/src/elements/elements.dart' show | 21 import 'package:compiler/src/elements/elements.dart' show |
| 22 ClassElement, | 22 ClassElement, |
| 23 ConstructorElement, | 23 ConstructorElement, |
| 24 Element, | 24 Element, |
| 25 ExportElement, | 25 ExportElement, |
| 26 FieldElement, | 26 FieldElement, |
| 27 FunctionElement, | 27 FunctionElement, |
| 28 ImportElement, | 28 ImportElement, |
| 29 LibraryElement, | 29 LibraryElement, |
| 30 Name, | 30 MixinApplicationElement, |
| 31 TypeVariableElement; | 31 TypeVariableElement; |
| 32 | 32 |
| 33 import 'package:compiler/src/elements/modelx.dart' show | 33 import 'package:compiler/src/elements/modelx.dart' show |
| 34 ErroneousFieldElementX; | 34 ErroneousFieldElementX; |
| 35 | 35 |
| 36 import 'package:compiler/src/dart_types.dart' show | 36 import 'package:compiler/src/dart_types.dart' show |
| 37 DartType, | 37 DartType, |
| 38 FunctionType, | 38 FunctionType, |
| 39 InterfaceType, | 39 InterfaceType, |
| 40 TypeKind, | 40 TypeKind, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 assert(() { | 129 assert(() { |
| 130 libraries.forEach(checkLibrary); | 130 libraries.forEach(checkLibrary); |
| 131 classes.forEach(checkMember); | 131 classes.forEach(checkMember); |
| 132 functions.forEach(checkMember); | 132 functions.forEach(checkMember); |
| 133 fields.forEach(checkMember); | 133 fields.forEach(checkMember); |
| 134 return true; | 134 return true; |
| 135 }); | 135 }); |
| 136 } | 136 } |
| 137 | 137 |
| 138 ir.Name irName(String name, Element element) { | 138 ir.Name irName(String name, Element element) { |
| 139 return new ir.Name(name, libraryToIr(element.library)); | 139 ir.Library irLibrary = null; |
| 140 } | 140 if (name.startsWith("_")) { |
| 141 | 141 ClassElement cls = element.enclosingClass; |
| 142 ir.Name nameToIrName(Name name) { | 142 if (cls != null && cls.isMixinApplication) { |
| 143 ir.Library library; | 143 MixinApplicationElement mixinApplication = cls; |
| 144 if (name.isPrivate) { | 144 element = mixinApplication.mixin; |
| 145 library = libraryToIr(name.library); | 145 } |
| 146 name = "$name@${element.library.libraryOrScriptName}"; | |
|
kustermann
2016/08/01 10:37:39
I landed a modified version of this patch on origi
ahe
2016/08/01 10:44:41
What kind of issues? In the Dart VM?
kustermann
2016/08/01 11:23:39
I don't recall the details, since it's almost 4 we
kasperl
2016/08/02 06:17:44
I think the VM may have special treatment of symbo
ahe
2016/08/02 11:09:10
This seems to work:
"${element.library.libraryOrS
| |
| 147 irLibrary = libraryToIr(element.library); | |
| 146 } | 148 } |
| 147 return new ir.Name(name.text, library); | 149 return new ir.Name(name, irLibrary); |
| 148 } | 150 } |
| 149 | 151 |
| 150 Future<ir.Library> loadLibrary(Uri uri) async { | 152 Future<ir.Library> loadLibrary(Uri uri) async { |
| 151 return libraryToIr(await compiler.libraryLoader.loadLibrary(uri)); | 153 return libraryToIr(await compiler.libraryLoader.loadLibrary(uri)); |
| 152 } | 154 } |
| 153 | 155 |
| 154 ir.Library libraryToIr(LibraryElement library) { | 156 ir.Library libraryToIr(LibraryElement library) { |
| 155 library = library.declaration; | 157 library = library.declaration; |
| 156 return libraries.putIfAbsent(library, () { | 158 return libraries.putIfAbsent(library, () { |
| 157 String name = library.hasLibraryName ? library.libraryName : null; | 159 String name = library.hasLibraryName ? library.libraryName : null; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 } | 431 } |
| 430 field = field.declaration; | 432 field = field.declaration; |
| 431 return fields.putIfAbsent(field, () { | 433 return fields.putIfAbsent(field, () { |
| 432 compiler.analyzeElement(field); | 434 compiler.analyzeElement(field); |
| 433 compiler.enqueuer.resolution.emptyDeferredTaskQueue(); | 435 compiler.enqueuer.resolution.emptyDeferredTaskQueue(); |
| 434 field = field.implementation; | 436 field = field.implementation; |
| 435 ir.DartType type = field.isMalformed | 437 ir.DartType type = field.isMalformed |
| 436 ? const ir.InvalidType() | 438 ? const ir.InvalidType() |
| 437 : typeToIr(field.type); | 439 : typeToIr(field.type); |
| 438 ir.Field fieldNode = new ir.Field( | 440 ir.Field fieldNode = new ir.Field( |
| 439 nameToIrName(field.memberName), type: type, initializer: null, | 441 irName(field.memberName.text, field), type: type, initializer: null, |
| 440 isFinal: field.isFinal, isStatic: field.isStatic || field.isTopLevel, | 442 isFinal: field.isFinal, isStatic: field.isStatic || field.isTopLevel, |
| 441 isConst: field.isConst); | 443 isConst: field.isConst); |
| 442 addWork(field, () { | 444 addWork(field, () { |
| 443 setParent(fieldNode, field); | 445 setParent(fieldNode, field); |
| 444 if (!field.isMalformed && !field.isInstanceMember && | 446 if (!field.isMalformed && !field.isInstanceMember && |
| 445 field.initializer != null) { | 447 field.initializer != null) { |
| 446 KernelVisitor visitor = | 448 KernelVisitor visitor = |
| 447 new KernelVisitor(field, field.treeElements, this); | 449 new KernelVisitor(field, field.treeElements, this); |
| 448 fieldNode.initializer = visitor.buildInitializer() | 450 fieldNode.initializer = visitor.buildInitializer() |
| 449 ..parent = fieldNode; | 451 ..parent = fieldNode; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 } | 665 } |
| 664 | 666 |
| 665 class ConstructorTarget { | 667 class ConstructorTarget { |
| 666 final ConstructorElement element; | 668 final ConstructorElement element; |
| 667 final DartType type; | 669 final DartType type; |
| 668 | 670 |
| 669 ConstructorTarget(this.element, this.type); | 671 ConstructorTarget(this.element, this.type); |
| 670 | 672 |
| 671 String toString() => "ConstructorTarget($element, $type)"; | 673 String toString() => "ConstructorTarget($element, $type)"; |
| 672 } | 674 } |
| OLD | NEW |