public abstract class BaseBodyCompiler extends Object implements BodyCompiler
Modifier and Type | Field and Description |
---|---|
protected int |
argParamCount |
protected org.objectweb.asm.Label[] |
currentLoopLabels |
protected boolean |
inNestedMethod |
protected boolean |
inRescue |
protected ASTInspector |
inspector |
protected InvocationCompiler |
invocationCompiler |
protected SkinnyMethodAdapter |
method |
protected String |
methodName |
protected org.objectweb.asm.Label |
redoJump |
protected String |
rubyName |
protected StaticScope |
scope |
protected org.objectweb.asm.Label |
scopeEnd |
protected int |
scopeIndex |
protected org.objectweb.asm.Label |
scopeStart |
protected StandardASMCompiler |
script |
protected VariableCompiler |
variableCompiler |
Constructor and Description |
---|
BaseBodyCompiler(StandardASMCompiler scriptCompiler,
String methodName,
String rubyName,
ASTInspector inspector,
StaticScope scope,
int scopeIndex) |
Modifier and Type | Method and Description |
---|---|
void |
aliasGlobal(String newName,
String oldName) |
void |
appendByteList(org.jruby.util.ByteList value,
int codeRange,
boolean is19)
Append the given bytelist + coderange to the string currently on the stack.
|
void |
appendObject(boolean is19)
Append the object on stack to the string below it.
|
void |
appendToArray() |
void |
appendToObjectArray() |
void |
aprintln()
For logging, println the object reference currently atop the stack
|
void |
argsCat()
Pass two stack elements, converting the first to an array, to the "argsCat" utility method.
|
void |
argsCatToArguments() |
void |
argsCatToArguments19() |
void |
argsPush()
Pass two stack elements, the first an array, to the "argsPush" utility method.
|
void |
aryToAry() |
void |
assignClassVariable(String name) |
void |
assignClassVariable(String name,
CompilerCallback value) |
void |
assignConstantInCurrent(String name,
CompilerCallback value)
Assign a constant on the class or module currently in scope.
|
void |
assignConstantInModule(String name,
CompilerCallback valueAndModule)
Assign a constant on a specific class or module.
|
void |
assignConstantInObject(String name,
CompilerCallback value)
Assign a constant on the Object class.
|
void |
assignGlobalVariable(String name)
Assign the top of the stack to the global variable with the specified name.
|
void |
assignGlobalVariable(String name,
CompilerCallback value)
Assign the top of the stack to the global variable with the specified name.
|
void |
assignInstanceVariable(String name)
Assign the value on top of the stack to the instance variable with the specified name
on the current "self".
|
void |
assignInstanceVariable(String name,
CompilerCallback value)
Assign the value on top of the stack to the instance variable with the specified name
on the current "self".
|
void |
asString() |
void |
attached() |
void |
backref()
Push the current back reference
|
void |
backrefMethod(String methodName)
Call a static helper method on RubyRegexp with the current backref
|
void |
beginChainedMethod() |
abstract void |
beginMethod(CompilerCallback args,
StaticScope scope) |
void |
buildNewString(ArrayCallback callback,
int count,
org.jcodings.Encoding encoding)
Build a string using the given callback.
|
void |
callZSuper(CompilerCallback closure) |
BodyCompiler |
chainToMethod(String methodName) |
void |
checkIsExceptionHandled(ArgumentsCallback rescueArgs) |
void |
checkWhenWithSplat() |
void |
clearErrorInfo() |
void |
compileSequencedConditional(CompilerCallback inputValue,
FastSwitchType fastSwitchType,
Map<CompilerCallback,int[]> switchCases,
List<ArgumentsCallback> conditionals,
List<CompilerCallback> bodies,
CompilerCallback fallback,
boolean outline)
Compile a "sequenced conditional", known as a case/when in Ruby or a switch in Java.
|
void |
concatArrays() |
void |
concatObjectArrays() |
void |
consumeCurrentValue()
As code executes, values are assumed to be "generated", often by being pushed
on to some execution stack.
|
void |
convertToJavaArray() |
void |
createDRegexp19(ArrayCallback arrayCallback,
Object[] sourceArray,
int options) |
void |
createEmptyArray()
Create an empty Ruby array
|
void |
createEmptyHash()
Create an empty Ruby Hash object and put a reference on top of the stack.
|
void |
createNewArray(boolean lightweight)
Given an aggregated set of objects (likely created through a call to createObjectArray)
create a Ruby array object.
|
void |
createNewArray(Object[] sourceArray,
ArrayCallback callback,
boolean lightweight)
Construct a Ruby array given an array of objects to feed to an ArrayCallback
to construct the elements of the array.
|
void |
createNewBignum(BigInteger value)
Generate a new "Bignum" value.
|
void |
createNewClosure(String file,
int line,
StaticScope scope,
int arity,
CompilerCallback body,
CompilerCallback args,
boolean hasMultipleArgsHead,
NodeType argsNodeId,
ASTInspector inspector)
Create a new closure (block) using the given lexical scope information, call arity, and
body generated by the body callback.
|
void |
createNewClosure19(String file,
int line,
StaticScope scope,
int arity,
CompilerCallback body,
CompilerCallback args,
boolean hasMultipleArgsHead,
NodeType argsNodeId,
String parameterList,
ASTInspector inspector)
Create a new closure (block) using the given lexical scope information, call arity, and
body generated by the body callback.
|
void |
createNewEndBlock(CompilerCallback body) |
void |
createNewFixnum(long value)
Generate a new "Fixnum" value.
|
void |
createNewFloat(double value)
Generate a new "Float" value.
|
void |
createNewForLoop(int arity,
CompilerCallback body,
CompilerCallback args,
boolean hasMultipleArgsHead,
NodeType argsNodeId,
ASTInspector inspector)
Create a new closure (block) for a for loop with the given call arity and
body generated by the body callback.
|
void |
createNewHash(Object elements,
ArrayCallback callback,
int keyCount)
Create a new hash by calling back to the specified ArrayCallback.
|
void |
createNewHash19(Object elements,
ArrayCallback callback,
int keyCount)
Create new hash running in ruby 1.9 compat version.
|
void |
createNewLambda(CompilerCallback closure)
Create a new literal lambda.
|
void |
createNewLiteralArray(Object[] sourceArray,
ArrayCallback callback,
boolean lightweight)
Construct a Ruby array given an array of objects to feed to an ArrayCallback
to construct the elements of the array.
|
void |
createNewLiteralHash(Object elements,
ArrayCallback callback,
int keyCount)
Create a new hash by calling back to the specified ArrayCallback.
|
void |
createNewRange(CompilerCallback beginEndCallback,
boolean isExclusive)
Create a new range.
|
void |
createNewRegexp(org.jruby.util.ByteList value,
int options) |
void |
createNewRegexp(CompilerCallback createStringCallback,
int options) |
void |
createNewString(ArrayCallback callback,
int count,
org.jcodings.Encoding encoding)
Generate a new dynamic "String" value.
|
void |
createNewString(org.jruby.util.ByteList value,
int codeRange)
Generate a new "String" value.
|
void |
createNewSymbol(ArrayCallback callback,
int count,
org.jcodings.Encoding encoding) |
void |
createNewSymbol(String name,
org.jcodings.Encoding encoding)
Generate a new "Symbol" value (or fetch the existing one).
|
void |
createObjectArray(Object[] sourceArray,
ArrayCallback callback) |
protected abstract void |
createVariableCompiler() |
void |
declareClassVariable(String name) |
void |
declareClassVariable(String name,
CompilerCallback value) |
void |
defineAlias(CompilerCallback args)
Define an alias for a new name to an existing oldName'd method.
|
void |
defineClass(String name,
StaticScope staticScope,
CompilerCallback superCallback,
CompilerCallback pathCallback,
CompilerCallback bodyCallback,
CompilerCallback receiverCallback,
ASTInspector inspector,
ISourcePosition startPosition) |
void |
definedCall(String name)
Check defined?() for a Call
|
void |
definedNot()
Check defined?() for a Not.
|
void |
defineModule(String name,
StaticScope staticScope,
CompilerCallback pathCallback,
CompilerCallback bodyCallback,
ASTInspector inspector,
ISourcePosition startPosition) |
void |
defineNewMethod(String name,
int methodArity,
StaticScope scope,
CompilerCallback body,
CompilerCallback args,
CompilerCallback receiver,
ASTInspector inspector,
boolean root,
String filename,
int line,
String parameterDesc)
Define a new method with the given name, arity, local variable count, and body callback.
|
void |
duplicateCurrentValue()
Push a copy the topmost value on the stack.
|
abstract void |
endBody()
End compilation for the method associated with the specified token.
|
void |
ensureMultipleAssignableRubyArray(boolean masgnHasHead)
Ensures that the present value is an IRubyObject[] by wrapping it with one or coercing it if it is not.
|
void |
ensureRubyArray()
Ensures that the present value is an IRubyObject[] by wrapping it with one if it is not.
|
void |
forEachInValueArray(int start,
int count,
Object source,
ArrayCallback callback,
CompilerCallback argsCallback)
Given an IRubyObject[] on the stack (or otherwise available as the present object)
call back to the provided ArrayCallback 'callback' for 'count' elements, starting with 'start'.
|
void |
forEachInValueArray(int start,
int preCount,
Object preSource,
int postCount,
Object postSource,
ArrayCallback callback,
CompilerCallback argsCallback)
Given an IRubyObject[] on the stack (or otherwise available as the present object)
call back to the provided ArrayCallback 'callback' for 'count' elements, starting with 'start'.
|
protected int |
getActualArgsCount(StaticScope scope) |
protected int |
getClosureIndex() |
void |
getCompiledClass() |
protected int |
getDynamicScopeIndex() |
protected int |
getExceptionIndex() |
protected int |
getFirstTempIndex() |
void |
getFrameKlazz() |
void |
getFrameName() |
void |
getInstanceVariable(String name) |
InvocationCompiler |
getInvocationCompiler() |
int |
getLastLine() |
String |
getNativeMethodName() |
Object |
getNewEnding() |
protected String |
getNewEnsureName() |
protected String |
getNewRescueName() |
protected int |
getPreviousExceptionIndex() |
String |
getRubyName() |
int |
getScopeIndex() |
StandardASMCompiler |
getScriptCompiler() |
protected abstract String |
getSignature() |
VariableCompiler |
getVariableCompiler() |
protected int |
getVarsArrayIndex() |
void |
getVisibilityFor(String name) |
void |
go(Object gotoToken) |
void |
hasBlock(BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
ifNotNull(Object gotoToken) |
void |
ifNotSuperMethodBound(Object token) |
void |
ifNull(Object gotoToken) |
void |
ifSingleton(Object gotoToken) |
void |
invokeIRubyObject(String methodName,
String signature) |
void |
invokeRuby(String methodName,
String signature) |
void |
invokeThreadContext(String methodName,
String signature) |
void |
invokeUtilityMethod(String methodName,
String signature)
This is for utility methods used by the compiler, to reduce the amount of code generation
necessary.
|
void |
isCaptured(int number,
BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isClassVarDefined(String name,
BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isConstantBranch(BranchCallback setup,
String name) |
void |
isConstantDefined(String name) |
void |
isGlobalDefined(String name,
BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isInstanceOf(Class clazz,
BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isInstanceVariableDefined(String name) |
void |
isMethodBound(String name,
BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isNil(BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isNotProtected(Object gotoToken,
int toConsume) |
void |
isNull(BranchCallback trueBranch,
BranchCallback falseBranch) |
void |
isPrivate(Object gotoToken,
int toConsume) |
void |
issueLoopBreak() |
void |
issueLoopNext() |
void |
issueLoopRedo() |
void |
issueRetryEvent() |
void |
isTrue()
Invoke IRubyObject.isTrue
|
void |
lineNumber(ISourcePosition position)
This method provides a way to specify a line number for the current piece of code
being compiled.
|
void |
literal(String value) |
void |
literalSwitch(int[] cases,
Object[] bodies,
ArrayCallback arrayCallback,
CompilerCallback defaultCallback) |
void |
loadBlock() |
void |
loadClass(String name) |
void |
loadCurrentModule() |
void |
loadEncoding(org.jcodings.Encoding encoding)
Load the specified encoding.
|
void |
loadException() |
void |
loadFalse()
Load a Ruby "false" value on top of the stack.
|
void |
loadFilename() |
void |
loadNil()
Load a Ruby "nil" value on top of the stack.
|
void |
loadNull() |
void |
loadObject()
Load the Object class
|
void |
loadRuntime() |
void |
loadSelf() |
void |
loadStandardError() |
protected void |
loadStaticScope() |
void |
loadThis() |
void |
loadThreadContext() |
void |
loadTrue()
Load a Ruby "true" value on top of the stack.
|
void |
mAssignConstantInCurrent(String name)
Assign a constant on the class or module currently in scope.
|
void |
mAssignConstantInModule(String name)
Assign a constant on a specific class or module.
|
void |
mAssignConstantInObject(String name)
Assign a constant on the Object class.
|
void |
match(boolean is19) |
void |
match2(CompilerCallback value,
boolean is19) |
void |
match2Capture(CompilerCallback value,
int[] scopeOffsets,
boolean is19) |
void |
match3(boolean is19) |
void |
metaclass() |
void |
negateCurrentValue()
Perform a logical Ruby "not" operation on the value on top of the stack, leaving the
negated result.
|
void |
notIsModuleAndClassVarDefined(String name,
Object gotoToken) |
void |
nthRef(int match) |
void |
nullToNil() |
abstract BaseBodyCompiler |
outline(String methodName) |
void |
performBackref(char type) |
void |
performBooleanBranch(BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a boolean branch operation based on the Ruby "true" value of the top value
on the stack.
|
void |
performBooleanBranch2(BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a boolean branch operation based on the boolean top value
on the stack.
|
void |
performBooleanConstantBranch(String globalName,
BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a boolean branch operation based on the boolean constant value
on the stack.
|
void |
performBooleanGlobalBranch(String globalName,
BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a boolean branch operation based on the boolean global value
on the stack.
|
void |
performBooleanLoop(BranchCallback condition,
BranchCallback body,
boolean checkFirst)
Perform a boolean loop using the given condition-calculating branch and body branch.
|
void |
performBooleanLoopLight(BranchCallback condition,
BranchCallback body,
boolean checkFirst)
Perform a boolean loop using the given condition-calculating branch and body branch.
|
void |
performBooleanLoopSafe(BranchCallback condition,
BranchCallback body,
boolean checkFirst)
Perform a boolean loop using the given condition-calculating branch and body branch.
|
void |
performEnsure(BranchCallback regularCode,
BranchCallback protectedCode) |
void |
performLogicalAnd(BranchCallback longBranch)
Perform a logical short-circuited Ruby "and" operation, using Ruby notions of true and false.
|
void |
performLogicalOr(BranchCallback longBranch)
Perform a logical short-circuited Ruby "or" operation, using Ruby notions of true and false.
|
void |
performRescue(BranchCallback regularCode,
BranchCallback rubyCatchCode,
BranchCallback rubyElseCode,
boolean needsRetry) |
void |
performRescueInternal(BranchCallback regularCode,
BranchCallback rubyCatchCode,
BranchCallback rubyElseCode,
boolean needsRetry,
boolean light) |
void |
performRescueLight(BranchCallback regularCode,
BranchCallback rubyCatchCode,
BranchCallback rubyElseCode,
boolean needsRetry) |
void |
pollThreadEvents() |
void |
preMultiAssign(int head,
boolean args) |
void |
println() |
void |
protect(BranchCallback regularCode,
BranchCallback protectedCode,
Class ret)
Makes sure that the code in protectedCode will always run after regularCode.
|
void |
pushByteList(org.jruby.util.ByteList byteList) |
void |
pushDefinedMessage(DefinedMessage definedMessage) |
void |
pushNull() |
void |
pushString(String str) |
void |
raiseTypeError(String msg) |
void |
rescue(BranchCallback regularCode,
Class exception,
BranchCallback catchCode,
Class ret) |
void |
rethrowException() |
void |
rethrowIfSystemExit() |
void |
retrieveClassVariable(String name) |
void |
retrieveConstant(String name)
Retrieve the constant with the specified name available at the current point in the
program's execution.
|
void |
retrieveConstantFromModule(String name)
Retreive a named constant from the RubyModule/RubyClass that's just been pushed.
|
void |
retrieveConstantFromObject(String name)
Retreive a named constant from the RubyModule/RubyClass that's just been pushed.
|
void |
retrieveGlobalVariable(String name)
Retrieve the global variable with the specified name to the top of the stack.
|
void |
retrieveInstanceVariable(String name)
Retrieve the instance variable with the given name, based on the current "self".
|
void |
retrieveSelf()
Retrieve the current "self" and put a reference on top of the stack.
|
void |
retrieveSelfClass()
Retrieve the current "self" object's metaclass and put a reference on top of the stack
|
void |
reverseValues(int count)
Reverse the top n values on the stack.
|
void |
runBeginBlock(StaticScope scope,
CompilerCallback body) |
void |
selfIsKindOf(Object gotoToken) |
void |
setEnding(Object endingToken) |
void |
setLinePosition(ISourcePosition position) |
void |
shortcutAppend(boolean is19)
A "shortcut" append that skips conversions to String where possible.
|
protected boolean |
shouldUseBoxedArgs(StaticScope scope) |
void |
singlifySplattedValue()
Given a splatted value, extract a single value.
|
void |
singlifySplattedValue19()
1.9 version of singlifySplattedValue.
|
void |
splatCurrentValue(String methodName)
Convert the current value into a "splatted value" suitable for passing as
method arguments or disassembling into multiple variables.
|
void |
splatToArguments() |
void |
splatToArguments19() |
void |
storeExceptionInErrorInfo()
Store the current live exception object in the $! thread-global.
|
void |
storeNativeExceptionInErrorInfo()
Store the current exception in $!, wrapping in NativeException if necessary.
|
void |
stringOrNil() |
void |
stringToSymbol(boolean is19)
Convert a String on stack to a Symbol
|
void |
superClass() |
void |
swapValues()
Swap the top and second values on the stack.
|
void |
toJavaString() |
void |
traceClass(ISourcePosition position) |
void |
traceEnd(int line) |
void |
traceLine(ISourcePosition position) |
void |
typeCheckBranch(Class type,
BranchCallback trueCallback,
BranchCallback falseCallback) |
void |
undefMethod(CompilerCallback nameArg) |
void |
unwrapPassedBlock() |
void |
unwrapRaiseException() |
void |
wrapJavaException() |
void |
wrapJavaObject() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isSimpleRoot, issueBreakEvent, issueNextEvent, issueRedoEvent, performReturn
protected SkinnyMethodAdapter method
protected VariableCompiler variableCompiler
protected InvocationCompiler invocationCompiler
protected int argParamCount
protected org.objectweb.asm.Label[] currentLoopLabels
protected org.objectweb.asm.Label scopeStart
protected org.objectweb.asm.Label scopeEnd
protected org.objectweb.asm.Label redoJump
protected boolean inNestedMethod
protected boolean inRescue
protected StaticScope scope
protected ASTInspector inspector
protected String methodName
protected String rubyName
protected StandardASMCompiler script
protected int scopeIndex
public BaseBodyCompiler(StandardASMCompiler scriptCompiler, String methodName, String rubyName, ASTInspector inspector, StaticScope scope, int scopeIndex)
public String getNativeMethodName()
getNativeMethodName
in interface BodyCompiler
public String getRubyName()
protected boolean shouldUseBoxedArgs(StaticScope scope)
protected int getActualArgsCount(StaticScope scope)
protected abstract String getSignature()
protected abstract void createVariableCompiler()
public abstract void beginMethod(CompilerCallback args, StaticScope scope)
public abstract void endBody()
BodyCompiler
endBody
in interface BodyCompiler
public BodyCompiler chainToMethod(String methodName)
chainToMethod
in interface BodyCompiler
public void beginChainedMethod()
public abstract BaseBodyCompiler outline(String methodName)
outline
in interface BodyCompiler
public StandardASMCompiler getScriptCompiler()
public void lineNumber(ISourcePosition position)
BodyCompiler
lineNumber
in interface BodyCompiler
position
- The ISourcePosition information to use.public int getLastLine()
public void loadThreadContext()
public void loadSelf()
loadSelf
in interface BodyCompiler
protected int getClosureIndex()
protected int getPreviousExceptionIndex()
protected int getDynamicScopeIndex()
protected int getVarsArrayIndex()
protected int getFirstTempIndex()
protected int getExceptionIndex()
protected void loadStaticScope()
public void loadThis()
public void loadRuntime()
public void loadBlock()
public void loadNil()
BodyCompiler
loadNil
in interface BodyCompiler
public void loadNull()
loadNull
in interface BodyCompiler
public void loadObject()
BodyCompiler
loadObject
in interface BodyCompiler
public void invokeUtilityMethod(String methodName, String signature)
public void consumeCurrentValue()
BodyCompiler
consumeCurrentValue
in interface BodyCompiler
public void duplicateCurrentValue()
BodyCompiler
duplicateCurrentValue
in interface BodyCompiler
public void swapValues()
BodyCompiler
swapValues
in interface BodyCompiler
public void reverseValues(int count)
BodyCompiler
reverseValues
in interface BodyCompiler
count
- The number of values to reverse.public void retrieveSelf()
BodyCompiler
retrieveSelf
in interface BodyCompiler
public void retrieveSelfClass()
BodyCompiler
retrieveSelfClass
in interface BodyCompiler
public VariableCompiler getVariableCompiler()
getVariableCompiler
in interface BodyCompiler
public InvocationCompiler getInvocationCompiler()
getInvocationCompiler
in interface BodyCompiler
public void assignConstantInCurrent(String name, CompilerCallback value)
BodyCompiler
assignConstantInCurrent
in interface BodyCompiler
name
- name of the constantvalue
- callback to load the valuepublic void assignConstantInModule(String name, CompilerCallback valueAndModule)
BodyCompiler
assignConstantInModule
in interface BodyCompiler
name
- name of the constantvalueAndModule
- callback to load the class/module and valuepublic void assignConstantInObject(String name, CompilerCallback value)
BodyCompiler
assignConstantInObject
in interface BodyCompiler
name
- name of the constantvalue
- callback to load the valuepublic void mAssignConstantInCurrent(String name)
BodyCompiler
mAssignConstantInCurrent
in interface BodyCompiler
name
- name of the constantpublic void mAssignConstantInModule(String name)
BodyCompiler
mAssignConstantInModule
in interface BodyCompiler
name
- name of the constantpublic void mAssignConstantInObject(String name)
BodyCompiler
mAssignConstantInObject
in interface BodyCompiler
name
- name of the constantpublic void retrieveConstant(String name)
BodyCompiler
retrieveConstant
in interface BodyCompiler
name
- The name of the constantpublic void retrieveConstantFromModule(String name)
BodyCompiler
retrieveConstantFromModule
in interface BodyCompiler
name
- The name of the constantpublic void retrieveConstantFromObject(String name)
BodyCompiler
retrieveConstantFromObject
in interface BodyCompiler
name
- The name of the constantpublic void retrieveClassVariable(String name)
retrieveClassVariable
in interface BodyCompiler
public void assignClassVariable(String name)
assignClassVariable
in interface BodyCompiler
public void assignClassVariable(String name, CompilerCallback value)
assignClassVariable
in interface BodyCompiler
public void declareClassVariable(String name)
declareClassVariable
in interface BodyCompiler
public void declareClassVariable(String name, CompilerCallback value)
declareClassVariable
in interface BodyCompiler
public void createNewFloat(double value)
BodyCompiler
createNewFloat
in interface BodyCompiler
public void createNewFixnum(long value)
BodyCompiler
createNewFixnum
in interface BodyCompiler
public void createNewBignum(BigInteger value)
BodyCompiler
createNewBignum
in interface BodyCompiler
public void createNewString(ArrayCallback callback, int count, org.jcodings.Encoding encoding)
BodyCompiler
createNewString
in interface BodyCompiler
public void buildNewString(ArrayCallback callback, int count, org.jcodings.Encoding encoding)
BodyCompiler
buildNewString
in interface BodyCompiler
public void appendByteList(org.jruby.util.ByteList value, int codeRange, boolean is19)
BodyCompiler
appendByteList
in interface BodyCompiler
public void appendObject(boolean is19)
BodyCompiler
appendObject
in interface BodyCompiler
public void shortcutAppend(boolean is19)
BodyCompiler
shortcutAppend
in interface BodyCompiler
public void stringToSymbol(boolean is19)
BodyCompiler
stringToSymbol
in interface BodyCompiler
public void createNewSymbol(ArrayCallback callback, int count, org.jcodings.Encoding encoding)
createNewSymbol
in interface BodyCompiler
public void createNewString(org.jruby.util.ByteList value, int codeRange)
BodyCompiler
createNewString
in interface BodyCompiler
public void createNewSymbol(String name, org.jcodings.Encoding encoding)
BodyCompiler
createNewSymbol
in interface BodyCompiler
public void createNewArray(boolean lightweight)
BodyCompiler
createNewArray
in interface BodyCompiler
public void createNewArray(Object[] sourceArray, ArrayCallback callback, boolean lightweight)
BodyCompiler
createNewArray
in interface BodyCompiler
sourceArray
- The objects that will be used to construct elementscallback
- The callback to which to pass the objectslightweight
- Whether the array should be lightweightpublic void createNewLiteralArray(Object[] sourceArray, ArrayCallback callback, boolean lightweight)
BodyCompiler
createNewLiteralArray
in interface BodyCompiler
sourceArray
- The objects that will be used to construct elementscallback
- The callback to which to pass the objectslightweight
- Whether the array should be lightweightpublic void createEmptyArray()
BodyCompiler
createEmptyArray
in interface BodyCompiler
public void createObjectArray(Object[] sourceArray, ArrayCallback callback)
createObjectArray
in interface BodyCompiler
public void createEmptyHash()
BodyCompiler
createEmptyHash
in interface BodyCompiler
public void createNewHash(Object elements, ArrayCallback callback, int keyCount)
BodyCompiler
createNewHash
in interface BodyCompiler
elements
- An object holding the elements from which to create the Hash.callback
- An ArrayCallback implementation to which the elements array and iteration counts
are passed in sequence.keyCount
- the total count of key-value pairs to be constructed from the elements collection.public void createNewLiteralHash(Object elements, ArrayCallback callback, int keyCount)
BodyCompiler
createNewLiteralHash
in interface BodyCompiler
elements
- An object holding the elements from which to create the Hash.callback
- An ArrayCallback implementation to which the elements array and iteration counts
are passed in sequence.keyCount
- the total count of key-value pairs to be constructed from the elements collection.public void createNewHash19(Object elements, ArrayCallback callback, int keyCount)
BodyCompiler
createNewHash19
in interface BodyCompiler
public void createNewRange(CompilerCallback beginEndCallback, boolean isExclusive)
BodyCompiler
createNewRange
in interface BodyCompiler
isExclusive
- Whether the range is exclusive or not (inclusive)public void createNewLambda(CompilerCallback closure)
BodyCompiler
createNewLambda
in interface BodyCompiler
public void isTrue()
isTrue
in interface BodyCompiler
public void performBooleanBranch(BranchCallback trueBranch, BranchCallback falseBranch)
BodyCompiler
performBooleanBranch
in interface BodyCompiler
trueBranch
- The callback for generating code for the "true" conditionfalseBranch
- The callback for generating code for the "false" conditionpublic void performBooleanBranch2(BranchCallback trueBranch, BranchCallback falseBranch)
BodyCompiler
performBooleanBranch2
in interface BodyCompiler
trueBranch
- The callback for generating code for the "true" conditionfalseBranch
- The callback for generating code for the "false" conditionpublic void performBooleanGlobalBranch(String globalName, BranchCallback trueBranch, BranchCallback falseBranch)
BodyCompiler
performBooleanGlobalBranch
in interface BodyCompiler
trueBranch
- The callback for generating code for the "true" conditionfalseBranch
- The callback for generating code for the "false" conditionpublic void performBooleanConstantBranch(String globalName, BranchCallback trueBranch, BranchCallback falseBranch)
BodyCompiler
performBooleanConstantBranch
in interface BodyCompiler
trueBranch
- The callback for generating code for the "true" conditionfalseBranch
- The callback for generating code for the "false" conditionpublic void performLogicalAnd(BranchCallback longBranch)
BodyCompiler
performLogicalAnd
in interface BodyCompiler
longBranch
- The branch to execute if the "and" operation does not short-circuit.public void performLogicalOr(BranchCallback longBranch)
BodyCompiler
performLogicalOr
in interface BodyCompiler
longBranch
- The branch to execute if the "or" operation does not short-circuit.public void performBooleanLoopSafe(BranchCallback condition, BranchCallback body, boolean checkFirst)
BodyCompiler
performBooleanLoopSafe
in interface BodyCompiler
condition
- The code to execute for calculating the loop condition. A Ruby true result will
cause the body to be executed again.body
- The body to executed for the loop.checkFirst
- whether to check the condition the first time through or not.public void performBooleanLoop(BranchCallback condition, BranchCallback body, boolean checkFirst)
BodyCompiler
performBooleanLoop
in interface BodyCompiler
condition
- The code to execute for calculating the loop condition. A Ruby true result will
cause the body to be executed again.body
- The body to executed for the loop.checkFirst
- whether to check the condition the first time through or not.public void performBooleanLoopLight(BranchCallback condition, BranchCallback body, boolean checkFirst)
BodyCompiler
performBooleanLoopLight
in interface BodyCompiler
condition
- The code to execute for calculating the loop condition. A Ruby true result will
cause the body to be executed again.body
- The body to executed for the loop.checkFirst
- whether to check the condition the first time through or not.public void createNewClosure(String file, int line, StaticScope scope, int arity, CompilerCallback body, CompilerCallback args, boolean hasMultipleArgsHead, NodeType argsNodeId, ASTInspector inspector)
BodyCompiler
createNewClosure
in interface BodyCompiler
public void createNewClosure19(String file, int line, StaticScope scope, int arity, CompilerCallback body, CompilerCallback args, boolean hasMultipleArgsHead, NodeType argsNodeId, String parameterList, ASTInspector inspector)
BodyCompiler
createNewClosure19
in interface BodyCompiler
public void runBeginBlock(StaticScope scope, CompilerCallback body)
runBeginBlock
in interface BodyCompiler
public void createNewForLoop(int arity, CompilerCallback body, CompilerCallback args, boolean hasMultipleArgsHead, NodeType argsNodeId, ASTInspector inspector)
BodyCompiler
createNewForLoop
in interface BodyCompiler
public void createNewEndBlock(CompilerCallback body)
createNewEndBlock
in interface BodyCompiler
public void getCompiledClass()
public void println()
public void defineAlias(CompilerCallback args)
BodyCompiler
defineAlias
in interface BodyCompiler
public void literal(String value)
literal
in interface BodyCompiler
public void loadFalse()
BodyCompiler
loadFalse
in interface BodyCompiler
public void loadTrue()
BodyCompiler
loadTrue
in interface BodyCompiler
public void loadCurrentModule()
loadCurrentModule
in interface BodyCompiler
public void retrieveInstanceVariable(String name)
BodyCompiler
retrieveInstanceVariable
in interface BodyCompiler
name
- The name of the instance variable to retrieve.public void assignInstanceVariable(String name)
BodyCompiler
assignInstanceVariable
in interface BodyCompiler
name
- The name of the value to assign.public void assignInstanceVariable(String name, CompilerCallback value)
BodyCompiler
assignInstanceVariable
in interface BodyCompiler
name
- The name of the value to assign.value
- A callback for compiling the value to assignpublic void retrieveGlobalVariable(String name)
BodyCompiler
retrieveGlobalVariable
in interface BodyCompiler
name
- The name of the global variable.public void assignGlobalVariable(String name)
BodyCompiler
assignGlobalVariable
in interface BodyCompiler
name
- The name of the global variable.public void assignGlobalVariable(String name, CompilerCallback value)
BodyCompiler
assignGlobalVariable
in interface BodyCompiler
name
- The name of the global variable.value
- The callback to compile the value to assignpublic void negateCurrentValue()
BodyCompiler
negateCurrentValue
in interface BodyCompiler
public void splatCurrentValue(String methodName)
BodyCompiler
splatCurrentValue
in interface BodyCompiler
public void singlifySplattedValue()
BodyCompiler
singlifySplattedValue
in interface BodyCompiler
public void singlifySplattedValue19()
BodyCompiler
singlifySplattedValue19
in interface BodyCompiler
public void aryToAry()
aryToAry
in interface BodyCompiler
public void ensureRubyArray()
BodyCompiler
ensureRubyArray
in interface BodyCompiler
public void ensureMultipleAssignableRubyArray(boolean masgnHasHead)
BodyCompiler
ensureMultipleAssignableRubyArray
in interface BodyCompiler
public void forEachInValueArray(int start, int count, Object source, ArrayCallback callback, CompilerCallback argsCallback)
BodyCompiler
forEachInValueArray
in interface BodyCompiler
public void forEachInValueArray(int start, int preCount, Object preSource, int postCount, Object postSource, ArrayCallback callback, CompilerCallback argsCallback)
BodyCompiler
forEachInValueArray
in interface BodyCompiler
public void asString()
asString
in interface BodyCompiler
public void toJavaString()
toJavaString
in interface BodyCompiler
public void nthRef(int match)
nthRef
in interface BodyCompiler
public void match(boolean is19)
match
in interface BodyCompiler
public void match2(CompilerCallback value, boolean is19)
match2
in interface BodyCompiler
public void match2Capture(CompilerCallback value, int[] scopeOffsets, boolean is19)
match2Capture
in interface BodyCompiler
public void match3(boolean is19)
match3
in interface BodyCompiler
public void createNewRegexp(org.jruby.util.ByteList value, int options)
createNewRegexp
in interface BodyCompiler
public void createNewRegexp(CompilerCallback createStringCallback, int options)
createNewRegexp
in interface BodyCompiler
public void createDRegexp19(ArrayCallback arrayCallback, Object[] sourceArray, int options)
createDRegexp19
in interface BodyCompiler
public void pollThreadEvents()
pollThreadEvents
in interface BodyCompiler
public void nullToNil()
nullToNil
in interface BodyCompiler
public void isInstanceOf(Class clazz, BranchCallback trueBranch, BranchCallback falseBranch)
isInstanceOf
in interface BodyCompiler
public void isCaptured(int number, BranchCallback trueBranch, BranchCallback falseBranch)
isCaptured
in interface BodyCompiler
public void backref()
BodyCompiler
backref
in interface BodyCompiler
public void backrefMethod(String methodName)
BodyCompiler
backrefMethod
in interface BodyCompiler
public void issueLoopBreak()
public void issueLoopNext()
public void issueLoopRedo()
protected String getNewEnsureName()
public void protect(BranchCallback regularCode, BranchCallback protectedCode, Class ret)
BodyCompiler
protect
in interface BodyCompiler
public void performEnsure(BranchCallback regularCode, BranchCallback protectedCode)
performEnsure
in interface BodyCompiler
protected String getNewRescueName()
public void storeExceptionInErrorInfo()
BodyCompiler
storeExceptionInErrorInfo
in interface BodyCompiler
public void storeNativeExceptionInErrorInfo()
BodyCompiler
storeNativeExceptionInErrorInfo
in interface BodyCompiler
public void clearErrorInfo()
clearErrorInfo
in interface BodyCompiler
public void rescue(BranchCallback regularCode, Class exception, BranchCallback catchCode, Class ret)
rescue
in interface BodyCompiler
public void performRescue(BranchCallback regularCode, BranchCallback rubyCatchCode, BranchCallback rubyElseCode, boolean needsRetry)
performRescue
in interface BodyCompiler
public void performRescueLight(BranchCallback regularCode, BranchCallback rubyCatchCode, BranchCallback rubyElseCode, boolean needsRetry)
performRescueLight
in interface BodyCompiler
public void performRescueInternal(BranchCallback regularCode, BranchCallback rubyCatchCode, BranchCallback rubyElseCode, boolean needsRetry, boolean light)
public void wrapJavaException()
wrapJavaException
in interface BodyCompiler
public void wrapJavaObject()
public void stringOrNil()
stringOrNil
in interface BodyCompiler
public void pushNull()
pushNull
in interface BodyCompiler
public void pushString(String str)
pushString
in interface BodyCompiler
public void pushByteList(org.jruby.util.ByteList byteList)
pushByteList
in interface BodyCompiler
public void pushDefinedMessage(DefinedMessage definedMessage)
pushDefinedMessage
in interface BodyCompiler
public void isMethodBound(String name, BranchCallback trueBranch, BranchCallback falseBranch)
isMethodBound
in interface BodyCompiler
public void hasBlock(BranchCallback trueBranch, BranchCallback falseBranch)
hasBlock
in interface BodyCompiler
public void isGlobalDefined(String name, BranchCallback trueBranch, BranchCallback falseBranch)
isGlobalDefined
in interface BodyCompiler
public void isConstantDefined(String name)
isConstantDefined
in interface BodyCompiler
public void isInstanceVariableDefined(String name)
isInstanceVariableDefined
in interface BodyCompiler
public void isClassVarDefined(String name, BranchCallback trueBranch, BranchCallback falseBranch)
isClassVarDefined
in interface BodyCompiler
public Object getNewEnding()
getNewEnding
in interface BodyCompiler
public void isNil(BranchCallback trueBranch, BranchCallback falseBranch)
isNil
in interface BodyCompiler
public void isNull(BranchCallback trueBranch, BranchCallback falseBranch)
isNull
in interface BodyCompiler
public void ifNull(Object gotoToken)
ifNull
in interface BodyCompiler
public void ifNotNull(Object gotoToken)
ifNotNull
in interface BodyCompiler
public void setEnding(Object endingToken)
setEnding
in interface BodyCompiler
public void go(Object gotoToken)
go
in interface BodyCompiler
public void isConstantBranch(BranchCallback setup, String name)
isConstantBranch
in interface BodyCompiler
public void metaclass()
metaclass
in interface BodyCompiler
public void aprintln()
BodyCompiler
aprintln
in interface BodyCompiler
public void getVisibilityFor(String name)
getVisibilityFor
in interface BodyCompiler
public void isPrivate(Object gotoToken, int toConsume)
isPrivate
in interface BodyCompiler
public void isNotProtected(Object gotoToken, int toConsume)
isNotProtected
in interface BodyCompiler
public void selfIsKindOf(Object gotoToken)
selfIsKindOf
in interface BodyCompiler
public void notIsModuleAndClassVarDefined(String name, Object gotoToken)
notIsModuleAndClassVarDefined
in interface BodyCompiler
public void ifSingleton(Object gotoToken)
ifSingleton
in interface BodyCompiler
public void getInstanceVariable(String name)
getInstanceVariable
in interface BodyCompiler
public void getFrameName()
getFrameName
in interface BodyCompiler
public void getFrameKlazz()
getFrameKlazz
in interface BodyCompiler
public void superClass()
superClass
in interface BodyCompiler
public void attached()
attached
in interface BodyCompiler
public void ifNotSuperMethodBound(Object token)
ifNotSuperMethodBound
in interface BodyCompiler
public void concatArrays()
concatArrays
in interface BodyCompiler
public void concatObjectArrays()
public void appendToArray()
appendToArray
in interface BodyCompiler
public void appendToObjectArray()
appendToObjectArray
in interface BodyCompiler
public void splatToArguments()
splatToArguments
in interface BodyCompiler
public void splatToArguments19()
splatToArguments19
in interface BodyCompiler
public void argsCatToArguments()
argsCatToArguments
in interface BodyCompiler
public void argsCatToArguments19()
argsCatToArguments19
in interface BodyCompiler
public void convertToJavaArray()
convertToJavaArray
in interface BodyCompiler
public void aliasGlobal(String newName, String oldName)
aliasGlobal
in interface BodyCompiler
public void raiseTypeError(String msg)
raiseTypeError
in interface BodyCompiler
public void undefMethod(CompilerCallback nameArg)
undefMethod
in interface BodyCompiler
public void defineClass(String name, StaticScope staticScope, CompilerCallback superCallback, CompilerCallback pathCallback, CompilerCallback bodyCallback, CompilerCallback receiverCallback, ASTInspector inspector, ISourcePosition startPosition)
defineClass
in interface BodyCompiler
public void defineModule(String name, StaticScope staticScope, CompilerCallback pathCallback, CompilerCallback bodyCallback, ASTInspector inspector, ISourcePosition startPosition)
defineModule
in interface BodyCompiler
public void unwrapPassedBlock()
unwrapPassedBlock
in interface BodyCompiler
public void performBackref(char type)
performBackref
in interface BodyCompiler
public void callZSuper(CompilerCallback closure)
callZSuper
in interface BodyCompiler
public void checkIsExceptionHandled(ArgumentsCallback rescueArgs)
checkIsExceptionHandled
in interface BodyCompiler
public void rethrowException()
rethrowException
in interface BodyCompiler
public void loadClass(String name)
loadClass
in interface BodyCompiler
public void loadStandardError()
loadStandardError
in interface BodyCompiler
public void unwrapRaiseException()
unwrapRaiseException
in interface BodyCompiler
public void loadException()
loadException
in interface BodyCompiler
public void setLinePosition(ISourcePosition position)
setLinePosition
in interface BodyCompiler
public void checkWhenWithSplat()
checkWhenWithSplat
in interface BodyCompiler
public void issueRetryEvent()
issueRetryEvent
in interface BodyCompiler
public void defineNewMethod(String name, int methodArity, StaticScope scope, CompilerCallback body, CompilerCallback args, CompilerCallback receiver, ASTInspector inspector, boolean root, String filename, int line, String parameterDesc)
BodyCompiler
defineNewMethod
in interface BodyCompiler
public void rethrowIfSystemExit()
rethrowIfSystemExit
in interface BodyCompiler
public void literalSwitch(int[] cases, Object[] bodies, ArrayCallback arrayCallback, CompilerCallback defaultCallback)
literalSwitch
in interface BodyCompiler
public void typeCheckBranch(Class type, BranchCallback trueCallback, BranchCallback falseCallback)
typeCheckBranch
in interface BodyCompiler
public void loadFilename()
loadFilename
in interface BodyCompiler
public void compileSequencedConditional(CompilerCallback inputValue, FastSwitchType fastSwitchType, Map<CompilerCallback,int[]> switchCases, List<ArgumentsCallback> conditionals, List<CompilerCallback> bodies, CompilerCallback fallback, boolean outline)
BodyCompiler
compileSequencedConditional
in interface BodyCompiler
inputValue
- callback to create the case/switch valuefastSwitchType
- type of fast-switching to use, if anyswitchCases
- callbacks and array of Java case values for fast switchingconditionals
- callbacks for eqq switchingbodies
- case bodiesfallback
- else bodyoutline
- whether the case bodies should be generated into their own JVM methodspublic void traceLine(ISourcePosition position)
traceLine
in interface BodyCompiler
public void traceClass(ISourcePosition position)
traceClass
in interface BodyCompiler
public void traceEnd(int line)
traceEnd
in interface BodyCompiler
public void preMultiAssign(int head, boolean args)
preMultiAssign
in interface BodyCompiler
public void argsPush()
BodyCompiler
argsPush
in interface BodyCompiler
public void argsCat()
BodyCompiler
argsCat
in interface BodyCompiler
public void loadEncoding(org.jcodings.Encoding encoding)
BodyCompiler
loadEncoding
in interface BodyCompiler
public void definedCall(String name)
BodyCompiler
definedCall
in interface BodyCompiler
public void definedNot()
BodyCompiler
definedNot
in interface BodyCompiler
public int getScopeIndex()
Copyright © 2001-2016 JRuby. All Rights Reserved.