|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.compiler.impl.StandardASMCompiler
Constructor Summary | |
StandardASMCompiler(Node node)
|
|
StandardASMCompiler(java.lang.String classname,
java.lang.String sourcename)
Creates a new instance of StandardCompilerContext |
Method Summary | |
void |
assignClassVariable(java.lang.String name)
|
void |
assignConstantInCurrent(java.lang.String name)
|
void |
assignConstantInModule(java.lang.String name)
|
void |
assignConstantInObject(java.lang.String name)
|
void |
assignGlobalVariable(java.lang.String name)
Assign the top of the stack to the global variable with the specified name. |
void |
assignGlobalVariableBlockArg(int argIndex,
java.lang.String name)
Assign the value from incoming block args to the global variable with the specified name. |
void |
assignInstanceVariable(java.lang.String name)
Assign the value on top of the stack to the instance variable with the specified name on the current "self". |
void |
assignInstanceVariableBlockArg(int argIndex,
java.lang.String name)
Assign the value from incoming block args instance variable with the specified name on the current "self". |
void |
assignLastLine()
Assigns the special "last line" variable $_ in the outermost local scope. |
void |
assignLocalVariable(int index)
Assigns the value on top of the stack to a local variable at the specified index, consuming that value in the process. |
void |
assignLocalVariable(int index,
int depth)
Assign the value on top of the stack to a local variable at the specified index and lexical scoping depth (0 = current scope), consuming that value in the process. |
void |
assignLocalVariableBlockArg(int argIndex,
int varIndex)
Assigns the value from incoming block args to a local variable at the specified index, consuming that value in the process. |
void |
assignLocalVariableBlockArg(int argIndex,
int varIndex,
int depth)
Assign the value from incoming block args to a local variable at the specified index and lexical scoping depth (0 = current scope), consuming that value in the process. |
void |
assignOptionalArgs(java.lang.Object object,
int expectedArgsCount,
int size,
ArrayCallback optEval)
|
void |
asString()
|
java.lang.Object |
beginMethod(java.lang.String friendlyName,
ClosureCallback args)
Begin compilation for a method that has the specified number of local variables. |
void |
consumeCurrentValue()
As code executes, values are assumed to be "generated", often by being pushed on to some execution stack. |
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()
Given an aggregated set of objects (likely created through a call to createObjectArray) create a Ruby array object. |
void |
createNewBignum(java.math.BigInteger value)
Generate a new "Bignum" value. |
void |
createNewClosure(StaticScope scope,
int arity,
ClosureCallback body,
ClosureCallback args)
Create a new closure (block) using the given lexical scope information, call arity, and body generated by the body callback. |
void |
createNewFixnum(long value)
Generate a new "Fixnum" value. |
void |
createNewFloat(double value)
Generate a new "Float" value. |
void |
createNewHash(java.lang.Object elements,
ArrayCallback callback,
int keyCount)
Create a new hash by calling back to the specified ArrayCallback. |
void |
createNewRange(boolean isExclusive)
Create a new range. |
void |
createNewRegexp(ByteList value,
int options,
java.lang.String lang)
|
void |
createNewString(ArrayCallback callback,
int count)
Generate a new dynamic "String" value. |
void |
createNewString(ByteList value)
Generate a new "String" value. |
void |
createNewSymbol(java.lang.String name)
Generate a new "Symbol" value (or fetch the existing one). |
void |
createObjectArray(int elementCount)
Combine the top |
void |
createObjectArray(java.lang.Object[] sourceArray,
ArrayCallback callback)
|
void |
defineAlias(java.lang.String newName,
java.lang.String oldName)
Define an alias for a new name to an existing oldName'd method. |
void |
defineClass(java.lang.String name,
StaticScope staticScope,
ClosureCallback superCallback,
ClosureCallback pathCallback,
ClosureCallback bodyCallback)
|
void |
defineModule(java.lang.String name,
StaticScope staticScope,
ClosureCallback pathCallback,
ClosureCallback bodyCallback)
|
void |
defineNewMethod(java.lang.String name,
StaticScope scope,
ClosureCallback body,
ClosureCallback args)
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. |
void |
endMethod(java.lang.Object token)
End compilation for the method associated with the specified token. |
void |
endScript()
End compilation for the current script, closing all context and structures used for the compilation. |
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,
java.lang.Object source,
ArrayCallback callback)
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'. |
int |
getArity()
|
java.lang.String |
getClassname()
|
ClassVisitor |
getClassVisitor()
|
SkinnyMethodAdapter |
getMethodAdapter()
|
java.lang.String |
getSourcename()
|
void |
invokeAttrAssign(java.lang.String name)
Attr assign calls have slightly different semantics that normal calls, so this method handles those additional semantics. |
void |
invokeDynamic(java.lang.String name,
boolean hasReceiver,
boolean hasArgs,
CallType callType,
ClosureCallback closureArg,
boolean attrAssign)
Invoke the named method as a "function", i.e. |
void |
issueBreakEvent()
|
void |
lineNumber(ISourcePosition position)
This method provides a way to specify a line number for the current piece of code being compiled. |
java.lang.Class |
loadClass(JRubyClassLoader classLoader)
|
void |
loadClosure()
|
void |
loadFalse()
Load a Ruby "false" value on top of the stack. |
void |
loadInteger(int value)
Load an integer value suitable for numeric comparisons |
void |
loadNil()
Load a Ruby "nil" value on top of the stack. |
void |
loadObject()
Load the Object class |
void |
loadRubyArraySize()
|
void |
loadRuntime()
|
void |
loadSelf()
|
void |
loadSymbol(java.lang.String symbol)
Load the given string as a symbol on to the top of the stack. |
void |
loadThreadContext()
|
void |
loadTrue()
Load a Ruby "true" value on top of the stack. |
void |
loadVisibility()
|
void |
match()
|
void |
match2()
|
void |
match3()
|
void |
negateCurrentValue()
Perform a logical Ruby "not" operation on the value on top of the stack, leaving the negated result. |
void |
nthRef(int match)
|
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 |
performBooleanLoop(BranchCallback condition,
BranchCallback body,
boolean checkFirst)
Perform a boolean loop using the given condition-calculating branch and body branch. |
void |
performGEBranch(BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a greater-than-or-equal test and branch, given the provided true and false branches. |
void |
performGTBranch(BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a greater-than test and branch, given the provided true and false branches. |
void |
performLEBranch(BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a greater-than-or-equal test and branch, given the provided true and false branches. |
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 |
performLTBranch(BranchCallback trueBranch,
BranchCallback falseBranch)
Perform a greater-than test and branch, given the provided true and false branches. |
void |
performReturn()
Return the current value on the top of the stack, taking into consideration surrounding blocks. |
void |
pollThreadEvents()
|
Arity |
popArity()
|
SkinnyMethodAdapter |
popMethodAdapter()
|
Label |
popScopeStart()
|
void |
processRequiredArgs(Arity arity,
int totalArgs)
|
void |
pushArity(Arity arity)
|
void |
pushMethodAdapter(SkinnyMethodAdapter mv)
|
void |
pushScopeStart(Label start)
|
void |
retrieveBackRef()
Retrieve the special "back ref" variable $~ from the outermost local scope. |
void |
retrieveClassVariable(java.lang.String name)
|
void |
retrieveConstant(java.lang.String name)
Retrieve the constant with the specified name available at the current point in the program's execution. |
void |
retrieveGlobalVariable(java.lang.String name)
Retrieve the global variable with the specified name to the top of the stack. |
void |
retrieveInstanceVariable(java.lang.String name)
Retrieve the instance variable with the given name, based on the current "self". |
void |
retrieveLastLine()
Retrieve the special "last line" variable $_ from the outermost local scope. |
void |
retrieveLocalVariable(int index)
Retrieve the local variable at the specified index to the top of the stack, using whatever local variable store is appropriate. |
void |
retrieveLocalVariable(int index,
int depth)
Retrieve the local variable as the specified index and lexical scoping depth to the top of the stack, using whatever local variable store is appropriate. |
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 |
singlifySplattedValue()
Given a splatted value, extract a single value. |
void |
splatCurrentValue()
Convert the current value into a "splatted value" suitable for passing as method arguments or disassembling into multiple variables. |
void |
startScript()
Begin compilation for a script, preparing all necessary context and code to support this script's compiled representation. |
void |
swapValues()
Swap the top and second values on the stack. |
void |
writeClass(java.io.File destination)
|
void |
yield(boolean hasArgs)
Invoke the block passed into this method, or throw an error if no block is present. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StandardASMCompiler(java.lang.String classname, java.lang.String sourcename)
public StandardASMCompiler(Node node)
Method Detail |
public java.lang.Class loadClass(JRubyClassLoader classLoader) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public void writeClass(java.io.File destination) throws java.io.IOException
java.io.IOException
public java.lang.String getClassname()
public java.lang.String getSourcename()
public ClassVisitor getClassVisitor()
public SkinnyMethodAdapter getMethodAdapter()
public SkinnyMethodAdapter popMethodAdapter()
public void pushMethodAdapter(SkinnyMethodAdapter mv)
public int getArity()
public void pushArity(Arity arity)
public Arity popArity()
public void pushScopeStart(Label start)
public Label popScopeStart()
public void startScript()
Compiler
startScript
in interface Compiler
public void endScript()
Compiler
endScript
in interface Compiler
public java.lang.Object beginMethod(java.lang.String friendlyName, ClosureCallback args)
Compiler
beginMethod
in interface Compiler
friendlyName
- The outward user-readable name of the method. A unique name will be generated based on this.
public void endMethod(java.lang.Object token)
Compiler
endMethod
in interface Compiler
token
- A token identifying the method to be terminated.public void lineNumber(ISourcePosition position)
Compiler
lineNumber
in interface Compiler
position
- The ISourcePosition information to use.public void invokeAttrAssign(java.lang.String name)
Compiler
invokeAttrAssign
in interface Compiler
public void invokeDynamic(java.lang.String name, boolean hasReceiver, boolean hasArgs, CallType callType, ClosureCallback closureArg, boolean attrAssign)
Compiler
invokeDynamic
in interface Compiler
public void yield(boolean hasArgs)
Compiler
yield
in interface Compiler
public void loadThreadContext()
public void loadClosure()
public void loadSelf()
public void loadRuntime()
public void loadVisibility()
public void loadNil()
Compiler
loadNil
in interface Compiler
public void loadSymbol(java.lang.String symbol)
Compiler
loadSymbol
in interface Compiler
symbol
- The symbol to load.public void loadObject()
Compiler
loadObject
in interface Compiler
public void consumeCurrentValue()
Compiler
consumeCurrentValue
in interface Compiler
public void duplicateCurrentValue()
Compiler
duplicateCurrentValue
in interface Compiler
public void swapValues()
Compiler
swapValues
in interface Compiler
public void retrieveSelf()
Compiler
retrieveSelf
in interface Compiler
public void retrieveSelfClass()
Compiler
retrieveSelfClass
in interface Compiler
public void assignLocalVariable(int index)
Compiler
assignLocalVariable
in interface Compiler
index
- The index of the local variable to which to assign the value.public void assignLastLine()
Compiler
assignLastLine
in interface Compiler
public void assignLocalVariableBlockArg(int argIndex, int varIndex)
Compiler
assignLocalVariableBlockArg
in interface Compiler
public void retrieveLocalVariable(int index)
Compiler
retrieveLocalVariable
in interface Compiler
index
- The index of the local variable to retrievepublic void retrieveLastLine()
Compiler
retrieveLastLine
in interface Compiler
public void retrieveBackRef()
Compiler
retrieveBackRef
in interface Compiler
public void assignLocalVariable(int index, int depth)
Compiler
assignLocalVariable
in interface Compiler
index
- The index in which to store the local variabledepth
- The lexical scoping depth in which to store the variablepublic void assignLocalVariableBlockArg(int argIndex, int varIndex, int depth)
Compiler
assignLocalVariableBlockArg
in interface Compiler
depth
- The lexical scoping depth in which to store the variablepublic void retrieveLocalVariable(int index, int depth)
Compiler
retrieveLocalVariable
in interface Compiler
index
- The index of the local variable to retrievedepth
- The lexical scoping depth from which to retrieve the variablepublic void assignConstantInCurrent(java.lang.String name)
assignConstantInCurrent
in interface Compiler
public void assignConstantInModule(java.lang.String name)
assignConstantInModule
in interface Compiler
public void assignConstantInObject(java.lang.String name)
assignConstantInObject
in interface Compiler
public void retrieveConstant(java.lang.String name)
Compiler
retrieveConstant
in interface Compiler
name
- The name of the constantpublic void retrieveClassVariable(java.lang.String name)
retrieveClassVariable
in interface Compiler
public void assignClassVariable(java.lang.String name)
assignClassVariable
in interface Compiler
public void createNewFloat(double value)
Compiler
createNewFloat
in interface Compiler
public void createNewFixnum(long value)
Compiler
createNewFixnum
in interface Compiler
public void createNewBignum(java.math.BigInteger value)
Compiler
createNewBignum
in interface Compiler
public void createNewString(ArrayCallback callback, int count)
Compiler
createNewString
in interface Compiler
public void createNewString(ByteList value)
Compiler
createNewString
in interface Compiler
public void createNewSymbol(java.lang.String name)
Compiler
createNewSymbol
in interface Compiler
public void createNewArray()
Compiler
createNewArray
in interface Compiler
public void createEmptyArray()
Compiler
createEmptyArray
in interface Compiler
public void createObjectArray(java.lang.Object[] sourceArray, ArrayCallback callback)
createObjectArray
in interface Compiler
public void createObjectArray(int elementCount)
Compiler
elementCountelements into a single element, generally an array or similar construct. The specified number of elements are consumed and an aggregate element remains.
createObjectArray
in interface Compiler
elementCount
- The number of elements to consumepublic void createEmptyHash()
Compiler
createEmptyHash
in interface Compiler
public void createNewHash(java.lang.Object elements, ArrayCallback callback, int keyCount)
Compiler
createNewHash
in interface Compiler
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 createNewRange(boolean isExclusive)
Compiler
createNewRange
in interface Compiler
isExclusive
- Whether the range is exclusive or not (inclusive)public void performBooleanBranch(BranchCallback trueBranch, BranchCallback falseBranch)
Compiler
performBooleanBranch
in interface Compiler
trueBranch
- The callback for generating code for the "true" conditionfalseBranch
- The callback for generating code for the "false" conditionpublic void performLogicalAnd(BranchCallback longBranch)
Compiler
performLogicalAnd
in interface Compiler
longBranch
- The branch to execute if the "and" operation does not short-circuit.public void performLogicalOr(BranchCallback longBranch)
Compiler
performLogicalOr
in interface Compiler
longBranch
- The branch to execute if the "or" operation does not short-circuit.public void performBooleanLoop(BranchCallback condition, BranchCallback body, boolean checkFirst)
Compiler
performBooleanLoop
in interface Compiler
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 performReturn()
Compiler
performReturn
in interface Compiler
public void createNewClosure(StaticScope scope, int arity, ClosureCallback body, ClosureCallback args)
Compiler
createNewClosure
in interface Compiler
scope
- The static scoping informationarity
- The arity of the block's argument listbody
- The callback which will generate the closure's bodypublic void defineAlias(java.lang.String newName, java.lang.String oldName)
Compiler
defineAlias
in interface Compiler
newName
- The new alias to createoldName
- The name of the existing method or aliaspublic void defineNewMethod(java.lang.String name, StaticScope scope, ClosureCallback body, ClosureCallback args)
Compiler
defineNewMethod
in interface Compiler
name
- The name to which to bind the resulting method.body
- The callback which will generate the method's body.public void processRequiredArgs(Arity arity, int totalArgs)
processRequiredArgs
in interface Compiler
public void assignOptionalArgs(java.lang.Object object, int expectedArgsCount, int size, ArrayCallback optEval)
assignOptionalArgs
in interface Compiler
public void loadFalse()
Compiler
loadFalse
in interface Compiler
public void loadTrue()
Compiler
loadTrue
in interface Compiler
public void retrieveInstanceVariable(java.lang.String name)
Compiler
retrieveInstanceVariable
in interface Compiler
name
- The name of the instance variable to retrieve.public void assignInstanceVariable(java.lang.String name)
Compiler
assignInstanceVariable
in interface Compiler
name
- The name of the value to assign.public void assignInstanceVariableBlockArg(int argIndex, java.lang.String name)
Compiler
assignInstanceVariableBlockArg
in interface Compiler
argIndex
- The index in the incoming arguments from which to get the ivar valuename
- The name of the ivar to assign.public void retrieveGlobalVariable(java.lang.String name)
Compiler
retrieveGlobalVariable
in interface Compiler
name
- The name of the global variable.public void assignGlobalVariable(java.lang.String name)
Compiler
assignGlobalVariable
in interface Compiler
name
- The name of the global variable.public void assignGlobalVariableBlockArg(int argIndex, java.lang.String name)
Compiler
assignGlobalVariableBlockArg
in interface Compiler
argIndex
- The index in the incoming arguments from which to get the gvar valuename
- The name of the global variable.public void negateCurrentValue()
Compiler
negateCurrentValue
in interface Compiler
public void splatCurrentValue()
Compiler
splatCurrentValue
in interface Compiler
public void singlifySplattedValue()
Compiler
singlifySplattedValue
in interface Compiler
public void ensureRubyArray()
Compiler
ensureRubyArray
in interface Compiler
public void forEachInValueArray(int start, int count, java.lang.Object source, ArrayCallback callback)
Compiler
forEachInValueArray
in interface Compiler
public void loadInteger(int value)
Compiler
loadInteger
in interface Compiler
public void performGEBranch(BranchCallback trueBranch, BranchCallback falseBranch)
Compiler
performGEBranch
in interface Compiler
public void performGTBranch(BranchCallback trueBranch, BranchCallback falseBranch)
Compiler
performGTBranch
in interface Compiler
public void performLEBranch(BranchCallback trueBranch, BranchCallback falseBranch)
Compiler
performLEBranch
in interface Compiler
public void performLTBranch(BranchCallback trueBranch, BranchCallback falseBranch)
Compiler
performLTBranch
in interface Compiler
public void loadRubyArraySize()
loadRubyArraySize
in interface Compiler
public void issueBreakEvent()
issueBreakEvent
in interface Compiler
public void asString()
asString
in interface Compiler
public void nthRef(int match)
nthRef
in interface Compiler
public void match()
match
in interface Compiler
public void match2()
match2
in interface Compiler
public void match3()
match3
in interface Compiler
public void createNewRegexp(ByteList value, int options, java.lang.String lang)
createNewRegexp
in interface Compiler
public void defineClass(java.lang.String name, StaticScope staticScope, ClosureCallback superCallback, ClosureCallback pathCallback, ClosureCallback bodyCallback)
defineClass
in interface Compiler
public void defineModule(java.lang.String name, StaticScope staticScope, ClosureCallback pathCallback, ClosureCallback bodyCallback)
defineModule
in interface Compiler
public void pollThreadEvents()
pollThreadEvents
in interface Compiler
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |