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

Unified Diff: lib/compiler/implementation/compile_time_constants.dart

Issue 10916002: Change switch to give errors when cases don't follow the newest syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: use .compileType on elements. Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compile_time_constants.dart
diff --git a/lib/compiler/implementation/compile_time_constants.dart b/lib/compiler/implementation/compile_time_constants.dart
index 6fde51a2fe69b7596e76ba03acf3bfb4394d552f..12f5ad6056f37b36e272fe1afe525833566f8b74 100644
--- a/lib/compiler/implementation/compile_time_constants.dart
+++ b/lib/compiler/implementation/compile_time_constants.dart
@@ -24,6 +24,8 @@ class Constant implements Hashable {
bool isNaN() => false;
+ abstract DartType computeType(ConstantHandler handler);
ngeoffray 2012/09/06 09:28:55 Please take a Compiler here instead of the Constan
Lasse Reichstein Nielsen 2012/09/06 12:03:36 Good point. I was trying to not make Constant depe
Lasse Reichstein Nielsen 2012/09/11 12:20:23 Done by someone else. Yey.
+
abstract void _writeJsCode(CodeBuffer buffer, ConstantHandler handler);
/**
* Unless the constant can be emitted multiple times (as for numbers and
@@ -94,6 +96,9 @@ class NullConstant extends PrimitiveConstant {
const NullConstant._internal();
bool isNull() => true;
get value => null;
+ DartType computeType(ConstantHandler handler) {
+ return handler.compiler.nullClass.computeType(handler.compiler);
+ }
void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
buffer.add(JsNull);
@@ -133,6 +138,10 @@ class IntConstant extends NumConstant {
const IntConstant._internal(this.value);
bool isInt() => true;
+ DartType computeType(ConstantHandler handler) {
+ return handler.compiler.intClass.computeType(handler.compiler);
+ }
+
void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
buffer.add("$value");
}
@@ -172,6 +181,11 @@ class DoubleConstant extends NumConstant {
bool isDouble() => true;
bool isNaN() => value.isNaN();
+ DartType computeType(ConstantHandler handler) {
+ return handler.compiler.doubleClass.computeType(handler.compiler);
+ }
+
+
void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
if (value.isNaN()) {
buffer.add("(0/0)");
@@ -208,6 +222,10 @@ class BoolConstant extends PrimitiveConstant {
const BoolConstant._internal();
bool isBool() => true;
+ DartType computeType(ConstantHandler handler) {
+ return handler.compiler.boolClass.computeType(handler.compiler);
+ }
+
BoolConstant unaryFold(String op) {
if (op == "!") return new BoolConstant(!value);
return null;
@@ -269,6 +287,10 @@ class StringConstant extends PrimitiveConstant {
}
bool isString() => true;
+ DartType computeType(ConstantHandler handler) {
+ return handler.compiler.stringClass.computeType(handler.compiler);
+ }
+
void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
buffer.add("'");
ConstantHandler.writeEscapedString(value, buffer, (reason) {
@@ -294,10 +316,10 @@ class ObjectConstant extends Constant {
ObjectConstant(this.type);
bool isObject() => true;
- // TODO(1603): The class should be marked as abstract, but the VM doesn't
- // currently allow this.
abstract int hashCode();
+ DartType computeType(ConstantHandler handler) => type;
+
void _writeCanonicalizedJsCode(CodeBuffer buffer, ConstantHandler handler) {
String name = handler.getNameForConstant(this);
buffer.add(handler.compiler.namer.isolatePropertiesAccessForConstant(name));
« no previous file with comments | « no previous file | lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698