polyglot.frontend
Interface ExtensionInfo

All Known Implementing Classes:
AbstractExtensionInfo, ExtensionInfo, ExtensionInfo, ExtensionInfo, ExtensionInfo

public interface ExtensionInfo

ExtensionInfo is the main interface for defining language extensions. The frontend will load the ExtensionInfo specified on the command-line. It defines the type system, AST node factory, parser, and other parameters of a language extension.


Method Summary
 void addDependencyToCurrentJob(Source s)
          Adds a dependency from the current job to the given Source.
 SourceJob addJob(Source source)
          Produce a job for the given source.
 SourceJob addJob(Source source, Node ast)
          Produce a job for a given source using the given AST.
 void afterPass(java.util.List passes, Pass.ID oldPass, java.util.List newPasses)
          Add a list of passes after an existing pass.
 void afterPass(java.util.List passes, Pass.ID oldPass, Pass newPass)
          Add a pass after an existing pass.
 void beforePass(java.util.List passes, Pass.ID oldPass, java.util.List newPasses)
          Add a list of passes before an existing pass.
 void beforePass(java.util.List passes, Pass.ID oldPass, Pass newPass)
          Add a pass before an existing pass.
 Compiler compiler()
           
 java.lang.String compilerName()
          The name of the compiler for usage messages
 ClassFile createClassFile(java.io.File classFileSource, byte[] code)
          Create class file
 java.lang.String defaultFileExtension()
          The default extension that source files are expected to have.
 java.lang.String[] defaultFileExtensions()
          The default extensions that source files are expected to have.
 java.lang.String[] fileExtensions()
          The extensions that source files are expected to have.
 Options getOptions()
          Return an Options object, which will be given the command line to parse.
 Stats getStats()
          Return a Stats object to accumulate and report statistics.
 void initCompiler(Compiler compiler)
          Initialize the extension with a particular compiler.
 NodeFactory nodeFactory()
          Produce a node factory for this language extension.
 Parser parser(java.io.Reader reader, FileSource source, ErrorQueue eq)
          Get a parser for this language extension.
 java.util.List passes(Job job)
          Get the list of passes for a given source job.
 java.util.List passes(Job job, Pass.ID begin, Pass.ID end)
          Get the sublist of passes for a given job.
 boolean readSource(FileSource source)
          Read a source file and compile up to the current job's barrier.
 void removePass(java.util.List passes, Pass.ID oldPass)
          Remove a pass.
 void replacePass(java.util.List passes, Pass.ID oldPass, java.util.List newPasses)
          Replace an existing pass with a list of new passes.
 void replacePass(java.util.List passes, Pass.ID oldPass, Pass newPass)
          Replace an existing pass with a new pass.
 boolean runAllPasses(Job job)
          Run the given job to completion.
 boolean runToCompletion()
          Run all jobs to completion.
 boolean runToPass(Job job, Pass.ID goal)
          Run the given job up to a given pass.
 SourceLoader sourceLoader()
          Produce a source factory for this language extension.
 Job spawnJob(Context c, Node ast, Job outerJob, Pass.ID begin, Pass.ID end)
          Spawn a new job.
 TargetFactory targetFactory()
          Produce a target factory for this language extension.
 TypeSystem typeSystem()
          Produce a type system for this language extension.
 Version version()
          Report the version of the extension.
 

Method Detail

compilerName

java.lang.String compilerName()
The name of the compiler for usage messages


version

Version version()
Report the version of the extension.


getOptions

Options getOptions()
Return an Options object, which will be given the command line to parse.


getStats

Stats getStats()
Return a Stats object to accumulate and report statistics.


initCompiler

void initCompiler(Compiler compiler)
Initialize the extension with a particular compiler. This must be called after the compiler is initialized, but before the compiler starts work.


compiler

Compiler compiler()

fileExtensions

java.lang.String[] fileExtensions()
The extensions that source files are expected to have. Defaults to the array defaultFileExtensions.


defaultFileExtensions

java.lang.String[] defaultFileExtensions()
The default extensions that source files are expected to have. Defaults to an array containing defaultFileExtension


defaultFileExtension

java.lang.String defaultFileExtension()
The default extension that source files are expected to have.


typeSystem

TypeSystem typeSystem()
Produce a type system for this language extension.


nodeFactory

NodeFactory nodeFactory()
Produce a node factory for this language extension.


sourceLoader

SourceLoader sourceLoader()
Produce a source factory for this language extension.


addDependencyToCurrentJob

void addDependencyToCurrentJob(Source s)
Adds a dependency from the current job to the given Source.


addJob

SourceJob addJob(Source source)
Produce a job for the given source. A new job will be created if needed. If the Source source has already been processed, and its job discarded to release resources, then null will be returned.


addJob

SourceJob addJob(Source source,
                 Node ast)
Produce a job for a given source using the given AST. A new job will be created if needed. If the Source source has already been processed, and its job discarded to release resources, then null will be returned.


spawnJob

Job spawnJob(Context c,
             Node ast,
             Job outerJob,
             Pass.ID begin,
             Pass.ID end)
Spawn a new job. All passes between the pass begin and end inclusive will be performed immediately on the AST ast.

Parameters:
c - the context that the AST occurs in
ast - the AST the new Job is for.
outerJob - the Job that spawned this job.
begin - the first pass to perform for this job.
end - the last pass to perform for this job.
Returns:
the new job. The caller can check the result with j.status() and get the ast with j.ast().

runToCompletion

boolean runToCompletion()
Run all jobs to completion.


runToPass

boolean runToPass(Job job,
                  Pass.ID goal)
                  throws CyclicDependencyException
Run the given job up to a given pass.

Throws:
CyclicDependencyException

runAllPasses

boolean runAllPasses(Job job)
Run the given job to completion.


readSource

boolean readSource(FileSource source)
Read a source file and compile up to the current job's barrier.


targetFactory

TargetFactory targetFactory()
Produce a target factory for this language extension. The target factory is responsible for naming and opening output files given a package name and a class or source file name.


parser

Parser parser(java.io.Reader reader,
              FileSource source,
              ErrorQueue eq)
Get a parser for this language extension.


passes

java.util.List passes(Job job)
Get the list of passes for a given source job.


passes

java.util.List passes(Job job,
                      Pass.ID begin,
                      Pass.ID end)
Get the sublist of passes for a given job.


beforePass

void beforePass(java.util.List passes,
                Pass.ID oldPass,
                Pass newPass)
Add a pass before an existing pass.


beforePass

void beforePass(java.util.List passes,
                Pass.ID oldPass,
                java.util.List newPasses)
Add a list of passes before an existing pass.


afterPass

void afterPass(java.util.List passes,
               Pass.ID oldPass,
               Pass newPass)
Add a pass after an existing pass.


afterPass

void afterPass(java.util.List passes,
               Pass.ID oldPass,
               java.util.List newPasses)
Add a list of passes after an existing pass.


replacePass

void replacePass(java.util.List passes,
                 Pass.ID oldPass,
                 Pass newPass)
Replace an existing pass with a new pass.


replacePass

void replacePass(java.util.List passes,
                 Pass.ID oldPass,
                 java.util.List newPasses)
Replace an existing pass with a list of new passes.


removePass

void removePass(java.util.List passes,
                Pass.ID oldPass)
Remove a pass. The removed pass cannot be a barrier.


createClassFile

ClassFile createClassFile(java.io.File classFileSource,
                          byte[] code)
Create class file