|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
declNode Class ReferenceDeclaration.
More...
|
Garbage collection. | |
bool | mark |
node_list | nodes |
map< Node *, bool > | deleted_nodes |
Public Types | |
enum | Decl_location { UNKNOWN, TOP, BLOCK, FORMAL, SU, ENUM, PROC } |
Declaration location. More... | |
enum | Storage_class { NONE, AUTO, EXTERN, REGISTER, STATIC, TYPEDEF } |
Storage class specifier. More... | |
Public Member Functions | |
declNode (const char *name, Storage_class sc, typeNode *the_type, exprNode *init, exprNode *bitsize, const Coord coord=Coord::Unknown) | |
Create a declaration. | |
virtual | ~declNode () |
Destroy a declNode. | |
typeNode * | base_type (bool TdefIndir) const |
Return the base data type of a node. | |
typeNode * | no_tdef_type () |
Return the type. | |
virtual declNode * | original () |
SSA original declaration. | |
virtual void | dataflow (FlowVal *v, FlowProblem &fp) |
Run the dataflow analyzer. | |
virtual Node * | clone () const |
Clone the input node. | |
virtual void | output (output_context &ct, Node *par) |
Generate C code. | |
typeNode * | datatype () const |
Call base_type() with the argument true. | |
typeNode * | datatype_superior () const |
Call base_type() with the argument false. | |
Parser constructors | |
declNode (idNode *id, Storage_class sc, typeNode *the_type, exprNode *init, exprNode *bitsize) | |
Create a declaration from an identifier. | |
declNode (idNode *name, exprNode *value) | |
Create an enum declaration. | |
declNode (typeNode *the_type, Storage_class sc) | |
Create a type-only declaration. | |
Accessors | |
Methods to get and set fields in the class. | |
typeNode * | type () const |
Return this declNode's base C data type. | |
typeNode * | get_type () |
Return this declNode's base C data type, and set the base C data type to be empty. | |
void | type (typeNode *the_type) |
Set this declNode's base C data type. | |
string & | name () |
Return the name of the variable declared by this declNode. | |
void | name (string name) |
Set the name of the variable declared by this declNode. | |
Decl_location | decl_location () const |
Return a Decl_location indicating the syntactic context in which this declaration occured. | |
void | decl_location (Decl_location loc) |
Set the syntactic context in which this declaration occured. | |
Storage_class | storage_class () const |
Return the storage class of the variable declared by this declNode. | |
void | storage_class (Storage_class sc) |
Set the storage class of the variable declared by this declNode. | |
bool | is_redundant_extern () const |
Return true iff this declaration is a redundant extern declaration. | |
void | set_redundant_extern (bool v) |
Set whether this declaration is a redundant extern declaration. | |
void | inc_references () |
Increment the number of identifier nodes that point to this declaration. | |
exprNode * | init () const |
Return the AST used to initialize the variable declared by this declNode. | |
void | init (exprNode *init) |
Define the AST node used to initialize the variable declared by this declNode. | |
exprNode * | bitsize () const |
Return this Node's bitsize. | |
void | bitsize (exprNode *bitsize) |
Define the bitsize for this declNode. | |
int | references () const |
Return the number of idNodes that point to this declaration. | |
void | references (int references) |
Set the number of idNodes that point to this declaration. | |
id_list & | ref_list () |
const id_list & | ref_list () const |
attrib_list & | attribs () |
Return a mutable reference to this declaration's attribute list. | |
const attrib_list & | attribs () const |
Return an immutable reference to this declaration's attribute list. | |
void | merge_attribs (attrib_list *attribs) |
Add each attribute in the given attribute list to this declNode's attribute list. | |
Storage_location & | storage_location () |
Returns a reference to the storage location for this data. | |
Parser methods | |
void | set_type (typeNode *the_type, Storage_class sc, ScopeState redeclare) |
declNode * | set_type_and (typeNode *the_type, Storage_class sc, ScopeState redeclare) |
declNode * | set_type_and (declNode *the_decltype, Storage_class sc, ScopeState redeclare) |
void | inherit_type (decl_list *others, ScopeState redeclare) |
declNode * | inherit_type_and (decl_list *others, ScopeState redeclare) |
void | modify_type (typeNode *the_type) |
declNode * | modify_type_and (typeNode *the_type) |
declNode * | modify_type_and (declNode *the_type) |
void | set_init (exprNode *init) |
declNode * | set_init_and (exprNode *init) |
void | add_parameter_types (decl_list *types) |
declNode * | add_parameter_types_and (decl_list *types) |
void | finish (Storage_class sc) |
declNode * | finish_and (Storage_class sc) |
AST Traversal | |
virtual void | visit (Visitor *the_visitor) |
Dispatch a Visitor. | |
virtual void | walk (Walker &the_walker) |
Dispatch a Walker. | |
virtual Node * | change (Changer &the_changer, bool redispatch=false) |
Dispatch a Changer. | |
Accessors | |
Methods to get and set fields in the class. | |
text_list & | pragmas () |
Accessors | |
Methods to get and set fields in the class. | |
NodeType | typ () const |
Get the node type. | |
Coord | coord () const |
Get the source location. | |
void | coord (const Coord coord) |
Set the source location. | |
bool | parenthesized () const |
Get the parenthesized boolean. | |
void | parenthesized (bool paren) |
Set the parenthesized boolean. | |
annote_list & | annotations () |
Get the annotations list. | |
FlowVal * | gen () const |
Get the "gen" flow value. | |
void | gen (FlowVal *g) |
Set the "gen" flow value. | |
FlowVal * | kill () const |
Get the "kill" flow value. | |
void | kill (FlowVal *k) |
Set the "kill" flow value. | |
Static Public Member Functions | |
void | report () |
Report node count statistics. | |
Output methods. | |
These two methods are used when generating C code to convert the Storage_class and Decl_location values into strings. | |
string | storage_class_name (Storage_class sc) |
Return a string value containing the C code for this Declaration's storage class. | |
string | decl_location_name (Decl_location dl) |
Return a string value containing the C code for this Declaration's location. | |
Private Attributes | |
TREE typeNode * | _type |
Type. | |
string | _name |
Name. | |
Decl_location | _decl_location |
Declaration location. | |
Storage_class | _storage_class |
Storage class. | |
Storage_location | _storage_location |
Storage location. | |
bool | _is_redundant_extern |
Redundant extern. | |
TREE exprNode * | _init |
Initializer expression. | |
TREE exprNode * | _bitsize |
Bitsize expression. | |
int | _references |
Reference count. | |
REF id_list | _ref_list |
List of ids. | |
TREE attrib_list | _attribs |
Attributes. |
This class represents all declarations. At its core, it is just a name and a data type, with the optional initializer and bitsize expressions. However, it also holds information about the syntactic location of the declaration and any associated storage class.
The NodeType is Decl.
Definition at line 742 of file ast.h.
|
Declaration location. This type is used to record some syntactic context information about the declaration. This information is computed by the id_lookup_walker.
Definition at line 755 of file ast.h. Referenced by UnificationBasedPtr::at_decl(), SSA::need_ssa(), subdeclNode::output(), and output(). |
|
Storage class specifier.
This type indicates any storage class information associated with the declaration. It is overloaded to also indicate when a declaration is a |
|
Create a declaration. Create a new declaration with the given parameters. This constructor allows most of the properties of the declaration to be specified explicitly. The exceptions are the declNode's location, which is set to UNKNOWN, and the boolean redundant_extern, which is set to false. User code should only need this constructor. The following example declaration is used to point out which features each parameter represents.
static int x = 12;
Definition at line 45 of file declnode.cc. References Decl. Referenced by clone(). |
|
Create a declaration from an identifier.
Definition at line 63 of file declnode.cc. References Decl. |
|
Create an enum declaration.
Definition at line 82 of file declnode.cc. |
|
Create a type-only declaration.
Definition at line 116 of file declnode.cc. |
|
Destroy a declNode.
Definition at line 723 of file declnode.cc. |
|
Definition at line 485 of file declnode.cc. References funcNode::add_parameter_types(), Func, Node::typ(), and type(). Referenced by add_parameter_types_and(). |
|
Definition at line 493 of file declnode.cc. References add_parameter_types(). |
|
Get the annotations list. This method returns a modifiable reference to the list of annotations on the node. Users can add new annotations, search for annotations, or remove annotations. Users are responsible for ensuring that every element of the annotation list points to a valid annotation. In particular, no element should be NULL.
Definition at line 276 of file ast.h. References annote_list. |
|
Return an immutable reference to this declaration's attribute list.
Definition at line 1115 of file ast.h. References attrib_list. |
|
Return a mutable reference to this declaration's attribute list.
Definition at line 1110 of file ast.h. References attrib_list. Referenced by tree_visitor::at_decl(), subdeclNode::change(), change(), subdeclNode::walk(), and walk(). |
|
Return the base data type of a node. This method differs from the Node::type() method in two respects. First, it follows some of the simple type inferences. For example, calling it on an idNode will return the type of its declaration. Second, the boolean argument indicates whether or not to follow typedef links.
Reimplemented from Node. Definition at line 467 of file declnode.cc. References typeNode::base_type(), and type(). Referenced by procNode::base_type(). |
|
Define the bitsize for this declNode. To set the bitsize of this declNode to be empty, call this method with a value of NULL. |
|
Return this Node's bitsize.
Definition at line 1085 of file ast.h. Referenced by vcgASTWalker::at_decl(), tree_visitor::at_decl(), subdeclNode::change(), change(), subdeclNode::output(), output(), subdeclNode::subdeclNode(), subdeclNode::walk(), and walk(). |
|
Dispatch a Changer. This abstract method works much the walker, but allows the tree to be changed.
Implements Node. Reimplemented in subdeclNode. Definition at line 663 of file declnode.cc. References Changer::at_decl(), attribs(), bitsize(), Changer::Both, Node::change(), change_list(), init(), Changer::order(), Changer::Order, Changer::Postorder, defNode::pragmas(), Changer::Preorder, and type(). Referenced by procNode::change(). |
|
Clone the input node. This is not a "deep" clone, so be careful. For a deep clone, use the ref_clone_changer class.
Implements Node. Reimplemented in subdeclNode. Definition at line 1229 of file ast.h. References declNode(). |
|
Set the source location. This location should indicate the position in the source text that this Node represents, or Coord::Unknown if it does not represent any node in the source text. It is not common to set the source location of a node. Currently, only the compiler error messages actually make use of it.
|
|
|
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.
Implements Node. Definition at line 580 of file declnode.cc. References Node::dataflow(), FlowProblem::flow_decl(), FlowProblem::forward(), and init(). |
|
Call base_type() with the argument true.
Definition at line 157 of file node.cc. References Node::base_type(). Referenced by funcNode::is_void_args(). |
|
Call base_type() with the argument false.
Definition at line 162 of file node.cc. References Node::base_type(). |
|
Set the syntactic context in which this declaration occured.
|
|
|
Return a string value containing the C code for this Declaration's location.
Definition at line 526 of file declnode.cc. References BLOCK, ENUM, FORMAL, PROC, SU, and TOP. Referenced by print_walker::at_decl(), and print_tree_visitor::at_decl(). |
|
Definition at line 170 of file declnode.cc. References typeNode::finish(), storage_class(), type(), TYPEDEF, and typeNode::verify_sue_complete(). Referenced by finish_and(), procNode::procNode(), and set_type(). |
|
Definition at line 186 of file declnode.cc. References finish(). |
|
Set the "gen" flow value. This value is used in dataflow analyses to store information that is generated at this node. Note that each node has exactly one "gen" flow value. In order to set the flow value to be empty, call this method with a value of NULL.
|
|
Get the "gen" flow value. This value is used in dataflow analyses to store information that is generated at this node. Note that each node has exactly one "gen" flow value.
|
|
Return this declNode's base C data type, and set the base C data type to be empty.
Definition at line 1013 of file ast.h. Referenced by set_type_and(). |
|
Increment the number of identifier nodes that point to this declaration.
Definition at line 1068 of file ast.h. Referenced by id_lookup_walker::at_binary(), and id_lookup_walker::at_call(). |
|
Definition at line 419 of file declnode.cc. References ref_clone_changer::clone(), decl_location(), typeNode::deep_base_type(), set_type(), storage_class(), and type(). Referenced by inherit_type_and(). |
|
Definition at line 433 of file declnode.cc. References inherit_type(). |
|
Define the AST node used to initialize the variable declared by this declNode. To set the initializer of this declNode to be empty, call this method with a value of NULL. |
|
Return the AST used to initialize the variable declared by this declNode.
Definition at line 1073 of file ast.h. Referenced by vcgASTWalker::at_decl(), UnificationBasedPtr::at_decl(), tree_visitor::at_decl(), semcheck_walker::at_decl(), InitializerDismantle::at_decl(), enum_value_walker::at_enum(), semcheck_walker::at_suespec(), subdeclNode::change(), change(), dataflow(), idNode::eval(), lir_gen_walker::gen_global_decl(), lir_gen_walker::gen_local_decl(), memoryModel::generate_array_elements_for(), InitializerDismantle::init_scalar(), function_inline::inliner(), ipConstantPropagation::lookup(), memoryModel::lookup_variable(), subdeclNode::output(), output(), constantAnalyzer::rebuild_flowvalue(), set_init(), subdeclNode::subdeclNode(), Unify_ECR::Unify_ECR(), subdeclNode::walk(), and walk(). |
|
Return true iff this declaration is a redundant extern declaration. Redundant extern declarations are allowed in C. Definition at line 1058 of file ast.h. Referenced by set_init(). |
|
Set the "kill" flow value. This value is used in dataflow analyses to store information that is killed at this node. Note that each node has exactly one "kill" flow value. To set the flow value to be empty, call this method with a value of NULL.
|
|
Get the "kill" flow value. This value is used in dataflow analyses to store information that is killed at this node. Note that each node has exactly one "kill" flow value.
|
|
Add each attribute in the given attribute list to this declNode's attribute list.
Definition at line 501 of file declnode.cc. References _attribs. |
|
Definition at line 138 of file declnode.cc. References typeNode::set_base_type(), and type(). Referenced by modify_type_and(), and set_type(). |
|
Definition at line 152 of file declnode.cc. References modify_type(), and type(). |
|
Definition at line 146 of file declnode.cc. References modify_type(). |
|
Set the name of the variable declared by this declNode.
|
|
|
Return the type. Return the type after following any typedefs to the real type.
Definition at line 476 of file declnode.cc. References typeNode::follow_tdefs(), and type(). Referenced by Pointers::assignment_operator(), UnificationBasedPtr::at_call(), UnificationBasedPtr::at_decl(), InitializerDismantle::at_decl(), UnificationBasedPtr::at_proc(), memoryModel::create_memory_object(), Pointers::determine_call_targets(), memoryBlock::dot(), Pointers::dot_operator(), Pointers::eval(), lir_gen_walker::gen_arg_decl(), lir_gen_walker::gen_local_decl(), memoryModel::generate_array_elements_for(), InitializerDismantle::init_scalar(), memoryModel::lookup_variable(), SSA::need_ssa(), Pointers::pass_parameters(), SSA::place_one_phi(), Pointers::star_operator(), Pointers::struct_union_assignment(), and memoryBlock::top_most_containers(). |
|
SSA original declaration. For use with subdeclNode when the code is in SSA form. This method returns the original declaration from which the sub-declaration was derived.
Reimplemented in subdeclNode. Definition at line 1210 of file ast.h. Referenced by subdeclNode::original(). |
|
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.
Implements Node. Reimplemented in subdeclNode. Definition at line 604 of file declnode.cc. References bitsize(), BLOCK, decl_location(), Decl_location, ENUM, FORMAL, init(), name(), output_context::new_line(), exprNode::output(), typeNode::output_type(), defNode::pragmas(), output_context::space(), storage_class(), storage_class_name(), SU, text_list_p, TOP, type(), and UNKNOWN. Referenced by procNode::output(). |
|
Set the parenthesized boolean. This boolean determines whether this expression will be parenthesized in the output. Note that that the parentheses will always be added when they are needed to disambiguate the output. This variable only controls the use of "un-necessary" parentheses.
|
|
Get the parenthesized boolean.
Definition at line 252 of file ast.h. Referenced by exprNode::parens(), and CBZ::WarnAboutPrecedence(). |
|
Definition at line 720 of file ast.h. References text_list. Referenced by procNode::change(), change(), output(), procNode::walk(), and walk(). |
|
Definition at line 1105 of file ast.h. References id_list. |
|
Definition at line 1104 of file ast.h. References id_list. Referenced by ref_clone_changer::at_decl(), print_walker::at_decl(), FlattenDismantle::at_decl(), idNode::decl(), and StaticToGlobalDismantle::rename_decl(). |
|
Set the number of idNodes that point to this declaration.
|
|
Return the number of idNodes that point to this declaration.
Definition at line 1097 of file ast.h. Referenced by id_lookup_walker::at_decl(), Externals_table::notify_exit_scope(), and Identifiers_table::notify_exit_scope(). |
|
Report node count statistics. The code can be configured to gather statistics about node usage according to type. This method prints the current state of that accounting information to standard out. Definition at line 184 of file node.cc. References Node::_count, Node::_t_count, Array, Attrib, Binary, Block, Break, Call, Case, Cast, Comma, Const, Continue, Decl, Do, Enum, Expr, For, Func, Goto, Id, If, Initializer, Label, Prim, Proc, Ptr, Return, Struct, sueSpec, Switch, Tdef, Ternary, Text, Unary, Undeclared, Union, and While. |
|
Definition at line 443 of file declnode.cc. References _init, init(), is_redundant_extern(), and set_redundant_extern(). Referenced by set_init_and(). |
|
Definition at line 457 of file declnode.cc. References set_init(). |
|
Set whether this declaration is a redundant extern declaration.
Definition at line 1063 of file ast.h. Referenced by set_init(). |
|
Definition at line 197 of file declnode.cc. References CBZ::current_unit, finish(), SymbolTable< declNode * >::insert(), typeNode::is_derived(), modify_type(), name(), storage_class(), TYPEDEF, and unitNode::types(). Referenced by inherit_type(), and set_type_and(). |
|
Definition at line 406 of file declnode.cc. References get_type(), and set_type(). |
|
Definition at line 400 of file declnode.cc. References set_type(). |
|
Set the storage class of the variable declared by this declNode.
|
|
Return the storage class of the variable declared by this declNode.
Definition at line 1045 of file ast.h. Referenced by UnificationBasedPtr::at_decl(), print_walker::at_decl(), print_tree_visitor::at_decl(), name_mangle_walker::at_decl(), id_lookup_walker::at_decl(), StaticToGlobalDismantle::at_decl(), has_struct_walker::at_decl(), findVarAssign::at_threeAddr(), finish(), lir_gen_walker::gen_global_decl(), lir_gen_walker::gen_local_decl(), inherit_type(), Identifiers_table::is_a_type(), Linker::link(), memoryModel::lookup_variable(), SSA::need_ssa(), Externals_table::notify_exit_scope(), Identifiers_table::notify_exit_scope(), subdeclNode::output(), output(), SSA::place_phi_functions(), procNode::procNode(), StaticToGlobalDismantle::rename_decl(), RequiresGatherer::requires(), and set_type(). |
|
Return a string value containing the C code for this Declaration's storage class.
Definition at line 513 of file declnode.cc. References AUTO, EXTERN, REGISTER, STATIC, and TYPEDEF. Referenced by print_walker::at_decl(), print_tree_visitor::at_decl(), subdeclNode::output(), and output(). |
|
Returns a reference to the storage location for this data.
Definition at line 1125 of file ast.h. Referenced by procNode::alloc_stack_local(), storage_alloc::assign_register(), LIR::DeclareLocal(), asm_gen_walker::doCalleeSave(), asm_gen_walker::doCallerSave(), lir_gen_walker::gen_arg_decl(), lir_gen_walker::gen_global_decl(), lir_gen_walker::gen_local_decl(), briggs_reg_alloc::genSpillCode(), storage_alloc::get_temp_var(), lir_gen_walker::load_global_addr(), lir_gen_walker::load_global_value(), lir_gen_walker::load_global_var(), lir_gen_walker::load_stack_addr(), lir_gen_walker::load_stack_value(), lir_gen_walker::load_stack_var(), lir_gen_walker::store_global(), and lir_gen_walker::store_stack(). |
|
|
Set this declNode's base C data type. To set the data type to be empty, call this method with a value of NULL. |
|
|
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.
Implements Node. Reimplemented in subdeclNode. Definition at line 543 of file declnode.cc. References Visitor::at_decl(). Referenced by tree_visitor::at_proc(). |
|
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.
Implements Node. Reimplemented in subdeclNode. Definition at line 548 of file declnode.cc. References Walker::at_decl(), attribs(), bitsize(), Walker::Both, Walker::depth(), init(), list_walker(), Walker::order(), Walker::Order, Walker::Postorder, defNode::pragmas(), Walker::Preorder, Walker::Subtree, type(), and Node::walk(). Referenced by StaticToGlobalDismantle::at_decl(), RequiresGatherer::at_id(), and procNode::walk(). |
|
Attributes. Currently unused. Definition at line 908 of file ast.h. Referenced by merge_attribs(). |
|
Bitsize expression. This AST subtree specifies the bitsize expression for bitfields, or is null if the declaration is not a bitfield. |
|
Declaration location. The syntactic location of the declaration.
|
|
Initializer expression. This AST subtree specifies the initializer expression, or is null if there isn't one. Definition at line 881 of file ast.h. Referenced by set_init(). |
|
Redundant extern. This boolean is true if the declaration is a redundant extern declaration (as allowed in C). |
|
Name. The name of the declaration. Definition at line 846 of file ast.h. Referenced by declNode(). |
|
List of ids. This list contains all the idNode's which refer to this declNode.
|
|
Reference count. Counts the number of identifier nodes that refer to this declaration.
|
|
Storage class. Storage class specifier.
|
|
Storage location. Storage location information.
|
|
Type. This AST subtree defines the type of the declaration. |
|
Definition at line 116 of file node.cc. Referenced by gcWalker::delete_nodes(), and Node::~Node(). |
|
Definition at line 170 of file ast.h. Referenced by gcWalker::at_binary(), gcWalker::at_node(), gcWalker::delete_nodes(), and SymbolTable< T >::mark_nodes(). |
|
Definition at line 115 of file node.cc. Referenced by gcWalker::delete_nodes(), gcWalker::gcWalker(), and Node::Node(). |
Generated on August 27, 2003
Back to the C-Breeze home page