Class DynamicVariable

java.lang.Object
org.codehaus.groovy.ast.DynamicVariable
All Implemented Interfaces:
Variable

public class DynamicVariable extends Object implements Variable
  • Constructor Details

    • DynamicVariable

      public DynamicVariable(String name, boolean context)
  • Method Details

    • getType

      public ClassNode getType()
      Description copied from interface: Variable
      Returns the type of the variable. If the type is not yet determined, implementations may return a dynamic or placeholder type.
      Specified by:
      getType in interface Variable
      Returns:
      the ClassNode representing this variable's type
    • getName

      public String getName()
      Description copied from interface: Variable
      Returns the name of the variable.
      Specified by:
      getName in interface Variable
      Returns:
      the variable name
    • getInitialExpression

      public Expression getInitialExpression()
      Description copied from interface: Variable
      Returns the initialization expression for this variable, or null if no initialization is present. For fields and local variables, this may contain the right-hand side of an assignment; for parameters, this represents a default value.
      Specified by:
      getInitialExpression in interface Variable
      Returns:
      the initialization Expression, or null
    • hasInitialExpression

      public boolean hasInitialExpression()
      Description copied from interface: Variable
      Returns true if this variable has an initialization expression.
      Specified by:
      hasInitialExpression in interface Variable
      Returns:
      true if initialized
    • isInStaticContext

      public boolean isInStaticContext()
      Description copied from interface: Variable
      Returns true if this variable is declared or used in a static context. A static context includes static initializers, static field declarations, static method bodies, and class-level code without instance access.
      Specified by:
      isInStaticContext in interface Variable
      Returns:
      true if in a static context
    • isDynamicTyped

      public boolean isDynamicTyped()
      Description copied from interface: Variable
      Returns true if this variable has dynamic type information that could not be resolved at compile time.
      Specified by:
      isDynamicTyped in interface Variable
      Returns:
      true if dynamically typed
    • isClosureSharedVariable

      public boolean isClosureSharedVariable()
      Description copied from interface: Variable
      Returns true if this variable is shared with and accessed by nested closures. Shared variables require special handling in bytecode generation to ensure proper access semantics.
      Specified by:
      isClosureSharedVariable in interface Variable
      Returns:
      true if shared with closures
    • setClosureSharedVariable

      public void setClosureSharedVariable(boolean inClosure)
      Description copied from interface: Variable
      Marks this variable as shared with nested closures. This affects code generation and variable access patterns.
      Specified by:
      setClosureSharedVariable in interface Variable
      Parameters:
      inClosure - true if shared with closures
    • getModifiers

      public int getModifiers()
      Description copied from interface: Variable
      Returns the modifiers (access flags) for this variable as per org.objectweb.asm.Opcodes. May include visibility modifiers (public, protected, private), static, final, etc.
      Specified by:
      getModifiers in interface Variable
      Returns:
      the modifier flags
      See Also:
      • Opcodes
    • getOriginType

      public ClassNode getOriginType()
      Description copied from interface: Variable
      Returns the original type of this variable before any type wrapping or transformation. For primitive types, this preserves the distinction between boxed and unboxed forms.
      Specified by:
      getOriginType in interface Variable
      Returns:
      the original ClassNode before transformations