001: package sisc.data;
002:
003: import java.io.*;
004: import sisc.interpreter.*;
005: import sisc.io.ValueWriter;
006: import sisc.ser.Serializer;
007: import sisc.ser.Deserializer;
008: import sisc.util.ExpressionVisitor;
009:
010: public class Values extends Value {
011: public Value[] values;
012:
013: public Values(Value[] v) {
014: values = v;
015: }
016:
017: public void display(ValueWriter w) throws IOException {
018: for (int i = 0; i < values.length - 1; i++) {
019: w.append(values[i]).append('\n');
020: }
021: if (values.length > 0)
022: w.append(values[values.length - 1]);
023: }
024:
025: public void eval(Interpreter r) throws ContinuationException {
026: error(r, liMessage(SISCB, "multiplevalues"));
027: }
028:
029: public boolean equals(Object v) {
030: if (!(v instanceof Values))
031: return false;
032: Values vs = (Values) v;
033: if (vs.values.length != values.length)
034: return false;
035: for (int i = values.length - 1; i >= 0; i--)
036: if (!values[i].equals(vs.values[i]))
037: return false;
038: return true;
039: }
040:
041: public int hashCode() {
042: int hc = 0;
043: for (int i = 0; i < values.length; i++)
044: hc ^= values[i].hashCode();
045: return hc;
046: }
047:
048: public void serialize(Serializer s) throws IOException {
049: s.writeInt(values.length);
050: for (int i = 0; i < values.length; i++) {
051: s.writeExpression(values[i]);
052: }
053: }
054:
055: public Values() {
056: }
057:
058: public void deserialize(Deserializer s) throws IOException {
059: int size = s.readInt();
060: values = new Value[size];
061: for (int i = 0; i < size; i++) {
062: values[i] = (Value) s.readExpression();
063: }
064: }
065:
066: public boolean visit(ExpressionVisitor v) {
067: for (int i = 0; i < values.length; i++) {
068: if (!v.visit(values[i]))
069: return false;
070: }
071: return true;
072: }
073: }
074: /*
075: * The contents of this file are subject to the Mozilla Public
076: * License Version 1.1 (the "License"); you may not use this file
077: * except in compliance with the License. You may obtain a copy of
078: * the License at http://www.mozilla.org/MPL/
079: *
080: * Software distributed under the License is distributed on an "AS
081: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
082: * implied. See the License for the specific language governing
083: * rights and limitations under the License.
084: *
085: * The Original Code is the Second Interpreter of Scheme Code (SISC).
086: *
087: * The Initial Developer of the Original Code is Scott G. Miller.
088: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
089: * Scott G. Miller. All Rights Reserved.
090: *
091: * Contributor(s):
092: * Matthias Radestock
093: *
094: * Alternatively, the contents of this file may be used under the
095: * terms of the GNU General Public License Version 2 or later (the
096: * "GPL"), in which case the provisions of the GPL are applicable
097: * instead of those above. If you wish to allow use of your
098: * version of this file only under the terms of the GPL and not to
099: * allow others to use your version of this file under the MPL,
100: * indicate your decision by deleting the provisions above and
101: * replace them with the notice and other provisions required by
102: * the GPL. If you do not delete the provisions above, a recipient
103: * may use your version of this file under either the MPL or the
104: * GPL.
105: */
|