| 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/selector.dart' show Selector; | 9 import '../universe/selector.dart' show Selector; |
| 10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return prim; | 97 return prim; |
| 98 } | 98 } |
| 99 | 99 |
| 100 /// Bind a constant value. | 100 /// Bind a constant value. |
| 101 Primitive makeConstant(ConstantValue constant) { | 101 Primitive makeConstant(ConstantValue constant) { |
| 102 return letPrim(new Constant(constant)); | 102 return letPrim(new Constant(constant)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 Primitive makeZero() => makeConstant(new IntConstantValue(0)); | 105 Primitive makeZero() => makeConstant(new IntConstantValue(0)); |
| 106 Primitive makeOne() => makeConstant(new IntConstantValue(1)); | 106 Primitive makeOne() => makeConstant(new IntConstantValue(1)); |
| 107 Primitive makeMinusOne() => makeConstant(new IntConstantValue(-1)); |
| 107 Primitive makeNull() => makeConstant(new NullConstantValue()); | 108 Primitive makeNull() => makeConstant(new NullConstantValue()); |
| 108 Primitive makeTrue() => makeConstant(new TrueConstantValue()); | 109 Primitive makeTrue() => makeConstant(new TrueConstantValue()); |
| 109 Primitive makeFalse() => makeConstant(new FalseConstantValue()); | 110 Primitive makeFalse() => makeConstant(new FalseConstantValue()); |
| 110 | 111 |
| 111 /// Invoke a built-in operator. | 112 /// Invoke a built-in operator. |
| 112 Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) { | 113 Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) { |
| 113 return letPrim(new ApplyBuiltinOperator(op, args, sourceInformation)); | 114 return letPrim(new ApplyBuiltinOperator(op, args, sourceInformation)); |
| 114 } | 115 } |
| 115 | 116 |
| 117 Primitive refine(Primitive value, TypeMask type) { |
| 118 return letPrim(new Refinement(value, type)); |
| 119 } |
| 120 |
| 116 Primitive invokeBuiltin(BuiltinMethod method, | 121 Primitive invokeBuiltin(BuiltinMethod method, |
| 117 Primitive receiver, | 122 Primitive receiver, |
| 118 List<Primitive> arguments, | 123 List<Primitive> arguments, |
| 119 {bool receiverIsNotNull: false}) { | 124 {bool receiverIsNotNull: false}) { |
| 120 ApplyBuiltinMethod apply = | 125 ApplyBuiltinMethod apply = |
| 121 new ApplyBuiltinMethod(method, receiver, arguments, sourceInformation); | 126 new ApplyBuiltinMethod(method, receiver, arguments, sourceInformation); |
| 122 apply.receiverIsNotNull = receiverIsNotNull; | 127 apply.receiverIsNotNull = receiverIsNotNull; |
| 123 return letPrim(apply); | 128 return letPrim(apply); |
| 124 } | 129 } |
| 125 | 130 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 339 } |
| 335 } | 340 } |
| 336 | 341 |
| 337 /// Removes [node], unlinking all its references and replaces it with [newNode]. | 342 /// Removes [node], unlinking all its references and replaces it with [newNode]. |
| 338 void destroyAndReplace(Expression node, Expression newNode) { | 343 void destroyAndReplace(Expression node, Expression newNode) { |
| 339 InteriorNode parent = node.parent; | 344 InteriorNode parent = node.parent; |
| 340 RemovalVisitor.remove(node); | 345 RemovalVisitor.remove(node); |
| 341 parent.body = newNode; | 346 parent.body = newNode; |
| 342 newNode.parent = parent; | 347 newNode.parent = parent; |
| 343 } | 348 } |
| OLD | NEW |