miSim

misim.asm
Class TokenOperator

java.lang.Object
  |
  +--misim.editor.Token
        |
        +--misim.asm.TokenOperator
All Implemented Interfaces:
java.lang.Cloneable

public class TokenOperator
extends Token


Field Summary
static int OP_ADD_EQ
           
static int OP_AND
           
static int OP_AND_EQ
           
static int OP_BIT_AND
           
static int OP_BIT_OR
           
static int OP_BIT_XOR
           
static int OP_CLOSE
           
static int OP_COMPLEMENT
           
static int OP_DECREMENT
           
static int OP_DIVIDE
           
static int OP_DIVIDE_EQ
           
static int OP_EQUAL
           
static int OP_GREATER
           
static int OP_GREATER_EQ
           
static int OP_INCREMENT
           
static int OP_L_SHIFT_EQ
           
static int OP_LEFTSHIFT
           
static int OP_LESS
           
static int OP_LESS_EQ
           
static int OP_MINUS
           
static int OP_MINUS_EQ
           
static int OP_MOD_EQ
           
static int OP_MODULUS
           
static int OP_MULTIPLY
           
static int OP_NOT
           
static int OP_NOT_EQUAL
           
static int OP_OPEN
           
static int OP_OR
           
static int OP_OR_EQ
           
static int OP_PLUS
           
static int OP_R_SHIFT_EQ
           
static int OP_RIGHTSHIFT
           
static int OP_SET_EQ
           
static int OP_TIMES_EQ
           
static int OP_XOR_EQ
           
 
Fields inherited from class misim.editor.Token
display, text, TYPE_ALIAS, TYPE_COLON, TYPE_COMMA, TYPE_COMMAND, TYPE_COMMENT, TYPE_INSTRUCTION, TYPE_LISTING, TYPE_NUMBER, TYPE_OPERATOR, TYPE_STRING, TYPE_TOKEN, TYPE_WHITESPACE
 
Constructor Summary
TokenOperator(java.lang.String text, int operator, EditorPrefs prefs)
           
 
Method Summary
static void addToNode(Node aNode, EditorPrefs prefs)
           
 boolean equals(int operator)
           
 int evaluate(int operand)
          Evaluate a unary operation, returning an integer value.
 int evaluate(int op1, int op2)
          Evaluate a binary operation, returning an integer value.
static java.lang.String getDelimiters()
           
 int getPrecedence()
          Return this operator's precedence.
 boolean isAssignment()
          Indicate if this operator is an assignment operator
 boolean isUnary()
          Indicate whether this operator should be treated as a unary operator.
 void processAssignment(AsmLine aLine, Token labelToken, Context context)
           
 void setUnary(boolean unary)
          Set whether this operator is unary or not.
 
Methods inherited from class misim.editor.Token
clone, consume, draw, drawChars, getColour, getColumn, getLength, getPixelPos, getPrefs, getType, getValue, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OP_OPEN

public static final int OP_OPEN

OP_CLOSE

public static final int OP_CLOSE

OP_NOT

public static final int OP_NOT

OP_COMPLEMENT

public static final int OP_COMPLEMENT

OP_MULTIPLY

public static final int OP_MULTIPLY

OP_DIVIDE

public static final int OP_DIVIDE

OP_MODULUS

public static final int OP_MODULUS

OP_PLUS

public static final int OP_PLUS

OP_MINUS

public static final int OP_MINUS

OP_LEFTSHIFT

public static final int OP_LEFTSHIFT

OP_RIGHTSHIFT

public static final int OP_RIGHTSHIFT

OP_GREATER_EQ

public static final int OP_GREATER_EQ

OP_GREATER

public static final int OP_GREATER

OP_LESS

public static final int OP_LESS

OP_LESS_EQ

public static final int OP_LESS_EQ

OP_EQUAL

public static final int OP_EQUAL

OP_NOT_EQUAL

public static final int OP_NOT_EQUAL

OP_BIT_AND

public static final int OP_BIT_AND

OP_BIT_OR

public static final int OP_BIT_OR

OP_BIT_XOR

public static final int OP_BIT_XOR

OP_AND

public static final int OP_AND

OP_OR

public static final int OP_OR

OP_SET_EQ

public static final int OP_SET_EQ

OP_ADD_EQ

public static final int OP_ADD_EQ

OP_MINUS_EQ

public static final int OP_MINUS_EQ

OP_TIMES_EQ

public static final int OP_TIMES_EQ

OP_DIVIDE_EQ

public static final int OP_DIVIDE_EQ

OP_MOD_EQ

public static final int OP_MOD_EQ

OP_L_SHIFT_EQ

public static final int OP_L_SHIFT_EQ

OP_R_SHIFT_EQ

public static final int OP_R_SHIFT_EQ

OP_AND_EQ

public static final int OP_AND_EQ

OP_OR_EQ

public static final int OP_OR_EQ

OP_XOR_EQ

public static final int OP_XOR_EQ

OP_INCREMENT

public static final int OP_INCREMENT

OP_DECREMENT

public static final int OP_DECREMENT
Constructor Detail

TokenOperator

public TokenOperator(java.lang.String text,
                     int operator,
                     EditorPrefs prefs)
Method Detail

getDelimiters

public static java.lang.String getDelimiters()

equals

public boolean equals(int operator)

setUnary

public void setUnary(boolean unary)
Set whether this operator is unary or not. This is used during expression evaluation to promote '+' and '-' (plus and minus) from binary to unary operators.
Parameters:
unary - True if this should be treated as a unary operator.

isUnary

public boolean isUnary()
Indicate whether this operator should be treated as a unary operator.
Returns:
True if this is a unary operator

isAssignment

public boolean isAssignment()
Indicate if this operator is an assignment operator
Returns:
True if this operator is an assignment operator

getPrecedence

public int getPrecedence()
Return this operator's precedence. Higher numbers indicate higher precedence (ie. '*', '/' are higher than '+', '-'
Returns:
The precedence of this operator.

evaluate

public int evaluate(int operand)
             throws EditorException
Evaluate a unary operation, returning an integer value.
Parameters:
operand - The single operand for this operation
Returns:
The result of evaluating this operation for the given operand

evaluate

public int evaluate(int op1,
                    int op2)
             throws EditorException
Evaluate a binary operation, returning an integer value. Note that for logical operators and comparisons, the value zero represents false, and any other value represents true.
Parameters:
op1 - The first operand
op2 - The second operand
Returns:
The result of evaluating the operation with the given operands

processAssignment

public void processAssignment(AsmLine aLine,
                              Token labelToken,
                              Context context)
                       throws EditorException

addToNode

public static void addToNode(Node aNode,
                             EditorPrefs prefs)

miSim