package element.obj;

public abstract class Obj {	
	
	public static final byte UNKNOWN = -1;
	
	public static final byte ANY = 0;

	public static final byte NUMBER = 1;
	public static final byte NUM = 11;
	public static final byte BIGNUM = 12;
	public static final byte RATIONAL_NUMBER = 13;
	
	public static final byte LIST = 2;
	public static final byte STR = 21;
	public static final byte NUMBERLIST = 22;
	public static final byte NUMBERITEMLIST = 23;
	public static final byte OBJLIST = 24;

	public static final byte CHAR = 3;
	
	public static final byte DICT = 4;
	
	public static final byte BLOCK = 5;

	public static final byte USEROBJ = 6;
	
	public static String typeName(byte type) {
		switch (type) {
		case NUM:
			return "NUM";
		case BIGNUM:
			return "BIGNUM";
		case RATIONAL_NUMBER:
			return "RATIONAL_NUMBER";
		case STR:
			return "STR";
		case NUMBERITEMLIST:
			return "NUMBERITEMLIST";
		case OBJLIST:
			return "OBJLIST";
		case CHAR:
			return "CHAR";
		case DICT:
			return "DICT";
		case ANY:
			return "ANY";
		default:
			return "Obj.typeName(" + type + ") not set up.";				
		}
	}
	
	/** Converts an ID to a char abbreviation */
	public static char IDToAbbrv(byte b) {
		switch(b) {
		//case BOOL : return 'B';
		case CHAR : return 'C' ;
		case NUM : return 'D';
		case BLOCK : return 'E';
		case BIGNUM : return 'F';
		case LIST : return 'L';
		case STR : return 'S';
		case NUMBER : return 'N';
		case DICT : return 'R';
		case ANY : return 'A';
		//case MODULE : return 'M';
		//case USER_OBJ : return 'U';
		default: return '?';
		}
	}
	
	/** Converts a character abbreviation to its ID */
	public static byte abbrvToID(char c) {
		switch(c) {
			//case 'B': return BOOL;
			//case 'C': return CHARACTER;
			case 'D': return NUM;
			case 'E': return BLOCK;
			case 'F': return BIGNUM;
			case 'L': return LIST;
			case 'S': return STR;
			case 'N': return NUMBER;
			case 'C': return CHAR;
			case 'A': return ANY;
			case 'R': return DICT;
			//case 'M': return MODULE;
			//case 'U': return USER_OBJ;
			default: return UNKNOWN;
		}
	}
	
	
	
	public abstract Obj deepcopy();
	public abstract boolean bool();
	public abstract String repr();
	public abstract String str();
	public abstract boolean equiv(Obj o);
	public abstract boolean isa(byte type);
	public abstract byte type();
	
	@Override
	public String toString() {
		return this.repr();
	}
	
	@Override
	public boolean equals(Object o) {
		return this.equiv((Obj)o);
	}
}

@@ -21,36 +21,182 @@
 %0D%0A%0D%0A
-public abstract class Obj %7B%09
+/**%0D%0A * Superclass for all runtime objects existing on the stack%0D%0A * @author Nick%0D%0A *%0D%0A */%0D%0Apublic abstract class Obj %7B%09%0D%0A%09%0D%0A%09//////////////%0D%0A%09// TYPE IDS //%0D%0A%09//////////////
 %0D%0A%09%0D
@@ -814,24 +814,158 @@
 BJ = 6;%0D%0A%09%0D%0A
+%09%0D%0A%09%0D%0A%09%0D%0A%09////////////////////%0D%0A%09// TYPE UTILITIES //%0D%0A%09////////////////////%0D%0A%09%0D%0A%09/** Given the typeId, return the full type name */%0D%0A
 %09public stat
@@ -1679,24 +1679,28 @@
 eturn 'F';%0D%0A
+%09%09%0D%0A
 %09%09case LIST 
@@ -1710,24 +1710,128 @@
 eturn 'L';%0D%0A
+%09%09case NUMBERLIST : return 'L';%0D%0A%09%09case NUMBERITEMLIST : return 'L';%0D%0A%09%09case OBJLIST : return 'L';%0D%0A%09%09%0D%0A
 %09%09case STR :
@@ -1930,70 +1930,8 @@
 ';%0D%0A
-%09%09//case MODULE : return 'M';%0D%0A%09%09//case USER_OBJ : return 'U';
 %0D%0A%09%09
@@ -2490,16 +2490,52 @@
 %0A%09%0D%0A%09%0D%0A%09
+/** Create a deep copy of the obj */
 %0D%0A%09publi
@@ -2567,72 +2567,288 @@
 ;%0D%0A%09
-public abstract boolean bool();%0D%0A%09public abstract String repr();
+%0D%0A%09/** Return the bool value of the object */%0D%0A%09public abstract boolean bool();%0D%0A%09%0D%0A%09/** Return a string representation of the object%0D%0A%09 * used for printing to the console during interactive%0D%0A%09 * sessions%0D%0A%09 */%0D%0A%09public abstract String repr();%0D%0A%09%0D%0A%09/** Cast the obj to a string */
 %0D%0A%09p
@@ -2873,24 +2873,53 @@
 ing str();%0D%0A
+%09%0D%0A%09/** Equivalence test */%0D%0A
 %09public abst
@@ -2951,47 +2951,177 @@
 ;%0D%0A%09
-public abstract boolean isa(byte type);
+%0D%0A%09/** Returns true if the item is a type or sub-type of the given id */%0D%0A%09public abstract boolean isa(byte type);%0D%0A%09%0D%0A%09/** Returns the object's most specific type id */
 %0D%0A%09p

Add docs to Obj.java