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 '../closure.dart' hide ClosureScope; |
| 8 import '../common.dart'; |
7 import '../common/names.dart' show | 9 import '../common/names.dart' show |
8 Names, | 10 Names, |
9 Selectors; | 11 Selectors; |
10 import '../compile_time_constants.dart' show | 12 import '../compile_time_constants.dart' show |
11 BackendConstantEnvironment; | 13 BackendConstantEnvironment; |
12 import '../constants/constant_system.dart'; | 14 import '../constants/constant_system.dart'; |
13 import '../constants/values.dart' show | 15 import '../constants/values.dart' show |
14 ConstantValue, | 16 ConstantValue, |
15 PrimitiveConstantValue; | 17 PrimitiveConstantValue; |
16 import '../dart_types.dart'; | 18 import '../dart_types.dart'; |
17 import '../diagnostics/invariant.dart' show | |
18 invariant; | |
19 import '../elements/elements.dart'; | 19 import '../elements/elements.dart'; |
20 import '../io/source_information.dart'; | 20 import '../io/source_information.dart'; |
| 21 import '../js/js.dart' as js show |
| 22 js, |
| 23 LiteralStatement, |
| 24 Template; |
| 25 import '../native/native.dart' show |
| 26 NativeBehavior; |
21 import '../tree/tree.dart' as ast; | 27 import '../tree/tree.dart' as ast; |
22 import '../types/types.dart' show | 28 import '../types/types.dart' show |
23 TypeMask; | 29 TypeMask; |
24 import '../closure.dart' hide ClosureScope; | |
25 import '../universe/call_structure.dart' show | 30 import '../universe/call_structure.dart' show |
26 CallStructure; | 31 CallStructure; |
27 import '../universe/selector.dart' show | 32 import '../universe/selector.dart' show |
28 Selector, | 33 Selector, |
29 SelectorKind; | 34 SelectorKind; |
30 import 'cps_ir_nodes.dart' as ir; | 35 |
31 import 'cps_ir_builder_task.dart' show | 36 import 'cps_ir_builder_task.dart' show |
32 DartCapturedVariables, | 37 DartCapturedVariables, |
33 GlobalProgramInformation; | 38 GlobalProgramInformation; |
| 39 import 'cps_ir_nodes.dart' as ir; |
34 | 40 |
35 import '../common.dart' as types show | |
36 TypeMask; | |
37 import '../js/js.dart' as js show Template, js, LiteralStatement; | |
38 import '../native/native.dart' show | |
39 NativeBehavior; | |
40 | 41 |
41 /// A mapping from variable elements to their compile-time values. | 42 /// A mapping from variable elements to their compile-time values. |
42 /// | 43 /// |
43 /// Map elements denoted by parameters and local variables to the | 44 /// Map elements denoted by parameters and local variables to the |
44 /// [ir.Primitive] that is their value. Parameters and locals are | 45 /// [ir.Primitive] that is their value. Parameters and locals are |
45 /// assigned indexes which can be used to refer to them. | 46 /// assigned indexes which can be used to refer to them. |
46 class Environment { | 47 class Environment { |
47 /// A map from locals to their environment index. | 48 /// A map from locals to their environment index. |
48 final Map<Local, int> variable2index; | 49 final Map<Local, int> variable2index; |
49 | 50 |
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2689 ir.Primitive buildInvocationMirror(Selector selector, | 2690 ir.Primitive buildInvocationMirror(Selector selector, |
2690 List<ir.Primitive> arguments) { | 2691 List<ir.Primitive> arguments) { |
2691 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); | 2692 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); |
2692 } | 2693 } |
2693 | 2694 |
2694 ir.Primitive buildForeignCode(js.Template codeTemplate, | 2695 ir.Primitive buildForeignCode(js.Template codeTemplate, |
2695 List<ir.Primitive> arguments, | 2696 List<ir.Primitive> arguments, |
2696 NativeBehavior behavior, | 2697 NativeBehavior behavior, |
2697 {Element dependency}) { | 2698 {Element dependency}) { |
2698 assert(behavior != null); | 2699 assert(behavior != null); |
2699 types.TypeMask type = program.getTypeMaskForForeign(behavior); | 2700 TypeMask type = program.getTypeMaskForForeign(behavior); |
2700 ir.Primitive result = _continueWithExpression((k) => new ir.ForeignCode( | 2701 ir.Primitive result = _continueWithExpression((k) => new ir.ForeignCode( |
2701 codeTemplate, | 2702 codeTemplate, |
2702 type, | 2703 type, |
2703 arguments, | 2704 arguments, |
2704 behavior, | 2705 behavior, |
2705 k, | 2706 k, |
2706 dependency: dependency)); | 2707 dependency: dependency)); |
2707 if (!codeTemplate.isExpression) { | 2708 if (!codeTemplate.isExpression) { |
2708 // Close the term if this is a "throw" expression or native body. | 2709 // Close the term if this is a "throw" expression or native body. |
2709 add(new ir.Unreachable()); | 2710 add(new ir.Unreachable()); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 } | 2886 } |
2886 | 2887 |
2887 class SwitchCaseInfo { | 2888 class SwitchCaseInfo { |
2888 final List<ir.Primitive> constants = <ir.Primitive>[]; | 2889 final List<ir.Primitive> constants = <ir.Primitive>[]; |
2889 final SubbuildFunction buildBody; | 2890 final SubbuildFunction buildBody; |
2890 | 2891 |
2891 SwitchCaseInfo(this.buildBody); | 2892 SwitchCaseInfo(this.buildBody); |
2892 | 2893 |
2893 void addConstant(ir.Primitive constant) => constants.add(constant); | 2894 void addConstant(ir.Primitive constant) => constants.add(constant); |
2894 } | 2895 } |
OLD | NEW |