C-Breeze
C Compiler Infrastructure

[ Project home page]
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

declNode Class Reference
[The AST nodes]

Declaration. More...

#include <ast.h>

Inheritance diagram for declNode:

defNode Node subdeclNode List of all members.

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.

typeNodebase_type (bool TdefIndir) const
 Return the base data type of a node.

typeNodeno_tdef_type ()
 Return the type.

virtual declNode * original ()
 SSA original declaration.

virtual void dataflow (FlowVal *v, FlowProblem &fp)
 Run the dataflow analyzer.

virtual Nodeclone () const
 Clone the input node.

virtual void output (output_context &ct, Node *par)
 Generate C code.

typeNodedatatype () const
 Call base_type() with the argument true.

typeNodedatatype_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.

typeNodetype () const
 Return this declNode's base C data type.

typeNodeget_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.

exprNodeinit () 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.

exprNodebitsize () 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_listref_list ()
const id_listref_list () const
attrib_listattribs ()
 Return a mutable reference to this declaration's attribute list.

const attrib_listattribs () 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_locationstorage_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
Methods to uniformly traverse the AST. See the documentation in the Node class.

virtual void visit (Visitor *the_visitor)
 Dispatch a Visitor.

virtual void walk (Walker &the_walker)
 Dispatch a Walker.

virtual Nodechange (Changer &the_changer, bool redispatch=false)
 Dispatch a Changer.

Accessors
Methods to get and set fields in the class.

text_listpragmas ()
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_listannotations ()
 Get the annotations list.

FlowValgen () const
 Get the "gen" flow value.

void gen (FlowVal *g)
 Set the "gen" flow value.

FlowValkill () 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.


Detailed Description

Declaration.

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.


Member Enumeration Documentation

enum declNode::Decl_location
 

Declaration location.

This type is used to record some syntactic context information about the declaration. This information is computed by the id_lookup_walker.

See also:
id_lookup_walker
Enumeration values:
UNKNOWN  No context provided
TOP  A top-level declaration (either a global variable or a function declaration).
BLOCK  A regular local variable declared inside a function body.
FORMAL  A formal argument declared in the function interface.
SU  A struct/union field declaration.
ENUM  An element of an enum declaration.
PROC  A function declaration that has the function definition.

Definition at line 755 of file ast.h.

Referenced by UnificationBasedPtr::at_decl(), SSA::need_ssa(), subdeclNode::output(), and output().

enum declNode::Storage_class
 

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 typedef.

Enumeration values:
NONE 
AUTO 
EXTERN 
REGISTER 
STATIC 
TYPEDEF 

Definition at line 772 of file ast.h.


Constructor & Destructor Documentation

declNode::declNode const char *    name,
Storage_class    sc,
typeNode   the_type,
exprNode   init,
exprNode   bitsize,
const Coord    coord = Coord::Unknown
 

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;
  

Parameters:
name a C string specifying the declaration name ("x" in the example). This value is copied.
sc the storage class of the declaration ("static" in the example).
the_type the type of the declaration ("int" in the example).
init an initializer expression, or NULL for none ("12" in the example).
bitsize a bitfield size expression, or NONE if the declaration does not declare a bitfield (the example does not declare a bitfield).
coord the location of the construct in the source file.

Definition at line 45 of file declnode.cc.

References Decl.

Referenced by clone().

declNode::declNode idNode   id,
Storage_class    sc,
typeNode   the_type,
exprNode   init,
exprNode   bitsize
 

Create a declaration from an identifier.

Definition at line 63 of file declnode.cc.

References Decl.

declNode::declNode idNode   name,
exprNode   value
 

Create an enum declaration.

Definition at line 82 of file declnode.cc.

References Decl, and type().

declNode::declNode typeNode   the_type,
Storage_class    sc
 

Create a type-only declaration.

Definition at line 116 of file declnode.cc.

References _name, and Decl.

declNode::~declNode   [virtual]
 

Destroy a declNode.

Warning:
Do not use the destructors to delete AST nodes. Instead, rely on the node garbage collector.

Definition at line 723 of file declnode.cc.


Member Function Documentation

void declNode::add_parameter_types decl_list   types
 

Definition at line 485 of file declnode.cc.

References funcNode::add_parameter_types(), Func, Node::typ(), and type().

Referenced by add_parameter_types_and().

declNode * declNode::add_parameter_types_and decl_list   types
 

Definition at line 493 of file declnode.cc.

References add_parameter_types().

annote_list& Node::annotations   [inline, inherited]
 

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.

See also:
Annote class

Definition at line 276 of file ast.h.

References annote_list.

const attrib_list& declNode::attribs   const [inline]
 

Return an immutable reference to this declaration's attribute list.

Definition at line 1115 of file ast.h.

References attrib_list.

attrib_list& declNode::attribs   [inline]
 

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().

typeNode * declNode::base_type bool    TdefIndir const [virtual]
 

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.

Parameters:
TdefIndir pass true to follow typedefs to their definitions.

Reimplemented from Node.

Definition at line 467 of file declnode.cc.

References typeNode::base_type(), and type().

Referenced by procNode::base_type().

void declNode::bitsize exprNode   bitsize [inline]
 

Define the bitsize for this declNode.

To set the bitsize of this declNode to be empty, call this method with a value of NULL.

Definition at line 1092 of file ast.h.

exprNode* declNode::bitsize   const [inline]
 

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().

Node * declNode::change Changer   the_changer,
bool    redispatch = false
[virtual]
 

Dispatch a Changer.

This abstract method works much the walker, but allows the tree to be changed.

Parameters:
the_changer the specific Changer object to use.
redispatch pass true to revisit parts of the tree that have 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().

virtual Node* declNode::clone   const [inline, virtual]
 

Clone the input node.

This is not a "deep" clone, so be careful. For a deep clone, use the ref_clone_changer class.

Returns:
a shallow copy of the node (no subtrees are copied).

Implements Node.

Reimplemented in subdeclNode.

Definition at line 1229 of file ast.h.

References declNode().

void Node::coord const Coord    coord [inline, inherited]
 

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.

Parameters:
coord the new location.

Definition at line 245 of file ast.h.

Coord Node::coord   const [inline, inherited]
 

Get the source location.

The Coord class holds a location in the input source (file, line, position). During parsing, each AST node created records the position of the source text that it represents. However, subsequent phases may create or change nodes, so no guarantee is given about how the source location corresponds to the original source text.

Returns:
the Coord structure indicating where the node came from in the source file.

Definition at line 232 of file ast.h.

Referenced by funcNode::add_parameter_types(), Unify_Structure::all_str(), Pointers::analyze_procedure(), semcheck_expr_visitor::at_binary(), id_lookup_walker::at_binary(), ExpressionDismantle::at_binary(), ArrowDismantle::at_binary(), SelectionDismantle::at_binary(), set_container_walker::at_break(), BreakContinueChanger::at_break(), UnificationBasedPtr::at_call(), semcheck_expr_visitor::at_call(), NodeLocator::at_call(), id_lookup_walker::at_call(), ExpressionDismantle::at_call(), set_container_walker::at_case(), constantsChanger::at_conditiongoto(), set_container_walker::at_continue(), BreakContinueChanger::at_continue(), NodeLocator::at_decl(), id_lookup_walker::at_decl(), InitializerDismantle::at_decl(), LoopDismantle::at_do(), enum_value_walker::at_enum(), NodeLocator::at_expr(), ExpressionDismantle::at_exprstmt(), LoopDismantle::at_for(), goto_label_walker::at_goto(), Linker::at_id(), id_lookup_walker::at_id(), SelectionDismantle::at_if(), goto_label_walker::at_label(), id_lookup_walker::at_proc(), ReturnDismantle::at_proc(), ReturnDismantle::at_return(), NodeLocator::at_stmt(), UnificationBasedPtr::at_suespec(), semcheck_walker::at_suespec(), SelectionDismantle::at_switch(), TernaryDismantle::at_ternary(), SizeofChanger::at_threeAddr(), AllocSizeChanger::at_unary(), ExpressionDismantle::at_unary(), LoopDismantle::at_while(), Pointers::call_operator(), semcheck_expr_visitor::check_binary(), semcheck_expr_visitor::check_unary(), UnificationBasedPtr::compatible_type(), procNode::define(), exprstmtNode::exprstmtNode(), typeNode::finish(), InitializerDismantle::init_array(), InitializerDismantle::init_scalar(), InitializerDismantle::init_struct(), function_inline::inliner(), exprNode::integral_promotions(), UnificationBasedPtr::make_compatible(), reachingDefinitionsWalker::make_ud_chains(), Unify_Structure::map_str(), primNode::merge_in(), metaexprNode::metaexprNode(), metastmtNode::metastmtNode(), vcgCCGWalker::node_label(), vcgASTWalker::node_label(), vcgCCGWalker::node_title(), vcgASTWalker::node_title(), DismantleUtil::Not(), Externals_table::notify_exit_scope(), Labels_table::notify_exit_scope(), Identifiers_table::notify_exit_scope(), Pointers::pass_parameters(), vcgCCGWalker::print_edge(), vcgASTWalker::print_edge(), vcgCCGWalker::print_node(), vcgASTWalker::print_node(), stmtLocation::print_path(), procNode::procNode(), NodeInfo::readCall(), NodeInfo::readDecl(), NodeInfo::readExprOrStmt(), NodeInfo::readsuef(), Pointers::record_external_inputs_and_outputs(), P::run(), Tags_table::shadow(), Identifiers_table::shadow(), memoryBlock::top_most_containers(), suespecNode::update(), exprNode::usual_arithmetic_conversions(), CBZ::WarnAboutPrecedence(), NodeInfo::writeDecl(), NodeInfo::writeExpr(), NodeInfo::writeProc(), NodeInfo::writeStmt(), and NodeInfo::writeType().

void declNode::dataflow FlowVal   v,
FlowProblem   fp
[virtual]
 

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.

Parameters:
v the flow value to pass through the node.
fp the flow problem (specifying the transfer functions).

Implements Node.

Definition at line 580 of file declnode.cc.

References Node::dataflow(), FlowProblem::flow_decl(), FlowProblem::forward(), and init().

typeNode * Node::datatype   const [inherited]
 

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().

typeNode * Node::datatype_superior   const [inherited]
 

Call base_type() with the argument false.

Definition at line 162 of file node.cc.

References Node::base_type().

void declNode::decl_location Decl_location    loc [inline]
 

Set the syntactic context in which this declaration occured.

Definition at line 1040 of file ast.h.

Decl_location declNode::decl_location   const [inline]
 

Return a Decl_location indicating the syntactic context in which this declaration occured.

Definition at line 1035 of file ast.h.

Referenced by id_lookup_walker::at_call(), UnificationBasedPtr::at_decl(), print_walker::at_decl(), print_tree_visitor::at_decl(), id_lookup_walker::at_decl(), StaticToGlobalDismantle::at_decl(), FlattenDismantle::at_decl(), Linker::at_id(), AllocToMemWalker::at_operand(), id_lookup_walker::at_proc(), StaticToGlobalDismantle::at_proc(), findVarAssign::at_threeAddr(), memoryModel::create_memory_object(), memoryBlock::dot(), UnificationBasedPtr::ecr1(), idNode::eval(), lir_gen_walker::gen_arg_decl(), lir_gen_walker::gen_global_decl(), lir_gen_walker::gen_load(), lir_gen_walker::gen_local_decl(), lir_gen_walker::gen_store(), briggs_reg_alloc::genSpillCode(), CBZ::get_temp_var(), inherit_type(), InitializerDismantle::init_scalar(), function_inline::inliner(), funcNode::is_compatible_with(), procedureInfo::is_library_routine(), Linker::link(), briggs_reg_alloc::loadSymReg(), ipConstantPropagation::lookup(), memoryModel::lookup_variable(), UnificationBasedPtr::mergeOperand(), memoryBlock::name(), SSA::need_ssa(), LirUtil::new_auto_decl(), LirUtil::new_static_global(), DismantleUtil::new_temp_decl(), Externals_table::notify_exit_scope(), Identifiers_table::notify_exit_scope(), subdeclNode::output(), output(), SSA::place_phi_functions(), procNode::procNode(), constantAnalyzer::rebuild_flowvalue(), Pointers::record_external_inputs_and_outputs(), SSA::rename_all_variables(), Pointers::self_assignment(), and memoryBlock::top_most_containers().

string declNode::decl_location_name Decl_location    dl [static]
 

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().

void declNode::finish Storage_class    sc
 

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().

declNode * declNode::finish_and Storage_class    sc
 

Definition at line 186 of file declnode.cc.

References finish().

void Node::gen FlowVal   g [inline, inherited]
 

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.

Parameters:
g the new gen flow value.

Definition at line 299 of file ast.h.

FlowVal* Node::gen   const [inline, inherited]
 

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.

Returns:
the "gen" flow value.

Definition at line 286 of file ast.h.

typeNode* declNode::get_type   [inline]
 

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().

void declNode::inc_references   [inline]
 

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().

void declNode::inherit_type decl_list   others,
ScopeState    redeclare
 

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().

declNode * declNode::inherit_type_and decl_list   others,
ScopeState    redeclare
 

Definition at line 433 of file declnode.cc.

References inherit_type().

void declNode::init exprNode   init [inline]
 

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.

Definition at line 1081 of file ast.h.

exprNode* declNode::init   const [inline]
 

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().

bool declNode::is_redundant_extern   const [inline]
 

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().

void Node::kill FlowVal   k [inline, inherited]
 

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.

Parameters:
k the new kill flow value.

Definition at line 322 of file ast.h.

FlowVal* Node::kill   const [inline, inherited]
 

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.

Returns:
the "kill" flow value.

Definition at line 309 of file ast.h.

void declNode::merge_attribs attrib_list   attribs
 

Add each attribute in the given attribute list to this declNode's attribute list.

Definition at line 501 of file declnode.cc.

References _attribs.

void declNode::modify_type typeNode   the_type
 

Definition at line 138 of file declnode.cc.

References typeNode::set_base_type(), and type().

Referenced by modify_type_and(), and set_type().

declNode * declNode::modify_type_and declNode *    the_type
 

Definition at line 152 of file declnode.cc.

References modify_type(), and type().

declNode * declNode::modify_type_and typeNode   the_type
 

Definition at line 146 of file declnode.cc.

References modify_type().

void declNode::name string    name [inline]
 

Set the name of the variable declared by this declNode.

Definition at line 1030 of file ast.h.

string& declNode::name   [inline]
 

Return the name of the variable declared by this declNode.

Definition at line 1025 of file ast.h.

Referenced by funcNode::add_parameter_types(), procedureDB::add_procedure(), memoryBlock::add_to_flow_sensitive_list(), Unify_Structure::all_str(), function_inline::already_inlined_calls(), DefUseWalker::at_basicblock(), UnificationBasedPtr::at_decl(), print_walker::at_decl(), print_tree_visitor::at_decl(), NodeLocator::at_decl(), name_mangle_walker::at_decl(), AllocToMemWalker::at_decl(), id_lookup_walker::at_decl(), FlattenDismantle::at_decl(), name_mangle_walker::at_id(), vcgCCGWalker::at_proc(), UnitWalker::at_proc(), TreeChecker::at_proc(), Optimizer::at_proc(), name_mangle_walker::at_proc(), id_lookup_walker::at_proc(), cfg_changer::at_proc(), LIR::BeginProc(), procedureDB::build(), Linker::clear(), LirInst::contents_str(), memoryModel::create_memory_object(), Linker::create_synthetic(), LIR::DeclareGlobal(), LIR::DeclareLocal(), Dominators::Dominators(), memoryBlock::dot(), UnificationBasedPtr::ecrField(), LIR::EndProc(), vcgWalker::excluded(), findmain(), lir_gen_walker::gen_global_decl(), memoryModel::generate_array_elements_for(), memoryModel::generate_su_field(), memoryBlock::generate_su_field_name(), NodeInfo::getType(), idNode::idNode(), memoryModel::initialize_struct(), function_inline::inliner(), function_inline::inlocalstack(), Pointers::is_allocation(), Pointers::is_deallocation(), Pointers::is_exit(), memoryBlock::is_in_flow_sensitive_list(), Pointers::is_reallocation(), Pointers::is_va_arg(), Pointers::is_va_start(), Linker::link(), lir_gen_walker::load_const(), Unify_Structure::map_str(), procedureInfo::name(), memoryBlock::name(), subdeclNode::name_with_index(), Externals_table::notify_exit_scope(), Identifiers_table::notify_exit_scope(), subdeclNode::output(), output(), Pointers::pass_parameters(), SSA::place_one_phi(), procedureInfo::print(), stmtLocation::print_callsite(), UnificationBasedPtr::print_ecr(), procLocation::print_path(), Pointers::procedure_call(), procedureInfo::procedureInfo(), Linker::process_call(), NodeInfo::readProc(), Pointers::record_external_inputs_and_outputs(), StaticToGlobalDismantle::rename_decl(), RequiresGatherer::requires(), pointers_phase::run(), set_type(), Identifiers_table::shadow(), procedureInfo::stats(), memoryBlock::stats(), Pointers::struct_union_assignment(), memoryBlock::top_most_containers(), NodeInfo::writeDecl(), and NodeInfo::writeProc().

typeNode * declNode::no_tdef_type  
 

Return the type.

Return the type after following any typedefs to the real type.

Returns:
the 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().

virtual declNode* declNode::original   [inline, virtual]
 

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.

Returns:
the original declaration

Reimplemented in subdeclNode.

Definition at line 1210 of file ast.h.

Referenced by subdeclNode::original().

void declNode::output output_context   ct,
Node   par
[virtual]
 

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.

Parameters:
ct the output context which describes the formatting.
par the parent node (or null, if at the top of a subtree).

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().

void Node::parenthesized bool    paren [inline, inherited]
 

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.

Parameters:
paren the new value of the parenthesized boolean.

Definition at line 264 of file ast.h.

bool Node::parenthesized   const [inline, inherited]
 

Get the parenthesized boolean.

Returns:
true if the construct corresponding to this Node was parenthesized in the source.

Definition at line 252 of file ast.h.

Referenced by exprNode::parens(), and CBZ::WarnAboutPrecedence().

text_list& defNode::pragmas   [inline, inherited]
 

Definition at line 720 of file ast.h.

References text_list.

Referenced by procNode::change(), change(), output(), procNode::walk(), and walk().

const id_list& declNode::ref_list   const [inline]
 

Definition at line 1105 of file ast.h.

References id_list.

id_list& declNode::ref_list   [inline]
 

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().

void declNode::references int    references [inline]
 

Set the number of idNodes that point to this declaration.

Definition at line 1102 of file ast.h.

int declNode::references   const [inline]
 

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().

void Node::report   [static, inherited]
 

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.

void declNode::set_init exprNode   init
 

Definition at line 443 of file declnode.cc.

References _init, init(), is_redundant_extern(), and set_redundant_extern().

Referenced by set_init_and().

declNode * declNode::set_init_and exprNode   init
 

Definition at line 457 of file declnode.cc.

References set_init().

void declNode::set_redundant_extern bool    v [inline]
 

Set whether this declaration is a redundant extern declaration.

Definition at line 1063 of file ast.h.

Referenced by set_init().

void declNode::set_type typeNode   the_type,
Storage_class    sc,
ScopeState    redeclare
 

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().

declNode * declNode::set_type_and declNode *    the_decltype,
Storage_class    sc,
ScopeState    redeclare
 

Definition at line 406 of file declnode.cc.

References get_type(), and set_type().

declNode * declNode::set_type_and typeNode   the_type,
Storage_class    sc,
ScopeState    redeclare
 

Definition at line 400 of file declnode.cc.

References set_type().

void declNode::storage_class Storage_class    sc [inline]
 

Set the storage class of the variable declared by this declNode.

Definition at line 1050 of file ast.h.

Storage_class declNode::storage_class   const [inline]
 

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().

string declNode::storage_class_name Storage_class    sc [static]
 

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().

Storage_location& declNode::storage_location   [inline]
 

Returns a reference to the storage location for this data.

See also:
_storage_location

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().

NodeType Node::typ   const [inline, inherited]
 

Get the node type.

This has nothing to do with types in the source code. It indicates what kind of AST node this is (e.g., a unary expression node or a while node).

Returns:
the node type.

Definition at line 218 of file ast.h.

References NodeType.

Referenced by add_parameter_types(), Pointers::analyze_procedure(), SSA::assignment(), Pointers::assignment_operator(), Assignment_walker::at_binary(), semcheck_expr_visitor::at_binary(), id_lookup_walker::at_binary(), ExpressionDismantle::at_binary(), constantAnalyzer::at_binary(), UnificationBasedPtr::at_call(), TreeChecker::at_call(), semcheck_expr_visitor::at_call(), NodeLocator::at_call(), Linker::at_call(), id_lookup_walker::at_call(), ExpressionDismantle::at_call(), ExpressionDismantle::at_cast(), constantAnalyzer::at_cast(), ExpressionDismantle::at_comma(), constantFoldingChanger::at_conditiongoto(), constantPropChanger::at_conditiongoto(), constantAnalyzer::at_const(), vcgASTWalker::at_decl(), UnificationBasedPtr::at_decl(), name_mangle_walker::at_decl(), AllocToMemWalker::at_decl(), id_lookup_walker::at_decl(), InitializerDismantle::at_decl(), remove_stale_type_walker::at_expr(), NodeLocator::at_expr(), constantPropChanger::at_expr(), FlattenDismantle::at_goto(), Linker::at_id(), callGraph::at_id(), CFS_Changer::at_if(), UnificationBasedPtr::at_initializer(), TreeChecker::at_label(), FlattenDismantle::at_label(), UnificationBasedPtr::at_proc(), LivenessWalker::at_proc(), FlattenDismantle::at_proc(), DefUseWalker::at_proc(), cfg_changer::at_proc(), unreachableCodeRemover::at_proc(), TreeChecker::at_return(), constantAnalyzer::at_sizeof(), NodeLocator::at_stmt(), print_walker::at_sue(), print_tree_visitor::at_sue(), vcgCCGWalker::at_threeAddr(), Linker::at_threeAddr(), identify_inlinees::at_threeAddr(), function_inline::at_threeAddr(), W::at_type(), ExpressionDismantle::at_unary(), fixPointerWalker::at_unary(), constantAnalyzer::at_unary(), callNode::base_type(), NodeInfo::canonical(), ipConstant::cast_operator(), semcheck_expr_visitor::check_binary(), semcheck_expr_visitor::check_unary(), UnificationBasedPtr::compatible_type(), memoryModel::create_memory_object(), UnificationBasedPtr::create_synthetic_proc(), NodeInfo::def_type(), gcWalker::delete_nodes(), Pointers::determine_call_targets(), DFPreds::DFPreds(), DominanceFrontiers::DominanceFrontiers(), memoryBlock::dot(), Pointers::dot_operator(), UnificationBasedPtr::ecr1(), typeNode::equal_to(), Pointers::eval(), castNode::eval(), typeNode::finish(), typeNode::follow_tdefs(), memoryModel::generate_array_elements_for(), DefUseWalker::get_def(), DefUseWalker::get_uses(), Register::getRegRetVal(), NodeInfo::getType(), memoryModel::initialize_struct(), function_inline::inliner(), typeNode::integral_promotions(), exprNode::integral_promotions(), labelNode::is_undeclared(), UnificationBasedPtr::is_va_list(), Pointers::is_va_list(), SSA::lhs(), Linker::link(), lir_gen_walker::load_global_value(), lir_gen_walker::load_stack_value(), LocalCopyPropChanger::local_copy_prop(), memoryModel::lookup_variable(), arch_info::make_template_replacements(), reachingDefinitionsWalker::make_ud_chains(), SSA::need_ssa(), vcgCCGWalker::node_label(), vcgCCGWalker::node_name(), vcgASTWalker::node_name(), vcgCCGWalker::node_title(), NodeInfo::nodeIndex(), operandNode::noncast_type(), DismantleUtil::Not(), Externals_table::notify_exit_scope(), Identifiers_table::notify_exit_scope(), stmtNode::output(), operandNode::output_expr(), blockNode::output_stmt(), sueNode::output_type(), ptrNode::output_type(), Pointers::pass_parameters(), SSA::phi(), SSA::place_one_phi(), vcgASTWalker::print_edge(), vcgCCGWalker::print_node(), vcgASTWalker::print_node(), procedureInfo::procedureInfo(), procNode::procNode(), LocalCopyPropChanger::prop(), LocalCopyPropChanger::prop_expr(), arrayNode::qualified_equal_to(), NodeInfo::readCall(), NodeInfo::readDecl(), NodeInfo::readExprOrStmt(), NodeInfo::readProc(), NodeInfo::readsuef(), NodeInfo::readType(), Unreachable::remove(), P::run(), dfpreds_phase::run(), ssa_phase::run(), pointers_phase::run(), SSA::search(), sueNode::set_name_fields(), Register::setType(), Unify_Size::sizeOf(), Unify_Size::sizeOfAssign(), SSA::SSA(), Pointers::star_operator(), lir_gen_walker::store_global(), lir_gen_walker::store_stack(), Pointers::struct_union_assignment(), blockNode::toBlock(), memoryBlock::top_most_containers(), P::type_name(), NodeInfo::type_name(), Unify_ECR::Unify_ECR(), typeNode::unwind_tdefs(), suespecNode::update(), typeNode::usual_arithmetic_conversions(), exprNode::usual_arithmetic_conversions(), binaryNode::walk(), CBZ::WarnAboutPrecedence(), NodeInfo::writeCall(), NodeInfo::writeExpr(), NodeInfo::writeProc(), NodeInfo::writeStmt(), and NodeInfo::writeType().

void declNode::type typeNode   the_type [inline]
 

Set this declNode's base C data type.

To set the data type to be empty, call this method with a value of NULL.

Definition at line 1020 of file ast.h.

typeNode* declNode::type   const [inline, virtual]
 

Return this declNode's base C data type.

Reimplemented from Node.

Definition at line 1007 of file ast.h.

Referenced by funcNode::add_parameter_types(), add_parameter_types(), procNode::alloc_stack_local(), dummy_reg_alloc::allocate_real_for_virtual(), storage_alloc::assign_register(), Pointers::assignment_operator(), UnificationBasedPtr::at_call(), vcgASTWalker::at_decl(), UnificationBasedPtr::at_decl(), tree_visitor::at_decl(), TreeChecker::at_decl(), name_mangle_walker::at_decl(), AllocToMemWalker::at_decl(), id_lookup_walker::at_decl(), StaticToGlobalDismantle::at_decl(), Linker::at_id(), callGraph::at_id(), UnificationBasedPtr::at_initializer(), UnificationBasedPtr::at_proc(), UnitWalker::at_proc(), name_mangle_walker::at_proc(), LivenessWalker::at_proc(), id_lookup_walker::at_proc(), FlattenDismantle::at_proc(), ReturnDismantle::at_proc(), vcgCCGWalker::at_threeAddr(), Linker::at_threeAddr(), identify_inlinees::at_threeAddr(), idNode::base_type(), base_type(), LIR::Call(), subdeclNode::change(), change(), semcheck_expr_visitor::check_binary(), UnificationBasedPtr::cjoin(), UnificationBasedPtr::create_synthetic_proc(), LIR::DeclareGlobal(), declNode(), Pointers::dot_operator(), UnificationBasedPtr::ecr(), UnificationBasedPtr::ecr1(), UnificationBasedPtr::ecrDeref(), UnificationBasedPtr::ensure_no_bottom(), UnificationBasedPtr::ensure_struct_obj(), Pointers::eval(), finish(), lir_gen_walker::gen_arg_decl(), lir_gen_walker::gen_global_decl(), memoryModel::generate_array_elements_for(), memoryModel::generate_su_field(), memoryBlock::generate_su_field_name(), briggs_reg_alloc::genSpillCode(), Unify_Structure::get(), Symbol::getLirVt(), NodeInfo::getType(), inherit_type(), InitializerDismantle::init_scalar(), memoryModel::initialize_struct(), function_inline::inliner(), UnificationBasedPtr::is_va_list(), Pointers::is_va_list(), Linker::link(), LIR::LoadStatic(), briggs_reg_alloc::loadSymReg(), modify_type(), modify_type_and(), memoryBlock::name(), no_tdef_type(), Externals_table::notify_exit_scope(), Identifiers_table::notify_exit_scope(), subdeclNode::output(), output(), UnificationBasedPtr::print_ecr(), procNode::procNode(), NodeInfo::readProc(), Pointers::record_external_inputs_and_outputs(), StaticToGlobalDismantle::rename_decl(), RequiresGatherer::requires(), Unify_Size::sizeOfAssign(), Pointers::star_operator(), subdeclNode::subdeclNode(), memoryBlock::top_most_container(), memoryBlock::top_most_containers(), Unify_ECR::Unify_ECR(), subdeclNode::walk(), walk(), and NodeInfo::writeProc().

void declNode::visit Visitor   the_visitor [virtual]
 

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.

Parameters:
the_visitor the specific Visitor object to use.

Implements Node.

Reimplemented in subdeclNode.

Definition at line 543 of file declnode.cc.

References Visitor::at_decl().

Referenced by tree_visitor::at_proc().

void declNode::walk Walker   the_walker [virtual]
 

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.

Parameters:
the_walker the specific Walker object to use.

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().


Member Data Documentation

TREE attrib_list declNode::_attribs [private]
 

Attributes.

Currently unused.

Definition at line 908 of file ast.h.

Referenced by merge_attribs().

TREE exprNode* declNode::_bitsize [private]
 

Bitsize expression.

This AST subtree specifies the bitsize expression for bitfields, or is null if the declaration is not a bitfield.

Definition at line 888 of file ast.h.

Decl_location declNode::_decl_location [private]
 

Declaration location.

The syntactic location of the declaration.

See also:
Decl_location

Definition at line 853 of file ast.h.

TREE exprNode* declNode::_init [private]
 

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().

bool declNode::_is_redundant_extern [private]
 

Redundant extern.

This boolean is true if the declaration is a redundant extern declaration (as allowed in C).

Definition at line 874 of file ast.h.

string declNode::_name [private]
 

Name.

The name of the declaration.

Definition at line 846 of file ast.h.

Referenced by declNode().

REF id_list declNode::_ref_list [private]
 

List of ids.

This list contains all the idNode's which refer to this declNode.

See also:
idNode

Definition at line 902 of file ast.h.

int declNode::_references [private]
 

Reference count.

Counts the number of identifier nodes that refer to this declaration.

See also:
idNode

Definition at line 895 of file ast.h.

Storage_class declNode::_storage_class [private]
 

Storage class.

Storage class specifier.

See also:
Storage_class

Definition at line 860 of file ast.h.

Storage_location declNode::_storage_location [private]
 

Storage location.

Storage location information.

See also:
Storage_location_type

Definition at line 867 of file ast.h.

TREE typeNode* declNode::_type [private]
 

Type.

This AST subtree defines the type of the declaration.

Definition at line 840 of file ast.h.

map< Node *, bool > Node::deleted_nodes [static, inherited]
 

Definition at line 116 of file node.cc.

Referenced by gcWalker::delete_nodes(), and Node::~Node().

bool Node::mark [inherited]
 

Definition at line 170 of file ast.h.

Referenced by gcWalker::at_binary(), gcWalker::at_node(), gcWalker::delete_nodes(), and SymbolTable< T >::mark_nodes().

node_list Node::nodes [static, inherited]
 

Definition at line 115 of file node.cc.

Referenced by gcWalker::delete_nodes(), gcWalker::gcWalker(), and Node::Node().


The documentation for this class was generated from the following files:

Generated on August 27, 2003
Back to the C-Breeze home page