Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 14079003: Implement Symbol correctly in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
index 93fd69cce8f4b4cf7a0478ec2b4480eb127528be..9477e6902c54c592bbdaa65dd73d42ab5ec98578 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -306,6 +306,23 @@ abstract class Compiler implements DiagnosticListener {
ClassElement listClass;
ClassElement typeClass;
ClassElement mapClass;
+ ClassElement symbolClass;
+
+ // Initialized after mirrorSystemClass has been resolved.
+ FunctionElement symbolConstructor;
+
+ // Initialized when dart:mirrors is loaded.
+ ClassElement mirrorSystemClass;
+
+ // Initialized after mirrorSystemClass has been resolved.
+ FunctionElement mirrorSystemGetNameFunction;
+
+ // Initialized when dart:_collection-dev is loaded.
+ ClassElement symbolImplementationClass;
+
+ // Initialized when symbolImplementationClass has been resolved.
+ FunctionElement symbolValidatedConstructor;
+
ClassElement jsInvocationMirrorClass;
/// Document class from dart:mirrors.
ClassElement documentClass;
@@ -385,6 +402,8 @@ abstract class Compiler implements DiagnosticListener {
new Selector.call(const SourceString('moveNext'), null, 0);
final Selector noSuchMethodSelector = new Selector.call(
Compiler.NO_SUCH_METHOD, null, Compiler.NO_SUCH_METHOD_ARG_COUNT);
+ final Selector symbolValidatedConstructorSelector = new Selector.call(
+ const SourceString('validated'), null, 1);
bool enabledNoSuchMethod = false;
bool enabledRuntimeType = false;
@@ -616,6 +635,23 @@ abstract class Compiler implements DiagnosticListener {
library.addToScope(dynamicClass, this);
});
}
+ if (uri == Uri.parse('dart:mirrors')) {
+ mirrorSystemClass = library.find(const SourceString('MirrorSystem'));
+ } else if (uri == Uri.parse('dart:_collection-dev')) {
+ symbolImplementationClass = library.find(const SourceString('Symbol'));
+ }
+ }
+
+ void onClassResolved(ClassElement cls) {
+ if (mirrorSystemClass == cls) {
+ mirrorSystemGetNameFunction =
+ cls.lookupLocalMember(const SourceString('getName'));
+ } else if (symbolClass == cls) {
+ symbolConstructor = cls.constructors.head;
+ } else if (symbolImplementationClass == cls) {
+ symbolValidatedConstructor = symbolImplementationClass.lookupConstructor(
+ symbolValidatedConstructorSelector);
+ }
}
LibraryElement scanBuiltinLibrary(String filename);
@@ -645,6 +681,11 @@ abstract class Compiler implements DiagnosticListener {
'$missingCoreClasses');
}
+ // The Symbol class may not exist during unit testing.
+ // TODO(ahe): It is possible that we have to require the presence
+ // of Symbol as we change how we implement noSuchMethod.
+ symbolClass = lookupCoreClass('Symbol');
+
final List missingHelperClasses = [];
ClassElement lookupHelperClass(String name) {
ClassElement result = jsHelperLibrary.find(new SourceString(name));
@@ -1013,6 +1054,14 @@ abstract class Compiler implements DiagnosticListener {
api.Diagnostic.ERROR);
}
+ // TODO(ahe): Rename to reportWarning when that method has been removed.
+ void reportWarningCode(Spannable node, MessageKind errorCode,
+ [Map arguments = const {}]) {
+ reportMessage(spanFromSpannable(node),
+ errorCode.error(arguments),
+ api.Diagnostic.WARNING);
+ }
+
void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) {
// TODO(ahe): The names Diagnostic and api.Diagnostic are in
// conflict. Fix it.
« no previous file with comments | « dart/sdk/lib/_collection_dev/symbol.dart ('k') | dart/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698