| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.send_structure; | 5 library dart2js.send_structure; |
| 6 | 6 |
| 7 import 'access_semantics.dart'; | 7 import 'access_semantics.dart'; |
| 8 import 'operators.dart'; | 8 import 'operators.dart'; |
| 9 import 'semantic_visitor.dart'; | 9 import 'semantic_visitor.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 node, semantics.element, semantics.type, | 2352 node, semantics.element, semantics.type, |
| 2353 node.send.argumentsNode, selector, arg); | 2353 node.send.argumentsNode, selector, arg); |
| 2354 case ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR: | 2354 case ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR: |
| 2355 return visitor.errorNonConstantConstructorInvoke( | 2355 return visitor.errorNonConstantConstructorInvoke( |
| 2356 node, semantics.element, semantics.type, | 2356 node, semantics.element, semantics.type, |
| 2357 node.send.argumentsNode, callStructure, arg); | 2357 node.send.argumentsNode, callStructure, arg); |
| 2358 case ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY: | 2358 case ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY: |
| 2359 return visitor.visitUnresolvedRedirectingFactoryConstructorInvoke( | 2359 return visitor.visitUnresolvedRedirectingFactoryConstructorInvoke( |
| 2360 node, semantics.element, semantics.type, | 2360 node, semantics.element, semantics.type, |
| 2361 node.send.argumentsNode, callStructure, arg); | 2361 node.send.argumentsNode, callStructure, arg); |
| 2362 case ConstructorAccessKind.INCOMPATIBLE: |
| 2363 return visitor.visitConstructorIncompatibleInvoke( |
| 2364 node, semantics.element, semantics.type, |
| 2365 node.send.argumentsNode, callStructure, arg); |
| 2362 } | 2366 } |
| 2363 throw new SpannableAssertionFailure(node, | 2367 throw new SpannableAssertionFailure(node, |
| 2364 "Unhandled constructor invocation kind: ${semantics.kind}"); | 2368 "Unhandled constructor invocation kind: ${semantics.kind}"); |
| 2365 } | 2369 } |
| 2370 |
| 2371 String toString() => 'new($semantics,$selector)'; |
| 2372 } |
| 2373 |
| 2374 enum ConstantInvokeKind { |
| 2375 CONSTRUCTED, |
| 2376 BOOL_FROM_ENVIRONMENT, |
| 2377 INT_FROM_ENVIRONMENT, |
| 2378 STRING_FROM_ENVIRONMENT, |
| 2366 } | 2379 } |
| 2367 | 2380 |
| 2368 /// The structure for a [NewExpression] of a constant invocation. For instance | 2381 /// The structure for a [NewExpression] of a constant invocation. For instance |
| 2369 /// `const C()`. | 2382 /// `const C()`. |
| 2370 class ConstInvokeStructure<R, A> extends NewStructure<R, A> { | 2383 class ConstInvokeStructure<R, A> extends NewStructure<R, A> { |
| 2371 final ConstructedConstantExpression constant; | 2384 final ConstantInvokeKind kind; |
| 2385 final ConstantExpression constant; |
| 2372 | 2386 |
| 2373 ConstInvokeStructure(this.constant); | 2387 ConstInvokeStructure(this.kind, this.constant); |
| 2374 | 2388 |
| 2375 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { | 2389 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { |
| 2376 return visitor.visitConstConstructorInvoke(node, constant, arg); | 2390 switch (kind) { |
| 2391 case ConstantInvokeKind.CONSTRUCTED: |
| 2392 return visitor.visitConstConstructorInvoke(node, constant, arg); |
| 2393 case ConstantInvokeKind.BOOL_FROM_ENVIRONMENT: |
| 2394 return visitor.visitBoolFromEnvironmentConstructorInvoke( |
| 2395 node, constant, arg); |
| 2396 case ConstantInvokeKind.INT_FROM_ENVIRONMENT: |
| 2397 return visitor.visitIntFromEnvironmentConstructorInvoke( |
| 2398 node, constant, arg); |
| 2399 case ConstantInvokeKind.STRING_FROM_ENVIRONMENT: |
| 2400 return visitor.visitStringFromEnvironmentConstructorInvoke( |
| 2401 node, constant, arg); |
| 2402 } |
| 2377 } | 2403 } |
| 2378 } | 2404 } |
| 2379 | 2405 |
| 2380 /// The structure of a parameter declaration. | 2406 /// The structure of a parameter declaration. |
| 2381 abstract class ParameterStructure<R, A> { | 2407 abstract class ParameterStructure<R, A> { |
| 2382 final VariableDefinitions definitions; | 2408 final VariableDefinitions definitions; |
| 2383 final Node node; | 2409 final Node node; |
| 2384 final ParameterElement parameter; | 2410 final ParameterElement parameter; |
| 2385 | 2411 |
| 2386 ParameterStructure(this.definitions, this.node, this.parameter); | 2412 ParameterStructure(this.definitions, this.node, this.parameter); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2603 ThisConstructorInvokeStructure( | 2629 ThisConstructorInvokeStructure( |
| 2604 this.node, this.constructor, this.callStructure); | 2630 this.node, this.constructor, this.callStructure); |
| 2605 | 2631 |
| 2606 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { | 2632 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { |
| 2607 return visitor.visitThisConstructorInvoke( | 2633 return visitor.visitThisConstructorInvoke( |
| 2608 node, constructor, node.argumentsNode, callStructure, arg); | 2634 node, constructor, node.argumentsNode, callStructure, arg); |
| 2609 } | 2635 } |
| 2610 | 2636 |
| 2611 bool get isConstructorInvoke => true; | 2637 bool get isConstructorInvoke => true; |
| 2612 } | 2638 } |
| OLD | NEW |