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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 929313002: Use an enum in embedded_names as input to JS_GET_NAME. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 ssa; 5 part of ssa;
6 6
7 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 SsaCodeGeneratorTask generator; 8 SsaCodeGeneratorTask generator;
9 SsaBuilderTask builder; 9 SsaBuilderTask builder;
10 SsaOptimizerTask optimizer; 10 SsaOptimizerTask optimizer;
(...skipping 3720 matching lines...) Expand 10 before | Expand all | Expand 10 after
3731 argument = arguments[0]; 3731 argument = arguments[0];
3732 break; 3732 break;
3733 default: 3733 default:
3734 for (int i = 1; i < arguments.length; i++) { 3734 for (int i = 1; i < arguments.length; i++) {
3735 compiler.reportError( 3735 compiler.reportError(
3736 arguments[i], MessageKind.GENERIC, 3736 arguments[i], MessageKind.GENERIC,
3737 {'text': 'Error: Extra argument to JS_GET_NAME.'}); 3737 {'text': 'Error: Extra argument to JS_GET_NAME.'});
3738 } 3738 }
3739 return; 3739 return;
3740 } 3740 }
3741 ast.LiteralString string = argument.asLiteralString(); 3741 Element element = elements[argument];
3742 if (string == null) { 3742 if (element == null ||
3743 element is! FieldElement ||
3744 element.enclosingClass != backend.jsGetNameEnum) {
3743 compiler.reportError( 3745 compiler.reportError(
3744 argument, MessageKind.GENERIC, 3746 argument, MessageKind.GENERIC,
3745 {'text': 'Error: Expected a literal string.'}); 3747 {'text': 'Error: Expected a JsGetName enum value.'});
3746 } 3748 }
3749 EnumClassElement enumClass = element.enclosingClass;
3750 int index = enumClass.enumValues.indexOf(element);
3747 stack.add( 3751 stack.add(
3748 addConstantString( 3752 addConstantString(
3749 backend.namer.getNameForJsGetName( 3753 backend.namer.getNameForJsGetName(
3750 argument, string.dartString.slowToString()))); 3754 argument, JsGetName.values[index])));
3751 } 3755 }
3752 3756
3753 void handleForeignJsEmbeddedGlobal(ast.Send node) { 3757 void handleForeignJsEmbeddedGlobal(ast.Send node) {
3754 List<ast.Node> arguments = node.arguments.toList(); 3758 List<ast.Node> arguments = node.arguments.toList();
3755 ast.Node globalNameNode; 3759 ast.Node globalNameNode;
3756 switch (arguments.length) { 3760 switch (arguments.length) {
3757 case 0: 3761 case 0:
3758 case 1: 3762 case 1:
3759 compiler.reportError( 3763 compiler.reportError(
3760 node, MessageKind.GENERIC, 3764 node, MessageKind.GENERIC,
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after
6915 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6919 if (unaliased is TypedefType) throw 'unable to unalias $type';
6916 unaliased.accept(this, builder); 6920 unaliased.accept(this, builder);
6917 } 6921 }
6918 6922
6919 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6923 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6920 JavaScriptBackend backend = builder.compiler.backend; 6924 JavaScriptBackend backend = builder.compiler.backend;
6921 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 6925 ClassElement cls = backend.findHelper('DynamicRuntimeType');
6922 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 6926 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
6923 } 6927 }
6924 } 6928 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698