Package org.jruby.ir
Class IRBuilder
java.lang.Object
org.jruby.ir.IRBuilder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceprivate static classprivate static classprivate static class(package private) static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Deque<IRBuilder.EnsureBlockInfo>private final Deque<IRBuilder.RescueBlockInfo>protected intprotected intprivate Variableprivate final Deque<IRBuilder.EnsureBlockInfo>private booleanprivate intprivate final Deque<IRBuilder.IRLoop>protected final IRManagerprivate RubySymbolprivate booleanprivate booleanprotected final IRBuilderprotected final IRScopeprivate int(package private) static final UnexecutableNilbooleanprotected IRBuilderprivate TemporaryVariable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Operand[]private voidaddArgReceiveInstr(Variable v, int argIndex, Signature signature) voidaddArgumentDescription(ArgumentType type, RubySymbol name) private voidvoidvoidaddInstrAtBeginning(Instr instr) private voidaddKeyArgDesc(AssignableNode kasgn, RubySymbol key) private voidaddRaiseError(String id, String message) private VariableaddResultInstr(ResultInstr instr) private Operand[]adjustVariableDepth(Operand[] args, int depthFromSuper) private VariableargumentResult(RubySymbol name) buildAlias(AliasNode alias) buildArgsCat(ArgsCatNode argsCatNode) voidbuildArgsMasgn(Node node, Operand argsArray, boolean isMasgnRoot, int preArgsCount, int postArgsCount, int index, boolean isSplat) buildArgsPush(ArgsPushNode node) buildArray(ArrayNode node, boolean operandOnly) voidbuildAssignment(Node node, Variable rhsVal) static Nodeprivate OperandbuildAttrAssign(Variable result, AttrAssignNode attrAssignNode) buildAttrAssignAssignment(Node node, Operand value) protected OperandbuildAttrAssignCallArgs(List<Operand> argsList, Node args, boolean containsAssignment) buildBackref(Variable result, BackRefNode node) buildBegin(BeginNode beginNode) buildBignum(BignumNode node) buildBlock(BlockNode node) voidbuildBlockArgsAssignment(Node node, Operand argsArray, int argIndex, boolean isSplat) buildBreak(BreakNode breakNode) protected Operand[]buildCallArgs(Node args) protected Operand[]buildCallArgsExcept(Node args, Node excludeKeywordArg) build each argument to a call but if we detect what appears to be a literal simple keyword argument signature we will pass that along to be excluded in the build here (we will build it separately).private OperandbuildCaseTestValue(CaseNode caseNode) buildClass(ClassNode classNode) Build a new class and add it to the current scope (s).buildClassVar(ClassVarNode node) buildClassVarAsgn(ClassVarAsgnNode classVarAsgnNode) buildColon2(Colon2Node colon2) private OperandbuildColon2ForConstAsgnDeclNode(Node lhs, Variable valueResult, boolean constMissing) buildColon3(Colon3Node node) buildComplex(ComplexNode node) private OperandbuildConditionalLoop(Node conditionNode, Node bodyNode, boolean isWhile, boolean isLoopHeadCondition) buildConstDecl(ConstDeclNode node) buildConstDeclAssignment(ConstDeclNode constDeclNode, Operand value) buildDAsgn(DAsgnNode dasgnNode) protected VariablebuildDefinitionCheck(ResultInstr definedInstr, String definedReturnValue) buildDefn(MethodDefNode node) protected VariablebuildDefnCheckIfThenPaths(Label undefLabel, Operand defVal) buildDRegexp(Variable result, DRegexpNode node) buildDSymbol(Variable result, DSymbolNode node) buildDXStr(Variable result, DXStrNode node) buildEncoding(EncodingNode node) buildEnsureInternal(Node ensureBodyNode, Node ensureNode) buildEnsureNode(EnsureNode ensureNode) buildEvalRoot(RootNode rootNode) buildFCall(Variable aResult, FCallNode fcallNode) buildFixnum(FixnumNode node) private OperandbuildFixnumCase(CaseNode caseNode) buildFloat(FloatNode node) buildForIter(ForNode forNode) buildGetArgumentDefinition(Node node, String type) buildGetDefinition(Node node) buildGlobalAsgn(GlobalAsgnNode globalAsgnNode) buildGlobalVar(Variable result, GlobalVarNode node) buildInstAsgn(InstAsgnNode instAsgnNode) buildInstVar(InstVarNode node) private InterpreterContextbuildIterInner(RubySymbol methodName, IterNode iterNode) private List<KeyValuePair<Operand,Operand>> buildKeywordArguments(HashNode keywordArgs) buildLambda(LambdaNode node) private InterpreterContextbuildLambdaInner(LambdaNode node) protected OperandbuildLazyWithOrder(CallNode node, Label lazyLabel, Label endLabel, boolean preserveOrder) buildLiteral(LiteralNode literalNode) buildLocalAsgn(LocalAsgnNode localAsgnNode) buildLocalVar(LocalVarNode node) buildMatch(Variable result, MatchNode matchNode) buildMatch2(Variable result, Match2Node matchNode) buildMatch3(Variable result, Match3Node matchNode) buildModule(ModuleNode moduleNode) private InterpreterContextbuildModuleOrClassBody(Node bodyNode, int startLine, int endLine) buildMultipleAsgn19(MultipleAsgnNode multipleAsgnNode) voidbuildMultipleAsgn19Assignment(MultipleAsgnNode multipleAsgnNode, Operand argsArray, Operand values) buildNil()buildNthRef(NthRefNode nthRefNode) buildOpAsgn(OpAsgnNode opAsgnNode) buildOpAsgnAnd(OpAsgnAndNode andNode) buildOpAsgnOr(OpAsgnOrNode orNode) private OperandbuildOpElementAsgnWith(OpElementAsgnNode opElementAsgnNode, Boolean truthy) buildOpElementAsgnWithMethod(OpElementAsgnNode opElementAsgnNode) private OperandbuildOperand(Variable result, Node node) buildPostExe(PostExeNode postExeNode) buildPreExe(PreExeNode preExeNode) buildPreExeInner(Node body) private InterpreterContextbuildPrePostExeInner(Node body) buildRational(RationalNode rationalNode) buildRegexp(RegexpNode reNode) buildRescue(RescueNode node) private voidbuildRescueBodyInternal(RescueBodyNode rescueBodyNode, Variable rv, Variable exc, Label endLabel) private OperandbuildRescueInternal(RescueNode rescueNode, IRBuilder.EnsureBlockInfo ensure) private VariablebuildRestKeywordArgs(HashNode keywordArgs) buildRetry(RetryNode retryNode) buildReturn(ReturnNode returnNode) static InterpreterContextprivate InterpreterContextbuildRootInner(RootNode rootNode) buildSClass(SClassNode sclassNode) buildSplat(SplatNode splatNode) buildStrRaw(StrNode strNode) buildSuper(SuperNode superNode) private OperandbuildSuperInstr(Operand block, Operand[] args) buildSValue(SValueNode node) buildSymbol(SymbolNode node) buildUndef(Node node) buildUntil(UntilNode untilNode) buildVAlias(VAliasNode valiasNode) buildVCall(Variable result, VCallNode node) voidprivate voidbuildWhenArgs(WhenNode whenNode, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals) private voidbuildWhenSplatValues(Variable eqqResult, Node node, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals) private voidbuildWhenValue(Variable eqqResult, Operand testValue, Label bodyLabel, Node node, Set<IRubyObject> seenLiterals, boolean needsSplat) private voidbuildWhenValues(Variable eqqResult, ListNode exprValues, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals) buildWhile(WhileNode whileNode) protected OperandbuildWithOrder(Node node, boolean preserveOrder) buildYield(YieldNode node, Variable result) buildZArray(Variable result) buildZSuper(ZSuperNode zsuperNode) private OperandbuildZSuperIfNest(Operand block) private voidprivate booleancanBacktraceBeRemoved(RescueNode rescueNode) classVarContainer(boolean declContext) Deprecated.private booleanvoidcomputeScopeFlagsFrom(List<Instr> instructions) protected Variablestatic InstrcreateBranch(Operand v1, Operand v2, Label jmpTarget) private TemporaryVariableprotected InterpreterContextdefineMethodInner(DefNode defNode, IRScope parent, int coverageMode) private IRMethoddefineNewMethod(MethodDefNode defNode, boolean isInstanceMethod) private voiddetermineIfMaybeRefined(RubySymbol methodName, Operand[] args) private CallInstrdetermineIfProcNew(Node receiverNode, CallInstr callInstr) private voidprivate intdynamicPiece(Operand[] pieces, int i, Node pieceNode) private voidprivate static voidextractCallOperands(List<Operand> callArgs, List<KeyValuePair<Operand, Operand>> keywordArgs, Instr instr) private Operandprotected LocalVariablegetArgVariable(RubySymbol name, int depth) protected LocalVariablegetBlockArgVariable(RubySymbol name, int depth) static Operand[]getCallArgs(IRScope scope, IRBuilder builder) Extract all call arguments from the specified scope (only useful for Closures and Methods) so that we can convert zsupers to supers with explicit arguments.private static Operand[]getCallOperands(IRScope scope, List<Operand> callArgs, List<KeyValuePair<Operand, Operand>> keywordArgs) private OperandgetContainerFromCPath(Colon3Node cpath) private IRBuilder.IRLoopprivate StringgetLocalVariable(RubySymbol name, int scopeDepth) getName()private LabelgetNewLocalVariable(RubySymbol name, int scopeDepth) private HashNodegetPossibleKeywordArgument(Node argsNode) protected Variableprivate StringgetVarNameFromScopeTree(IRScope scope, int depth, int offset) private IRubyObjectgetWhenLiteral(Node node) Get the variable for accessing the "yieldable" closure in this scope.private voidprivate voidprivate booleanprivate voidif_else(Operand testVariable, Operand testValue, IRBuilder.VoidCodeBlock ifBlock, IRBuilder.VoidCodeBlock elseBlock) Generate if testVariable NEQ testValue { ifBlock } else { elseBlock }.private booleanprivate static booleanisErrorInfoGlobal(String name) private booleanprivate booleanliteralWhenCheck(Node value, Set<IRubyObject> seenLiterals) private RubySymbolprivate booleannewIRBuilder(IRManager manager, IRScope newScope) private NotCompilableExceptionnotCompilable(String message, Node node) private voidoutputExceptionCheck(Operand excType, Operand excObj, Label caughtLabel) private voidprivate voidPrepare closure runtime state.private voidPrepare implicit runtime state needed for typical methods to execute.private OperandprocessEnsureRescueBlocks(Operand retVal) private OperandprotectCodeWithRescue(IRBuilder.CodeBlock protectedCode, IRBuilder.CodeBlock rescueBlock) private OperandputConstant(Colon2Node node, Operand value) private OperandputConstant(Colon3Node node, Operand value) private OperandputConstant(RubySymbol name, Operand value) private OperandputConstantAssignment(OpAsgnConstDeclNode node, Operand value) voidreceiveArgs(ArgsNode argsNode) Process all arguments specified for this scope.protected voidreceiveBlockArg(ArgsNode argsNode) Reify the implicit incoming block into a full Proc, for use as "block arg", but only if a block arg is specified in this scope's arguments.protected voidreceiveBlockArg(Variable v, Operand argsArray, int argIndex, boolean isSplat) voidreceiveBlockArgs(IterNode node) private voidreceiveBreakException(Operand block, CallInstr callInstr) private OperandreceiveBreakException(Operand block, IRBuilder.CodeBlock codeBlock) voidreceiveMethodArgs(ArgsNode argsNode) protected voidreceiveNonBlockArgs(ArgsNode argsNode) voidreceiveRequiredArg(Node node, int argIndex, Signature signature) private OperandsearchConst(RubySymbol name) private OperandsearchModuleForConst(Operand startingModule, RubySymbol name) Operand[]setupCallArgs(Node args) private OperandsetupCallClosure(Node node) private RubySymbolprivate RubySymbolprivate voidthrowSyntaxError(Node node, String message) static IRBuildertopIRBuilder(IRManager manager, IRScope newScope)
-
Field Details
-
U_NIL
-
activeRescueBlockStack
-
activeEnsureBlockStack
-
ensureBodyBuildStack
-
activeRescuers
-
loopStack
-
lastProcessedLineNum
private int lastProcessedLineNum -
needsLineNumInfo
private boolean needsLineNumInfo -
underscoreVariableSeen
public boolean underscoreVariableSeen -
parent
-
variableBuilder
-
manager
-
scope
-
instructions
-
argumentDescriptions
-
coverageMode
protected int coverageMode -
executesOnce
private boolean executesOnce -
temporaryVariableIndex
private int temporaryVariableIndex -
needsYieldBlock
private boolean needsYieldBlock -
methodName
-
afterPrologueIndex
protected int afterPrologueIndex -
yieldClosureVariable
-
currentModuleVariable
-
flags
-
-
Constructor Details
-
IRBuilder
-
IRBuilder
-
-
Method Details
-
buildAST
-
getCurrentLoop
-
needsCodeCoverage
private boolean needsCodeCoverage() -
addArgumentDescription
-
addInstr
-
addInstrAtBeginning
-
emitEnsureBlocks
-
determineIfWeNeedLineNumber
-
notCompilable
-
buildOperand
- Throws:
NotCompilableException
-
hasListener
private boolean hasListener() -
newIRBuilder
-
topIRBuilder
-
build
-
build
-
buildLambdaInner
-
preloadBlockImplicitClosure
private void preloadBlockImplicitClosure() -
buildLambda
-
buildEncoding
-
buildMultipleAsgn19
-
copyAndReturnValue
-
buildWithOrder
-
buildLazyWithOrder
-
getValueInTemporaryVariable
-
buildAttrAssignCallArgs
-
buildCallArgs
-
buildCallArgsExcept
build each argument to a call but if we detect what appears to be a literal simple keyword argument signature we will pass that along to be excluded in the build here (we will build it separately).- Parameters:
args- for a call to be builtexcludeKeywordArg- do not build the last one since it is a keyword arg- Returns:
- the operands for the call.
-
setupCallArgs
-
addArg
-
buildAssignment
-
getBlockArgVariable
-
receiveBlockArg
-
buildVersionSpecificBlockArgsAssignment
-
buildBlockArgsAssignment
-
buildAlias
-
buildAnd
-
buildArray
-
buildArgsCat
-
buildArgsPush
-
buildAttrAssign
-
buildAttrAssignAssignment
-
buildBackref
-
buildBegin
-
buildBignum
-
buildBlock
-
buildBreak
-
throwSyntaxError
-
handleNonlocalReturnInMethod
private void handleNonlocalReturnInMethod() -
receiveBreakException
-
receiveBreakException
-
buildCall
-
buildKeywordArguments
-
determineIfProcNew
-
getPossibleKeywordArgument
-
buildCase
-
buildCaseTestValue
-
literalWhenCheck
-
buildWhenValues
-
buildWhenValue
-
buildWhenSplatValues
-
buildWhenArgs
private void buildWhenArgs(WhenNode whenNode, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals) -
getWhenLiteral
-
buildFixnumCase
-
buildClass
Build a new class and add it to the current scope (s). -
buildSClass
-
buildClassVar
-
addResultInstr
-
buildClassVarAsgn
-
classVarDeclarationContainer
Deprecated. -
classVarDefinitionContainer
-
classVarContainer
-
buildConstDecl
-
findContainerModule
-
buildConstDeclAssignment
-
putConstant
-
putConstant
-
putConstant
-
putConstantAssignment
-
searchModuleForConst
-
searchConst
-
buildColon2
-
buildColon3
-
buildComplex
-
protectCodeWithRescue
private Operand protectCodeWithRescue(IRBuilder.CodeBlock protectedCode, IRBuilder.CodeBlock rescueBlock) -
buildGetDefinition
-
buildDefnCheckIfThenPaths
-
buildDefinitionCheck
-
buildGetArgumentDefinition
-
buildDAsgn
-
defineMethodInner
-
defineNewMethod
-
buildDefn
-
buildDefs
-
getArgVariable
-
addArgReceiveInstr
-
argumentResult
-
receiveRequiredArg
-
receiveNonBlockArgs
-
receiveBlockArg
Reify the implicit incoming block into a full Proc, for use as "block arg", but only if a block arg is specified in this scope's arguments.- Parameters:
argsNode- the arguments containing the block arg, if any
-
prepareImplicitState
private void prepareImplicitState()Prepare implicit runtime state needed for typical methods to execute. This includes such things as the implicit self variable and any yieldable block available to this scope. -
prepareClosureImplicitState
private void prepareClosureImplicitState()Prepare closure runtime state. This includes the implicit self variable and setting up a variable to hold any frame closure if it is needed later. -
receiveArgs
Process all arguments specified for this scope. This includes pre args (required args at the beginning of the argument list), opt args (arguments with a default value), a rest arg (catch-all for argument list overflow), post args (required arguments after a rest arg) and a block arg (to reify an incoming block into a Proc object.- Parameters:
argsNode- the args node containing the specification for the arguments
-
addKeyArgDesc
-
isRequiredKeywordArgumentValue
-
buildArgsMasgn
-
buildMultipleAsgn19Assignment
public void buildMultipleAsgn19Assignment(MultipleAsgnNode multipleAsgnNode, Operand argsArray, Operand values) -
handleBreakAndReturnsInLambdas
private void handleBreakAndReturnsInLambdas() -
receiveMethodArgs
-
receiveBlockArgs
-
buildDot
-
dynamicPiece
-
buildDRegexp
-
buildDStr
-
buildDSymbol
-
buildDVar
-
buildDXStr
-
buildEnsureNode
-
buildEnsureInternal
-
buildFalse
-
if_else
private void if_else(Operand testVariable, Operand testValue, IRBuilder.VoidCodeBlock ifBlock, IRBuilder.VoidCodeBlock elseBlock) Generate if testVariable NEQ testValue { ifBlock } else { elseBlock }.- Parameters:
testVariable- what we will test against testValuetestValue- what we want to testVariable to NOT be equal to.ifBlock- the code if test values do NOT matchelseBlock- the code to execute otherwise.
-
buildRestKeywordArgs
-
buildFCall
-
setupCallClosure
-
determineIfMaybeRefined
-
buildFixnum
-
buildFlip
-
buildFloat
-
buildFor
-
buildForIter
-
buildGlobalAsgn
-
buildGlobalVar
-
buildHash
-
buildIf
-
buildInstAsgn
-
buildInstVar
-
buildIterInner
-
buildIter
-
buildLiteral
-
buildLocalAsgn
-
buildLocalVar
-
buildMatch
-
buildMatch2
-
getVarNameFromScopeTree
-
buildMatch3
-
getContainerFromCPath
-
buildModule
-
buildNext
-
buildNthRef
-
buildNil
-
buildOpAsgn
-
buildColon2ForConstAsgnDeclNode
-
buildOpAsgnConstDeclNode
-
buildOpAsgnAnd
-
buildOpAsgnOr
-
buildOpElementAsgn
-
buildOpElementAsgnWith
-
buildOpElementAsgnWithMethod
-
buildOr
-
buildPrePostExeInner
-
buildPreExeInner
-
buildPostExe
-
buildPreExe
-
buildRational
-
buildRedo
-
buildRegexp
-
buildRescue
-
canBacktraceBeRemoved
-
isErrorInfoGlobal
-
buildRescueInternal
-
outputExceptionCheck
-
buildRescueBodyInternal
private void buildRescueBodyInternal(RescueBodyNode rescueBodyNode, Variable rv, Variable exc, Label endLabel) -
buildRetry
-
processEnsureRescueBlocks
-
buildReturn
-
buildEvalRoot
-
buildRoot
-
addCurrentModule
private void addCurrentModule() -
buildRootInner
-
buildSelf
-
buildSplat
-
buildStr
-
buildStrRaw
-
buildSuperInstr
-
buildSuper
-
buildSValue
-
buildSymbol
-
buildTrue
-
buildUndef
-
buildConditionalLoop
-
buildUntil
-
buildVAlias
-
buildVCall
-
buildWhile
-
buildXStr
-
buildYield
-
copy
-
copy
-
buildZArray
-
buildZSuperIfNest
-
isDefineMethod
private boolean isDefineMethod() -
addRaiseError
-
buildZSuper
-
adjustVariableDepth
-
buildModuleOrClassBody
-
methodNameFor
-
createTemporaryVariable
-
getLocalVariable
-
getNewLocalVariable
-
getName
-
getNewLabel
-
getFileName
-
symbol
-
symbol
-
getCallArgs
Extract all call arguments from the specified scope (only useful for Closures and Methods) so that we can convert zsupers to supers with explicit arguments. Note: This is fairly expensive because we walk entire scope when we could potentially stop earlier if we knew when recv_* were done. -
extractCallOperands
-
getCallOperands
-
createBranch
-
getYieldClosureVariable
Get the variable for accessing the "yieldable" closure in this scope. -
getCurrentModuleVariable
-
createCurrentModuleVariable
-
computeScopeFlagsFrom
-
calculateClosureScopeFlags
private void calculateClosureScopeFlags() -
computeNeedsDynamicScopeFlag
private boolean computeNeedsDynamicScopeFlag()
-