org.extex.ocpware.compiler.arith
Class Constant

java.lang.Object
  extended by org.extex.ocpware.compiler.arith.ArithExpr
      extended by org.extex.ocpware.compiler.arith.Constant
All Implemented Interfaces:
Left, Expr

public class Constant
extends ArithExpr
implements Expr, Left

This class provides a constant arithmetic expression. It holds a number.

Version:
$Revision:6007 $
Author:
Gerd Neugebauer

Constructor Summary
Constant(int n)
          Creates a new object.
 
Method Summary
 java.util.List<java.lang.Integer> genLeft(State state, CompilerState cs)
          Compile the left item and add the appropriate instructions to the state.
 void outRight(CompilerState cs, boolean withOffset)
          Compile the string expression into a set of ΩCP instructions.
 java.lang.String toString()
          
 
Methods inherited from class org.extex.ocpware.compiler.arith.ArithExpr
needsParen, parse, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constant

public Constant(int n)
Creates a new object.

Parameters:
n - the value
Method Detail

genLeft

public java.util.List<java.lang.Integer> genLeft(State state,
                                                 CompilerState cs)
                                          throws ArgmentTooBigException,
                                                 java.io.IOException,
                                                 IllegalOpcodeException
Compile the left item and add the appropriate instructions to the state. As a result a list of indices into the code is returned which should need to be fixed. This fix inserts the position of the code into the places given. Thus it is possible to put destinations for goto statements into the holes.

Specified by:
genLeft in interface Left
Parameters:
state - the current state
cs - the compiler state
Returns:
the list of instructions to fix
Throws:
ArgmentTooBigException - in case that an argument is encountered which does not fit into two bytes
AliasNotDefinedException - in case that no matching alias is known for a symbolic table reference
java.io.IOException - in case of an I/O error
IllegalOpcodeException - in case of an illegal op code
See Also:
Left.genLeft( org.extex.ocpware.compiler.parser.State, CompilerState)

outRight

public void outRight(CompilerState cs,
                     boolean withOffset)
              throws java.io.IOException,
                     ArgmentTooBigException
Compile the string expression into a set of ΩCP instructions.

Specified by:
outRight in interface Expr
Parameters:
cs - the compiler state for lookup
withOffset - use push back instead of output
Throws:
java.io.IOException - in case of an I/O error
TableNotDefinedException - in case that no matching table is known for a symbolic table reference
ArgmentTooBigException - in case that an argument is encountered which does not fit into two bytes
See Also:
Expr.outRight( org.extex.ocpware.compiler.parser.CompilerState, boolean)

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()