class JCompilationUnit extends JAST
compilationUnit, line
Constructor and Description |
---|
JCompilationUnit(String fileName,
int line,
TypeName packageName,
ArrayList<TypeName> imports,
ArrayList<JAST> typeDeclarations)
Construct an AST node for a compilation unit given a file name, class
directory, line number, package name, list of imports, and type
declarations.
|
Modifier and Type | Method and Description |
---|---|
JAST |
analyze(Context context)
Perform semantic analysis on the AST in the specified context.
|
ArrayList<CLFile> |
clFiles()
Return the list of CLFile objects corresponding to the type declarations
in this compilation unit.
|
void |
codegen(CLEmitter output)
Generating code for a compilation unit means generating code for each of
the type declarations.
|
boolean |
errorHasOccurred()
Has a semantic error occurred up to now?
|
String |
packageName()
The package in which this compilation unit is defined.
|
void |
preAnalyze()
Construct a context for the compilation unit, initializing it with
imported types.
|
void |
reportSemanticError(int line,
String message,
Object... arguments)
Report a semantic error.
|
void |
writeToStdOut(PrettyPrinter p)
Write the information pertaining to this AST to STDOUT.
|
line, partialCodegen
public JCompilationUnit(String fileName, int line, TypeName packageName, ArrayList<TypeName> imports, ArrayList<JAST> typeDeclarations)
fileName
- the name of the source file.line
- line in which the compilation unit occurs in the source file.packageName
- package name.imports
- a list of imports.typeDeclarations
- type declarations.public String packageName()
public boolean errorHasOccurred()
public void reportSemanticError(int line, String message, Object... arguments)
line
- line in which the error occurred in the source file.message
- message identifying the error.arguments
- related values.public void preAnalyze()
public JAST analyze(Context context)
public void codegen(CLEmitter output)
public ArrayList<CLFile> clFiles()
public void writeToStdOut(PrettyPrinter p)
JAST
writeToStdOut
in class JAST
p
- for pretty printing with indentation.