polyglot.ext.jl.ast
Class SourceFile_c

java.lang.Object
  extended by polyglot.ext.jl.ast.Node_c
      extended by polyglot.ext.jl.ast.SourceFile_c
All Implemented Interfaces:
java.lang.Cloneable, JL, Node, NodeOps, SourceFile, Copy

public class SourceFile_c
extends Node_c
implements SourceFile

A SourceFile is an immutable representations of a Java langauge source file. It consists of a package name, a list of Imports, and a list of GlobalDecls.


Field Summary
protected  java.util.List decls
           
protected  java.util.List imports
           
protected  ImportTable importTable
           
protected  PackageNode package_
           
protected  Source source
           
 
Fields inherited from class polyglot.ext.jl.ast.Node_c
del, ext, position
 
Constructor Summary
SourceFile_c(Position pos, PackageNode package_, java.util.List imports, java.util.List decls)
           
 
Method Summary
 Node buildTypes(TypeBuilder tb)
          Build type objects for the source file.
 NodeVisitor buildTypesEnter(TypeBuilder tb)
          Build type objects for the source file.
 java.util.List decls()
          Get the declarations of the source file.
 SourceFile decls(java.util.List decls)
          Set the declarations of the source file.
 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.
 java.util.List imports()
          Get the imports of the source file.
 SourceFile imports(java.util.List imports)
          Set the imports of the source file.
 ImportTable importTable()
          Get the declarations of the source file.
 SourceFile importTable(ImportTable importTable)
          Set the declarations of the source file.
 PackageNode package_()
          Get the package of the source file.
 SourceFile package_(PackageNode package_)
          Set the package of the source file.
 void prettyPrint(CodeWriter w, PrettyPrinter tr)
          Write the source file to an output file.
protected  SourceFile_c reconstruct(PackageNode package_, java.util.List imports, java.util.List decls)
          Reconstruct the source file.
 Source source()
          Get the source of the source file.
 SourceFile source(Source source)
          Set the source of the source file.
 java.lang.String toString()
           
 Node typeCheck(TypeChecker tc)
          Type check the source file.
 Node visitChildren(NodeVisitor v)
          Visit the children of the source file.
 
Methods inherited from class polyglot.ext.jl.ast.Node_c
addDecls, addMembers, addMembersEnter, addMembersOverride, buildTypesOverride, childExpectedType, copy, del, del, disambiguate, disambiguateEnter, disambiguateOverride, dump, enterScope, exceptionCheck, exceptionCheckEnter, exceptionCheckOverride, ext, ext, ext, ext, init, node, position, position, print, printBlock, printSubStmt, throwTypes, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface polyglot.ast.Node
childExpectedType, del, del, dump, ext, ext, ext, ext, position, position, visit, visitChild, visitEdge, visitList
 
Methods inherited from interface polyglot.ast.JL
init, node
 
Methods inherited from interface polyglot.ast.NodeOps
addDecls, addMembers, addMembersEnter, disambiguate, disambiguateEnter, enterScope, exceptionCheck, exceptionCheckEnter, throwTypes, translate, typeCheckEnter
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

package_

protected PackageNode package_

imports

protected java.util.List imports

decls

protected java.util.List decls

importTable

protected ImportTable importTable

source

protected Source source
Constructor Detail

SourceFile_c

public SourceFile_c(Position pos,
                    PackageNode package_,
                    java.util.List imports,
                    java.util.List decls)
Method Detail

source

public Source source()
Get the source of the source file.

Specified by:
source in interface SourceFile

source

public SourceFile source(Source source)
Set the source of the source file.

Specified by:
source in interface SourceFile

package_

public PackageNode package_()
Get the package of the source file.

Specified by:
package_ in interface SourceFile

package_

public SourceFile package_(PackageNode package_)
Set the package of the source file.

Specified by:
package_ in interface SourceFile

imports

public java.util.List imports()
Get the imports of the source file.

Specified by:
imports in interface SourceFile
Returns:
A list of Import.

imports

public SourceFile imports(java.util.List imports)
Set the imports of the source file.

Specified by:
imports in interface SourceFile
Parameters:
imports - A list of Import.

decls

public java.util.List decls()
Get the declarations of the source file.

Specified by:
decls in interface SourceFile
Returns:
A list of TopLevelDecl.

decls

public SourceFile decls(java.util.List decls)
Set the declarations of the source file.

Specified by:
decls in interface SourceFile
Parameters:
decls - A list of TopLevelDecl.

importTable

public ImportTable importTable()
Get the declarations of the source file.

Specified by:
importTable in interface SourceFile

importTable

public SourceFile importTable(ImportTable importTable)
Set the declarations of the source file.

Specified by:
importTable in interface SourceFile

reconstruct

protected SourceFile_c reconstruct(PackageNode package_,
                                   java.util.List imports,
                                   java.util.List decls)
Reconstruct the source file.


visitChildren

public Node visitChildren(NodeVisitor v)
Visit the children of the source file.

Specified by:
visitChildren in interface NodeOps
Overrides:
visitChildren in class Node_c
Parameters:
v - The visitor that will traverse/rewrite the AST.
Returns:
A new AST if a change was made, or this.

buildTypesEnter

public NodeVisitor buildTypesEnter(TypeBuilder tb)
                            throws SemanticException
Build type objects for the source file. Set the visitor's import table field before we recurse into the declarations.

Specified by:
buildTypesEnter in interface NodeOps
Overrides:
buildTypesEnter in class Node_c
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

buildTypes

public Node buildTypes(TypeBuilder tb)
                throws SemanticException
Build type objects for the source file. Sets the import table field for the source.

Specified by:
buildTypes in interface NodeOps
Overrides:
buildTypes in class Node_c
Parameters:
tb - The visitor which adds new type objects to the TypeSystem.
Throws:
SemanticException

enterScope

public Context enterScope(Context c)
Description copied from class: Node_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.

Specified by:
enterScope in interface NodeOps
Overrides:
enterScope in class Node_c
Parameters:
c - the current Context
Returns:
the Context to be used for visiting this node.

typeCheck

public Node typeCheck(TypeChecker tc)
               throws SemanticException
Type check the source file.

Specified by:
typeCheck in interface NodeOps
Overrides:
typeCheck in class Node_c
Parameters:
tc - The type checking visitor.
Throws:
SemanticException

toString

public java.lang.String toString()
Overrides:
toString in class Node_c

prettyPrint

public void prettyPrint(CodeWriter w,
                        PrettyPrinter tr)
Write the source file to an output file.

Specified by:
prettyPrint in interface NodeOps
Overrides:
prettyPrint in class Node_c
Parameters:
w - The code writer to which to write.
tr - The pretty printer. This is not a visitor.