org.millscript.millscript.expr
Class NameExpr

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

public final class NameExpr
extends Expr<PushAction>
implements OneResult

This class implements a name expression. This expression can only return one result, which will be the value associated with the name.

See Also:
PushAlienAction, PushLocalAction, PushGlobalAction

Constructor Summary
NameExpr(java.lang.String s)
          Creates a new name expression for the specified symbol.
 
Method Summary
 PushAction compileIt()
          Compiles this expression into an action.
 void declareGlobal(CompilerState state, boolean isConst)
          Declares this name expression to be a global identifier in the specified compiler state, with the specified constant state.
 void declareLocal(boolean isConst)
          Declares this name expression to be a local identifier, with the specified constant state.
 Ident getIdent()
          Returns the ident for this name expression.
 java.lang.String getName()
          Returns the symbol for this name expression.
 java.lang.String getNickname()
          Returns the package nickname for this name expression.
 void resolve(CompilerState state)
          Resolves any NameExpr in the tree so that they refer to the correct ident.
 void setIdent(Ident id)
          Sets this name expressions ident to that specified.
 void setNickname(java.lang.String s)
          Sets the package nickname for this name expression.
 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

NameExpr

public NameExpr(java.lang.String s)
Creates a new name expression for the specified symbol.

Parameters:
s - the symbol for this name expression
Method Detail

compileIt

public PushAction compileIt()
Compiles this expression into an action.

Specified by:
compileIt in class Expr<PushAction>
Returns:
a PushAlienAction, PushLocalAction or a PushGlobalAction for this expression, depending on the type of variable this name represents

declareGlobal

public void declareGlobal(CompilerState state,
                          boolean isConst)
Declares this name expression to be a global identifier in the specified compiler state, with the specified constant state.

Parameters:
state - the compiler state in which to declare this name a global identifier
isConst - a boolean indicating if this new global identifier is a constant

declareLocal

public void declareLocal(boolean isConst)
Declares this name expression to be a local identifier, with the specified constant state.

Parameters:
isConst - a boolean indicating if this new local identifier is a constant

getIdent

public Ident getIdent()
Returns the ident for this name expression.

Returns:
the Ident for this name

getName

public java.lang.String getName()
Returns the symbol for this name expression.

Returns:
a string containing the symbol for this name expression

getNickname

public java.lang.String getNickname()
Returns the package nickname for this name expression.

Returns:
a string containing the package nickname for this name expression

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<PushAction>
Parameters:
state - the compiler state we are resolving in
See Also:

A name expression has a complicated renaming process. This is responsible for ensuring idents are shared properly, so that variables of the same name really do refer to the same variable.


setIdent

public void setIdent(Ident id)
Sets this name expressions ident to that specified.

Parameters:
id - the ident for this name expression

setNickname

public void setNickname(java.lang.String s)
Sets the package nickname for this name expression.

Parameters:
s - the package nickname for this name expression

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<PushAction>
Parameters:
n - the indent level at which to start displaying
See Also:
Expr.show(int)


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