package orc.trace.values;

import java.io.IOException;
import java.io.Serializable;
import java.io.Writer;

import xtc.util.Utilities;

/**
 * Constant (not just immutable, but atomic) value,
 * such as a String, Number, Boolean, or Character.
 * @author quark
 */
public class ConstantValue extends AbstractValue {
	public final Serializable constant;
	public ConstantValue(final Serializable constant) {
		super();
		this.constant = constant;
	}
	public void prettyPrint(Writer out, int indent) throws IOException {
		if (constant instanceof String) {
			out.write('"' + Utilities.escape((String)constant, Utilities.JAVA_ESCAPES) + '"');
		} else out.write(constant.toString());
	}
	public boolean equals(Object that) {
		return that instanceof ConstantValue
				&& ((ConstantValue)that).constant.equals(constant);
	}
}

@@ -222,19 +222,16 @@
 Boolean,
- or
  Charact
@@ -232,16 +232,25 @@
 haracter
+, or null
 .%0A * @au
@@ -523,140 +523,42 @@
 %7B%0A%09%09
-if (constant instanceof String) %7B%0A%09%09%09out.write('%22' + Utilities.escape((String)constant, Utilities.JAVA_ESCAPES) + '%22');%0A%09%09%7D else out
+out.write(orc.runtime.values.Value
 .wri
@@ -572,18 +572,8 @@
 tant
-.toString(
 ));%0A
@@ -598,16 +598,22 @@
  equals(
+final 
 Object t
@@ -625,73 +625,205 @@
 %7B%0A%09%09
-return that instanceof ConstantValue%0A%09%09%09%09&& ((ConstantValue)that)
+if (that == null) return false;%0A%09%09if (!(that instanceof ConstantValue)) return false;%0A%09%09final ConstantValue cv = (ConstantValue)that;%0A%09%09if (cv.constant == null) return constant == null;%0A%09%09return cv
 .con

Fix bug with displaying/comparing null values in traces.