mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-22 23:29:34 +00:00
Added constant types as well as value of variable.
This commit is contained in:
parent
e677fe4baf
commit
3721db440e
@ -24,18 +24,24 @@ package com.webcodepro.applecommander.compiler;
|
||||
* @author Rob
|
||||
*/
|
||||
public class Variable {
|
||||
// FIXME: Should Variable have specific subclasses that handle the types appropriately?
|
||||
public static final int TYPE_STRING = 1;
|
||||
public static final int TYPE_INTEGER = 2;
|
||||
public static final int TYPE_FLOAT = 3;
|
||||
public static final int CONST_STRING = 4;
|
||||
public static final int CONST_INTEGER = 5;
|
||||
public static final int CONST_FLOAT = 6;
|
||||
private String name;
|
||||
private String value;
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* Construct a Variable.
|
||||
*/
|
||||
public Variable(String name, int type) {
|
||||
public Variable(String name, int type, String value) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,4 +78,46 @@ public class Variable {
|
||||
public boolean isTypeFloat() {
|
||||
return type == TYPE_FLOAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers true if this is a variable.
|
||||
*/
|
||||
public boolean isVariableType() {
|
||||
return isTypeFloat() || isTypeInteger() || isTypeString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers true if this is a string constant.
|
||||
*/
|
||||
public boolean isConstantString() {
|
||||
return type == CONST_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers true if this is an integer constant.
|
||||
*/
|
||||
public boolean isConstantInteger() {
|
||||
return type == CONST_INTEGER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers true if this is a floating point constant.
|
||||
*/
|
||||
public boolean isConstantFloat() {
|
||||
return type == CONST_FLOAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers true if this is a constant value.
|
||||
*/
|
||||
public boolean isConstant() {
|
||||
return isConstantString() || isConstantInteger() || isConstantFloat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user