org.millscript.millscript.expr
Class ConstantExpr

java.lang.Object
  extended by org.millscript.millscript.expr.Expr<ConstAction>
      extended by org.millscript.millscript.expr.ConstantExpr
All Implemented Interfaces:
OneResult

public final class ConstantExpr
extends Expr<ConstAction>
implements OneResult

This class implements a constant expression. A constant expression always returns the same single result. As the returned result is an object, it is possible it could be modified. e.g. adding/changing/removing keys in a map.

See Also:
ConstAction

Constructor Summary
ConstantExpr(java.lang.Object v)
          Creates a new constant expression for the specified object.
 
Method Summary
 ConstAction compileIt()
          Compiles this expression into an action.
 java.lang.Object getValue()
          Returns this constant expressions value.
 void resolve(CompilerState state)
          Resolves any NameExpr in the tree so that they refer to the correct ident.
 void show(int n)
          Displays details about this expression, with the specified indent level.
 
Methods inherited from class org.millscript.millscript.expr.Expr
arity, compile, isIntegerExpr, resolveList, setLineNumber, setOrigin, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantExpr

public ConstantExpr(java.lang.Object v)
Creates a new constant expression for the specified object.

Parameters:
v - the value for this constant expression
Method Detail

compileIt

public ConstAction compileIt()
Description copied from class: Expr
Compiles this expression into an action.

Specified by:
compileIt in class Expr<ConstAction>
Returns:
the Action for this expression
See Also:
Expr.compileIt()

getValue

public java.lang.Object getValue()
Returns this constant expressions value.

Returns:
this constant expressions value

resolve

public void resolve(CompilerState state)
Description copied from class: Expr
Resolves any NameExpr in the tree so that they refer to the correct ident. e.g. This method is responsible for ensuring that references to a function argument in the body of a function actually refer to the correct value.

Specified by:
resolve in class Expr<ConstAction>
Parameters:
state - the compiler state we are resolving in
See Also:
Expr.resolve(org.millscript.millscript.vm.CompilerState)

show

public void show(int n)
Description copied from class: Expr
Displays details about this expression, with the specified indent level. This expressions class name, origin and, at a new indent level, component expressions.

Overrides:
show in class Expr<ConstAction>
Parameters:
n - the indent level at which to start displaying
See Also:
Expr.show(int)


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.