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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/TypeState.java

Issue 113143004: Constant evaluation support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean-up Created 7 years 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/TypeState.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/TypeState.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/TypeState.java
new file mode 100644
index 0000000000000000000000000000000000000000..59c79b5c55f9717bac06a9eda1877525bea938ae
--- /dev/null
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/TypeState.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013, the Dart project authors.
+ *
+ * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.dart.engine.internal.object;
+
+import com.google.dart.engine.element.Element;
+import com.google.dart.engine.utilities.general.ObjectUtilities;
+
+/**
+ * Instances of the class {@code TypeState} represent the state of an object representing a type.
+ */
+public class TypeState extends InstanceState {
+ /**
+ * The element representing the type being modeled.
+ */
+ private Element element;
+
+ /**
+ * Initialize a newly created state to represent the given value.
+ *
+ * @param element the element representing the type being modeled
+ */
+ public TypeState(Element element) {
+ this.element = element;
+ }
+
+ @Override
+ public StringState convertToString() throws EvaluationException {
+ if (element == null) {
+ return StringState.UNKNOWN_VALUE;
+ }
+ return new StringState(element.getName());
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return object instanceof TypeState
+ && ObjectUtilities.equals(element, ((TypeState) object).element);
+ }
+
+ @Override
+ public BoolState equalEqual(InstanceState rightOperand) throws EvaluationException {
+ assertBoolNumStringOrNull(rightOperand);
+ if (element == null) {
+ return BoolState.UNKNOWN_VALUE;
+ }
+ if (rightOperand instanceof TypeState) {
+ Element rightElement = ((TypeState) rightOperand).element;
+ if (rightElement == null) {
+ return BoolState.UNKNOWN_VALUE;
+ }
+ return BoolState.from(element.equals(rightElement));
+ } else if (rightOperand instanceof DynamicState) {
+ return BoolState.UNKNOWN_VALUE;
+ }
+ return BoolState.FALSE_STATE;
+ }
+
+ @Override
+ public String getTypeName() {
+ return "Type"; //$NON-NLS-0$
+ }
+
+ @Override
+ public int hashCode() {
+ return element == null ? 0 : element.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return element == null ? "-unknown-" : element.getName();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698