| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
| 6 /** | 6 /** |
| 7 * Represents a meta-value for code generation. | 7 * Represents a meta-value for code generation. |
| 8 */ | 8 */ |
| 9 class Value { | 9 class Value { |
| 10 /** The inferred (i.e. most precise) [Type] of the [Value]. */ | 10 /** The inferred (i.e. most precise) [Type] of the [Value]. */ |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 final Value value; | 1331 final Value value; |
| 1332 | 1332 |
| 1333 VariableValue(Type staticType, String code, SourceSpan span, | 1333 VariableValue(Type staticType, String code, SourceSpan span, |
| 1334 [this.isFinal=false, Value value]): | 1334 [this.isFinal=false, Value value]): |
| 1335 value = _unwrap(value), | 1335 value = _unwrap(value), |
| 1336 super(staticType, code, span) { | 1336 super(staticType, code, span) { |
| 1337 | 1337 |
| 1338 // these are not really first class | 1338 // these are not really first class |
| 1339 assert(value === null || !value.isType && !value.isSuper); | 1339 assert(value === null || !value.isType && !value.isSuper); |
| 1340 | 1340 |
| 1341 // Value should've been converted already | 1341 // TODO(jmesserly): should we do convertTo here, so the check doesn't get |
| 1342 // TODO(jmesserly): should this setter do the conversion? | 1342 // missed? There are some cases where this assert doesn't hold. |
| 1343 // Or maybe we should we have an "assign" method that returns a Value with | 1343 // assert(value === null || value.staticType == staticType); |
| 1344 // code to do the assignment? | |
| 1345 assert(value === null || value.staticType == staticType); | |
| 1346 } | 1344 } |
| 1347 | 1345 |
| 1348 static Value _unwrap(Value v) { | 1346 static Value _unwrap(Value v) { |
| 1349 if (v === null) return null; | 1347 if (v === null) return null; |
| 1350 if (v is ConvertedValue) { | 1348 if (v is ConvertedValue) { |
| 1351 v = v.dynamic.value; | 1349 v = v.dynamic.value; |
| 1352 } | 1350 } |
| 1353 if (v is VariableValue) { | 1351 if (v is VariableValue) { |
| 1354 v = v.dynamic.value; | 1352 v = v.dynamic.value; |
| 1355 } | 1353 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1376 } | 1374 } |
| 1377 return super.unop(kind, context, node); | 1375 return super.unop(kind, context, node); |
| 1378 } | 1376 } |
| 1379 Value binop(int kind, var other, MethodGenerator context, var node) { | 1377 Value binop(int kind, var other, MethodGenerator context, var node) { |
| 1380 if (value != null) { | 1378 if (value != null) { |
| 1381 return replaceValue(value.binop(kind, _unwrap(other), context, node)); | 1379 return replaceValue(value.binop(kind, _unwrap(other), context, node)); |
| 1382 } | 1380 } |
| 1383 return super.binop(kind, other, context, node); | 1381 return super.binop(kind, other, context, node); |
| 1384 } | 1382 } |
| 1385 } | 1383 } |
| OLD | NEW |