org.jruby.compiler
Interface ScriptCompiler

All Known Implementing Classes:
StandardASMCompiler

public interface ScriptCompiler

Compiler represents the current state of a compiler and all appropriate transitions and modifications that can be made within it. The methods here begin and end a class for a given compile run, begin and end methods for the script being compiled, set line number information, and generate code for all the basic operations necessary for a script to run. The intent of this interface is to provide a library-neutral set of functions for compiling a given script using any backend or any output format.


Method Summary
 void endScript(boolean generateLoad, boolean generateMain)
          End compilation for the current script, closing all context and structures used for the compilation.
 BodyCompiler startFileMethod(CompilerCallback args, StaticScope scope, ASTInspector inspector)
          Begin compilation for the root of a script named __file__.
 BodyCompiler startMethod(java.lang.String rubyName, java.lang.String javaName, CompilerCallback argsHandler, StaticScope scope, ASTInspector inspector)
          Begin compilation for a method that has the specified number of local variables.
 BodyCompiler startRoot(java.lang.String rubyName, java.lang.String javaName, StaticScope scope, ASTInspector inspector)
          Begin compilation for a the root of a script.
 void startScript(StaticScope scope)
          Begin compilation for a script, preparing all necessary context and code to support this script's compiled representation.
 

Method Detail

startScript

void startScript(StaticScope scope)
Begin compilation for a script, preparing all necessary context and code to support this script's compiled representation.


endScript

void endScript(boolean generateLoad,
               boolean generateMain)
End compilation for the current script, closing all context and structures used for the compilation.


startMethod

BodyCompiler startMethod(java.lang.String rubyName,
                         java.lang.String javaName,
                         CompilerCallback argsHandler,
                         StaticScope scope,
                         ASTInspector inspector)
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.

Parameters:
javaName - The outward user-readable name of the method. A unique name will be generated based on this.
arity - The arity of the method's argument list
localVarCount - The number of local variables that will be used by the method.
Returns:
An Object that represents the method within this compiler. Used in calls to endMethod once compilation for this method is completed.

startRoot

BodyCompiler startRoot(java.lang.String rubyName,
                       java.lang.String javaName,
                       StaticScope scope,
                       ASTInspector inspector)
Begin compilation for a the root of a script. This differs from method compilation in that it doesn't do specific-arity logic, nor does it require argument processing.

Parameters:
javaName - The outward user-readable name of the method. A unique name will be generated based on this.
arity - The arity of the method's argument list
localVarCount - The number of local variables that will be used by the method.
Returns:
An Object that represents the method within this compiler. Used in calls to endMethod once compilation for this method is completed.

startFileMethod

BodyCompiler startFileMethod(CompilerCallback args,
                             StaticScope scope,
                             ASTInspector inspector)
Begin compilation for the root of a script named __file__.

Parameters:
args - Arguments to the script, as passed via jitted wrappers
scope - The StaticScope for the script
inspector - The ASTInspector for the nodes for the script
Returns:
A new BodyCompiler for the body of the script


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