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 cps_ir.cps_fragment; | 5 library cps_ir.cps_fragment; |
6 | 6 |
7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
9 import '../universe/universe.dart' show Selector; | 9 import '../universe/selector.dart' show Selector; |
10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
11 import '../io/source_information.dart'; | 11 import '../io/source_information.dart'; |
12 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
13 | 13 |
14 /// Builds a CPS fragment that can be plugged into another CPS term. | 14 /// Builds a CPS fragment that can be plugged into another CPS term. |
15 /// | 15 /// |
16 /// A CPS fragment contains a CPS term, possibly with a "hole" in it denoting | 16 /// A CPS fragment contains a CPS term, possibly with a "hole" in it denoting |
17 /// where to insert new IR nodes. We say a fragment is "open" if it has such | 17 /// where to insert new IR nodes. We say a fragment is "open" if it has such |
18 /// a hole. Otherwise, the fragment is "closed" and cannot be extended further. | 18 /// a hole. Otherwise, the fragment is "closed" and cannot be extended further. |
19 /// | 19 /// |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 Primitive makeOne() => makeConstant(new IntConstantValue(1)); | 105 Primitive makeOne() => makeConstant(new IntConstantValue(1)); |
106 Primitive makeNull() => makeConstant(new NullConstantValue()); | 106 Primitive makeNull() => makeConstant(new NullConstantValue()); |
107 Primitive makeTrue() => makeConstant(new TrueConstantValue()); | 107 Primitive makeTrue() => makeConstant(new TrueConstantValue()); |
108 Primitive makeFalse() => makeConstant(new FalseConstantValue()); | 108 Primitive makeFalse() => makeConstant(new FalseConstantValue()); |
109 | 109 |
110 /// Invoke a built-in operator. | 110 /// Invoke a built-in operator. |
111 Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) { | 111 Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) { |
112 return letPrim(new ApplyBuiltinOperator(op, args, sourceInformation)); | 112 return letPrim(new ApplyBuiltinOperator(op, args, sourceInformation)); |
113 } | 113 } |
114 | 114 |
115 Primitive invokeBuiltin(BuiltinMethod method, | 115 Primitive invokeBuiltin(BuiltinMethod method, |
116 Primitive receiver, | 116 Primitive receiver, |
117 List<Primitive> arguments, | 117 List<Primitive> arguments, |
118 {bool receiverIsNotNull: false}) { | 118 {bool receiverIsNotNull: false}) { |
119 ApplyBuiltinMethod apply = | 119 ApplyBuiltinMethod apply = |
120 new ApplyBuiltinMethod(method, receiver, arguments, sourceInformation); | 120 new ApplyBuiltinMethod(method, receiver, arguments, sourceInformation); |
121 apply.receiverIsNotNull = receiverIsNotNull; | 121 apply.receiverIsNotNull = receiverIsNotNull; |
122 return letPrim(apply); | 122 return letPrim(apply); |
123 } | 123 } |
124 | 124 |
125 /// Inserts an invocation. binds its continuation, and returns the | 125 /// Inserts an invocation. binds its continuation, and returns the |
126 /// continuation parameter (i.e. the return value of the invocation). | 126 /// continuation parameter (i.e. the return value of the invocation). |
127 /// | 127 /// |
128 /// The continuation body becomes the new hole. | 128 /// The continuation body becomes the new hole. |
129 Parameter invokeMethod(Primitive receiver, | 129 Parameter invokeMethod(Primitive receiver, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 letPrim(new SetMutable(variable, value)); | 291 letPrim(new SetMutable(variable, value)); |
292 } | 292 } |
293 | 293 |
294 /// Declare a new mutable variable. | 294 /// Declare a new mutable variable. |
295 void letMutable(MutableVariable variable, Primitive initialValue) { | 295 void letMutable(MutableVariable variable, Primitive initialValue) { |
296 LetMutable let = new LetMutable(variable, initialValue); | 296 LetMutable let = new LetMutable(variable, initialValue); |
297 put(let); | 297 put(let); |
298 context = let; | 298 context = let; |
299 } | 299 } |
300 } | 300 } |
OLD | NEW |