| 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 class Constant implements Hashable { | 5 class Constant implements Hashable { |
| 6 const Constant(); | 6 const Constant(); |
| 7 | 7 |
| 8 bool isNull() => false; | 8 bool isNull() => false; |
| 9 bool isBool() => false; | 9 bool isBool() => false; |
| 10 bool isTrue() => false; | 10 bool isTrue() => false; |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } | 605 } |
| 606 | 606 |
| 607 /** Attempts to compile a constant expression. Returns null if not possible */ | 607 /** Attempts to compile a constant expression. Returns null if not possible */ |
| 608 Constant tryCompileNodeWithDefinitions(Node node, TreeElements definitions) { | 608 Constant tryCompileNodeWithDefinitions(Node node, TreeElements definitions) { |
| 609 return measure(() { | 609 return measure(() { |
| 610 assert(node !== null); | 610 assert(node !== null); |
| 611 try { | 611 try { |
| 612 TryCompileTimeConstantEvaluator evaluator = | 612 TryCompileTimeConstantEvaluator evaluator = |
| 613 new TryCompileTimeConstantEvaluator(definitions, compiler); | 613 new TryCompileTimeConstantEvaluator(definitions, compiler); |
| 614 return evaluator.evaluate(node); | 614 return evaluator.evaluate(node); |
| 615 } catch (CompileTimeConstantError exn) { | 615 } on CompileTimeConstantError catch (exn) { |
| 616 return null; | 616 return null; |
| 617 } | 617 } |
| 618 }); | 618 }); |
| 619 } | 619 } |
| 620 | 620 |
| 621 /** | 621 /** |
| 622 * Returns a [List] of static non final fields that need to be initialized. | 622 * Returns a [List] of static non final fields that need to be initialized. |
| 623 * The list must be evaluated in order since the fields might depend on each | 623 * The list must be evaluated in order since the fields might depend on each |
| 624 * other. | 624 * other. |
| 625 */ | 625 */ |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 Constant fieldValue = fieldValues[field]; | 1210 Constant fieldValue = fieldValues[field]; |
| 1211 if (fieldValue === null) { | 1211 if (fieldValue === null) { |
| 1212 // Use the default value. | 1212 // Use the default value. |
| 1213 fieldValue = compiler.compileVariable(field); | 1213 fieldValue = compiler.compileVariable(field); |
| 1214 } | 1214 } |
| 1215 jsNewArguments.add(fieldValue); | 1215 jsNewArguments.add(fieldValue); |
| 1216 }); | 1216 }); |
| 1217 return jsNewArguments; | 1217 return jsNewArguments; |
| 1218 } | 1218 } |
| 1219 } | 1219 } |
| OLD | NEW |