| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.ir_builder; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
| 8 import '../constants/values.dart' show PrimitiveConstantValue; | 8 import '../constants/values.dart' show PrimitiveConstantValue; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../dart2jslib.dart'; | 10 import '../dart2jslib.dart'; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 /// The delimited visitor has its own compile-time environment mapping | 361 /// The delimited visitor has its own compile-time environment mapping |
| 362 /// local variables to their values, which is initially a copy of the parent | 362 /// local variables to their values, which is initially a copy of the parent |
| 363 /// environment. It has its own context for building an IR expression, so | 363 /// environment. It has its own context for building an IR expression, so |
| 364 /// the built expression is not plugged into the parent's context. | 364 /// the built expression is not plugged into the parent's context. |
| 365 IrBuilder makeDelimitedBuilder() { | 365 IrBuilder makeDelimitedBuilder() { |
| 366 return _makeInstance() | 366 return _makeInstance() |
| 367 ..state = state | 367 ..state = state |
| 368 ..environment = new Environment.from(environment); | 368 ..environment = new Environment.from(environment); |
| 369 } | 369 } |
| 370 | 370 |
| 371 /// Construct a builder for making constructor field initializers. |
| 372 IrBuilder makeInitializerBuilder() { |
| 373 return _makeInstance() |
| 374 ..state = new IrBuilderDelimitedState(state.constantSystem, |
| 375 state.currentElement) |
| 376 ..environment = new Environment.from(environment); |
| 377 } |
| 378 |
| 371 /// Construct a visitor for a recursive continuation. | 379 /// Construct a visitor for a recursive continuation. |
| 372 /// | 380 /// |
| 373 /// The recursive continuation builder has fresh parameters (i.e. SSA phis) | 381 /// The recursive continuation builder has fresh parameters (i.e. SSA phis) |
| 374 /// for all the local variables in the parent, because the invocation sites | 382 /// for all the local variables in the parent, because the invocation sites |
| 375 /// of the continuation are not all known when the builder is created. The | 383 /// of the continuation are not all known when the builder is created. The |
| 376 /// recursive invocations will be passed values for all the local variables, | 384 /// recursive invocations will be passed values for all the local variables, |
| 377 /// which may be eliminated later if they are redundant---if they take on | 385 /// which may be eliminated later if they are redundant---if they take on |
| 378 /// the same value at all invocation sites. | 386 /// the same value at all invocation sites. |
| 379 IrBuilder makeRecursiveBuilder() { | 387 IrBuilder makeRecursiveBuilder() { |
| 380 IrBuilder inner = _makeInstance() | 388 IrBuilder inner = _makeInstance() |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 return new ir.FunctionDefinition.abstract( | 667 return new ir.FunctionDefinition.abstract( |
| 660 element, state.functionParameters, defaults); | 668 element, state.functionParameters, defaults); |
| 661 } else { | 669 } else { |
| 662 ir.RunnableBody body = makeRunnableBody(); | 670 ir.RunnableBody body = makeRunnableBody(); |
| 663 return new ir.FunctionDefinition( | 671 return new ir.FunctionDefinition( |
| 664 element, state.functionParameters, body, | 672 element, state.functionParameters, body, |
| 665 state.localConstants, defaults); | 673 state.localConstants, defaults); |
| 666 } | 674 } |
| 667 } | 675 } |
| 668 | 676 |
| 677 /// Create a constructor definition without a body, for representing |
| 678 /// external constructors declarations. |
| 679 ir.ConstructorDefinition makeAbstractConstructorDefinition( |
| 680 List<ConstantExpression> defaults) { |
| 681 FunctionElement element = state.currentElement; |
| 682 assert(invariant(element, _root == null, |
| 683 message: "Non-empty body for external constructor $element: $_root")); |
| 684 assert(invariant(element, state.localConstants.isEmpty, |
| 685 message: "Local constants for external constructor $element: " |
| 686 "${state.localConstants}")); |
| 687 return new ir.ConstructorDefinition.abstract( |
| 688 element, state.functionParameters, defaults); |
| 689 } |
| 690 |
| 669 ir.ConstructorDefinition makeConstructorDefinition( | 691 ir.ConstructorDefinition makeConstructorDefinition( |
| 670 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { | 692 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { |
| 671 FunctionElement element = state.currentElement; | 693 FunctionElement element = state.currentElement; |
| 672 if (element.isExternal) { | |
| 673 assert(invariant(element, _root == null, | |
| 674 message: "Non-empty body for external constructor $element: $_root")); | |
| 675 assert(invariant(element, state.localConstants.isEmpty, | |
| 676 message: "Local constants for external constructor $element: " | |
| 677 "${state.localConstants}")); | |
| 678 return new ir.ConstructorDefinition.abstract( | |
| 679 element, state.functionParameters, defaults); | |
| 680 } | |
| 681 ir.RunnableBody body = makeRunnableBody(); | 694 ir.RunnableBody body = makeRunnableBody(); |
| 682 return new ir.ConstructorDefinition( | 695 return new ir.ConstructorDefinition( |
| 683 element, state.functionParameters, body, initializers, | 696 element, state.functionParameters, body, initializers, |
| 684 state.localConstants, defaults); | 697 state.localConstants, defaults); |
| 685 } | 698 } |
| 686 | 699 |
| 687 /// Create a super invocation where the method name and the argument structure | 700 /// Create a super invocation where the method name and the argument structure |
| 688 /// are defined by [selector] and the argument values are defined by | 701 /// are defined by [selector] and the argument values are defined by |
| 689 /// [arguments]. | 702 /// [arguments]. |
| 690 ir.Primitive buildSuperInvocation(Element target, | 703 ir.Primitive buildSuperInvocation(Element target, |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 final Map<Local, ClosureLocation> freeVariables; | 2124 final Map<Local, ClosureLocation> freeVariables; |
| 2112 | 2125 |
| 2113 ClosureEnvironment(this.selfReference, this.thisLocal, this.freeVariables); | 2126 ClosureEnvironment(this.selfReference, this.thisLocal, this.freeVariables); |
| 2114 } | 2127 } |
| 2115 | 2128 |
| 2116 class TryStatementInfo { | 2129 class TryStatementInfo { |
| 2117 final Set<LocalVariableElement> declared = new Set<LocalVariableElement>(); | 2130 final Set<LocalVariableElement> declared = new Set<LocalVariableElement>(); |
| 2118 final Set<LocalVariableElement> boxedOnEntry = | 2131 final Set<LocalVariableElement> boxedOnEntry = |
| 2119 new Set<LocalVariableElement>(); | 2132 new Set<LocalVariableElement>(); |
| 2120 } | 2133 } |
| OLD | NEW |