public class AST extends ASTNode
PackageDeclaration
, a List
of ImportDeclaration
s (also
optional), the global SymbolTable
, and a List
containing
ClassifierAssignment
s, ConstraintDeclaration
s, and
InferenceDeclaration
s.
The PackageDeclaration
specifies what package will contain the generated classes.
The ImportDeclaration
s work similarly to import
declarations in regular
Java code: they allow the user to name classes in other packages without using their full package
names. The list of Declaration
s comprises the LBJava program. The global
SymbolTable
simply associates variable names with their type information in the
program.
Modifier and Type | Field and Description |
---|---|
DeclarationList |
declarations
(¬ø) The list of classifier, constraint, and inference declarations representing
the LBJava program.
|
static SymbolTable |
globalSymbolTable
The
symbolTable variable mirrors this variable. |
ImportList |
imports
(¬ø) The list of import statements at the top of the source file.
|
PackageDeclaration |
packageDeclaration
(ø) An optional declaration of the package that generated classes should be a part of.
|
byteOffset, line, nodeID, symbolTable
Constructor and Description |
---|
AST(DeclarationList d)
Initializes just the statement list.
|
AST(ImportList i,
DeclarationList d)
Initializes both lists.
|
AST(PackageDeclaration p,
DeclarationList d)
Initializes package declaration and statement list.
|
AST(PackageDeclaration p,
ImportList i,
DeclarationList d)
Initializes all member variables.
|
AST(PackageDeclaration p,
ImportList i,
DeclarationList d,
int line,
int byteOffset)
Full constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates a new object with the same primitive data, and recursively creates new member data
objects as well.
|
ASTNodeIterator |
iterator()
Returns an iterator used to successively access the children of this node.
|
void |
runPass(Pass pass)
Ensures that the correct
run() method is called for this type of node. |
void |
write(StringBuffer buffer)
Writes a string representation of this
ASTNode to the specified buffer. |
public static final SymbolTable globalSymbolTable
symbolTable
variable mirrors this variable.public PackageDeclaration packageDeclaration
public ImportList imports
public DeclarationList declarations
public AST(DeclarationList d)
d
- The declarations comprising the program.public AST(ImportList i, DeclarationList d)
import
list.i
- The import
declarations.d
- The declarations comprising the program.public AST(PackageDeclaration p, DeclarationList d)
package
declaration.p
- The package
declaration.d
- The declarations comprising the program.public AST(PackageDeclaration p, ImportList i, DeclarationList d)
package
declaration.p
- The package
declaration.i
- The import
declarations.d
- The declarations comprising the program.public AST(PackageDeclaration p, ImportList i, DeclarationList d, int line, int byteOffset)
p
- The package
declaration.i
- The import
declarations.d
- The declarations comprising the program.line
- The line on which the source code represented by this node is found.byteOffset
- The byte offset from the beginning of the source file at which the source
code represented by this node is found.public ASTNodeIterator iterator()
public Object clone()
public void runPass(Pass pass)
run()
method is called for this type of node.public void write(StringBuffer buffer)
ASTNode
to the specified buffer. The
representation written is parsable by the LBJava compiler, but not very readable.Copyright © 2016. All rights reserved.