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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 45143003: Implement JS_INTERCEPTOR_CONSTANT (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Element get currentElement; 8 Element get currentElement;
9 Setlet<Node> get superUses; 9 Setlet<Node> get superUses;
10 10
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 bool inCheckContext; 1919 bool inCheckContext;
1920 bool inCatchBlock; 1920 bool inCatchBlock;
1921 Scope scope; 1921 Scope scope;
1922 ClassElement currentClass; 1922 ClassElement currentClass;
1923 ExpressionStatement currentExpressionStatement; 1923 ExpressionStatement currentExpressionStatement;
1924 bool sendIsMemberAccess = false; 1924 bool sendIsMemberAccess = false;
1925 StatementScope statementScope; 1925 StatementScope statementScope;
1926 int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION 1926 int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION
1927 | ElementCategory.IMPLIES_TYPE; 1927 | ElementCategory.IMPLIES_TYPE;
1928 1928
1929 /**
1930 * Record of argument nodes to JS_INTERCEPTOR_CONSTANT for deferred
1931 * processing.
1932 */
1933 Set<Node> argumentsToJsInterceptorConstant = null;
ngeoffray 2013/10/29 20:30:18 This does not look very resolver related... why no
sra1 2013/10/30 17:18:18 Because it causes more classes to be instantiated,
1934
1929 /// When visiting the type declaration of the variable in a [ForIn] loop, 1935 /// When visiting the type declaration of the variable in a [ForIn] loop,
1930 /// the initializer of the variable is implicit and we should not emit an 1936 /// the initializer of the variable is implicit and we should not emit an
1931 /// error when verifying that all final variables are initialized. 1937 /// error when verifying that all final variables are initialized.
1932 bool allowFinalWithoutInitializer = false; 1938 bool allowFinalWithoutInitializer = false;
1933 1939
1934 /// The nodes for which variable access and mutation must be registered in 1940 /// The nodes for which variable access and mutation must be registered in
1935 /// order to determine when the static type of variables types is promoted. 1941 /// order to determine when the static type of variables types is promoted.
1936 Link<Node> promotionScope = const Link<Node>(); 1942 Link<Node> promotionScope = const Link<Node>();
1937 1943
1938 bool isPotentiallyMutableTarget(Element target) { 1944 bool isPotentiallyMutableTarget(Element target) {
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 Selector call = new Selector.callClosureFrom(selector); 2621 Selector call = new Selector.callClosureFrom(selector);
2616 world.registerDynamicInvocation(call); 2622 world.registerDynamicInvocation(call);
2617 } else if (target.impliesType()) { 2623 } else if (target.impliesType()) {
2618 // We call 'call()' on a Type instance returned from the reference to a 2624 // We call 'call()' on a Type instance returned from the reference to a
2619 // class or typedef literal. We do not need to register this call as a 2625 // class or typedef literal. We do not need to register this call as a
2620 // dynamic invocation, because we statically know what the target is. 2626 // dynamic invocation, because we statically know what the target is.
2621 } else if (!selector.applies(target, compiler)) { 2627 } else if (!selector.applies(target, compiler)) {
2622 warnArgumentMismatch(node, target); 2628 warnArgumentMismatch(node, target);
2623 } 2629 }
2624 2630
2625 if (target != null && 2631 if (target != null && target.isForeign(compiler)) {
2626 target.isForeign(compiler) && 2632 if (selector.name == 'JS') {
2627 selector.name == 'JS') { 2633 world.registerJsCall(node, this);
2628 world.registerJsCall(node, this); 2634 } else if (selector.name == 'JS_INTERCEPTOR_CONSTANT') {
2635 if (!node.argumentsNode.isEmpty) {
2636 Node argument = node.argumentsNode.nodes.head;
2637 if (argumentsToJsInterceptorConstant == null)
ngeoffray 2013/10/29 20:30:18 Please use braces.
sra1 2013/10/30 17:18:18 I will sneak this into another CL.
2638 argumentsToJsInterceptorConstant = new Set<Node>();
2639 argumentsToJsInterceptorConstant.add(argument);
2640 }
2641 }
2629 } 2642 }
2630 } 2643 }
2631 2644
2632 // TODO(ngeoffray): Warn if target is null and the send is 2645 // TODO(ngeoffray): Warn if target is null and the send is
2633 // unqualified. 2646 // unqualified.
2634 useElement(node, target); 2647 useElement(node, target);
2635 registerSend(selector, target); 2648 registerSend(selector, target);
2636 if (node.isPropertyAccess && Elements.isStaticOrTopLevelFunction(target)) { 2649 if (node.isPropertyAccess && Elements.isStaticOrTopLevelFunction(target)) {
2637 world.registerGetOfStaticFunction(target.declaration); 2650 world.registerGetOfStaticFunction(target.declaration);
2638 } 2651 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 } 3048 }
3036 if (node.isConst()) { 3049 if (node.isConst()) {
3037 analyzeConstant(node); 3050 analyzeConstant(node);
3038 } 3051 }
3039 3052
3040 return null; 3053 return null;
3041 } 3054 }
3042 3055
3043 void analyzeConstant(Node node, {bool isConst: true}) { 3056 void analyzeConstant(Node node, {bool isConst: true}) {
3044 addDeferredAction(enclosingElement, () { 3057 addDeferredAction(enclosingElement, () {
3045 compiler.constantHandler.compileNodeWithDefinitions( 3058 Constant constant = compiler.constantHandler.compileNodeWithDefinitions(
3046 node, mapping, isConst: isConst); 3059 node, mapping, isConst: isConst);
3060
3061 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names
3062 // a class that will be instantiated outside the program by attaching a
3063 // native class dispatch record referencing the interceptor.
3064 if (argumentsToJsInterceptorConstant != null &&
3065 argumentsToJsInterceptorConstant.contains(node)) {
3066 if (constant.isType()) {
3067 TypeConstant typeConstant = constant;
3068 if (typeConstant.representedType is InterfaceType) {
3069 world.registerInstantiatedType(typeConstant.representedType,
3070 mapping);
3071 } else {
3072 compiler.reportError(node,
3073 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
3074 }
3075 } else {
3076 compiler.reportError(node,
3077 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
3078 }
3079 }
3047 }); 3080 });
3048 } 3081 }
3049 3082
3050 bool validateSymbol(Node node, String name, {bool reportError: true}) { 3083 bool validateSymbol(Node node, String name, {bool reportError: true}) {
3051 if (name.isEmpty) return true; 3084 if (name.isEmpty) return true;
3052 if (name.startsWith('_')) { 3085 if (name.startsWith('_')) {
3053 if (reportError) { 3086 if (reportError) {
3054 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER, 3087 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER,
3055 {'value': name}); 3088 {'value': name});
3056 } 3089 }
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
4681 return finishConstructorReference(visit(expression), 4714 return finishConstructorReference(visit(expression),
4682 expression, expression); 4715 expression, expression);
4683 } 4716 }
4684 } 4717 }
4685 4718
4686 /// Looks up [name] in [scope] and unwraps the result. 4719 /// Looks up [name] in [scope] and unwraps the result.
4687 Element lookupInScope(Compiler compiler, Node node, 4720 Element lookupInScope(Compiler compiler, Node node,
4688 Scope scope, String name) { 4721 Scope scope, String name) {
4689 return Elements.unwrap(scope.lookup(name), compiler, node); 4722 return Elements.unwrap(scope.lookup(name), compiler, node);
4690 } 4723 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698