value.java
来自「是有关解释器的.用JAVA编写.可以解释一般的JAVA程序.」· Java 代码 · 共 154 行
JAVA
154 行
/** Superclass for all values saveable in an Environment. */
public abstract class Value extends FoundValue {
boolean isValue() {
return true;
}
/**
* Checks the type of the value against the given string.
*
* @param typeName
* string describing the type to check for
*/
abstract boolean isOfType(String typeName);
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value plus(Value v) throws InterpreterException {
throw new InterpreterException("This type does not support addition.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value minus(Value v) throws InterpreterException {
throw new InterpreterException(
"This type does not support substraction.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value multipliedBy(Value v) throws InterpreterException {
throw new InterpreterException(
"This type does not support multiplication.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value dividedBy(Value v) throws InterpreterException {
throw new InterpreterException("This type does not support division.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value isLess(Value v) throws InterpreterException {
throw new InterpreterException(
"This type does not support less comparison.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value isGreater(Value v) throws InterpreterException {
throw new InterpreterException(
"This type does not support greater comparison.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value isEqual(Value v) throws InterpreterException {
throw new InterpreterException("This type does not support equation.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "operation" "own value" and returning the result in a new
* value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value negate() throws InterpreterException {
throw new InterpreterException("This type does not support negation.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value or(Value v) throws InterpreterException {
throw new InterpreterException(
"This type does not support disjunction.");
}
/**
* Evaluates the mathematic operation denoted by the method name by
* calculating "own value" "operation" "given value" and returning the
* result in a new value.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value and(Value v) throws InterpreterException {
throw new InterpreterException(
"This type does not support conjunction.");
}
/**
* Assigns the given value to the own value and returns it. No new instance
* is created.
*
* @throws InterpreterException
* if the types for the operation don't match
*/
Value assign(Value v) throws InterpreterException {
throw new InterpreterException("This type does not support assignment.");
}
abstract Value cloneValue();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?