org.problets.domain.model.expression.node.operator.assignment
Class PrefixAssignment
java.lang.Object
org.problets.domain.model.DomainModel
org.problets.domain.model.expression.node.NodeModel
org.problets.domain.model.expression.node.operator.Operator
org.problets.domain.model.expression.node.operator.assignment.Assignment
org.problets.domain.model.expression.node.operator.assignment.PrefixAssignment
- All Implemented Interfaces:
- java.lang.Cloneable, Assignable
- Direct Known Subclasses:
- PrefixDecrement, PrefixIncrement
public abstract class PrefixAssignment
- extends Assignment
- implements Assignable
Serves as the base class for prefix increment and decrement operators
- Since:
- 3 / 26 / 2008
- Author:
- Amruth Kumar
Fields inherited from class org.problets.domain.model.DomainModel |
BOOLEAN, BREAKPOINT, CHARACTER, DOUBLE_PRECISION_REAL, ERROR_TYPE, EVAL_STATUS, expACTION, expASSIGNMENT, expAUTO_DEALLOCATION, expCALL, expCONDITION, expDECLARATION, expDEREFERENCING, expDYNAMIC_ALLOCATION, expDYNAMIC_ALLOCATION_INITIALIZATION, expDYNAMIC_DEALLOCATION, expELSE_CLAUSE, expERROR, expEXECUTION, expIF_CLAUSE, expINITIALIZATION, expINPUT, expPARAMETER_PASSING, expPRINT, expQUESTIONABLE, expREFERENCING, expRETURN, expRUNTIME_ERROR, expSEMANTIC_ERROR, expSYNTAX_ERROR, expUPDATE, IDENTITY, MAX_OBJECT_IDENTITY, MIN_OBJECT_IDENTITY, QUADRUPLE_PRECISION_REAL, RUNTIME_ERROR, SEMANTIC_ERROR, SIGNED_INTEGER, SIGNED_LONG, SIGNED_SHORT, SINGLE_PRECISION_REAL, SYNTAX_ERROR, UNDEFINED_TYPE, UNSIGNED_INTEGER, UNSIGNED_LONG, UNSIGNED_SHORT, WARNING |
Constructor Summary |
PrefixAssignment(java.lang.String inSymbol,
int inPrecedence,
java.lang.String inAssociativity,
int inArity)
|
Method Summary |
boolean |
canAssign()
Returns whether this node is assignable - since prefix
operator returns lvalue in C++, it is true for C++,
but false for Java. |
Value |
evaluate()
Method to detect any errors before subclasses evaluate expressions
Not to be used by client. |
void |
explain(java.util.Vector explanation,
java.util.Vector errors)
Textually explains the evaluation of the tree -
as opposed to graphical explanation by the view |
AbstractVarModel |
getClone()
If right is a VarOperand, get its varClone
Else, call getClone recursively on the right operand,
In either case, add getIncrement() to the value of the clone, and return it. |
AbstractVarModel |
getVarReference()
Returns a reference to the variable that is this operand. |
static void |
main(java.lang.String[] args)
|
void |
setVarValue(Value inValue)
Sets the value of the variable which is this operand. |
Methods inherited from class org.problets.domain.model.expression.node.operator.Operator |
coerceToReal, contentEquals, contentEquals, getArity, getAssociativity, getLocalLearningObjectives, getOperatorType, getPrecedence, getQualifiedLearningObject, getSymbol, grade, locateOperator, recursiveContentEquals, recursiveSetValue |
Methods inherited from class org.problets.domain.model.expression.node.NodeModel |
classifyNodes, getContent, getLeftChild, getNonRecursiveContent, getOrder, getPosition, getRecursiveContent, getRightChild, getValue, insertInOrder, setLeftChild, setOrder, setPosition, setRightChild, setValue, shortCircuit, skip, subExpToString, toString, valueEquals |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
PrefixAssignment
public PrefixAssignment(java.lang.String inSymbol,
int inPrecedence,
java.lang.String inAssociativity,
int inArity)
canAssign
public boolean canAssign()
- Returns whether this node is assignable - since prefix
operator returns lvalue in C++, it is true for C++,
but false for Java.
- Specified by:
canAssign
in interface Assignable
getVarReference
public AbstractVarModel getVarReference()
- Returns a reference to the variable that is this operand.
Do not directly reference the variable returned by this function
as part of any expression evaluation - use getValue() instead.
Feel free to set the value of the variable returned by this function.
- Specified by:
getVarReference
in interface Assignable
setVarValue
public void setVarValue(Value inValue)
- Sets the value of the variable which is this operand.
Use this always to set the value of the variable
- Specified by:
setVarValue
in interface Assignable
getClone
public AbstractVarModel getClone()
- If right is a VarOperand, get its varClone
Else, call getClone recursively on the right operand,
In either case, add getIncrement() to the value of the clone, and return it.
- Specified by:
getClone
in interface Assignable
evaluate
public Value evaluate()
- Description copied from class:
Assignment
- Method to detect any errors before subclasses evaluate expressions
Not to be used by client.
Checks if LHS is a variable, and RHS evaluates correctly
- Overrides:
evaluate
in class Assignment
explain
public void explain(java.util.Vector explanation,
java.util.Vector errors)
- Textually explains the evaluation of the tree -
as opposed to graphical explanation by the view
- Overrides:
explain
in class Operator
main
public static void main(java.lang.String[] args)