public class SourceFile_c extends Node_c implements SourceFile
SourceFile is an immutable representations of a Java
language source file. It consists of a package name, a list of
Imports, and a list of GlobalDecls.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<TopLevelDecl> |
decls |
protected java.util.List<Import> |
imports |
protected ImportTable |
importTable |
protected PackageNode |
package_ |
protected Source |
source |
| Constructor and Description |
|---|
SourceFile_c(Position pos,
PackageNode package_,
java.util.List<Import> imports,
java.util.List<TopLevelDecl> decls) |
SourceFile_c(Position pos,
PackageNode package_,
java.util.List<Import> imports,
java.util.List<TopLevelDecl> decls,
Ext ext) |
| Modifier and Type | Method and Description |
|---|---|
Node |
buildTypes(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
NodeVisitor |
buildTypesEnter(TypeBuilder tb)
Build type objects for the source file.
|
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
java.util.List<TopLevelDecl> |
decls()
Get the source's top-level declarations.
|
SourceFile |
decls(java.util.List<TopLevelDecl> decls)
Set the source's top-level declarations.
|
protected <N extends SourceFile_c> |
decls(N n,
java.util.List<TopLevelDecl> decls) |
Node |
disambiguateOverride(Node parent,
AmbiguityRemover ar)
Disambiguate the AST.
|
void |
dump(CodeWriter w)
Dump the AST node for debugging purposes.
|
Context |
enterScope(Context c)
Push a new scope upon entering this node, and add any declarations to the
context that should be in scope when visiting children of this node.
|
Node |
extRewrite(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
java.util.List<Import> |
imports()
Get the source's declared imports.
|
SourceFile |
imports(java.util.List<Import> imports)
Set the source's declared imports.
|
protected <N extends SourceFile_c> |
imports(N n,
java.util.List<Import> imports) |
ImportTable |
importTable()
Get the source's import table.
|
SourceFile |
importTable(ImportTable importTable)
Set the source's import table.
|
protected <N extends SourceFile_c> |
importTable(N n,
ImportTable importTable) |
boolean |
isDisambiguated() |
PackageNode |
package_()
Get the source's declared package.
|
protected <N extends SourceFile_c> |
package_(N n,
PackageNode package_) |
SourceFile |
package_(PackageNode package_)
Set the source's declared package.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter. |
protected <N extends SourceFile_c> |
reconstruct(N n,
PackageNode package_,
java.util.List<Import> imports,
java.util.List<TopLevelDecl> decls)
Reconstruct the source file.
|
Source |
source()
Get the source file.
|
protected <N extends SourceFile_c> |
source(N n,
Source source) |
SourceFile |
source(Source source)
Set the source file.
|
java.lang.String |
toString() |
Node |
typeCheck(TypeChecker tc)
Type check the AST.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
addDecls, checkConstants, childExpectedType, copy, copy, copyIfNeeded, del, del, disambiguate, disambiguateEnter, dump, dump, dump, dump, enterChildScope, error, error, error, exceptionCheck, exceptionCheckEnter, ext, ext, ext, ext, extRewriteEnter, isTypeChecked, lang, position, position, position, prettyPrint, prettyPrint, prettyPrint, prettyPrint, print, printBlock, printSubStmt, throwTypes, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitListclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdel, del, error, error, ext, ext, ext, ext, isTypeChecked, position, position, visit, visitEdgeaddDecls, checkConstants, childExpectedType, copy, disambiguate, disambiguateEnter, dump, dump, dump, dump, enterChildScope, exceptionCheck, exceptionCheckEnter, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, throwTypes, translate, typeCheckEnter, typeCheckOverride, visitChild, visitListprotected PackageNode package_
protected java.util.List<Import> imports
protected java.util.List<TopLevelDecl> decls
protected ImportTable importTable
protected Source source
public SourceFile_c(Position pos, PackageNode package_, java.util.List<Import> imports, java.util.List<TopLevelDecl> decls)
public SourceFile_c(Position pos, PackageNode package_, java.util.List<Import> imports, java.util.List<TopLevelDecl> decls, Ext ext)
public boolean isDisambiguated()
isDisambiguated in interface NodeisDisambiguated in class Node_cpublic Source source()
SourceFilesource in interface SourceFilepublic SourceFile source(Source source)
SourceFilesource in interface SourceFileprotected <N extends SourceFile_c> N source(N n, Source source)
public PackageNode package_()
SourceFilepackage_ in interface SourceFilepublic SourceFile package_(PackageNode package_)
SourceFilepackage_ in interface SourceFileprotected <N extends SourceFile_c> N package_(N n, PackageNode package_)
public java.util.List<Import> imports()
SourceFileimports in interface SourceFileImport.public SourceFile imports(java.util.List<Import> imports)
SourceFileimports in interface SourceFileimports - A list of Import.protected <N extends SourceFile_c> N imports(N n, java.util.List<Import> imports)
public java.util.List<TopLevelDecl> decls()
SourceFiledecls in interface SourceFileTopLevelDecl.public SourceFile decls(java.util.List<TopLevelDecl> decls)
SourceFiledecls in interface SourceFiledecls - A list of TopLevelDecl.protected <N extends SourceFile_c> N decls(N n, java.util.List<TopLevelDecl> decls)
public ImportTable importTable()
SourceFileimportTable in interface SourceFilepublic SourceFile importTable(ImportTable importTable)
SourceFileimportTable in interface SourceFileprotected <N extends SourceFile_c> N importTable(N n, ImportTable importTable)
protected <N extends SourceFile_c> N reconstruct(N n, PackageNode package_, java.util.List<Import> imports, java.util.List<TopLevelDecl> decls)
public Node visitChildren(NodeVisitor v)
NodeOpsvisitChildren in interface NodeOpsvisitChildren in class Node_cv - The visitor that will traverse/rewrite the AST.this.public NodeVisitor buildTypesEnter(TypeBuilder tb) throws SemanticException
buildTypesEnter in interface NodeOpsbuildTypesEnter in class Node_ctb - The visitor which adds new type objects to the
TypeSystem.SemanticExceptionpublic Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOpsTypeSystem.
This method is called by the leave() method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this or a new copy of the node which will be
installed as a child of the node's parent.buildTypes in interface NodeOpsbuildTypes in class Node_ctb - The visitor which adds new type objects to the
TypeSystem.SemanticExceptionpublic Context enterScope(Context c)
Node_centerScope in interface NodeOpsenterScope in class Node_cc - the current ContextContext to be used for visiting this node.public Node typeCheck(TypeChecker tc) throws SemanticException
NodeOpsleave() method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this or a new copy of the node which will be
installed as a child of the node's parent.typeCheck in interface NodeOpstypeCheck in class Node_ctc - The type checking visitor.SemanticExceptionpublic Node extRewrite(ExtensionRewriter rw) throws SemanticException
NodeOpsleave() method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this or a new copy of the node which will be
installed as a child of the node's parent.extRewrite in interface NodeOpsextRewrite in class Node_crw - The visitor.SemanticExceptionpublic void prettyPrint(CodeWriter w, PrettyPrinter tr)
Node_cCodeWriter.prettyPrint in interface NodeOpsprettyPrint in class Node_cw - The code writer to which to write.tr - The pretty printer. This is not a visitor.public Node disambiguateOverride(Node parent, AmbiguityRemover ar) throws SemanticException
NodeOpsoverride() method of the
visitor. If this method returns non-null, the node's children
will not be visited automatically. Thus, the method should check
both the node this and it's children, usually by
invoking visitChildren with tc or
with another visitor, returning a non-null node. OR, the method
should do nothing and simply return null to allow
enter, visitChildren, and leave
to be invoked on the node.
The default implementation returns null.
Overriding of this method is discouraged, but sometimes necessary.disambiguateOverride in interface NodeOpsdisambiguateOverride in class Node_car - The visitor which disambiguates.SemanticExceptionpublic void dump(CodeWriter w)
Node