An abstract representation of a program. This is the highest level representation and the one typically used first in most cases. The program is represented by a single AST, which is obtained by merging a set of ASTs representing translation units.
Future work: change the representation of a program to consist of a set of entities and a set of ASTs, each representing one translation unit. There should be a a method to get the "outer" (file-scope) entities, and a method to get each AST. In this approach, there should not be any need for renaming different entities, i.e., it should be possible, for example, for two structs to have the same name but denote distinct entities because they come from distinct translation units.
It seems that all the constituent ASTs can be analyzed using the same analyzer, factories, etc.
Hence there wil be two ways to create a program: (1) from a collection of ASTs, or (2) from one merged AST (which requires renaming).
-
Method Summary
Modifier and TypeMethodDescriptionvoidapply(Transformer transformer) Transforms this program using the given Transformer.voidapply(Iterable<Transformer> transformers) Applies the given sequence of transformers to this program.voidapplyTransformer(String code) Transforms program using the transformer specifid by the unique code.voidapplyTransformers(Iterable<String> codes) Applies the sequence of transformers specified by the given code sequence to this program.getAST()Returns the abstract syntax tree of this program.Returns the token factory used for the producing and manipulation of tokens associated to this Program.booleanChecks if the AST of this program contains any pragma node with the identifier "omp".voidprettyPrint(PrintStream out) Prints a human readable representation of the program in original language.voidprint(PrintStream out) Prints a human readable abstract representation of the program to the given output stream.void
-
Method Details
-
getAST
AST getAST()Returns the abstract syntax tree of this program. Note that this can return different values as the program is modified. I.e., a whole new AST can replace the current one.- Returns:
- the current AST of the program
-
getTokenFactory
TokenFactory getTokenFactory()Returns the token factory used for the producing and manipulation of tokens associated to this Program.- Returns:
- the token factory
-
print
Prints a human readable abstract representation of the program to the given output stream. (Not in source code format.)- Parameters:
out- a print stream
-
prettyPrint
Prints a human readable representation of the program in original language.- Parameters:
out- a print stream
-
printSymbolTable
-
apply
Transforms this program using the given Transformer.- Parameters:
transformer- a program transformer- Throws:
SyntaxException- if the syntax of this program is discovered to be incompatible with that expected by the transformer
-
applyTransformer
Transforms program using the transformer specifid by the unique code.- Parameters:
code- transformer code, e.g., "prune" or "mpi"- Throws:
SyntaxException- if the syntax of this program is discovered to be incompatible with that expected by the transformer
-
apply
Applies the given sequence of transformers to this program. The transformers will be applied in order.- Parameters:
transformers- any kind of iterable sequence of transformers- Throws:
SyntaxException- if the syntax of this program is discovered to be incompatible with that expected by any transformer in the sequence
-
applyTransformers
Applies the sequence of transformers specified by the given code sequence to this program. The transformers will be applied in order.- Parameters:
codes- a sequence of transformer codes- Throws:
SyntaxException- if the syntax of this program is discovered to be incompatible with that expected by any transformer in the sequence
-
hasOmpPragma
boolean hasOmpPragma()Checks if the AST of this program contains any pragma node with the identifier "omp".- Returns:
- True if the AST of this program contains at least one pragma nodes with the identifier "omp"
-