Package org.jruby.ir.builder
Class IRBuilder<U,V,W,X,Y,Z>
java.lang.Object
org.jruby.ir.builder.IRBuilder<U,V,W,X,Y,Z>
- Direct Known Subclasses:
IRBuilderAST
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumprotected static interfaceprotected static interfaceprotected static interfaceprotected static interfaceprotected static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected org.jcodings.Encodingbooleanprotected intprotected final IRScopeboolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Variablestatic Operand[]voidaddArgumentDescription(ArgumentType type, RubySymbol name) voidvoidaddInstrAtBeginning(Instr instr) protected OperandaddRaiseError(String id, String message) protected VariableaddResultInstr(ResultInstr instr) protected abstract booleanalwaysFalse(U node) protected abstract booleanalwaysTrue(U node) protected VariableargumentResult(RubySymbol name) protected Variableprotected IRBuilder.BinaryTypebinaryType(U node) protected abstract Uprotected abstract Operandabstract Operandbuild(ParseResult result) protected abstract Operandprotected OperandbuildAlias(Operand newName, Operand oldName) protected OperandbuildAnd(Operand left, IRBuilder.CodeBlock right, IRBuilder.BinaryType truth) protected voidbuildArrayPattern(Label testEnd, Variable result, Variable deconstructed, U constant, U[] pre, U rest, U[] post, Operand obj, boolean inAlteration, boolean isSinglePattern, Variable errorString) protected abstract voidbuildAssignment(U reference, Operand rhs) protected abstract voidbuildAssocs(Label testEnd, Operand original, Variable result, Z assocs, boolean inAlteration, boolean isSinglePattern, Variable errorString, boolean hasRest, Variable d) protected OperandbuildAttrAssign(Variable result, U receiver, U argsNode, U blockNode, RubySymbol name, boolean isLazy, boolean containsAssignment) protected abstract Operand[]buildAttrAssignCallArgs(U args, Operand[] rhs, boolean containsAssignment) protected OperandbuildBreak(IRBuilder.CodeBlock value, int line) protected abstract Operand[]buildCallArgs(U args, int[] flags) protected Operandprotected OperandbuildClass(ByteList className, U superNode, U cpath, U bodyNode, StaticScope scope, int line, int endLine) protected OperandbuildClassVar(Variable result, RubySymbol name) protected OperandbuildClassVarAsgn(RubySymbol name, U valueNode) protected Variableprotected abstract OperandbuildColon2ForConstAsgnDeclNode(U lhs, Variable valueResult, boolean constMissing) protected OperandbuildConditional(Variable result, U predicate, U statements, U consequent) protected OperandbuildConditionalLoop(U conditionNode, U bodyNode, boolean isWhile, boolean isLoopHeadCondition) protected Variableprotected VariablebuildDefinitionCheck(ResultInstr definedInstr, String definedReturnValue) protected Operandprotected VariablebuildDefnCheckIfThenPaths(Label undefLabel, Operand defVal) protected Operandprotected OperandbuildDRegex(Variable result, U[] children, RegexpOptions options) protected OperandbuildDStr(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, boolean isFrozen, int line) Deprecated.protected OperandbuildDStr(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, StringStyle stringStyle, int line) protected OperandbuildDSymbol(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, int line) buildDXStr(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, int line) protected OperandbuildEncoding(org.jcodings.Encoding encoding) protected OperandbuildEnsureInternal(U body, U elseNode, U[] exceptions, U rescueBody, X optRescue, boolean isModifier, U ensureNode, boolean isRescue, U reference) buildEvalRoot(ParseResult rootNode) protected voidbuildFindPattern(Label testEnd, Variable result, Variable deconstructed, U constant, U pre, U[] args, U post, Operand obj, boolean inAlteration, boolean isSinglePattern, Variable errorString) protected Operandprotected OperandbuildFor(U receiverNode, U var, U body, StaticScope staticScope, Signature signature, int line, int endLine) protected OperandbuildForIter(U var, U body, StaticScope staticScope, Signature signature, int line, int endLine) protected abstract OperandbuildGetDefinition(U node) protected OperandbuildGlobalAsgn(RubySymbol name, U valueNode) protected OperandbuildGlobalVar(Variable result, RubySymbol name) protected Variableprotected voidbuildHashPattern(Label testEnd, Variable result, Variable deconstructed, U constant, Z assocs, U[] assocsKeys, U rest, Operand obj, boolean inAlteration, boolean isSinglePattern, Variable errorString) protected OperandbuildInstAsgn(RubySymbol name, U valueNode) protected OperandbuildInstVar(RubySymbol name) protected Operandprotected OperandbuildIter(U var, U body, StaticScope staticScope, Signature signature, int line, int endLine) protected voidbuildIterInner(RubySymbol methodName, U var, U body, int endLine) buildLambda(U args, U body, StaticScope staticScope, Signature signature, int line) protected voidbuildLambdaInner(U blockArgs, U body) protected OperandbuildLocalVariableAssign(RubySymbol name, int depth, U valueNode) buildMatch(Variable result, Operand regexp) protected OperandbuildModule(ByteList name, U cpath, U bodyNode, StaticScope scope, int line, int endLine) protected voidbuildModuleOrClassBody(U body, int startLine, int endLine) protected Operandprotected OperandbuildNthRef(int matchNumber) protected OperandbuildOpAsgn(U receiver, U value, RubySymbol reader, RubySymbol writer, RubySymbol operator, boolean isLazy) protected Operandprotected OperandbuildOpAsgnConstDecl(Y left, RubySymbol name, U right, RubySymbol operator) protected OperandbuildOpAsgnConstDecl(Y left, U right, RubySymbol operator) Deprecated.protected OperandbuildOpAsgnConstDeclAnd(U left, U right, RubySymbol leftName) protected OperandbuildOpAsgnConstDeclOr(U left, U right, RubySymbol leftName) protected Operandprotected OperandbuildOpAsgnOrWithDefined(U first, U second) protected Operandprotected OperandbuildOpElementAsgnWithMethod(U receiver, U args, U block, U value, RubySymbol operator) protected OperandbuildOr(Operand left, IRBuilder.CodeBlock right, IRBuilder.BinaryType type) protected OperandbuildPatternCase(U test, U[] cases, U consequent) protected abstract VariablebuildPatternEach(Label testEnd, Variable result, Operand original, Variable deconstructed, Operand value, U exprNodes, boolean inAlternation, boolean isSinglePattern, Variable errorString) protected voidbuildPatternEachHash(Label testEnd, Variable result, Operand original, Variable deconstructed, Operand value, U key, U assocValue, boolean inAlternation, boolean isSinglePattern, Variable errorString) protected voidbuildPatternEachIf(Variable result, Operand original, Variable deconstructed, Operand value, U condition, U thenBody, U elseBody, boolean inAlternation, boolean isSinglePattern, Variable errorString) protected voidbuildPatternLocal(Operand value, RubySymbol name, int line, int depth, boolean inAlternation) protected voidbuildPatternMatch(Variable result, Operand original, Variable deconstructed, U arg, Operand obj, boolean inAlternation, boolean isSinglePattern, Variable errorString) protected voidbuildPatternOr(Label testEnd, Operand original, Variable result, Variable deconstructed, Operand value, U left, U right, boolean isSinglePattern, Variable errorString) protected voidbuildPatternSetEQQError(Variable errorString, Variable result, Operand obj, Operand expression, Operand value) protected voidbuildPatternSetGeneralError(Variable errorString, Variable result, Operand... args) protected OperandbuildPostExe(U body, int line) protected OperandbuildPreExe(U body) protected OperandbuildRange(U beginNode, U endNode, boolean isExclusive) protected OperandbuildRational(U numerator, U denominator) protected OperandbuildRedo(int line) protected voidbuildRescueBodyInternal(U[] exceptions, U body, X consequent, Variable rv, Variable exc, Label endLabel, U reference) protected OperandbuildRescueInternal(U bodyNode, U elseNode, U[] exceptions, U rescueBody, X optRescue, boolean isModifier, org.jruby.ir.builder.EnsureBlockInfo ensure, U reference) protected OperandbuildRetry(int line) protected OperandbuildReturn(Operand value, int line) static InterpreterContextbuildRoot(IRManager manager, ParseResult rootNode) protected InterpreterContextbuildRootInner(ParseResult parseResult) protected OperandbuildSClass(U receiverNode, U bodyNode, StaticScope scope, int line, int endLine) protected Variableprotected OperandbuildSuper(Variable aResult, U iterNode, U argsNode, int line, boolean isNewline) protected OperandbuildUndef(Operand name) buildVAlias(RubySymbol left, RubySymbol right) protected abstract voidbuildWhenArgs(W whenNode, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs) protected voidbuildWhenValue(Variable eqqResult, Operand testValue, Label bodyLabel, U node, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs, boolean needsSplat) protected voidbuildWhenValues(Variable eqqResult, U[] exprValues, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs) protected OperandbuildWithOrder(U node, boolean preserveOrder) protected OperandbuildZSuper(Variable result, Operand block) protected OperandbuildZSuper(Variable result, U iter) protected OperandbuildZSuperIfNest(Variable result, Operand block) protected Variableprotected Variablecall(Variable result, Operand object, RubySymbol name, Operand... args) protected booleancanBacktraceBeRemoved(U[] exceptions, U rescueBody, X optRescue, U elseNode, boolean isModifier) protected abstract booleancanBeLazyMethod(V defNode) Combination of whether it is feasible for a method being processed to be lazy (e.g.classVarContainer(boolean declContext) voidcomputeScopeFlagsFrom(List<Instr> instructions) protected voidprotected voidcond(Label endLabel, Operand value, Operand test, IRBuilder.RunIt body) protected voidcond_ne_false(Label label, Operand value) protected voidcond_ne_nil(Label endLabel, Operand value, IRBuilder.RunIt body) protected voidcond_ne_true(Label label, Operand value) protected abstract booleancontainsVariableAssignment(U node) protected ArgumentDescriptor[]static InstrcreateBranch(Operand v1, Operand v2, Label jmpTarget) protected VariablecreateCall(Variable result, Operand receiver, CallType callType, RubySymbol name, U argsNode, U iter, int line, boolean isNewline) protected voidcreatePrefixFromArgs(ByteList prefix, U var) protected VariabledeconstructHashPatternKeys(Label testEnd, Variable errorString, U constantNode, U[] keyNodes, U rest, Variable result, Operand obj, boolean isSinglePattern) voiddefineMethodInner(LazyMethodDefinition<U, V, W, X, Y, Z> defNode, IRScope parent, int coverageMode) protected IRMethoddefineNewMethod(LazyMethodDefinition<U, V, W, X, Y, Z> defn, ByteList name, int line, StaticScope scope, boolean isInstanceMethod) protected voiddetermineIfMaybeRefined(RubySymbol methodName, Operand[] args) protected voiddetermineIfWeNeedLineNumber(int line, boolean isNewline, boolean implicitNil, boolean def) protected CallInstrdetermineSuperInstr(Variable result, Operand[] args, Operand block, int flags, boolean inClassBody, boolean isInstanceMethod) voiddetermineZSuperCallArgs(IRScope scope, IRBuilder<U, V, W, X, Y, Z> builder, List<Operand> callArgs, List<KeyValuePair<Operand, Operand>> keywordArgs) protected abstract intdynamicPiece(Operand[] pieces, int index, U piece, org.jcodings.Encoding encoding) protected voidemitEnsureBlocks(org.jruby.ir.builder.IRLoop loop) protected abstract U[]exceptionNodesFor(X node) protected static voidextractCallOperands(List<Operand> callArgs, List<KeyValuePair<Operand, Operand>> keywordArgs, Instr instr) protected Booleanfals()protected Variableprotected Variablefcall(Variable result, Operand object, RubySymbol name, Operand... args) protected Operandprotected Fixnumfix(long value) protected voidprotected abstract Operandfrozen_string(U node) protected abstract OperandgetContainerFromCPath(U cpath) protected org.jruby.ir.builder.IRLoopprotected org.jcodings.Encodingprotected Stringprotected abstract Uprotected abstract UgetInExpression(U node) protected abstract intabstract LocalVariablegetLocalVariable(RubySymbol name, int scopeDepth) getName()protected Labelprotected LabelgetNewLabel(String labelName) getNewLocalVariable(RubySymbol name, int scopeDepth) protected Variableprotected abstract IRubyObjectgetWhenLiteral(U node) Get the variable for accessing the "yieldable" closure in this scope.protected static Operand[]getZSuperCallOperands(IRScope scope, List<Operand> callArgs, List<KeyValuePair<Operand, Operand>> keywordArgs, int[] flags) protected voidhackPostExeSource(IRBuilder builder) protected voidprotected voidprotected booleanprotected voidif_else(Operand testVariable, Operand testValue, IRBuilder.VoidCodeBlock ifBlock, IRBuilder.VoidCodeBlock elseBlock) Generate if testVariable NEQ testValue { ifBlock } else { elseBlock }.protected voidif_not(Operand testVariable, Operand testValue, IRBuilder.VoidCodeBlock ifBlock) voidinitFlipStateVariable(Variable v, Operand initState) protected abstract booleanisBareStar(U node) protected abstract booleanisErrorInfoGlobal(U body) protected abstract booleanisLiteralString(U node) protected abstract booleanprotected abstract booleanisSideEffectFree(U node) protected booleanprotected booleanprotected voidprotected voidprotected booleanliteralWhenCheck(U value, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs) protected voidmaybeGenerateIsNotEmptyErrorString(Variable errorString, Operand result, Operand value) protected RubySymbolprotected abstract booleanneedsDefinitionCheck(U node) protected Nilnil()protected abstract XoptRescueFor(X node) protected voidoutputExceptionCheck(Operand excType, Operand excObj, Label caughtLabel) protected OperandprocessEnsureRescueBlocks(Operand retVal) protected OperandprotectCodeWithRescue(IRBuilder.CodeBlock protectedCode, IRBuilder.CodeBlock rescueBlock) protected OperandputConstant(Operand parent, RubySymbol name, Operand value) protected OperandputConstant(RubySymbol name, Operand value) protected abstract OperandputConstant(Y constant, IRBuilder.CodeBlock value) protected abstract OperandputConstant(Y constant, Operand value) Deprecated.protected abstract voidreceiveBlockArgs(U node) protected voidreceiveBreakException(Operand block, CallInstr callInstr) protected abstract voidreceiveForArgs(U node) protected abstract voidreceiveMethodArgs(V defNode) protected abstract UreferenceFor(X node) static Operand[]protected OperandsearchConst(Variable result, RubySymbol name) protected OperandsearchModuleForConst(Variable result, Operand startingModule, RubySymbol name) protected OperandsearchModuleForConstNoFrills(Variable result, Operand startingModule, RubySymbol name) protected Operand[]setupCallArgs(U args, int[] flags) protected abstract OperandsetupCallClosure(U args, U iter) protected RubySymbolprotected RubySymbolprotected Operandprotected Variabletemp()protected voidthrowSyntaxError(int line, String message) protected voidtimes(int times, IRBuilder.Consume2<Label, Integer> body) protected Booleantru()protected voidtype_error(String message) protected abstract U
-
Field Details
-
scope
-
parent
-
instructions
-
coverageMode
protected int coverageMode -
variableBuilder
-
argumentDescriptions
-
executesOnce
public boolean executesOnce -
underscoreVariableSeen
public boolean underscoreVariableSeen -
encoding
protected org.jcodings.Encoding encoding -
flipVariableCount
protected int flipVariableCount -
evalType
-
afterPrologueIndex
protected int afterPrologueIndex
-
-
Constructor Details
-
IRBuilder
-
-
Method Details
-
buildRoot
-
buildEnsureInternal
-
buildEvalRoot
-
buildRootInner
-
computeScopeFlagsFrom
-
hasListener
protected boolean hasListener() -
maybeGenerateIsNotEmptyErrorString
-
methodNameFor
-
getCurrentLoop
protected org.jruby.ir.builder.IRLoop getCurrentLoop() -
addInstr
-
addInstrAtBeginning
-
addResultInstr
-
emitEnsureBlocks
protected void emitEnsureBlocks(org.jruby.ir.builder.IRLoop loop) -
isTopLevel
protected boolean isTopLevel() -
isTopScope
protected boolean isTopScope() -
outputExceptionCheck
-
protectCodeWithRescue
protected Operand protectCodeWithRescue(IRBuilder.CodeBlock protectedCode, IRBuilder.CodeBlock rescueBlock) -
createBranch
-
determineZSuperCallArgs
-
addArg
-
putConstant
-
putConstant
-
removeArg
-
searchModuleForConst
-
searchModuleForConstNoFrills
protected Operand searchModuleForConstNoFrills(Variable result, Operand startingModule, RubySymbol name) -
searchConst
-
classVarContainer
-
addRaiseError
-
extractCallOperands
-
receiveBreakException
-
handleBreakAndReturnsInLambdas
protected void handleBreakAndReturnsInLambdas() -
handleNonlocalReturnInMethod
protected void handleNonlocalReturnInMethod() -
call
-
call
-
_call
-
classVarDefinitionContainer
-
cond
-
cond
-
cond_ne_true
-
cond_ne_false
-
cond_ne_nil
-
copy
-
copy
-
fals
-
fcall
-
fcall
-
fix
-
if_else
protected 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.
-
if_not
-
for_loop
-
jump
-
label
-
nil
-
symbol
-
symbol
-
tap
-
temp
-
type_error
-
times
-
tru
-
createCurrentModuleVariable
-
getCurrentModuleVariable
-
getFileName
-
getName
-
getNewLabel
-
getNewLabel
-
getValueInTemporaryVariable
-
getYieldClosureVariable
Get the variable for accessing the "yieldable" closure in this scope. -
getZSuperCallOperands
-
canBacktraceBeRemoved
-
exceptionNodesFor
-
bodyFor
-
optRescueFor
-
referenceFor
-
isSideEffectFree
-
isErrorInfoGlobal
-
canBeLazyMethod
Combination of whether it is feasible for a method being processed to be lazy (e.g. methods containing break/next cannot for syntax error purposes) or whether it is enabled as an option (feature does not exist yet).- Parameters:
defNode- syntactical representation of the definition- Returns:
- true if can be lazy
-
build
-
buildWithOrder
-
buildAlias
-
buildAnd
-
buildBreak
-
setupCallArgs
-
buildCase
-
whenBody
-
buildClass
-
getContainerFromCPath
-
buildClassVar
-
buildClassVarAsgn
-
buildConditional
-
buildDefn
-
buildDefs
-
buildDRegex
-
buildDStr
@Deprecated protected Operand buildDStr(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, boolean isFrozen, int line) Deprecated. -
buildDStr
protected Operand buildDStr(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, StringStyle stringStyle, int line) -
buildDSymbol
-
buildDXStr
-
buildEncoding
-
buildFlip
-
buildFor
-
buildForIter
protected Operand buildForIter(U var, U body, StaticScope staticScope, Signature signature, int line, int endLine) -
buildGlobalAsgn
-
buildGlobalVar
-
buildInstAsgn
-
buildInstVar
-
buildClassVarGetDefinition
-
buildConstantGetDefinition
-
buildGlobalVarGetDefinition
-
buildInstVarGetDefinition
-
buildIter
protected Operand buildIter(U var, U body, StaticScope staticScope, Signature signature, int line, int endLine) -
createPrefixFromArgs
-
buildIterInner
-
buildLambda
-
buildLambdaInner
-
buildLocalVariableAssign
-
buildConditionalLoop
-
buildDefinitionCheck
-
buildDefnCheckIfThenPaths
-
buildMatch
-
buildModule
protected Operand buildModule(ByteList name, U cpath, U bodyNode, StaticScope scope, int line, int endLine) -
buildModuleOrClassBody
-
buildNext
-
buildNthRef
-
buildOpAsgn
protected Operand buildOpAsgn(U receiver, U value, RubySymbol reader, RubySymbol writer, RubySymbol operator, boolean isLazy) -
buildOpAsgnAnd
-
buildOpAsgnConstDeclOr
-
buildOpAsgnConstDeclAnd
-
buildColon2ForConstAsgnDeclNode
-
buildOpAsgnConstDecl
Deprecated. -
buildOpAsgnConstDecl
-
putConstant
Deprecated. -
putConstant
-
buildOpAsgnOr
-
buildOpElementAsgnWith
-
buildOpElementAsgnWithMethod
-
buildOpAsgnOrWithDefined
-
buildOr
-
deconstructHashPatternKeys
-
getInExpression
-
getInBody
-
isBareStar
-
buildArrayPattern
-
buildPatternSetEQQError
-
buildPatternSetGeneralError
-
buildFindPattern
-
buildPatternCase
-
buildPatternEach
-
buildPatternEachIf
-
buildAssocs
-
buildHashPattern
-
buildPatternEachHash
-
isNilRest
-
buildPatternLocal
protected void buildPatternLocal(Operand value, RubySymbol name, int line, int depth, boolean inAlternation) -
buildPatternOr
-
buildPatternMatch
-
hackPostExeSource
-
buildPostExe
-
buildPreExe
-
buildRange
-
buildRational
-
buildRedo
-
buildRescueBodyInternal
-
buildAssignment
-
buildAttrAssign
-
buildAttrAssignCallArgs
-
buildRescueInternal
-
buildRetry
-
buildReturn
-
buildSClass
-
buildSelf
-
buildSuper
-
buildUndef
-
buildVAlias
-
buildWhenArgs
protected abstract void buildWhenArgs(W whenNode, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs) -
buildWhenValue
protected void buildWhenValue(Variable eqqResult, Operand testValue, Label bodyLabel, U node, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs, boolean needsSplat) -
buildWhenValues
protected void buildWhenValues(Variable eqqResult, U[] exprValues, Operand testValue, Label bodyLabel, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs) -
buildCallArgs
-
buildGetDefinition
-
containsVariableAssignment
-
frozen_string
-
getLine
-
getWhenLiteral
-
isLiteralString
-
needsDefinitionCheck
-
receiveForArgs
-
receiveBlockArgs
-
setupCallClosure
-
literalWhenCheck
protected boolean literalWhenCheck(U value, Set<IRubyObject> seenLiterals, Map<IRubyObject, Integer> origLocs) -
buildZSuper
-
buildZSuper
-
buildZSuperIfNest
-
alwaysFalse
-
alwaysTrue
-
build
-
build
-
dynamicPiece
-
receiveMethodArgs
-
defineNewMethod
protected IRMethod defineNewMethod(LazyMethodDefinition<U, V, W, X, Y, Z> defn, ByteList name, int line, StaticScope scope, boolean isInstanceMethod) -
defineMethodInner
-
createArgumentDescriptor
-
addArgumentDescription
-
argumentResult
-
createCall
-
determineIfWeNeedLineNumber
protected void determineIfWeNeedLineNumber(int line, boolean isNewline, boolean implicitNil, boolean def) -
determineIfMaybeRefined
-
determineSuperInstr
-
findContainerModule
-
as_fixnum
-
getLocalVariable
-
getNewLocalVariable
-
getManager
-
processEnsureRescueBlocks
-
throwSyntaxError
-
binaryType
-
getEncoding
protected org.jcodings.Encoding getEncoding() -
initFlipStateVariable
-