1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
package tinybasic;
import antlr.collections.AST;
public abstract class DTDataType {
protected Scope scope;
protected int theType;
protected static int INT_VAR = TinyBasicTokenTypes.INT_VAR;
protected static int FLT_VAR = TinyBasicTokenTypes.FLT_VAR;
protected static int STR_VAR = TinyBasicTokenTypes.STR_VAR;
protected static int INT_CONST = TinyBasicTokenTypes.INT_CONST;
protected static int FLT_CONST = TinyBasicTokenTypes.FLT_CONST;
protected static int STR_CONST = TinyBasicTokenTypes.STR_CONST;
public DTDataType(Scope scope,int _ttype){
this.scope=scope;
theType=_ttype;
}
public int getType(){
return theType;
}
public int getInteger () { return 12345; }
public double getFloat () { return 12345.0;}
public String getString () { return null; }
public void setInteger (DTDataType tbd){setInteger (tbd.getInteger ());}
public void setFloat (DTDataType tbd){setFloat (tbd.getFloat ());}
public void setString (DTDataType tbd){setString (tbd.getString ());}
public void setInteger (int i){}
public void setFloat (double d){}
public void setString (String s){}
public DTDataType getDTDataType(DTDataType i1){return null;}
public DTDataType getDTDataType(DTDataType i1,DTDataType i2){return null;}
public DTDataType getDTDataType(DTDataType i1,DTDataType i2,DTDataType i3){return null;}
public void setDTDataType(DTDataType i1,DTDataType s){}
public void setDTDataType(DTDataType i1,DTDataType i2,DTDataType s){}
public void setDTDataType(DTDataType i1,DTDataType i2,DTDataType i3,DTDataType s){}
public void assign(DTDataType tbd){}
public int getDimension(){return 0;}
public int getDimensioned(int i){return 0;}
public DTDataType multiply(DTDataType other) { return null;}
public DTDataType divide(DTDataType other) { return null;}
public DTDataType add(DTDataType other) { return null;}
public DTDataType subtract(DTDataType other) { return null;}
public DTDataType mod(DTDataType other) { return null;}
public DTDataType round(DTDataType other) { return null;}
public DTDataType truncate(DTDataType other) { return null;}
protected DTDataType getOne(){
return getOne(theType,scope);
}
public static DTDataType getOne(int aType,Scope scope){
if ( aType==INT_CONST ){
return new DTInteger(scope,0);
} else if ( aType==INT_VAR ){
return new DTInteger(scope,0);
} else if ( aType==FLT_CONST ){
return new DTFloat (scope,0.0);
} else if ( aType==FLT_VAR ){
return new DTFloat (scope,0.0);
} else if ( aType==STR_CONST ){
return new DTString (scope,"");
} else if ( aType==STR_VAR ){
return new DTString (scope,"");
}
return null;
}
protected DTDataType getOne(DTDataType s){
DTDataType t=getOne();
t.assign(s);
return t;
}
public DTDataType cloneDTDataType()
{
return getOne(this);
}
public void setDimension(int i1){
}
public void setDimension(int i1,int i2){
}
public void setDimension(int i1,int i2,int i3){
}
public abstract int compareTo(Object o);
public void attach(DTDataType theBoss){}
}
|