org.jrubyparser.ast
Class LocalVarNode

java.lang.Object
  extended by org.jrubyparser.ast.Node
      extended by org.jrubyparser.ast.NamedNode
          extended by org.jrubyparser.ast.LocalVarNode
All Implemented Interfaces:
ILocalVariable, INameMatchable, INameNode, ISourcePositionHolder

public class LocalVarNode
extends NamedNode
implements ILocalVariable

Access a local variable


Constructor Summary
LocalVarNode(SourcePosition position, int location, String name)
           
 
Method Summary
 Object accept(NodeVisitor iVisitor)
          Accept for the visitor pattern.
 ILocalVariable getDeclaration()
          Declaration is the first parameter value (ArgumentNode) or the first LocalAsgnNode.
 IScope getDefinedScope()
          Which Variable Scope does this variable belong to? Note that RootNode is a special ILocalScope for the implicit scope created at top-level.
 int getDepth()
          How many scopes should we burrow down to until we need to set the block variable value.
 int getIndex()
          Gets the index within the scope construct that actually holds the eval'd value of this local variable
 NodeType getNodeType()
           
 List<ILocalVariable> getOccurrences()
          Find all occurences of this variable including itself.
 
Methods inherited from class org.jrubyparser.ast.NamedNode
getLexicalName, getLexicalNamePosition, getName, getNamePosition, isNameMatch, isSame, setName
 
Methods inherited from class org.jrubyparser.ast.Node
adopt, adopt, adoptUsingNodesPosition, childNodes, comparePositionWith, createList, getClosestIScope, getClosestModule, getGrandParent, getInlineComment, getInnermostIter, getMethodFor, getNodeAt, getNodeName, getOutermostIter, getParent, getPosition, getPositionIncludingComments, getPreviousComments, insertAfter, insertAll, insertBefore, insertNode, isBlockParameter, isDescendentOf, isLeaf, isMethodParameter, setParent, setPosition, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jrubyparser.ast.INameNode
getLexicalName, getLexicalNamePosition, getName, getNamePosition, setName
 
Methods inherited from interface org.jrubyparser.ast.INameMatchable
isNameMatch
 

Constructor Detail

LocalVarNode

public LocalVarNode(SourcePosition position,
                    int location,
                    String name)
Method Detail

getNodeType

public NodeType getNodeType()
Specified by:
getNodeType in class Node
Returns:
the nodeId

accept

public Object accept(NodeVisitor iVisitor)
Accept for the visitor pattern.

Specified by:
accept in class Node
Parameters:
iVisitor - the visitor

getDepth

public int getDepth()
How many scopes should we burrow down to until we need to set the block variable value.

Returns:
0 for current scope, 1 for one down, ...

getIndex

public int getIndex()
Gets the index within the scope construct that actually holds the eval'd value of this local variable

Returns:
Returns an int offset into storage structure

getDefinedScope

public IScope getDefinedScope()
Description copied from interface: ILocalVariable
Which Variable Scope does this variable belong to? Note that RootNode is a special ILocalScope for the implicit scope created at top-level.

Specified by:
getDefinedScope in interface ILocalVariable

getOccurrences

public List<ILocalVariable> getOccurrences()
Description copied from interface: ILocalVariable
Find all occurences of this variable including itself.

Specified by:
getOccurrences in interface ILocalVariable

getDeclaration

public ILocalVariable getDeclaration()
Declaration is the first parameter value (ArgumentNode) or the first LocalAsgnNode. The first LocalAsgnNode is somewhat arbtrarily defined as decl since there could be multiple LocalAsgnNode and one may seem more like the decl than another. With static analysis we cannot know which one is really first so we choose the one closest to beginning of scope.

Specified by:
getDeclaration in interface ILocalVariable


Copyright © 2013. All Rights Reserved.