|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.visit.PrettyPrinter
polyglot.visit.Translator
polyglot.visit.TypedTranslator
polyglot.visit.CppTranslator
public class CppTranslator
Field Summary | |
---|---|
protected Context |
context
|
protected static java.util.HashMap |
createdFiles
|
Fields inherited from class polyglot.visit.Translator |
---|
job, nf, tf, ts |
Fields inherited from class polyglot.visit.PrettyPrinter |
---|
appendSemicolon, printType |
Constructor Summary | |
---|---|
CppTranslator(Job job,
TypeSystem ts,
NodeFactory nf,
TargetFactory tf)
|
Method Summary | |
---|---|
protected static boolean |
cppBackend()
|
static java.lang.String |
cScope(java.lang.String s)
Turns a package or class name from Java "x.y.z" format into a C-style scope ("x::y::z") |
java.lang.String |
cTypeString(Type type)
|
static java.util.HashMap |
getFileNames()
|
HeaderTranslator |
headerContext(Context c)
Create a new Translator identical to this ,
except: a) wrapped inside a HeaderTranslator object, and b) with
a new context c |
void |
print(Node parent,
Node child,
CodeWriter w)
Print an ast node using the given code writer. |
protected boolean |
translateSource(SourceFile sfn)
Transate a single SourceFile node |
protected void |
writeFooter(SourceFile sfn,
CodeWriter w)
C++ files also require a footer terminal '}' because they need to close the namespace they're opening. |
protected void |
writeHeader(SourceFile sfn,
CodeWriter w)
Write the package and import declarations for a source file. |
protected void |
writeHFileFooter(SourceFile sfn,
CodeWriter w)
Write the footer of the .h file if we're in C++ mode |
protected void |
writeHFileHeader(SourceFile sfn,
java.lang.String className,
CodeWriter w)
Write the opening lines of the header file for a given class |
Methods inherited from class polyglot.visit.TypedTranslator |
---|
context, context, translateTopLevelDecl |
Methods inherited from class polyglot.visit.Translator |
---|
copy, exports, job, macroEscape, nodeFactory, targetFactory, toString, translate, typeSystem |
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 Context context
protected static java.util.HashMap createdFiles
Constructor Detail |
---|
public CppTranslator(Job job, TypeSystem ts, NodeFactory nf, TargetFactory tf)
Method Detail |
---|
protected static boolean cppBackend()
public static java.util.HashMap getFileNames()
public HeaderTranslator headerContext(Context c)
Translator
identical to this
,
except: a) wrapped inside a HeaderTranslator object, and b) with
a new context c
c
- - the new context to use
public static java.lang.String cScope(java.lang.String s)
s
- the input package or class name
public java.lang.String cTypeString(Type type)
public void print(Node parent, Node child, CodeWriter w)
Translator
translate(Node)
instead. This method should only be called
by nodes to print their children.
print
in class TypedTranslator
protected boolean translateSource(SourceFile sfn)
translateSource
in class Translator
protected void writeHFileHeader(SourceFile sfn, java.lang.String className, CodeWriter w)
sfn
- - representation of the source file we're compiling; used for Imports.className
- - The name of the class we're describingw
- - The CodeWriter to write it all out to (the .h file)protected void writeHFileFooter(SourceFile sfn, CodeWriter w)
w
- protected void writeFooter(SourceFile sfn, CodeWriter w)
protected void writeHeader(SourceFile sfn, CodeWriter w)
writeHeader
in class Translator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |