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

Side by Side Diff: dart/pkg/compiler/lib/src/resolution/members.dart

Issue 935033005: Register literals through backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Changes commited as r43876. 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 resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 Modifiers modifiers = element.modifiers; 690 Modifiers modifiers = element.modifiers;
691 if (initializer != null) { 691 if (initializer != null) {
692 // TODO(johnniwinther): Avoid analyzing initializers if 692 // TODO(johnniwinther): Avoid analyzing initializers if
693 // [Compiler.analyzeSignaturesOnly] is set. 693 // [Compiler.analyzeSignaturesOnly] is set.
694 visitor.visit(initializer); 694 visitor.visit(initializer);
695 } else if (modifiers.isConst) { 695 } else if (modifiers.isConst) {
696 compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER); 696 compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER);
697 } else if (modifiers.isFinal && !element.isInstanceMember) { 697 } else if (modifiers.isFinal && !element.isInstanceMember) {
698 compiler.reportError(element, MessageKind.FINAL_WITHOUT_INITIALIZER); 698 compiler.reportError(element, MessageKind.FINAL_WITHOUT_INITIALIZER);
699 } else { 699 } else {
700 registry.registerInstantiatedClass(compiler.nullClass); 700 registry.registerLiteralNull();
701 } 701 }
702 702
703 if (Elements.isStaticOrTopLevelField(element)) { 703 if (Elements.isStaticOrTopLevelField(element)) {
704 visitor.addDeferredAction(element, () { 704 visitor.addDeferredAction(element, () {
705 if (element.modifiers.isConst) { 705 if (element.modifiers.isConst) {
706 constantCompiler.compileConstant(element); 706 constantCompiler.compileConstant(element);
707 } else { 707 } else {
708 constantCompiler.compileVariable(element); 708 constantCompiler.compileVariable(element);
709 } 709 }
710 }); 710 });
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 // Run the body in a fresh statement scope. 2522 // Run the body in a fresh statement scope.
2523 StatementScope oldStatementScope = statementScope; 2523 StatementScope oldStatementScope = statementScope;
2524 statementScope = new StatementScope(); 2524 statementScope = new StatementScope();
2525 visit(node.body); 2525 visit(node.body);
2526 statementScope = oldStatementScope; 2526 statementScope = oldStatementScope;
2527 2527
2528 scope = oldScope; 2528 scope = oldScope;
2529 enclosingElement = previousEnclosingElement; 2529 enclosingElement = previousEnclosingElement;
2530 2530
2531 registry.registerClosure(function); 2531 registry.registerClosure(function);
2532 registry.registerInstantiatedClass(compiler.functionClass); 2532 registry.registerLiteralFunction();
2533 } 2533 }
2534 2534
2535 visitIf(If node) { 2535 visitIf(If node) {
2536 doInPromotionScope(node.condition.expression, () => visit(node.condition)); 2536 doInPromotionScope(node.condition.expression, () => visit(node.condition));
2537 doInPromotionScope(node.thenPart, 2537 doInPromotionScope(node.thenPart,
2538 () => visitIn(node.thenPart, new BlockScope(scope))); 2538 () => visitIn(node.thenPart, new BlockScope(scope)));
2539 visitIn(node.elsePart, new BlockScope(scope)); 2539 visitIn(node.elsePart, new BlockScope(scope));
2540 } 2540 }
2541 2541
2542 ResolutionResult resolveSend(Send node) { 2542 ResolutionResult resolveSend(Send node) {
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 3045
3046 // Make sure we include the + and - operators if we are using 3046 // Make sure we include the + and - operators if we are using
3047 // the ++ and -- ones. Also, if op= form is used, include op itself. 3047 // the ++ and -- ones. Also, if op= form is used, include op itself.
3048 void registerBinaryOperator(String name) { 3048 void registerBinaryOperator(String name) {
3049 Selector binop = new Selector.binaryOperator(name); 3049 Selector binop = new Selector.binaryOperator(name);
3050 registry.registerDynamicInvocation(binop); 3050 registry.registerDynamicInvocation(binop);
3051 registry.setOperatorSelectorInComplexSendSet(node, binop); 3051 registry.setOperatorSelectorInComplexSendSet(node, binop);
3052 } 3052 }
3053 if (identical(source, '++')) { 3053 if (identical(source, '++')) {
3054 registerBinaryOperator('+'); 3054 registerBinaryOperator('+');
3055 registry.registerInstantiatedClass(compiler.intClass); 3055 registry.registerLiteralInt();
3056 } else if (identical(source, '--')) { 3056 } else if (identical(source, '--')) {
3057 registerBinaryOperator('-'); 3057 registerBinaryOperator('-');
3058 registry.registerInstantiatedClass(compiler.intClass); 3058 registry.registerLiteralInt();
3059 } else if (source.endsWith('=')) { 3059 } else if (source.endsWith('=')) {
3060 registerBinaryOperator(Elements.mapToUserOperator(operatorName)); 3060 registerBinaryOperator(Elements.mapToUserOperator(operatorName));
3061 } 3061 }
3062 } 3062 }
3063 3063
3064 registerSend(selector, setter); 3064 registerSend(selector, setter);
3065 return new ElementResult(registry.useElement(node, setter)); 3065 return new ElementResult(registry.useElement(node, setter));
3066 } 3066 }
3067 3067
3068 void registerSend(Selector selector, Element target) { 3068 void registerSend(Selector selector, Element target) {
(...skipping 10 matching lines...) Expand all
3079 // instead resolved through their enclosing type declaration. 3079 // instead resolved through their enclosing type declaration.
3080 if (!target.isTypeVariable) { 3080 if (!target.isTypeVariable) {
3081 // [target] might be the implementation element and only declaration 3081 // [target] might be the implementation element and only declaration
3082 // elements may be registered. 3082 // elements may be registered.
3083 registry.registerStaticUse(target.declaration); 3083 registry.registerStaticUse(target.declaration);
3084 } 3084 }
3085 } 3085 }
3086 } 3086 }
3087 3087
3088 visitLiteralInt(LiteralInt node) { 3088 visitLiteralInt(LiteralInt node) {
3089 registry.registerInstantiatedClass(compiler.intClass); 3089 registry.registerLiteralInt();
3090 } 3090 }
3091 3091
3092 visitLiteralDouble(LiteralDouble node) { 3092 visitLiteralDouble(LiteralDouble node) {
3093 registry.registerInstantiatedClass(compiler.doubleClass); 3093 registry.registerLiteralDouble();
3094 } 3094 }
3095 3095
3096 visitLiteralBool(LiteralBool node) { 3096 visitLiteralBool(LiteralBool node) {
3097 registry.registerInstantiatedClass(compiler.boolClass); 3097 registry.registerLiteralBool();
3098 } 3098 }
3099 3099
3100 visitLiteralString(LiteralString node) { 3100 visitLiteralString(LiteralString node) {
3101 registry.registerInstantiatedClass(compiler.stringClass); 3101 registry.registerLiteralString();
3102 } 3102 }
3103 3103
3104 visitLiteralNull(LiteralNull node) { 3104 visitLiteralNull(LiteralNull node) {
3105 registry.registerInstantiatedClass(compiler.nullClass); 3105 registry.registerLiteralNull();
3106 } 3106 }
3107 3107
3108 visitLiteralSymbol(LiteralSymbol node) { 3108 visitLiteralSymbol(LiteralSymbol node) {
3109 registry.registerInstantiatedClass(compiler.symbolClass); 3109 registry.registerLiteralSymbol(node.slowNameString);
3110 registry.registerStaticUse(compiler.symbolConstructor.declaration);
3111 registry.registerConstSymbol(node.slowNameString);
3112 if (!validateSymbol(node, node.slowNameString, reportError: false)) { 3110 if (!validateSymbol(node, node.slowNameString, reportError: false)) {
3113 compiler.reportError(node, 3111 compiler.reportError(node,
3114 MessageKind.UNSUPPORTED_LITERAL_SYMBOL, 3112 MessageKind.UNSUPPORTED_LITERAL_SYMBOL,
3115 {'value': node.slowNameString}); 3113 {'value': node.slowNameString});
3116 } 3114 }
3117 analyzeConstantDeferred(node); 3115 analyzeConstantDeferred(node);
3118 } 3116 }
3119 3117
3120 visitStringJuxtaposition(StringJuxtaposition node) { 3118 visitStringJuxtaposition(StringJuxtaposition node) {
3121 registry.registerInstantiatedClass(compiler.stringClass); 3119 registry.registerLiteralString();
3122 node.visitChildren(this); 3120 node.visitChildren(this);
3123 } 3121 }
3124 3122
3125 visitNodeList(NodeList node) { 3123 visitNodeList(NodeList node) {
3126 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { 3124 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) {
3127 visit(link.head); 3125 visit(link.head);
3128 } 3126 }
3129 } 3127 }
3130 3128
3131 visitOperator(Operator node) { 3129 visitOperator(Operator node) {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 sendIsMemberAccess = false; 3515 sendIsMemberAccess = false;
3518 } 3516 }
3519 3517
3520 visitConditional(Conditional node) { 3518 visitConditional(Conditional node) {
3521 doInPromotionScope(node.condition, () => visit(node.condition)); 3519 doInPromotionScope(node.condition, () => visit(node.condition));
3522 doInPromotionScope(node.thenExpression, () => visit(node.thenExpression)); 3520 doInPromotionScope(node.thenExpression, () => visit(node.thenExpression));
3523 visit(node.elseExpression); 3521 visit(node.elseExpression);
3524 } 3522 }
3525 3523
3526 visitStringInterpolation(StringInterpolation node) { 3524 visitStringInterpolation(StringInterpolation node) {
3527 registry.registerInstantiatedClass(compiler.stringClass); 3525 registry.registerLiteralString();
3528 registry.registerStringInterpolation(); 3526 registry.registerStringInterpolation();
3529 node.visitChildren(this); 3527 node.visitChildren(this);
3530 } 3528 }
3531 3529
3532 visitStringInterpolationPart(StringInterpolationPart node) { 3530 visitStringInterpolationPart(StringInterpolationPart node) {
3533 registerImplicitInvocation('toString', 0); 3531 registerImplicitInvocation('toString', 0);
3534 node.visitChildren(this); 3532 node.visitChildren(this);
3535 } 3533 }
3536 3534
3537 visitBreakStatement(BreakStatement node) { 3535 visitBreakStatement(BreakStatement node) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
3982 DartType exceptionType = registry.getType(node.type); 3980 DartType exceptionType = registry.getType(node.type);
3983 Node exceptionVariable = exceptionDefinition.definitions.nodes.head; 3981 Node exceptionVariable = exceptionDefinition.definitions.nodes.head;
3984 VariableElementX exceptionElement = 3982 VariableElementX exceptionElement =
3985 registry.getDefinition(exceptionVariable); 3983 registry.getDefinition(exceptionVariable);
3986 exceptionElement.variables.type = exceptionType; 3984 exceptionElement.variables.type = exceptionType;
3987 } 3985 }
3988 if (stackTraceDefinition != null) { 3986 if (stackTraceDefinition != null) {
3989 Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; 3987 Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head;
3990 VariableElementX stackTraceElement = 3988 VariableElementX stackTraceElement =
3991 registry.getDefinition(stackTraceVariable); 3989 registry.getDefinition(stackTraceVariable);
3992 registry.registerInstantiatedClass(compiler.stackTraceClass);
3993 stackTraceElement.variables.type = compiler.stackTraceClass.rawType; 3990 stackTraceElement.variables.type = compiler.stackTraceClass.rawType;
3994 } 3991 }
3995 } 3992 }
3996 3993
3997 visitTypedef(Typedef node) { 3994 visitTypedef(Typedef node) {
3998 internalError(node, 'typedef'); 3995 internalError(node, 'typedef');
3999 } 3996 }
4000 } 3997 }
4001 3998
4002 class TypeDefinitionVisitor extends MappingVisitor<DartType> { 3999 class TypeDefinitionVisitor extends MappingVisitor<DartType> {
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 if (scope.variableReferencedInInitializer) { 4772 if (scope.variableReferencedInInitializer) {
4776 compiler.reportError( 4773 compiler.reportError(
4777 identifier, MessageKind.REFERENCE_IN_INITIALIZATION, 4774 identifier, MessageKind.REFERENCE_IN_INITIALIZATION,
4778 {'variableName': name}); 4775 {'variableName': name});
4779 } 4776 }
4780 return identifier; 4777 return identifier;
4781 } 4778 }
4782 4779
4783 Identifier visitIdentifier(Identifier node) { 4780 Identifier visitIdentifier(Identifier node) {
4784 // The variable is initialized to null. 4781 // The variable is initialized to null.
4785 registry.registerInstantiatedClass(compiler.nullClass); 4782 registry.registerLiteralNull();
4786 if (definitions.modifiers.isConst) { 4783 if (definitions.modifiers.isConst) {
4787 compiler.reportError(node, MessageKind.CONST_WITHOUT_INITIALIZER); 4784 compiler.reportError(node, MessageKind.CONST_WITHOUT_INITIALIZER);
4788 } 4785 }
4789 if (definitions.modifiers.isFinal && 4786 if (definitions.modifiers.isFinal &&
4790 !resolver.allowFinalWithoutInitializer) { 4787 !resolver.allowFinalWithoutInitializer) {
4791 compiler.reportError(node, MessageKind.FINAL_WITHOUT_INITIALIZER); 4788 compiler.reportError(node, MessageKind.FINAL_WITHOUT_INITIALIZER);
4792 } 4789 }
4793 return node; 4790 return node;
4794 } 4791 }
4795 4792
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
5061 } 5058 }
5062 5059
5063 /// The result for the resolution of the `assert` method. 5060 /// The result for the resolution of the `assert` method.
5064 class AssertResult implements ResolutionResult { 5061 class AssertResult implements ResolutionResult {
5065 const AssertResult(); 5062 const AssertResult();
5066 5063
5067 Element get element => null; 5064 Element get element => null;
5068 5065
5069 String toString() => 'AssertResult()'; 5066 String toString() => 'AssertResult()';
5070 } 5067 }
OLDNEW
« no previous file with comments | « dart/pkg/compiler/lib/src/js_backend/backend.dart ('k') | dart/pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698