| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/NullState.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/NullState.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/NullState.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a4caca920fe5eb621e04fa811f5da53d1e2fe799
|
| --- /dev/null
|
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/NullState.java
|
| @@ -0,0 +1,82 @@
|
| +/*
|
| + * 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.error.CompileTimeErrorCode;
|
| +
|
| +/**
|
| + * The unique instance of the class {@code NullState} represents the state of the value 'null'.
|
| + */
|
| +public class NullState extends InstanceState {
|
| + /**
|
| + * An instance representing the boolean value 'true'.
|
| + */
|
| + public static final NullState NULL_STATE = new NullState();
|
| +
|
| + /**
|
| + * Initialize a newly created state to represent the value 'null'.
|
| + */
|
| + private NullState() {
|
| + super();
|
| + }
|
| +
|
| + @Override
|
| + public BoolState convertToBool() throws EvaluationException {
|
| + throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
|
| + }
|
| +
|
| + @Override
|
| + public StringState convertToString() {
|
| + return new StringState("null");
|
| + }
|
| +
|
| + @Override
|
| + public BoolState equalEqual(InstanceState rightOperand) throws EvaluationException {
|
| + assertBoolNumStringOrNull(rightOperand);
|
| + if (rightOperand instanceof DynamicState) {
|
| + return BoolState.UNKNOWN_VALUE;
|
| + }
|
| + return BoolState.from(rightOperand instanceof NullState);
|
| + }
|
| +
|
| + @Override
|
| + public boolean equals(Object object) {
|
| + return object instanceof NullState;
|
| + }
|
| +
|
| + @Override
|
| + public String getTypeName() {
|
| + return "Null"; //$NON-NLS-0$
|
| + }
|
| +
|
| + @Override
|
| + public int hashCode() {
|
| + return 0;
|
| + }
|
| +
|
| + @Override
|
| + public boolean isBoolNumStringOrNull() {
|
| + return true;
|
| + }
|
| +
|
| + @Override
|
| + public BoolState logicalNot() throws EvaluationException {
|
| + throw new EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
|
| + }
|
| +
|
| + @Override
|
| + public String toString() {
|
| + return "null";
|
| + }
|
| +}
|
|
|