org.codehaus.groovy.ast
Class VariableScope

java.lang.Object
  extended by org.codehaus.groovy.ast.VariableScope

public class VariableScope
extends java.lang.Object

Represents a variable scope. This is primarily used to determine variable sharing across method and closure boundaries.

Version:
$Revision: 14564 $
Author:
James Strachan, Jochen Theodorou

Field Summary
private  ClassNode clazzScope
           
private  java.util.Map declaredVariables
           
private  boolean inStaticContext
           
private  VariableScope parent
           
private  java.util.Map referencedClassVariables
           
private  java.util.Map referencedLocalVariables
           
private  boolean resolvesDynamic
           
 
Constructor Summary
VariableScope()
           
VariableScope(VariableScope parent)
           
 
Method Summary
 VariableScope copy()
           
 ClassNode getClassScope()
          Non-null iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.
 Variable getDeclaredVariable(java.lang.String name)
           
 VariableScope getParent()
           
 Variable getReferencedClassVariable(java.lang.String name)
           
 java.util.Map getReferencedClassVariables()
          Gets a map containing the class variables referenced by this scope.
 java.util.Iterator getReferencedClassVariablesIterator()
          Gets an iterator for the referenced class variables.
 Variable getReferencedLocalVariable(java.lang.String name)
           
 int getReferencedLocalVariablesCount()
           
 java.util.Iterator getReferencedLocalVariablesIterator()
           
 boolean isClassScope()
          Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.
 boolean isInStaticContext()
           
 boolean isReferencedClassVariable(java.lang.String name)
           
 boolean isReferencedLocalVariable(java.lang.String name)
           
 boolean isResolvingDynamic()
           
 boolean isRoot()
           
 void putDeclaredVariable(Variable var)
           
 void putReferencedClassVariable(Variable var)
           
 void putReferencedLocalVariable(Variable var)
           
 java.lang.Object removeReferencedClassVariable(java.lang.String name)
           
 void setClassScope(ClassNode node)
           
 void setDynamicResolving(boolean resolvesDynamic)
           
 void setInStaticContext(boolean inStaticContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

declaredVariables

private java.util.Map declaredVariables

referencedLocalVariables

private java.util.Map referencedLocalVariables

referencedClassVariables

private java.util.Map referencedClassVariables

inStaticContext

private boolean inStaticContext

resolvesDynamic

private boolean resolvesDynamic

clazzScope

private ClassNode clazzScope

parent

private VariableScope parent
Constructor Detail

VariableScope

public VariableScope()

VariableScope

public VariableScope(VariableScope parent)
Method Detail

getDeclaredVariable

public Variable getDeclaredVariable(java.lang.String name)

isReferencedLocalVariable

public boolean isReferencedLocalVariable(java.lang.String name)

isReferencedClassVariable

public boolean isReferencedClassVariable(java.lang.String name)

getParent

public VariableScope getParent()

isInStaticContext

public boolean isInStaticContext()

setInStaticContext

public void setInStaticContext(boolean inStaticContext)

isResolvingDynamic

public boolean isResolvingDynamic()

setDynamicResolving

public void setDynamicResolving(boolean resolvesDynamic)

setClassScope

public void setClassScope(ClassNode node)

getClassScope

public ClassNode getClassScope()
Non-null iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.


isClassScope

public boolean isClassScope()
Returns true iff this scope corresponds to a class; as opposed to a method, "if" statement, block statement, etc.


isRoot

public boolean isRoot()

copy

public VariableScope copy()

putDeclaredVariable

public void putDeclaredVariable(Variable var)

getReferencedLocalVariablesIterator

public java.util.Iterator getReferencedLocalVariablesIterator()

getReferencedLocalVariablesCount

public int getReferencedLocalVariablesCount()

getReferencedLocalVariable

public Variable getReferencedLocalVariable(java.lang.String name)

putReferencedLocalVariable

public void putReferencedLocalVariable(Variable var)

putReferencedClassVariable

public void putReferencedClassVariable(Variable var)

getReferencedClassVariable

public Variable getReferencedClassVariable(java.lang.String name)

removeReferencedClassVariable

public java.lang.Object removeReferencedClassVariable(java.lang.String name)

getReferencedClassVariables

public java.util.Map getReferencedClassVariables()
Gets a map containing the class variables referenced by this scope. This not can not be modified.

Returns:
a map containing the class variable references

getReferencedClassVariablesIterator

public java.util.Iterator getReferencedClassVariablesIterator()
Gets an iterator for the referenced class variables. The remove operation is not supported.

Returns:
an iterator for the referenced class variables


Copyright © ${year} The Codehaus. All Rights Reserved.