| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/ListState.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/ListState.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/ListState.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a22ca0692ceb95b251165e8bb49b884662cc2526
|
| --- /dev/null
|
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/ListState.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;
|
| +
|
| +/**
|
| + * The unique instance of the class {@code ListState} represents the state of an object representing
|
| + * a list.
|
| + */
|
| +public class ListState extends InstanceState {
|
| + /**
|
| + * The elements of the list.
|
| + */
|
| + private DartObjectImpl[] elements;
|
| +
|
| + /**
|
| + * Initialize a newly created state to represent a list with the given elements.
|
| + *
|
| + * @param elements the elements of the list
|
| + */
|
| + public ListState(DartObjectImpl[] elements) {
|
| + this.elements = elements;
|
| + }
|
| +
|
| + @Override
|
| + public StringState convertToString() {
|
| + return StringState.UNKNOWN_VALUE;
|
| + }
|
| +
|
| + @Override
|
| + public boolean equals(Object object) {
|
| + if (!(object instanceof ListState)) {
|
| + return false;
|
| + }
|
| + DartObjectImpl[] otherElements = ((ListState) object).elements;
|
| + int count = elements.length;
|
| + if (otherElements.length != count) {
|
| + return false;
|
| + } else if (count == 0) {
|
| + return true;
|
| + }
|
| + for (int i = 0; i < count; i++) {
|
| + if (!elements[i].equals(otherElements[i])) {
|
| + return false;
|
| + }
|
| + }
|
| + return true;
|
| + }
|
| +
|
| + @Override
|
| + public BoolState equalEqual(InstanceState rightOperand) throws EvaluationException {
|
| + assertBoolNumStringOrNull(rightOperand);
|
| + if (rightOperand instanceof DynamicState) {
|
| + return BoolState.UNKNOWN_VALUE;
|
| + }
|
| + return BoolState.from(equals(rightOperand));
|
| + }
|
| +
|
| + @Override
|
| + public String getTypeName() {
|
| + return "List"; //$NON-NLS-0$
|
| + }
|
| +
|
| + @Override
|
| + public int hashCode() {
|
| + int value = 0;
|
| + int count = elements.length;
|
| + for (int i = 0; i < count; i++) {
|
| + value = (value << 3) ^ elements[i].hashCode();
|
| + }
|
| + return value;
|
| + }
|
| +}
|
|
|