package fr.lifl.stc.stan.execution.stack; /** * 16 Juillet 2004 * 15 fevrier 2005 * * @author yann * */ import org.apache.bcel.generic.Type; /** * * @author dorina * * Abstract representation of a primitive */ public class Value extends JvmType { static public int ARGUMENT_TYPE = 1, RETURNED_TYPE = 2, CONSTANT_TYPE = 3 ; static String types [] = {"","A", "R", "C"}; private int internalType; private int id; private boolean is32bits; //private Type t; //removed 06.03.2006 //private String typename; //private boolean exactType; ////////////////////////////////////////////////////////////// //// Constructors ////////////////////////////////////////////////////////////// /* static Value shortValue = new Value(1); static Value longValue = new Value(2); */ private static Value shortValue = new Value(-1, true); private static Value longValue = new Value(-2, false); private Value(int id, boolean is32bits) { super(); internalType = CONSTANT_TYPE; this.id = id; this.is32bits = is32bits; } public Value(int internalType, Type primitiveType, int line /*, String typename, boolean exact*/){ super(); this.internalType = internalType; this.id = line; //removed 06.03.2006 //this.exactType = exact;//TODO do we need this? //this.typename = typename; this.is32bits = (primitiveType.getSize() == 1); } private Value(int internalType, boolean is32bits, int line){ super(); this.internalType = internalType; this.id = line; this.is32bits = is32bits; } static public Value getShortInstance() { return shortValue; } static public Value getLongInstance() { return longValue; } ////////////////////////////////////////////////////////////// //// Getters and setters ////////////////////////////////////////////////////////////// public Type getType(){ //FIXME return Type.UNKNOWN; } public Object clone (){ Value v = new Value (internalType, is32bits , id); return v; } public boolean equals(Object r) { if (!(r instanceof Value)) return false; Value rr = (Value)r; return (internalType == rr.internalType) && (id == rr.id) && (is32bits == rr.is32bits); //&& (exactType == rr.exactType); } public int getId() { return id; } /* public String getTypeName() { return t.toString(); } */ public boolean isArgument() { return internalType == ARGUMENT_TYPE; } public boolean isConstant() { return internalType == CONSTANT_TYPE; } public boolean isReturned() { return internalType == RETURNED_TYPE; } public int typeSize() { return is32bits?1:2; } ////////////////////////////////////////////////////////////// //// ToString ////////////////////////////////////////////////////////////// public String toString() { return "P(" + types[internalType] + "," + id + ")\t"; } public String toHTML() { return toString(); } }