public class Translator extends PrettyPrinter implements Copy<Translator>
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.Modifier and Type | Field and Description |
---|---|
protected Context |
context
The current typing context, or null if type information is unavailable in
this subtree of the AST.
|
protected Job |
job |
protected NodeFactory |
nf |
protected TargetFactory |
tf |
protected TypeSystem |
ts |
appendSemicolon, printType
Constructor and Description |
---|
Translator(Job job,
TypeSystem ts,
NodeFactory nf,
TargetFactory tf)
Create a Translator.
|
Modifier and Type | Method and Description |
---|---|
Context |
context()
Get the current typing context, or null.
|
Translator |
context(Context c)
Create a new
Translator identical to this but
with new context c |
Translator |
copy()
Copy the translator.
|
protected java.util.Map<java.lang.String,java.util.List<TopLevelDecl>> |
filenames(SourceFile sf)
Determine the list of file names that top-level declarations in the
given source file will reside.
|
Job |
job()
Return the job associated with this Translator.
|
NodeFactory |
nodeFactory()
Get the extension's node factory.
|
void |
print(Node parent,
Node child,
CodeWriter w)
Print an AST node using the given code writer.
|
java.lang.String |
toString() |
boolean |
translate(Node ast)
Translate the entire AST.
|
protected boolean |
translateSource(SourceFile sf)
Translate a single SourceFile node
|
protected void |
translateTopLevelDecl(CodeWriter w,
SourceFile source,
TopLevelDecl decl)
Translate a top-level declaration
decl of source file
source . |
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.
|
appendSemicolon, appendSemicolon, lang, printAst, printType, printType
protected Job job
protected NodeFactory nf
protected TargetFactory tf
protected TypeSystem ts
protected Context context
public Translator(Job job, TypeSystem ts, NodeFactory nf, TargetFactory tf)
outputFiles
.public Job job()
public Translator copy()
copy
in interface Copy<Translator>
public TypeSystem typeSystem()
public NodeFactory nodeFactory()
public Context context()
public Translator context(Context c)
Translator
identical to this
but
with new context c
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 sf)
protected void translateTopLevelDecl(CodeWriter w, SourceFile source, TopLevelDecl decl)
decl
of source file
source
.w
- source
- decl
- protected void writeHeader(SourceFile sfn, CodeWriter w)
protected java.util.Map<java.lang.String,java.util.List<TopLevelDecl>> filenames(SourceFile sf)
sf
- public java.lang.String toString()
toString
in class java.lang.Object