org.jruby.compiler.ir
Class IRExecutionScope

java.lang.Object
  extended by org.jruby.compiler.ir.IRScopeImpl
      extended by org.jruby.compiler.ir.IRExecutionScope
All Implemented Interfaces:
IRScope
Direct Known Subclasses:
IRClosure, IRMethod

public abstract class IRExecutionScope
extends IRScopeImpl


Field Summary
protected  int optionalArgs
           
protected  int requiredArgs
           
protected  int restArg
           
 
Constructor Summary
IRExecutionScope(IRScope lexicalParent, Operand container, java.lang.String name, StaticScope staticScope)
           
 
Method Summary
 void addClosure(IRClosure c)
           
 void addInstr(Instr i)
          methods and closures
 StaticScope allocateStaticScope(StaticScope parent)
          Create and (re)assign a static scope.
 CFG buildCFG()
           
 void calculateParameterCounts()
           
 boolean canCaptureCallersBinding()
           
 void computeExecutionScopeFlags()
           
protected abstract  StaticScope constructStaticScope(StaticScope parent)
          Closures and Methods have different static scopes.
 void endLoop(IRLoop l)
           
 CFG getCFG()
           
 IRMethod getClosestMethodAncestor()
           
 java.util.List<IRClosure> getClosures()
           
 IRLoop getCurrentLoop()
           
 java.util.List<Instr> getInstrs()
           
 java.util.Iterator<LocalVariable> getLiveLocalVariables()
           
 LocalVariable getLocalVariable(java.lang.String name)
          Get Local Variable from this scope
 int getLocalVariablesCount()
           
 Variable getSelf()
           
 boolean modifiesCode()
           
 boolean requiresBinding()
           
 void runCompilerPassOnNestedScopes(CompilerPass p)
           
 void setCodeModificationFlag(boolean f)
           
 void startLoop(IRLoop l)
           
 java.lang.String toStringInstrs()
           
 java.lang.String toStringVariables()
           
 
Methods inherited from class org.jruby.compiler.ir.IRScopeImpl
getContainer, getContainerModule, getLexicalParent, getName, getNearestModule, getNewInlineVariable, getNewLabel, getNewLabel, getNewTemporaryClosureVariable, getNewTemporaryVariable, getNextClosureId, getPrefixCountSize, getRenamedVariableSize, getScopeName, getStaticScope, getTemporaryVariableSize, prepareForInterpretation, recordMethodAlias, runCompilerPass, setContainer, setName, toString, unaliasMethodName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requiredArgs

protected int requiredArgs

optionalArgs

protected int optionalArgs

restArg

protected int restArg
Constructor Detail

IRExecutionScope

public IRExecutionScope(IRScope lexicalParent,
                        Operand container,
                        java.lang.String name,
                        StaticScope staticScope)
Method Detail

addClosure

public void addClosure(IRClosure c)

addInstr

public void addInstr(Instr i)
Description copied from interface: IRScope
methods and closures

Specified by:
addInstr in interface IRScope
Overrides:
addInstr in class IRScopeImpl

startLoop

public void startLoop(IRLoop l)

endLoop

public void endLoop(IRLoop l)

getCurrentLoop

public IRLoop getCurrentLoop()

getClosures

public java.util.List<IRClosure> getClosures()

getInstrs

public java.util.List<Instr> getInstrs()
Overrides:
getInstrs in class IRScopeImpl

getClosestMethodAncestor

public IRMethod getClosestMethodAncestor()

setCodeModificationFlag

public void setCodeModificationFlag(boolean f)

modifiesCode

public boolean modifiesCode()

requiresBinding

public boolean requiresBinding()

canCaptureCallersBinding

public boolean canCaptureCallersBinding()

buildCFG

public CFG buildCFG()

getCFG

public CFG getCFG()

runCompilerPassOnNestedScopes

public void runCompilerPassOnNestedScopes(CompilerPass p)
Overrides:
runCompilerPassOnNestedScopes in class IRScopeImpl

computeExecutionScopeFlags

public void computeExecutionScopeFlags()

toStringInstrs

public java.lang.String toStringInstrs()
Overrides:
toStringInstrs in class IRScopeImpl

toStringVariables

public java.lang.String toStringVariables()
Overrides:
toStringVariables in class IRScopeImpl

getLiveLocalVariables

public java.util.Iterator<LocalVariable> getLiveLocalVariables()

allocateStaticScope

public StaticScope allocateStaticScope(StaticScope parent)
Create and (re)assign a static scope. In general local variables should never change even if we optimize more, but I was not positive so I am pretending this can change over time. The obvious secondary benefit to storing this on execution scope is we can grab it when we allocate static scopes for all closures. Note: We are missing a distinct life-cycle point to run methods like this since this method can be modified at any point. Not being fully set up is less of an issue since we are calling this when we construct a live runtime version of the method/closure etc, but for profiled optimizations this is less clear if/when we can run this. <-- Assumes this ever needs changing.

Parameters:
parent - scope should be non-null for all closures and null for methods

calculateParameterCounts

public void calculateParameterCounts()

constructStaticScope

protected abstract StaticScope constructStaticScope(StaticScope parent)
Closures and Methods have different static scopes. This returns the correct instance.

Parameters:
parent - scope should be non-null for all closures and null for methods
Returns:
a newly allocated static scope

getSelf

public Variable getSelf()

getLocalVariable

public LocalVariable getLocalVariable(java.lang.String name)
Description copied from interface: IRScope
Get Local Variable from this scope


getLocalVariablesCount

public int getLocalVariablesCount()


Copyright © 2002-2009 JRuby Team. All Rights Reserved.