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

public abstract class IRBuilder<U,V,W,X,Y,Z> extends Object
  • Field Details

    • scope

      protected final IRScope scope
    • parent

      protected final IRBuilder<U,V,W,X,Y,Z> parent
    • instructions

      protected final List<Instr> instructions
    • coverageMode

      protected int coverageMode
    • variableBuilder

      protected IRBuilder<U,V,W,X,Y,Z> variableBuilder
    • argumentDescriptions

      protected List<Object> argumentDescriptions
    • executesOnce

      public boolean executesOnce
    • underscoreVariableSeen

      public boolean underscoreVariableSeen
    • encoding

      protected org.jcodings.Encoding encoding
    • flipVariableCount

      protected int flipVariableCount
    • evalType

      public EvalType evalType
    • afterPrologueIndex

      protected int afterPrologueIndex
  • Constructor Details

  • Method Details

    • buildRoot

      public static InterpreterContext buildRoot(IRManager manager, ParseResult rootNode)
    • buildEnsureInternal

      protected Operand buildEnsureInternal(U body, U elseNode, U[] exceptions, U rescueBody, X optRescue, boolean isModifier, U ensureNode, boolean isRescue, U reference)
    • buildEvalRoot

      public InterpreterContext buildEvalRoot(ParseResult rootNode)
    • buildRootInner

      protected InterpreterContext buildRootInner(ParseResult parseResult)
    • computeScopeFlagsFrom

      public void computeScopeFlagsFrom(List<Instr> instructions)
    • hasListener

      protected boolean hasListener()
    • maybeGenerateIsNotEmptyErrorString

      protected void maybeGenerateIsNotEmptyErrorString(Variable errorString, Operand result, Operand value)
    • methodNameFor

      protected RubySymbol methodNameFor()
    • getCurrentLoop

      protected org.jruby.ir.builder.IRLoop getCurrentLoop()
    • addInstr

      public void addInstr(Instr instr)
    • addInstrAtBeginning

      public void addInstrAtBeginning(Instr instr)
    • addResultInstr

      protected Variable addResultInstr(ResultInstr instr)
    • emitEnsureBlocks

      protected void emitEnsureBlocks(org.jruby.ir.builder.IRLoop loop)
    • isTopLevel

      protected boolean isTopLevel()
    • isTopScope

      protected boolean isTopScope()
    • outputExceptionCheck

      protected void outputExceptionCheck(Operand excType, Operand excObj, Label caughtLabel)
    • protectCodeWithRescue

      protected Operand protectCodeWithRescue(IRBuilder.CodeBlock protectedCode, IRBuilder.CodeBlock rescueBlock)
    • createBranch

      public static Instr createBranch(Operand v1, Operand v2, Label jmpTarget)
    • determineZSuperCallArgs

      public void determineZSuperCallArgs(IRScope scope, IRBuilder<U,V,W,X,Y,Z> builder, List<Operand> callArgs, List<KeyValuePair<Operand,Operand>> keywordArgs)
    • addArg

      public static Operand[] addArg(Operand[] args, Operand extraArg)
    • putConstant

      protected Operand putConstant(RubySymbol name, Operand value)
    • putConstant

      protected Operand putConstant(Operand parent, RubySymbol name, Operand value)
    • removeArg

      public static Operand[] removeArg(Operand[] args)
    • searchModuleForConst

      protected Operand searchModuleForConst(Variable result, Operand startingModule, RubySymbol name)
    • searchModuleForConstNoFrills

      protected Operand searchModuleForConstNoFrills(Variable result, Operand startingModule, RubySymbol name)
    • searchConst

      protected Operand searchConst(Variable result, RubySymbol name)
    • classVarContainer

      public Operand classVarContainer(boolean declContext)
    • addRaiseError

      protected Operand addRaiseError(String id, String message)
    • extractCallOperands

      protected static void extractCallOperands(List<Operand> callArgs, List<KeyValuePair<Operand,Operand>> keywordArgs, Instr instr)
    • receiveBreakException

      protected void receiveBreakException(Operand block, CallInstr callInstr)
    • handleBreakAndReturnsInLambdas

      protected void handleBreakAndReturnsInLambdas()
    • handleNonlocalReturnInMethod

      protected void handleNonlocalReturnInMethod()
    • call

      protected Variable call(Variable result, Operand object, String name, Operand... args)
    • call

      protected Variable call(Variable result, Operand object, RubySymbol name, Operand... args)
    • _call

      protected Variable _call(Variable result, CallType type, Operand object, RubySymbol name, Operand... args)
    • classVarDefinitionContainer

      public Operand classVarDefinitionContainer()
    • cond

      protected void cond(Label label, Operand value, Operand test)
    • cond

      protected void cond(Label endLabel, Operand value, Operand test, IRBuilder.RunIt body)
    • cond_ne_true

      protected void cond_ne_true(Label label, Operand value)
    • cond_ne_false

      protected void cond_ne_false(Label label, Operand value)
    • cond_ne_nil

      protected void cond_ne_nil(Label endLabel, Operand value, IRBuilder.RunIt body)
    • copy

      public Variable copy(Operand value)
    • copy

      public Variable copy(Variable result, Operand value)
    • fals

      protected Boolean fals()
    • fcall

      protected Variable fcall(Variable result, Operand object, String name, Operand... args)
    • fcall

      protected Variable fcall(Variable result, Operand object, RubySymbol name, Operand... args)
    • fix

      protected Fixnum fix(long value)
    • 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 testValue
      testValue - what we want to testVariable to NOT be equal to.
      ifBlock - the code if test values do NOT match
      elseBlock - the code to execute otherwise.
    • if_not

      protected void if_not(Operand testVariable, Operand testValue, IRBuilder.VoidCodeBlock ifBlock)
    • for_loop

      protected void for_loop(Consumer<Label> test, Consumer<Label> increment, IRBuilder.Consume2<Label,Label> body)
    • jump

      protected void jump(Label label)
    • label

      protected void label(String labelName, Consumer<Label> block)
    • nil

      protected Nil nil()
    • symbol

      protected RubySymbol symbol(String id)
    • symbol

      protected RubySymbol symbol(ByteList bytelist)
    • tap

      protected Operand tap(Operand value, Consumer<Operand> block)
    • temp

      protected Variable temp()
    • type_error

      protected void type_error(String message)
    • times

      protected void times(int times, IRBuilder.Consume2<Label,Integer> body)
    • tru

      protected Boolean tru()
    • createCurrentModuleVariable

      public Variable createCurrentModuleVariable()
    • getCurrentModuleVariable

      public Variable getCurrentModuleVariable()
    • getFileName

      protected String getFileName()
    • getName

      public RubySymbol getName()
    • getNewLabel

      protected Label getNewLabel()
    • getNewLabel

      protected Label getNewLabel(String labelName)
    • getValueInTemporaryVariable

      protected Variable getValueInTemporaryVariable(Operand val)
    • getYieldClosureVariable

      public TemporaryVariable getYieldClosureVariable()
      Get the variable for accessing the "yieldable" closure in this scope.
    • getZSuperCallOperands

      protected static Operand[] getZSuperCallOperands(IRScope scope, List<Operand> callArgs, List<KeyValuePair<Operand,Operand>> keywordArgs, int[] flags)
    • canBacktraceBeRemoved

      protected boolean canBacktraceBeRemoved(U[] exceptions, U rescueBody, X optRescue, U elseNode, boolean isModifier)
    • exceptionNodesFor

      protected abstract U[] exceptionNodesFor(X node)
    • bodyFor

      protected abstract U bodyFor(X node)
    • optRescueFor

      protected abstract X optRescueFor(X node)
    • referenceFor

      protected abstract U referenceFor(X node)
    • isSideEffectFree

      protected abstract boolean isSideEffectFree(U node)
    • isErrorInfoGlobal

      protected abstract boolean isErrorInfoGlobal(U body)
    • canBeLazyMethod

      protected abstract boolean canBeLazyMethod(V defNode)
      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

      public abstract Operand build(ParseResult result)
    • buildWithOrder

      protected Operand buildWithOrder(U node, boolean preserveOrder)
    • buildAlias

      protected Operand buildAlias(Operand newName, Operand oldName)
    • buildAnd

      protected Operand buildAnd(Operand left, IRBuilder.CodeBlock right, IRBuilder.BinaryType truth)
    • buildBreak

      protected Operand buildBreak(IRBuilder.CodeBlock value, int line)
    • setupCallArgs

      protected Operand[] setupCallArgs(U args, int[] flags)
    • buildCase

      protected Operand buildCase(U predicate, U[] arms, U elsey)
    • whenBody

      protected abstract U whenBody(W arm)
    • buildClass

      protected Operand buildClass(ByteList className, U superNode, U cpath, U bodyNode, StaticScope scope, int line, int endLine)
    • getContainerFromCPath

      protected abstract Operand getContainerFromCPath(U cpath)
    • buildClassVar

      protected Operand buildClassVar(Variable result, RubySymbol name)
    • buildClassVarAsgn

      protected Operand buildClassVarAsgn(RubySymbol name, U valueNode)
    • buildConditional

      protected Operand buildConditional(Variable result, U predicate, U statements, U consequent)
    • buildDefn

      protected Operand buildDefn(IRMethod method)
    • buildDefs

      protected Operand buildDefs(U receiver, IRMethod method)
    • buildDRegex

      protected Operand buildDRegex(Variable result, U[] children, RegexpOptions options)
    • 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

      protected Operand buildDSymbol(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, int line)
    • buildDXStr

      public Operand buildDXStr(Variable result, U[] nodePieces, org.jcodings.Encoding encoding, int line)
    • buildEncoding

      protected Operand buildEncoding(org.jcodings.Encoding encoding)
    • buildFlip

      protected Operand buildFlip(U begin, U end, boolean isExclusive)
    • buildFor

      protected Operand buildFor(U receiverNode, U var, U body, StaticScope staticScope, Signature signature, int line, int endLine)
    • buildForIter

      protected Operand buildForIter(U var, U body, StaticScope staticScope, Signature signature, int line, int endLine)
    • buildGlobalAsgn

      protected Operand buildGlobalAsgn(RubySymbol name, U valueNode)
    • buildGlobalVar

      protected Operand buildGlobalVar(Variable result, RubySymbol name)
    • buildInstAsgn

      protected Operand buildInstAsgn(RubySymbol name, U valueNode)
    • buildInstVar

      protected Operand buildInstVar(RubySymbol name)
    • buildClassVarGetDefinition

      protected Variable buildClassVarGetDefinition(RubySymbol name)
    • buildConstantGetDefinition

      protected Variable buildConstantGetDefinition(RubySymbol name)
    • buildGlobalVarGetDefinition

      protected Variable buildGlobalVarGetDefinition(RubySymbol name)
    • buildInstVarGetDefinition

      protected Operand buildInstVarGetDefinition(RubySymbol name)
    • buildIter

      protected Operand buildIter(U var, U body, StaticScope staticScope, Signature signature, int line, int endLine)
    • createPrefixFromArgs

      protected void createPrefixFromArgs(ByteList prefix, U var)
    • buildIterInner

      protected void buildIterInner(RubySymbol methodName, U var, U body, int endLine)
    • buildLambda

      public Operand buildLambda(U args, U body, StaticScope staticScope, Signature signature, int line)
    • buildLambdaInner

      protected void buildLambdaInner(U blockArgs, U body)
    • buildLocalVariableAssign

      protected Operand buildLocalVariableAssign(RubySymbol name, int depth, U valueNode)
    • buildConditionalLoop

      protected Operand buildConditionalLoop(U conditionNode, U bodyNode, boolean isWhile, boolean isLoopHeadCondition)
    • buildDefinitionCheck

      protected Variable buildDefinitionCheck(ResultInstr definedInstr, String definedReturnValue)
    • buildDefnCheckIfThenPaths

      protected Variable buildDefnCheckIfThenPaths(Label undefLabel, Operand defVal)
    • buildMatch

      public Operand buildMatch(Variable result, Operand regexp)
    • buildModule

      protected Operand buildModule(ByteList name, U cpath, U bodyNode, StaticScope scope, int line, int endLine)
    • buildModuleOrClassBody

      protected void buildModuleOrClassBody(U body, int startLine, int endLine)
    • buildNext

      protected Operand buildNext(Operand rv, int line)
    • buildNthRef

      protected Operand buildNthRef(int matchNumber)
    • buildOpAsgn

      protected Operand buildOpAsgn(U receiver, U value, RubySymbol reader, RubySymbol writer, RubySymbol operator, boolean isLazy)
    • buildOpAsgnAnd

      protected Operand buildOpAsgnAnd(IRBuilder.CodeBlock lhs, IRBuilder.CodeBlock rhs)
    • buildOpAsgnConstDeclOr

      protected Operand buildOpAsgnConstDeclOr(U left, U right, RubySymbol leftName)
    • buildOpAsgnConstDeclAnd

      protected Operand buildOpAsgnConstDeclAnd(U left, U right, RubySymbol leftName)
    • buildColon2ForConstAsgnDeclNode

      protected abstract Operand buildColon2ForConstAsgnDeclNode(U lhs, Variable valueResult, boolean constMissing)
    • buildOpAsgnConstDecl

      @Deprecated protected Operand buildOpAsgnConstDecl(Y left, U right, RubySymbol operator)
      Deprecated.
    • buildOpAsgnConstDecl

      protected Operand buildOpAsgnConstDecl(Y left, RubySymbol name, U right, RubySymbol operator)
    • putConstant

      @Deprecated protected abstract Operand putConstant(Y constant, Operand value)
      Deprecated.
    • putConstant

      protected abstract Operand putConstant(Y constant, IRBuilder.CodeBlock value)
    • buildOpAsgnOr

      protected Operand buildOpAsgnOr(IRBuilder.CodeBlock lhs, IRBuilder.CodeBlock rhs)
    • buildOpElementAsgnWith

      protected Operand buildOpElementAsgnWith(U receiver, U args, U block, U value, Boolean truthy)
    • buildOpElementAsgnWithMethod

      protected Operand buildOpElementAsgnWithMethod(U receiver, U args, U block, U value, RubySymbol operator)
    • buildOpAsgnOrWithDefined

      protected Operand buildOpAsgnOrWithDefined(U first, U second)
    • buildOr

      protected Operand buildOr(Operand left, IRBuilder.CodeBlock right, IRBuilder.BinaryType type)
    • deconstructHashPatternKeys

      protected Variable deconstructHashPatternKeys(Label testEnd, Variable errorString, U constantNode, U[] keyNodes, U rest, Variable result, Operand obj, boolean isSinglePattern)
    • getInExpression

      protected abstract U getInExpression(U node)
    • getInBody

      protected abstract U getInBody(U node)
    • isBareStar

      protected abstract boolean isBareStar(U node)
    • buildArrayPattern

      protected void buildArrayPattern(Label testEnd, Variable result, Variable deconstructed, U constant, U[] pre, U rest, U[] post, Operand obj, boolean inAlteration, boolean isSinglePattern, Variable errorString)
    • buildPatternSetEQQError

      protected void buildPatternSetEQQError(Variable errorString, Variable result, Operand obj, Operand expression, Operand value)
    • buildPatternSetGeneralError

      protected void buildPatternSetGeneralError(Variable errorString, Variable result, Operand... args)
    • buildFindPattern

      protected void buildFindPattern(Label testEnd, Variable result, Variable deconstructed, U constant, U pre, U[] args, U post, Operand obj, boolean inAlteration, boolean isSinglePattern, Variable errorString)
    • buildPatternCase

      protected Operand buildPatternCase(U test, U[] cases, U consequent)
    • buildPatternEach

      protected abstract Variable buildPatternEach(Label testEnd, Variable result, Operand original, Variable deconstructed, Operand value, U exprNodes, boolean inAlternation, boolean isSinglePattern, Variable errorString)
    • buildPatternEachIf

      protected void buildPatternEachIf(Variable result, Operand original, Variable deconstructed, Operand value, U condition, U thenBody, U elseBody, boolean inAlternation, boolean isSinglePattern, Variable errorString)
    • buildAssocs

      protected abstract void buildAssocs(Label testEnd, Operand original, Variable result, Z assocs, boolean inAlteration, boolean isSinglePattern, Variable errorString, boolean hasRest, Variable d)
    • buildHashPattern

      protected void buildHashPattern(Label testEnd, Variable result, Variable deconstructed, U constant, Z assocs, U[] assocsKeys, U rest, Operand obj, boolean inAlteration, boolean isSinglePattern, Variable errorString)
    • buildPatternEachHash

      protected void buildPatternEachHash(Label testEnd, Variable result, Operand original, Variable deconstructed, Operand value, U key, U assocValue, boolean inAlternation, boolean isSinglePattern, Variable errorString)
    • isNilRest

      protected abstract boolean isNilRest(U rest)
    • buildPatternLocal

      protected void buildPatternLocal(Operand value, RubySymbol name, int line, int depth, boolean inAlternation)
    • buildPatternOr

      protected void buildPatternOr(Label testEnd, Operand original, Variable result, Variable deconstructed, Operand value, U left, U right, boolean isSinglePattern, Variable errorString)
    • buildPatternMatch

      protected void buildPatternMatch(Variable result, Operand original, Variable deconstructed, U arg, Operand obj, boolean inAlternation, boolean isSinglePattern, Variable errorString)
    • hackPostExeSource

      protected void hackPostExeSource(IRBuilder builder)
    • buildPostExe

      protected Operand buildPostExe(U body, int line)
    • buildPreExe

      protected Operand buildPreExe(U body)
    • buildRange

      protected Operand buildRange(U beginNode, U endNode, boolean isExclusive)
    • buildRational

      protected Operand buildRational(U numerator, U denominator)
    • buildRedo

      protected Operand buildRedo(int line)
    • buildRescueBodyInternal

      protected void buildRescueBodyInternal(U[] exceptions, U body, X consequent, Variable rv, Variable exc, Label endLabel, U reference)
    • buildAssignment

      protected abstract void buildAssignment(U reference, Operand rhs)
    • buildAttrAssign

      protected Operand buildAttrAssign(Variable result, U receiver, U argsNode, U blockNode, RubySymbol name, boolean isLazy, boolean containsAssignment)
    • buildAttrAssignCallArgs

      protected abstract Operand[] buildAttrAssignCallArgs(U args, Operand[] rhs, boolean containsAssignment)
    • buildRescueInternal

      protected Operand buildRescueInternal(U bodyNode, U elseNode, U[] exceptions, U rescueBody, X optRescue, boolean isModifier, org.jruby.ir.builder.EnsureBlockInfo ensure, U reference)
    • buildRetry

      protected Operand buildRetry(int line)
    • buildReturn

      protected Operand buildReturn(Operand value, int line)
    • buildSClass

      protected Operand buildSClass(U receiverNode, U bodyNode, StaticScope scope, int line, int endLine)
    • buildSelf

      protected Variable buildSelf()
    • buildSuper

      protected Operand buildSuper(Variable aResult, U iterNode, U argsNode, int line, boolean isNewline)
    • buildUndef

      protected Operand buildUndef(Operand name)
    • buildVAlias

      public Operand buildVAlias(RubySymbol left, RubySymbol right)
    • 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

      protected abstract Operand[] buildCallArgs(U args, int[] flags)
    • buildGetDefinition

      protected abstract Operand buildGetDefinition(U node)
    • containsVariableAssignment

      protected abstract boolean containsVariableAssignment(U node)
    • frozen_string

      protected abstract Operand frozen_string(U node)
    • getLine

      protected abstract int getLine(U node)
    • getWhenLiteral

      protected abstract IRubyObject getWhenLiteral(U node)
    • isLiteralString

      protected abstract boolean isLiteralString(U node)
    • needsDefinitionCheck

      protected abstract boolean needsDefinitionCheck(U node)
    • receiveForArgs

      protected abstract void receiveForArgs(U node)
    • receiveBlockArgs

      protected abstract void receiveBlockArgs(U node)
    • setupCallClosure

      protected abstract Operand setupCallClosure(U args, U iter)
    • literalWhenCheck

      protected boolean literalWhenCheck(U value, Set<IRubyObject> seenLiterals, Map<IRubyObject,Integer> origLocs)
    • buildZSuper

      protected Operand buildZSuper(Variable result, U iter)
    • buildZSuper

      protected Operand buildZSuper(Variable result, Operand block)
    • buildZSuperIfNest

      protected Operand buildZSuperIfNest(Variable result, Operand block)
    • alwaysFalse

      protected abstract boolean alwaysFalse(U node)
    • alwaysTrue

      protected abstract boolean alwaysTrue(U node)
    • build

      protected abstract Operand build(Variable result, U node)
    • build

      protected abstract Operand build(U node)
    • dynamicPiece

      protected abstract int dynamicPiece(Operand[] pieces, int index, U piece, org.jcodings.Encoding encoding)
    • receiveMethodArgs

      protected abstract void receiveMethodArgs(V defNode)
    • defineNewMethod

      protected IRMethod defineNewMethod(LazyMethodDefinition<U,V,W,X,Y,Z> defn, ByteList name, int line, StaticScope scope, boolean isInstanceMethod)
    • defineMethodInner

      public void defineMethodInner(LazyMethodDefinition<U,V,W,X,Y,Z> defNode, IRScope parent, int coverageMode)
    • createArgumentDescriptor

      protected ArgumentDescriptor[] createArgumentDescriptor()
    • addArgumentDescription

      public void addArgumentDescription(ArgumentType type, RubySymbol name)
    • argumentResult

      protected Variable argumentResult(RubySymbol name)
    • createCall

      protected Variable createCall(Variable result, Operand receiver, CallType callType, RubySymbol name, U argsNode, U iter, int line, boolean isNewline)
    • determineIfWeNeedLineNumber

      protected void determineIfWeNeedLineNumber(int line, boolean isNewline, boolean implicitNil, boolean def)
    • determineIfMaybeRefined

      protected void determineIfMaybeRefined(RubySymbol methodName, Operand[] args)
    • determineSuperInstr

      protected CallInstr determineSuperInstr(Variable result, Operand[] args, Operand block, int flags, boolean inClassBody, boolean isInstanceMethod)
    • findContainerModule

      protected Operand findContainerModule()
    • as_fixnum

      protected Variable as_fixnum(Operand value)
    • getLocalVariable

      public abstract LocalVariable getLocalVariable(RubySymbol name, int scopeDepth)
    • getNewLocalVariable

      public LocalVariable getNewLocalVariable(RubySymbol name, int scopeDepth)
    • getManager

      public IRManager getManager()
    • processEnsureRescueBlocks

      protected Operand processEnsureRescueBlocks(Operand retVal)
    • throwSyntaxError

      protected void throwSyntaxError(int line, String message)
    • binaryType

      protected IRBuilder.BinaryType binaryType(U node)
    • getEncoding

      protected org.jcodings.Encoding getEncoding()
    • initFlipStateVariable

      public void initFlipStateVariable(Variable v, Operand initState)