|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.visit.PrettyPrinter
polyglot.visit.Translator
public class Translator
A Translator generates output code from the processed AST.
Output is sent to one or more java file in the directory
Options.output_directory
. Each SourceFile in the AST
is output to exactly one java file. The name of that file is
determined as follows:
new Translator(job, ts, nf, tf).translate(ast);The
ast
must be either a SourceFile or a SourceCollection.
Field Summary | |
---|---|
protected Context |
context
|
protected Job |
job
|
protected NodeFactory |
nf
|
protected ClassType |
outerClass
|
protected TargetFactory |
tf
|
protected TypeSystem |
ts
|
Fields inherited from class polyglot.visit.PrettyPrinter |
---|
appendSemicolon, printType |
Constructor Summary | |
---|---|
Translator(Job job,
TypeSystem ts,
NodeFactory nf,
TargetFactory tf)
Create a Translator. |
Method Summary | |
---|---|
Context |
context()
Get the current context in which we are translating. |
Translator |
context(Context c)
Create a new Translator identical to this but
with new context c |
java.lang.Object |
copy()
Copy the translator. |
protected java.util.List |
exports(SourceFile sfn)
Get the list of public top-level classes declared in the source file. |
Job |
job()
Return the job associated with this Translator. |
NodeFactory |
nodeFactory()
Get the extension's node factory. |
ClassType |
outerClass()
Set the outer class context of the translator. |
void |
print(Node parent,
Node child,
CodeWriter w)
Print an ast node using the given code writer. |
void |
setOuterClass(ClassType ct)
Destructively set the outer class context of the translator. |
java.lang.String |
toString()
|
boolean |
translate(Node ast)
Translate the entire AST. |
protected boolean |
translateSource(SourceFile sfn)
Translate a single SourceFile node |
TypeSystem |
typeSystem()
Get the extension's type system. |
protected void |
writeHeader(SourceFile sfn,
CodeWriter w)
Write the package and import declarations for a source file. |
Methods inherited from class polyglot.visit.PrettyPrinter |
---|
appendSemicolon, appendSemicolon, printAst, printType, printType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Job job
protected NodeFactory nf
protected TargetFactory tf
protected TypeSystem ts
protected Context context
protected ClassType outerClass
Constructor Detail |
---|
public Translator(Job job, TypeSystem ts, NodeFactory nf, TargetFactory tf)
outputFiles
.
Method Detail |
---|
public Job job()
public Translator context(Context c)
Translator
identical to this
but
with new context c
public java.lang.Object copy()
copy
in interface Copy
public ClassType outerClass()
outerClass
), rather
than in the current context returned by context()
.
public void setOuterClass(ClassType ct)
public TypeSystem typeSystem()
public Context context()
public NodeFactory nodeFactory()
public void print(Node parent, Node child, CodeWriter w)
translate(Node)
instead. This method should only be called
by nodes to print their children.
print
in class PrettyPrinter
public boolean translate(Node ast)
protected boolean translateSource(SourceFile sfn)
protected void writeHeader(SourceFile sfn, CodeWriter w)
protected java.util.List exports(SourceFile sfn)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |