|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object polyglot.frontend.AbstractExtensionInfo
public abstract class AbstractExtensionInfo
This is an abstract ExtensionInfo
.
Field Summary | |
---|---|
protected Compiler |
compiler
|
protected static java.lang.Object |
COMPLETED_JOB
|
protected Job |
currentJob
The currently running job, or null if no job is running. |
protected java.util.Map |
jobs
A map from Source s to SourceJob s or to
the COMPLETED_JOB object if the SourceJob previously existed
but has now finished. |
protected NodeFactory |
nf
|
protected SourceLoader |
source_loader
|
protected Stats |
stats
|
protected TargetFactory |
target_factory
|
protected TypeSystem |
ts
|
protected java.util.LinkedList |
worklist
A list of all active (that is, uncompleted) SourceJob s. |
Constructor Summary | |
---|---|
AbstractExtensionInfo()
|
Method Summary | |
---|---|
void |
addDependencyToCurrentJob(Source s)
Adds a dependency from the current job to the given Source. |
SourceJob |
addJob(Source source)
Add a new SourceJob for the Source source . |
SourceJob |
addJob(Source source,
Node ast)
Add a new SourceJob for the Source source ,
with AST ast . |
void |
afterPass(java.util.List passes,
Pass.ID id,
java.util.List newPasses)
Insert the list of newPasses into passes
immediately after the pass named id . |
void |
afterPass(java.util.List passes,
Pass.ID id,
Pass pass)
Insert the pass pass into passes
immediately after the pass named id . |
void |
beforePass(java.util.List passes,
Pass.ID id,
java.util.List newPasses)
Insert the list of newPasses into passes
immediately before the pass named id . |
void |
beforePass(java.util.List passes,
Pass.ID id,
Pass pass)
Insert the pass pass into passes
immediately before the pass named id . |
Compiler |
compiler()
|
ClassFile |
createClassFile(java.io.File classFileSource,
byte[] code)
Create class file |
protected Job |
createJob(Node ast,
Context context,
Job outer,
Pass.ID begin,
Pass.ID end)
Create a new non- SourceJob Job , for the
given AST. |
protected abstract NodeFactory |
createNodeFactory()
Create the node factory for this extension. |
protected Options |
createOptions()
|
protected SourceJob |
createSourceJob(Source source,
Node ast)
Create a new SourceJob for the given source and AST. |
protected abstract TypeSystem |
createTypeSystem()
Create the type system for this extension. |
java.lang.String[] |
defaultFileExtensions()
Get the default list of file extensions. |
protected void |
enforceInvariants(Job job,
Pass pass)
Before running Pass pass on SourceJob job
make sure that all appropriate scheduling invariants are satisfied,
to ensure that all passes of other jobs that job depends
on will have already been done. |
java.lang.String[] |
fileExtensions()
Get the file name extension of source files. |
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. |
protected abstract void |
initTypeSystem()
|
JobExt |
jobExt()
Get the job extension for this language extension. |
NodeFactory |
nodeFactory()
Get the AST node factory for this extension. |
abstract Parser |
parser(java.io.Reader reader,
FileSource source,
ErrorQueue eq)
Get the parser for this language extension. |
abstract java.util.List |
passes(Job job)
Get the complete list of passes for the job. |
java.util.List |
passes(Job job,
Pass.ID begin,
Pass.ID end)
Get the sub-list of passes for the job between passes begin and end , inclusive. |
boolean |
readSource(FileSource source)
Read a source file and compile it up to the the current job's last barrier. |
void |
removePass(java.util.List passes,
Pass.ID id)
Remove the pass named id from passes . |
void |
replacePass(java.util.List passes,
Pass.ID id,
java.util.List newPasses)
Replace the pass named id in passes with
the list of newPasses . |
void |
replacePass(java.util.List passes,
Pass.ID id,
Pass pass)
Replace the pass named id in passes with
the pass pass . |
boolean |
runAllPasses(Job job)
Run all pending passes on job . |
protected void |
runPass(Job job,
Pass pass)
Run the pass pass on the job. |
boolean |
runToCompletion()
Run all jobs in the work list (and any children they have) to completion. |
boolean |
runToPass(Job job,
Pass.ID goal)
Run a job until the goal pass completes. |
boolean |
runToPass(Job job,
Pass goal)
Run a job up to the goal pass. |
protected SourceJob |
selectJobFromWorklist()
Select and remove a SourceJob from the non-empty
worklist . |
SourceLoader |
sourceLoader()
Get the source file loader object for this extension. |
Job |
spawnJob(Context c,
Node ast,
Job outerJob,
Pass.ID begin,
Pass.ID end)
Spawn a new job. |
TargetFactory |
targetFactory()
Get the target factory object for this extension. |
java.lang.String |
toString()
|
TypeSystem |
typeSystem()
Get the type system for this extension. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface polyglot.frontend.ExtensionInfo |
---|
compilerName, defaultFileExtension, version |
Field Detail |
---|
protected Compiler compiler
protected TypeSystem ts
protected NodeFactory nf
protected SourceLoader source_loader
protected TargetFactory target_factory
protected Stats stats
protected java.util.LinkedList worklist
SourceJob
s.
protected java.util.Map jobs
Source
s to SourceJob
s or to
the COMPLETED_JOB
object if the SourceJob previously existed
but has now finished. The map contains entries for all
Source
s that have had Job
s added for them.
protected static final java.lang.Object COMPLETED_JOB
protected Job currentJob
Constructor Detail |
---|
public AbstractExtensionInfo()
Method Detail |
---|
public Options getOptions()
ExtensionInfo
getOptions
in interface ExtensionInfo
protected Options createOptions()
public Stats getStats()
getStats
in interface ExtensionInfo
public Compiler compiler()
compiler
in interface ExtensionInfo
public void initCompiler(Compiler compiler)
ExtensionInfo
initCompiler
in interface ExtensionInfo
protected abstract void initTypeSystem()
public boolean runToCompletion()
true
if all jobs were
successfully completed. If all jobs were successfully completed, then
the worklist will be empty.
The scheduling of Job
s uses two methods to maintain
scheduling invariants: selectJobFromWorklist
selects
a SourceJob
from worklist
(a list of
jobs that still need to be processed); enforceInvariants
is
called before a pass is performed on a SourceJob
and is
responsible for ensuring all dependencies are satisfied before the
pass proceeds, i.e. enforcing any scheduling invariants.
runToCompletion
in interface ExtensionInfo
protected SourceJob selectJobFromWorklist()
SourceJob
from the non-empty
worklist
. Return the selected SourceJob
which will be scheduled to run all of its remaining passes.
public boolean readSource(FileSource source)
readSource
in interface ExtensionInfo
public boolean runAllPasses(Job job)
job
.
runAllPasses
in interface ExtensionInfo
public boolean runToPass(Job job, Pass.ID goal)
goal
pass completes.
runToPass
in interface ExtensionInfo
public boolean runToPass(Job job, Pass goal)
goal
pass.
protected void runPass(Job job, Pass pass) throws CyclicDependencyException
pass
on the job. Before running the pass on
the job, if the job is a SourceJob
, then this method will
ensure that the scheduling invariants are enforced by calling
enforceInvariants
.
CyclicDependencyException
protected void enforceInvariants(Job job, Pass pass) throws CyclicDependencyException
Pass pass
on SourceJob job
make sure that all appropriate scheduling invariants are satisfied,
to ensure that all passes of other jobs that job
depends
on will have already been done.
CyclicDependencyException
public java.lang.String[] fileExtensions()
fileExtensions
in interface ExtensionInfo
public java.lang.String[] defaultFileExtensions()
defaultFileExtensions
in interface ExtensionInfo
public SourceLoader sourceLoader()
sourceLoader
in interface ExtensionInfo
public TargetFactory targetFactory()
targetFactory
in interface ExtensionInfo
protected abstract TypeSystem createTypeSystem()
public TypeSystem typeSystem()
typeSystem
in interface ExtensionInfo
protected abstract NodeFactory createNodeFactory()
public NodeFactory nodeFactory()
nodeFactory
in interface ExtensionInfo
public JobExt jobExt()
Job
class
without subtyping.
public void addDependencyToCurrentJob(Source s)
addDependencyToCurrentJob
in interface ExtensionInfo
public SourceJob addJob(Source source)
SourceJob
for the Source 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
in interface ExtensionInfo
public SourceJob addJob(Source source, Node ast)
SourceJob
for the Source source
,
with AST 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.
addJob
in interface ExtensionInfo
protected SourceJob createSourceJob(Source source, Node ast)
SourceJob
for the given source and AST.
In general, this method should only be called by addJob
.
protected Job createJob(Node ast, Context context, Job outer, Pass.ID begin, Pass.ID end)
SourceJob
Job
, for the
given AST. In general this method should only be called by
spawnJob
.
ast
- the AST the new Job is for.context
- the context that the AST occurs inouter
- the Job
that spawned this job.begin
- the first pass to perform for this job.end
- the last pass to perform for this job.public Job spawnJob(Context c, Node ast, Job outerJob, Pass.ID begin, Pass.ID end)
begin
and end
inclusive will be performed immediately on
the AST ast
.
spawnJob
in interface ExtensionInfo
c
- the context that the AST occurs inast
- 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.
j.status()
and get the ast with j.ast()
.public abstract Parser parser(java.io.Reader reader, FileSource source, ErrorQueue eq)
parser
in interface ExtensionInfo
public void replacePass(java.util.List passes, Pass.ID id, java.util.List newPasses)
id
in passes
with
the list of newPasses
.
replacePass
in interface ExtensionInfo
public void removePass(java.util.List passes, Pass.ID id)
id
from passes
.
removePass
in interface ExtensionInfo
public void beforePass(java.util.List passes, Pass.ID id, java.util.List newPasses)
newPasses
into passes
immediately before the pass named id
.
beforePass
in interface ExtensionInfo
public void afterPass(java.util.List passes, Pass.ID id, java.util.List newPasses)
newPasses
into passes
immediately after the pass named id
.
afterPass
in interface ExtensionInfo
public void replacePass(java.util.List passes, Pass.ID id, Pass pass)
id
in passes
with
the pass pass
.
replacePass
in interface ExtensionInfo
public void beforePass(java.util.List passes, Pass.ID id, Pass pass)
pass
into passes
immediately before the pass named id
.
beforePass
in interface ExtensionInfo
public void afterPass(java.util.List passes, Pass.ID id, Pass pass)
pass
into passes
immediately after the pass named id
.
afterPass
in interface ExtensionInfo
public abstract java.util.List passes(Job job)
passes
in interface ExtensionInfo
public java.util.List passes(Job job, Pass.ID begin, Pass.ID end)
begin
and end
, inclusive.
passes
in interface ExtensionInfo
public java.lang.String toString()
toString
in class java.lang.Object
public ClassFile createClassFile(java.io.File classFileSource, byte[] code)
ExtensionInfo
createClassFile
in interface ExtensionInfo
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |