Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: lib/compiler/implementation/compile_time_constants.dart

Issue 10001008: Many type fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return new StringConstant(new DartString.concat(left.value, right.value)); 788 return new StringConstant(new DartString.concat(left.value, right.value));
789 } 789 }
790 790
791 Constant visitStringInterpolation(StringInterpolation node) { 791 Constant visitStringInterpolation(StringInterpolation node) {
792 StringConstant initialString = evaluate(node.string); 792 StringConstant initialString = evaluate(node.string);
793 DartString accumulator = initialString.value; 793 DartString accumulator = initialString.value;
794 for (StringInterpolationPart part in node.parts) { 794 for (StringInterpolationPart part in node.parts) {
795 Constant expression = evaluate(part.expression); 795 Constant expression = evaluate(part.expression);
796 DartString expressionString; 796 DartString expressionString;
797 if (expression.isNum() || expression.isBool()) { 797 if (expression.isNum() || expression.isBool()) {
798 Object value = expression.value; 798 PrimitiveConstant primitive = expression;
799 expressionString = new DartString.literal(value.toString()); 799 expressionString = new DartString.literal(primitive.value.toString());
800 } else if (expression.isString()) { 800 } else if (expression.isString()) {
801 expressionString = expression.value; 801 PrimitiveConstant primitive = expression;
802 expressionString = primitive.value;
802 } else { 803 } else {
803 error(part.expression); 804 error(part.expression);
804 } 805 }
805 accumulator = new DartString.concat(accumulator, expressionString); 806 accumulator = new DartString.concat(accumulator, expressionString);
806 StringConstant partString = evaluate(part.string); 807 StringConstant partString = evaluate(part.string);
807 accumulator = new DartString.concat(accumulator, partString.value); 808 accumulator = new DartString.concat(accumulator, partString.value);
808 }; 809 };
809 return new StringConstant(accumulator); 810 return new StringConstant(accumulator);
810 } 811 }
811 812
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 Constant fieldValue = fieldValues[field]; 1126 Constant fieldValue = fieldValues[field];
1126 if (fieldValue === null) { 1127 if (fieldValue === null) {
1127 // Use the default value. 1128 // Use the default value.
1128 fieldValue = compiler.compileVariable(field); 1129 fieldValue = compiler.compileVariable(field);
1129 } 1130 }
1130 jsNewArguments.add(fieldValue); 1131 jsNewArguments.add(fieldValue);
1131 }); 1132 });
1132 return jsNewArguments; 1133 return jsNewArguments;
1133 } 1134 }
1134 } 1135 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698