Index: pkg/compiler/lib/src/constant_system_dart.dart |
diff --git a/pkg/compiler/lib/src/constant_system_dart.dart b/pkg/compiler/lib/src/constant_system_dart.dart |
index 4a15ac9aff7cba10487fe95cb9a8086619ee39ea..25adefb1f6060d04db817a7aaf8466489132746b 100644 |
--- a/pkg/compiler/lib/src/constant_system_dart.dart |
+++ b/pkg/compiler/lib/src/constant_system_dart.dart |
@@ -9,6 +9,9 @@ import 'compiler.dart' show |
import 'constants/constant_system.dart'; |
import 'constants/values.dart'; |
import 'dart_types.dart'; |
+import 'elements/elements.dart' show |
+ ClassElement, |
+ FieldElement; |
import 'tree/tree.dart' show |
DartString; |
@@ -319,6 +322,22 @@ class EqualsOperation implements BinaryOperation { |
apply(left, right) => left == right; |
} |
+class NotEqualsOperation implements BinaryOperation { |
+ final String name = '!='; |
+ const NotEqualsOperation(); |
+ |
+ @override |
+ ConstantValue fold(ConstantValue left, ConstantValue right) { |
+ BoolConstantValue result = const EqualsOperation().fold(left, right); |
+ if (result != null) { |
+ result = result.negate(); |
+ } |
+ return result; |
+ } |
+ |
+ apply(left, right) => left != right; |
+} |
+ |
class IdentityOperation implements BinaryOperation { |
final String name = '==='; |
const IdentityOperation(); |
@@ -388,6 +407,7 @@ class DartConstantSystem extends ConstantSystem { |
final multiply = const MultiplyOperation(); |
final negate = const NegateOperation(); |
final not = const NotOperation(); |
+ final notEqual = const NotEqualsOperation(); |
final shiftLeft = const ShiftLeftOperation(); |
final shiftRight = const ShiftRightOperation(); |
final subtract = const SubtractOperation(); |
@@ -437,6 +457,20 @@ class DartConstantSystem extends ConstantSystem { |
compiler.backend.typeImplementation.computeType(compiler.resolution)); |
} |
+ @override |
+ ConstantValue createSymbol(Compiler compiler, String text) { |
+ // TODO(johnniwinther): Create a backend agnostic value. |
+ InterfaceType type = compiler.symbolClass.rawType; |
+ ConstantValue argument = createString(new DartString.literal(text)); |
+ Map<FieldElement, ConstantValue> fields = <FieldElement, ConstantValue>{}; |
+ compiler.symbolImplementationClass.forEachInstanceField( |
+ (ClassElement enclosingClass, FieldElement field) { |
+ fields[field] = argument; |
+ }); |
+ assert(fields.length == 1); |
+ return new ConstructedConstantValue(type, fields); |
+ } |
+ |
bool isInt(ConstantValue constant) => constant.isInt; |
bool isDouble(ConstantValue constant) => constant.isDouble; |
bool isString(ConstantValue constant) => constant.isString; |