#include <ast.h>
Inheritance diagram for unitNode::
Public Methods | |
unitNode (string input_file, string output_file, const Coord coord=Coord::Unknown) | |
Create a new translation unit from a source file. More... | |
virtual | ~unitNode () |
Destroy a unitNode. More... | |
void | parse (str_list *cpp_flags) |
Parse the input file. More... | |
void | fixup () |
Run fixup passes. More... | |
void | merge_in (def_list *defs) |
Merge in external definitions. More... | |
void | enter_scope () |
Enter a new scope. More... | |
void | exit_scope () |
Exit scope. More... | |
virtual void | dataflow (FlowVal *v, FlowProblem &fp) |
Run the dataflow analyzer. More... | |
virtual Node * | clone () const |
Clone the input node. More... | |
virtual void | output (output_context &ct, Node *par) |
Generate C code. More... | |
Accessors | |
Methods to get and set fields in the class. | |
def_list & | defs () |
const def_list & | defs () const |
int | symbol_level () const |
Identifiers_table * | types () const |
Tags_table * | tags () const |
string & | input_file () |
string & | output_file () |
int | errors () const |
void | inc_errors () |
int | warnings () const |
void | inc_warnings () |
decl_list & | undef_funcs () |
suespec_list & | suespecs () |
AST Traversal | |
virtual void | visit (Visitor *the_visitor) |
Dispatch a Visitor. More... | |
virtual void | walk (Walker &the_walker) |
Dispatch a Walker. More... | |
virtual Node * | change (Changer &the_changer, bool redispatch=false) |
Dispatch a Changer. More... | |
Private Methods | |
FILE * | _open_input_file (str_list *cpp_flags) |
Open the input file. More... | |
Private Attributes | |
TREE def_list | _defs |
The external definitions. More... | |
int | _symbol_level |
Depth of the scope. More... | |
Identifiers_table * | _types |
Table of type names. More... | |
Tags_table * | _tags |
Table of struct/union tags. More... | |
string | _input_file |
Source file name. More... | |
string | _output_file |
The output file name. More... | |
int | _errors |
The number of errors. More... | |
int | _warnings |
The number of warnings. More... | |
TREE decl_list | _undef_funcs |
Undeclared functions. More... | |
TREE suespec_list | _suespecs |
struct/enum/union contents. More... |
A translation unit corresponds to a single input source file (with all header files included). To parse a source file in, create a unitNode and then call the parse() method. However, this is typically done by the main driver, which also handles the flags provided on the command line.
All instances of unitNode created by the main driver are stored in a global list in the CBZ class.
The NodeType is Unit.
In addition to containing the AST for the code, unitNode contains auxillary information gathered during the parsing. This includes:
|
Create a new translation unit from a source file. Instantiate a new unitNode with the given input and output source file names. This is typically done automatically by the front-end driver.
|
|
Destroy a unitNode.
|
|
Open the input file.
|
|
Dispatch a Changer. This abstract method works much the walker, but allows the tree to be changed.
Reimplemented from Node. |
|
Clone the input node. This is not a "deep" clone, so be careful. For a deep clone, use the clone_changer class.
Reimplemented from Node. |
|
Run the dataflow analyzer. Each subclass overrides this method to define it's semantics for dataflow analysis. It alters the input flow value to reflect the effect of the node within the given flow problem, calling dataflow() on it's subtrees as necessary. See the dataflow analysis documentation for more information.
Reimplemented from Node. |
|
|
|
|
|
Enter a new scope.
|
|
|
|
Exit scope.
|
|
Run fixup passes. Run the various fix-up passes, just as we would after parsing. |
|
|
|
|
|
|
|
Merge in external definitions.
|
|
Generate C code. Each subclass overrides this method to define how to produce the output C code. To use this method, pass an output_context and a null parent.
Reimplemented from Node. |
|
|
|
Parse the input file. Run the parser on the input file using the given preprocessor flags. The resulting AST is stored in the various unitNode fields ( _defs, _types, etc.).
|
|
|
|
|
|
|
|
|
|
|
|
Dispatch a Visitor. This abstract method is the entry point for the visitor design pattern. Each node subclass defines a visit() method that calls the appropriate at_ method in the visitor. For more information see the Visitor documentation.
Reimplemented from Node. |
|
Dispatch a Walker. This abstract method works much like the visitor, but instead walks the entire underlying subtree calling the appropriate at_ method at each node. For more information see the Walker documentation.
Reimplemented from Node. |
|
|
|
The external definitions. The list of external definitions (top level) parsed in from the source. This is the top of the AST. |
|
The number of errors. The number of errors encountered during parsing. |
|
Source file name. The name of the source file from which this AST was parsed. |
|
The output file name. The name of the output file to which the resulting code is written (only if the -c-code flag is given). |
|
struct/enum/union contents. During parsing, we maintain a separate, global list of the contents of struct/enum/union definitions. The reason is that this avoids the problem of which declaration "owns" the content definition. Instead, all uses of the s/u/e type simply refer to one of the elements of this list. |
|
Depth of the scope.
|
|
Table of struct/union tags.
|
|
Table of type names.
|
|
Undeclared functions. This list will contain a function declaration for any functions not explicitly declared in the source. |
|
The number of warnings. The number of warnings encountered during parsing. |