| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 serialization.summarize_const_expr; | 5 library serialization.summarize_const_expr; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/scanner.dart'; | 8 import 'package:analyzer/src/generated/scanner.dart'; |
| 9 import 'package:analyzer/src/summary/format.dart'; | 9 import 'package:analyzer/src/summary/format.dart'; |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 UnlinkedConstBuilder toBuilder() { | 119 UnlinkedConstBuilder toBuilder() { |
| 120 return new UnlinkedConstBuilder( | 120 return new UnlinkedConstBuilder( |
| 121 operations: operations, | 121 operations: operations, |
| 122 ints: ints, | 122 ints: ints, |
| 123 doubles: doubles, | 123 doubles: doubles, |
| 124 strings: strings, | 124 strings: strings, |
| 125 references: references); | 125 references: references); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void _pushInt(int value) { | 128 void _pushInt(int value) { |
| 129 // TODO(scheglov) add support for arbitrary precision ints | 129 assert(value >= 0); |
| 130 assert(value.abs() < (2 << 31)); | 130 if (value >= (1 << 32)) { |
| 131 ints.add(value & 0xFFFFFFFF); | 131 _pushInt(value >> 32); |
| 132 operations.add(UnlinkedConstOperation.pushInt); | 132 operations.add(UnlinkedConstOperation.shiftOr); |
| 133 ints.add(value & 0xFFFFFFFF); |
| 134 } else { |
| 135 operations.add(UnlinkedConstOperation.pushInt); |
| 136 ints.add(value); |
| 137 } |
| 133 } | 138 } |
| 134 | 139 |
| 135 void _serializeBinaryExpression(BinaryExpression expr) { | 140 void _serializeBinaryExpression(BinaryExpression expr) { |
| 136 serialize(expr.leftOperand); | 141 serialize(expr.leftOperand); |
| 137 serialize(expr.rightOperand); | 142 serialize(expr.rightOperand); |
| 138 TokenType operator = expr.operator.type; | 143 TokenType operator = expr.operator.type; |
| 139 if (operator == TokenType.EQ_EQ) { | 144 if (operator == TokenType.EQ_EQ) { |
| 140 operations.add(UnlinkedConstOperation.equal); | 145 operations.add(UnlinkedConstOperation.equal); |
| 141 } else if (operator == TokenType.BANG_EQ) { | 146 } else if (operator == TokenType.BANG_EQ) { |
| 142 operations.add(UnlinkedConstOperation.equal); | 147 operations.add(UnlinkedConstOperation.equal); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 * Error that describes a problem during a constant expression serialization. | 278 * Error that describes a problem during a constant expression serialization. |
| 274 */ | 279 */ |
| 275 class _ConstExprSerializationError { | 280 class _ConstExprSerializationError { |
| 276 final String message; | 281 final String message; |
| 277 | 282 |
| 278 _ConstExprSerializationError(this.message); | 283 _ConstExprSerializationError(this.message); |
| 279 | 284 |
| 280 @override | 285 @override |
| 281 String toString() => message; | 286 String toString() => message; |
| 282 } | 287 } |
| OLD | NEW |