org.jruby.compiler.impl
Class StandardASMCompiler

java.lang.Object
  extended byorg.jruby.compiler.impl.StandardASMCompiler
All Implemented Interfaces:
Compiler

public class StandardASMCompiler
extends java.lang.Object
implements Compiler

Author:
headius

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

StandardASMCompiler

public StandardASMCompiler(java.lang.String classname,
                           java.lang.String sourcename)
Creates a new instance of StandardCompilerContext


StandardASMCompiler

public StandardASMCompiler(Node node)
Method Detail

loadClass

public java.lang.Class loadClass(JRubyClassLoader classLoader)
                          throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

writeClass

public void writeClass(java.io.File destination)
                throws java.io.IOException
Throws:
java.io.IOException

getClassname

public java.lang.String getClassname()

getSourcename

public java.lang.String getSourcename()

getClassVisitor

public ClassVisitor getClassVisitor()

getMethodAdapter

public SkinnyMethodAdapter getMethodAdapter()

popMethodAdapter

public SkinnyMethodAdapter popMethodAdapter()

pushMethodAdapter

public void pushMethodAdapter(SkinnyMethodAdapter mv)

getArity

public int getArity()

pushArity

public void pushArity(Arity arity)

popArity

public Arity popArity()

pushScopeStart

public void pushScopeStart(Label start)

popScopeStart

public Label popScopeStart()

startScript

public void startScript()
Description copied from interface: Compiler
Begin compilation for a script, preparing all necessary context and code to support this script's compiled representation.

Specified by:
startScript in interface Compiler

endScript

public void endScript()
Description copied from interface: Compiler
End compilation for the current script, closing all context and structures used for the compilation.

Specified by:
endScript in interface Compiler

beginMethod

public java.lang.Object beginMethod(java.lang.String friendlyName,
                                    ClosureCallback args)
Description copied from interface: Compiler
Begin compilation for a method that has the specified number of local variables. The returned value is a token that can be used to end the method later.

Specified by:
beginMethod in interface Compiler
Parameters:
friendlyName - The outward user-readable name of the method. A unique name will be generated based on this.
Returns:
An Object that represents the method within this compiler. Used in calls to endMethod once compilation for this method is completed.

endMethod

public void endMethod(java.lang.Object token)
Description copied from interface: Compiler
End compilation for the method associated with the specified token. This should close out all structures created for compilation of the method.

Specified by:
endMethod in interface Compiler
Parameters:
token - A token identifying the method to be terminated.

lineNumber

public void lineNumber(ISourcePosition position)
Description copied from interface: Compiler
This method provides a way to specify a line number for the current piece of code being compiled. The compiler may use this information to create debugging information in a bytecode-format-dependent way.

Specified by:
lineNumber in interface Compiler
Parameters:
position - The ISourcePosition information to use.

invokeAttrAssign

public void invokeAttrAssign(java.lang.String name)
Description copied from interface: Compiler
Attr assign calls have slightly different semantics that normal calls, so this method handles those additional semantics.

Specified by:
invokeAttrAssign in interface Compiler

invokeDynamic

public void invokeDynamic(java.lang.String name,
                          boolean hasReceiver,
                          boolean hasArgs,
                          CallType callType,
                          ClosureCallback closureArg,
                          boolean attrAssign)
Description copied from interface: Compiler
Invoke the named method as a "function", i.e. as a method on the current "self" object, using the specified argument count. It is expected that previous calls to the compiler has prepared the exact number of argument values necessary for this call. Those values will be consumed, and the result of the call will be generated.

Specified by:
invokeDynamic in interface Compiler

yield

public void yield(boolean hasArgs)
Description copied from interface: Compiler
Invoke the block passed into this method, or throw an error if no block is present. If arguments have been prepared for the block, specify true. Otherwise the default empty args will be used.

Specified by:
yield in interface Compiler

loadThreadContext

public void loadThreadContext()

loadClosure

public void loadClosure()

loadSelf

public void loadSelf()

loadRuntime

public void loadRuntime()

loadVisibility

public void loadVisibility()

loadNil

public void loadNil()
Description copied from interface: Compiler
Load a Ruby "nil" value on top of the stack.

Specified by:
loadNil in interface Compiler

loadSymbol

public void loadSymbol(java.lang.String symbol)
Description copied from interface: Compiler
Load the given string as a symbol on to the top of the stack.

Specified by:
loadSymbol in interface Compiler
Parameters:
symbol - The symbol to load.

loadObject

public void loadObject()
Description copied from interface: Compiler
Load the Object class

Specified by:
loadObject in interface Compiler

consumeCurrentValue

public void consumeCurrentValue()
Description copied from interface: Compiler
As code executes, values are assumed to be "generated", often by being pushed on to some execution stack. Generally, these values are consumed by other methods on the context, but occasionally a value must be "thrown out". This method provides a way to discard the previous value generated by some other call(s).

Specified by:
consumeCurrentValue in interface Compiler

duplicateCurrentValue

public void duplicateCurrentValue()
Description copied from interface: Compiler
Push a copy the topmost value on the stack.

Specified by:
duplicateCurrentValue in interface Compiler

swapValues

public void swapValues()
Description copied from interface: Compiler
Swap the top and second values on the stack.

Specified by:
swapValues in interface Compiler

retrieveSelf

public void retrieveSelf()
Description copied from interface: Compiler
Retrieve the current "self" and put a reference on top of the stack.

Specified by:
retrieveSelf in interface Compiler

retrieveSelfClass

public void retrieveSelfClass()
Description copied from interface: Compiler
Retrieve the current "self" object's metaclass and put a reference on top of the stack

Specified by:
retrieveSelfClass in interface Compiler

assignLocalVariable

public void assignLocalVariable(int index)
Description copied from interface: Compiler
Assigns the value on top of the stack to a local variable at the specified index, consuming that value in the process. This assumes a lexical scoping depth of 0.

Specified by:
assignLocalVariable in interface Compiler
Parameters:
index - The index of the local variable to which to assign the value.

assignLastLine

public void assignLastLine()
Description copied from interface: Compiler
Assigns the special "last line" variable $_ in the outermost local scope.

Specified by:
assignLastLine in interface Compiler

assignLocalVariableBlockArg

public void assignLocalVariableBlockArg(int argIndex,
                                        int varIndex)
Description copied from interface: Compiler
Assigns the value from incoming block args to a local variable at the specified index, consuming that value in the process. This assumes a lexical scoping depth of 0.

Specified by:
assignLocalVariableBlockArg in interface Compiler

retrieveLocalVariable

public void retrieveLocalVariable(int index)
Description copied from interface: Compiler
Retrieve the local variable at the specified index to the top of the stack, using whatever local variable store is appropriate. This assumes the local variable in question should be present at the current lexical scoping depth (0).

Specified by:
retrieveLocalVariable in interface Compiler
Parameters:
index - The index of the local variable to retrieve

retrieveLastLine

public void retrieveLastLine()
Description copied from interface: Compiler
Retrieve the special "last line" variable $_ from the outermost local scope.

Specified by:
retrieveLastLine in interface Compiler

retrieveBackRef

public void retrieveBackRef()
Description copied from interface: Compiler
Retrieve the special "back ref" variable $~ from the outermost local scope.

Specified by:
retrieveBackRef in interface Compiler

assignLocalVariable

public void assignLocalVariable(int index,
                                int depth)
Description copied from interface: Compiler
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.

Specified by:
assignLocalVariable in interface Compiler
Parameters:
index - The index in which to store the local variable
depth - The lexical scoping depth in which to store the variable

assignLocalVariableBlockArg

public void assignLocalVariableBlockArg(int argIndex,
                                        int varIndex,
                                        int depth)
Description copied from interface: Compiler
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.

Specified by:
assignLocalVariableBlockArg in interface Compiler
Parameters:
depth - The lexical scoping depth in which to store the variable

retrieveLocalVariable

public void retrieveLocalVariable(int index,
                                  int depth)
Description copied from interface: Compiler
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.

Specified by:
retrieveLocalVariable in interface Compiler
Parameters:
index - The index of the local variable to retrieve
depth - The lexical scoping depth from which to retrieve the variable

assignConstantInCurrent

public void assignConstantInCurrent(java.lang.String name)
Specified by:
assignConstantInCurrent in interface Compiler

assignConstantInModule

public void assignConstantInModule(java.lang.String name)
Specified by:
assignConstantInModule in interface Compiler

assignConstantInObject

public void assignConstantInObject(java.lang.String name)
Specified by:
assignConstantInObject in interface Compiler

retrieveConstant

public void retrieveConstant(java.lang.String name)
Description copied from interface: Compiler
Retrieve the constant with the specified name available at the current point in the program's execution.

Specified by:
retrieveConstant in interface Compiler
Parameters:
name - The name of the constant

retrieveClassVariable

public void retrieveClassVariable(java.lang.String name)
Specified by:
retrieveClassVariable in interface Compiler

assignClassVariable

public void assignClassVariable(java.lang.String name)
Specified by:
assignClassVariable in interface Compiler

createNewFloat

public void createNewFloat(double value)
Description copied from interface: Compiler
Generate a new "Float" value.

Specified by:
createNewFloat in interface Compiler

createNewFixnum

public void createNewFixnum(long value)
Description copied from interface: Compiler
Generate a new "Fixnum" value.

Specified by:
createNewFixnum in interface Compiler

createNewBignum

public void createNewBignum(java.math.BigInteger value)
Description copied from interface: Compiler
Generate a new "Bignum" value.

Specified by:
createNewBignum in interface Compiler

createNewString

public void createNewString(ArrayCallback callback,
                            int count)
Description copied from interface: Compiler
Generate a new dynamic "String" value.

Specified by:
createNewString in interface Compiler

createNewString

public void createNewString(ByteList value)
Description copied from interface: Compiler
Generate a new "String" value.

Specified by:
createNewString in interface Compiler

createNewSymbol

public void createNewSymbol(java.lang.String name)
Description copied from interface: Compiler
Generate a new "Symbol" value (or fetch the existing one).

Specified by:
createNewSymbol in interface Compiler

createNewArray

public void createNewArray()
Description copied from interface: Compiler
Given an aggregated set of objects (likely created through a call to createObjectArray) create a Ruby array object.

Specified by:
createNewArray in interface Compiler

createEmptyArray

public void createEmptyArray()
Description copied from interface: Compiler
Create an empty Ruby array

Specified by:
createEmptyArray in interface Compiler

createObjectArray

public void createObjectArray(java.lang.Object[] sourceArray,
                              ArrayCallback callback)
Specified by:
createObjectArray in interface Compiler

createObjectArray

public void createObjectArray(int elementCount)
Description copied from interface: Compiler
Combine the top
elementCount
elements into a single element, generally an array or similar construct. The specified number of elements are consumed and an aggregate element remains.

Specified by:
createObjectArray in interface Compiler
Parameters:
elementCount - The number of elements to consume

createEmptyHash

public void createEmptyHash()
Description copied from interface: Compiler
Create an empty Ruby Hash object and put a reference on top of the stack.

Specified by:
createEmptyHash in interface Compiler

createNewHash

public void createNewHash(java.lang.Object elements,
                          ArrayCallback callback,
                          int keyCount)
Description copied from interface: Compiler
Create a new hash by calling back to the specified ArrayCallback. It is expected that the keyCount will be the actual count of key/value pairs, and the caller will handle passing an appropriate elements collection in and dealing with the sequential indices passed to the callback.

Specified by:
createNewHash in interface Compiler
Parameters:
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.

createNewRange

public void createNewRange(boolean isExclusive)
Description copied from interface: Compiler
Create a new range. It is expected that the stack will contain the end and begin values for the range as its topmost and second topmost elements.

Specified by:
createNewRange in interface Compiler
Parameters:
isExclusive - Whether the range is exclusive or not (inclusive)

performBooleanBranch

public void performBooleanBranch(BranchCallback trueBranch,
                                 BranchCallback falseBranch)
Description copied from interface: Compiler
Perform a boolean branch operation based on the Ruby "true" value of the top value on the stack. If Ruby "true", invoke the true branch callback. Otherwise, invoke the false branch callback.

Specified by:
performBooleanBranch in interface Compiler
Parameters:
trueBranch - The callback for generating code for the "true" condition
falseBranch - The callback for generating code for the "false" condition

performLogicalAnd

public void performLogicalAnd(BranchCallback longBranch)
Description copied from interface: Compiler
Perform a logical short-circuited Ruby "and" operation, using Ruby notions of true and false. If the value on top of the stack is false, it remains and the branch is not executed. If it is true, the top of the stack is replaced with the result of the branch.

Specified by:
performLogicalAnd in interface Compiler
Parameters:
longBranch - The branch to execute if the "and" operation does not short-circuit.

performLogicalOr

public void performLogicalOr(BranchCallback longBranch)
Description copied from interface: Compiler
Perform a logical short-circuited Ruby "or" operation, using Ruby notions of true and false. If the value on top of the stack is true, it remains and the branch is not executed. If it is false, the top of the stack is replaced with the result of the branch.

Specified by:
performLogicalOr in interface Compiler
Parameters:
longBranch - The branch to execute if the "or" operation does not short-circuit.

performBooleanLoop

public void performBooleanLoop(BranchCallback condition,
                               BranchCallback body,
                               boolean checkFirst)
Description copied from interface: Compiler
Perform a boolean loop using the given condition-calculating branch and body branch. For while loops, pass true for checkFirst. For statement-modifier while loops, pass false. For unless loops, reverse the result of the condition after calculating it.

Specified by:
performBooleanLoop in interface Compiler
Parameters:
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.

performReturn

public void performReturn()
Description copied from interface: Compiler
Return the current value on the top of the stack, taking into consideration surrounding blocks.

Specified by:
performReturn in interface Compiler

createNewClosure

public void createNewClosure(StaticScope scope,
                             int arity,
                             ClosureCallback body,
                             ClosureCallback args)
Description copied from interface: Compiler
Create a new closure (block) using the given lexical scope information, call arity, and body generated by the body callback. The closure will capture containing scopes and related information.

Specified by:
createNewClosure in interface Compiler
Parameters:
scope - The static scoping information
arity - The arity of the block's argument list
body - The callback which will generate the closure's body

defineAlias

public void defineAlias(java.lang.String newName,
                        java.lang.String oldName)
Description copied from interface: Compiler
Define an alias for a new name to an existing oldName'd method.

Specified by:
defineAlias in interface Compiler
Parameters:
newName - The new alias to create
oldName - The name of the existing method or alias

defineNewMethod

public void defineNewMethod(java.lang.String name,
                            StaticScope scope,
                            ClosureCallback body,
                            ClosureCallback args)
Description copied from interface: Compiler
Define a new method with the given name, arity, local variable count, and body callback. This will create a new compiled method and bind it to the given name at this point in the program's execution.

Specified by:
defineNewMethod in interface Compiler
Parameters:
name - The name to which to bind the resulting method.
body - The callback which will generate the method's body.

processRequiredArgs

public void processRequiredArgs(Arity arity,
                                int totalArgs)
Specified by:
processRequiredArgs in interface Compiler

assignOptionalArgs

public void assignOptionalArgs(java.lang.Object object,
                               int expectedArgsCount,
                               int size,
                               ArrayCallback optEval)
Specified by:
assignOptionalArgs in interface Compiler

loadFalse

public void loadFalse()
Description copied from interface: Compiler
Load a Ruby "false" value on top of the stack.

Specified by:
loadFalse in interface Compiler

loadTrue

public void loadTrue()
Description copied from interface: Compiler
Load a Ruby "true" value on top of the stack.

Specified by:
loadTrue in interface Compiler

retrieveInstanceVariable

public void retrieveInstanceVariable(java.lang.String name)
Description copied from interface: Compiler
Retrieve the instance variable with the given name, based on the current "self".

Specified by:
retrieveInstanceVariable in interface Compiler
Parameters:
name - The name of the instance variable to retrieve.

assignInstanceVariable

public void assignInstanceVariable(java.lang.String name)
Description copied from interface: Compiler
Assign the value on top of the stack to the instance variable with the specified name on the current "self". The value is consumed.

Specified by:
assignInstanceVariable in interface Compiler
Parameters:
name - The name of the value to assign.

assignInstanceVariableBlockArg

public void assignInstanceVariableBlockArg(int argIndex,
                                           java.lang.String name)
Description copied from interface: Compiler
Assign the value from incoming block args instance variable with the specified name on the current "self".

Specified by:
assignInstanceVariableBlockArg in interface Compiler
Parameters:
argIndex - The index in the incoming arguments from which to get the ivar value
name - The name of the ivar to assign.

retrieveGlobalVariable

public void retrieveGlobalVariable(java.lang.String name)
Description copied from interface: Compiler
Retrieve the global variable with the specified name to the top of the stack.

Specified by:
retrieveGlobalVariable in interface Compiler
Parameters:
name - The name of the global variable.

assignGlobalVariable

public void assignGlobalVariable(java.lang.String name)
Description copied from interface: Compiler
Assign the top of the stack to the global variable with the specified name.

Specified by:
assignGlobalVariable in interface Compiler
Parameters:
name - The name of the global variable.

assignGlobalVariableBlockArg

public void assignGlobalVariableBlockArg(int argIndex,
                                         java.lang.String name)
Description copied from interface: Compiler
Assign the value from incoming block args to the global variable with the specified name.

Specified by:
assignGlobalVariableBlockArg in interface Compiler
Parameters:
argIndex - The index in the incoming arguments from which to get the gvar value
name - The name of the global variable.

negateCurrentValue

public void negateCurrentValue()
Description copied from interface: Compiler
Perform a logical Ruby "not" operation on the value on top of the stack, leaving the negated result.

Specified by:
negateCurrentValue in interface Compiler

splatCurrentValue

public void splatCurrentValue()
Description copied from interface: Compiler
Convert the current value into a "splatted value" suitable for passing as method arguments or disassembling into multiple variables.

Specified by:
splatCurrentValue in interface Compiler

singlifySplattedValue

public void singlifySplattedValue()
Description copied from interface: Compiler
Given a splatted value, extract a single value. If no splat or length is zero, use nil

Specified by:
singlifySplattedValue in interface Compiler

ensureRubyArray

public void ensureRubyArray()
Description copied from interface: Compiler
Ensures that the present value is an IRubyObject[] by wrapping it with one if it is not.

Specified by:
ensureRubyArray in interface Compiler

forEachInValueArray

public void forEachInValueArray(int start,
                                int count,
                                java.lang.Object source,
                                ArrayCallback callback)
Description copied from interface: Compiler
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'.

Specified by:
forEachInValueArray in interface Compiler

loadInteger

public void loadInteger(int value)
Description copied from interface: Compiler
Load an integer value suitable for numeric comparisons

Specified by:
loadInteger in interface Compiler

performGEBranch

public void performGEBranch(BranchCallback trueBranch,
                            BranchCallback falseBranch)
Description copied from interface: Compiler
Perform a greater-than-or-equal test and branch, given the provided true and false branches.

Specified by:
performGEBranch in interface Compiler

performGTBranch

public void performGTBranch(BranchCallback trueBranch,
                            BranchCallback falseBranch)
Description copied from interface: Compiler
Perform a greater-than test and branch, given the provided true and false branches.

Specified by:
performGTBranch in interface Compiler

performLEBranch

public void performLEBranch(BranchCallback trueBranch,
                            BranchCallback falseBranch)
Description copied from interface: Compiler
Perform a greater-than-or-equal test and branch, given the provided true and false branches.

Specified by:
performLEBranch in interface Compiler

performLTBranch

public void performLTBranch(BranchCallback trueBranch,
                            BranchCallback falseBranch)
Description copied from interface: Compiler
Perform a greater-than test and branch, given the provided true and false branches.

Specified by:
performLTBranch in interface Compiler

loadRubyArraySize

public void loadRubyArraySize()
Specified by:
loadRubyArraySize in interface Compiler

issueBreakEvent

public void issueBreakEvent()
Specified by:
issueBreakEvent in interface Compiler

asString

public void asString()
Specified by:
asString in interface Compiler

nthRef

public void nthRef(int match)
Specified by:
nthRef in interface Compiler

match

public void match()
Specified by:
match in interface Compiler

match2

public void match2()
Specified by:
match2 in interface Compiler

match3

public void match3()
Specified by:
match3 in interface Compiler

createNewRegexp

public void createNewRegexp(ByteList value,
                            int options,
                            java.lang.String lang)
Specified by:
createNewRegexp in interface Compiler

defineClass

public void defineClass(java.lang.String name,
                        StaticScope staticScope,
                        ClosureCallback superCallback,
                        ClosureCallback pathCallback,
                        ClosureCallback bodyCallback)
Specified by:
defineClass in interface Compiler

defineModule

public void defineModule(java.lang.String name,
                         StaticScope staticScope,
                         ClosureCallback pathCallback,
                         ClosureCallback bodyCallback)
Specified by:
defineModule in interface Compiler

pollThreadEvents

public void pollThreadEvents()
Specified by:
pollThreadEvents in interface Compiler


Copyright © 2002-2007 JRuby Team. All Rights Reserved.