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  

typeNode Class Reference
[The AST nodes]

Type node. More...

#include <ast.h>

Inheritance diagram for typeNode:

Node arrayNode funcNode primNode ptrNode sueNode suespecNode tdefNode enumNode structNode unionNode List of all members.

Garbage collection.

bool mark
node_list nodes
map< Node *, bool > deleted_nodes

Public Types

enum  Type_qualifiers {
  NONE = 0x0, CONST = 0x1, VOLATILE = 0x2, INLINE = 0x4,
  COMPATIBLE = 0x3
}
 Type qualifiers. More...


Public Member Functions

 typeNode (NodeType typ, Type_qualifiers tq, typeNode *subtype, const Coord coord)
 Create a new type.

virtual ~typeNode ()
 Destroy a typeNode.

virtual bool qualified_equal_to (typeNode *other, bool strict_toplevel, bool strict_recursive)
 Virtual type comparison routine.

typeNode * unwind_tdefs (Type_qualifiers &the_tq)
 Unwind typedefs.

typeNode * no_tdef_type ()
typeNode * follow_tdefs ()
 Follow typedefs.

virtual typeNode * usual_unary_conversion_type ()
 Usual unary conversion type.

virtual typeNode * base_type (bool TdefIndir) const
 Return the base data type of a node.

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

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

virtual void output_type (output_context &ct, Node *par, Assoc context, Type_qualifiers q)=0
 Output a type.

typeNode * datatype () const
 Call base_type() with the argument true.

typeNode * datatype_superior () const
 Call base_type() with the argument false.

virtual Nodeclone () const=0
 Clone the input node.

Accessors
Methods to get and set fields in the class.

typeNode * type () const
 Return this typeNode's subtype.

typeNode * get_type ()
 Return this typeNode's subtype, and set it to be empty.

void type (typeNode *the_type)
 Set this typeNode's subtype.

Type_qualifiers type_qualifiers () const
 Return this typeNode's type qualifiers.

void type_qualifiers (Type_qualifiers the_tq)
 Set this typeNode's type qualifiers.

string type_qualifiers_name ()
 Return a string representation of this typeNode's type qualifiers.

void add_type_qualifiers (Type_qualifiers the_tq)
 Add a new type qualifier to this typeNode.

typeNode * add_type_qualifiers_and (Type_qualifiers the_tq)
 Add a new type qualifier to this typeNode, and return the typeNode.

void remove_type_qualifiers (Type_qualifiers the_tq)
 Remove a type qualifier from this typeNode.

int alloc_size (void) const
 Indicates the size of memory necessary for this type.

void alloc_size (int size)
 Sets the size necessary for this type.

int alloc_align (void) const
 Indicates the word alignment necessary for this type.

void alloc_align (int align)
 Sets the alignment necessary for this type.

Parser methods
void finish ()
typeNode * finish_and ()
void set_base_type (typeNode *base)
typeNode * set_base_type_and (typeNode *base)
void verify_sue_complete ()
Type comparison operators
These operators are used to compare types. They recursively descend the compound types and verify the structure. There are several different variations, depending on the level of strictness. In all cases, typedefs are followed so they don't interfere with the comparison. All operators use the static equal_to() method.

See also:
equal_to()


bool operator== (typeNode &second)
 Strict type comparison.

bool operator<= (typeNode &second)
 Weaker type comparison.

bool operator!= (typeNode &second)
 Strict type inequality.

Type predicates
These methods support a variety of useful type predicates, most of which are self-explanatory. Each typeNode subclass overrides the methods for which it returns true.

virtual bool is_char () const
virtual bool is_int () const
virtual bool is_float () const
virtual bool is_void () const
virtual bool is_ellipsis () const
virtual bool is_integer () const
virtual bool is_arithmetic () const
virtual bool is_scalar () const
virtual bool is_aggregate () const
virtual bool is_derived () const
virtual bool is_pointer () const
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.

AST traversal
These methods provide a uniform way to traverse the AST without explicitly testing the node types. They are all variations of the visitor design pattern. The input object is an instance of a user-defined subclass of Visitor, Walker or Changer. By overriding virtual methods, the user can define what to do at each kind of node that is encountered. See the C-Breeze documentation for more details.

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

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

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


Static Public Member Functions

string type_qualifiers_name (Type_qualifiers tq)
 Convert type qualifiers to string.

typeNode * integral_promotions (typeNode *old_type)
 Integral promotions.

pair< typeNode *, typeNode * > usual_arithmetic_conversions (typeNode *left, typeNode *right)
 Usual arithmetic conversions.

bool equal_to (typeNode *first, typeNode *second, bool strict_toplevel, bool strict_recursive)
 Type comparison.

void report ()
 Report node count statistics.


Private Attributes

TREE typeNode * _type
 The sub-type.

Type_qualifiers _type_qualifiers
 Type qualifiers.

int _alloc_size
 The size of memory necessary for this type.

int _alloc_align
 The word alignment necessary for this type.


Detailed Description

Type node.

This class provides a base class for all nodes that represent C data types. Types are represented in the tree with the outer-most type specifier at the top and the primitive base type at the bottom. For example, "int * a[3]" is translated into a structure like this: arrayNode --> ptrNode -->primNode (int).

The NodeType is determined by the subclass.

Definition at line 1631 of file ast.h.


Member Enumeration Documentation

enum typeNode::Type_qualifiers
 

Type qualifiers.

This enum holds the possible type qualifiers. The special COMPATIBLE value indicates which type qualifiers are relevant when comparing two types for compatibility: const and volatile.

Enumeration values:
NONE  No type qualifier
CONST  Type is const
VOLATILE  Type is volatile
INLINE  Type is inline
COMPATIBLE  Mask the qualifiers that are relevant to type compatibility

Definition at line 1642 of file ast.h.

Referenced by add_type_qualifiers(), equal_to(), finish(), remove_type_qualifiers(), and unwind_tdefs().


Constructor & Destructor Documentation

typeNode::typeNode NodeType    typ,
Type_qualifiers    tq,
typeNode *    subtype,
const Coord    coord
 

Create a new type.

Create a type node of the appropriate node type. This constructor is only used by the subclasses, which represent specific types.

Parameters:
typ the kind of node (passed to the superclass constructor)
tq the type qualifiers
subtype the subtype, or 0 if there is none
coord the location of the construct in the source file.

Definition at line 44 of file typenode.cc.

typeNode::~typeNode   [virtual]
 

Destroy a typeNode.

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

Definition at line 454 of file typenode.cc.


Member Function Documentation

void typeNode::add_type_qualifiers Type_qualifiers    the_tq [inline]
 

Add a new type qualifier to this typeNode.

Definition at line 1783 of file ast.h.

References Type_qualifiers.

Referenced by add_type_qualifiers_and(), and finish().

typeNode* typeNode::add_type_qualifiers_and Type_qualifiers    the_tq [inline]
 

Add a new type qualifier to this typeNode, and return the typeNode.

Definition at line 1789 of file ast.h.

References add_type_qualifiers().

void typeNode::alloc_align int    align [inline]
 

Sets the alignment necessary for this type.

Definition at line 1807 of file ast.h.

int typeNode::alloc_align void    const [inline]
 

Indicates the word alignment necessary for this type.

Definition at line 1804 of file ast.h.

Referenced by procNode::alloc_stack_local(), storage_alloc::assign_arg_stack(), AllocSizeChanger::at_array(), AllocSizeChanger::at_enum(), AllocSizeChanger::at_prim(), AllocSizeChanger::at_ptr(), AllocSizeChanger::at_struct(), AllocSizeChanger::at_tdef(), AllocSizeChanger::at_union(), asm_gen_walker::createTempForRegSave(), LIR::DeclareGlobal(), lir_gen_walker::field_offset(), and lir_gen_walker::gen_call().

void typeNode::alloc_size int    size [inline]
 

Sets the size necessary for this type.

Definition at line 1801 of file ast.h.

int typeNode::alloc_size void    const [inline]
 

Indicates the size of memory necessary for this type.

Definition at line 1798 of file ast.h.

Referenced by procNode::alloc_stack_local(), storage_alloc::assign_arg_stack(), AllocSizeChanger::at_array(), AllocSizeChanger::at_enum(), AllocSizeChanger::at_prim(), AllocSizeChanger::at_ptr(), AllocSizeChanger::at_struct(), AllocSizeChanger::at_tdef(), SizeofChanger::at_threeAddr(), AllocSizeChanger::at_unary(), AllocSizeChanger::at_union(), asm_gen_walker::createTempForRegSave(), LIR::DeclareGlobal(), lir_gen_walker::gen_binary_assignment(), lir_gen_walker::gen_call(), lir_gen_walker::gen_global_decl(), and lir_gen_walker::index_offset().

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.

virtual typeNode* typeNode::base_type bool    TdefIndir const [inline, 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.

Reimplemented in tdefNode.

Definition at line 1972 of file ast.h.

Referenced by tdefNode::base_type(), idNode::base_type(), exprNode::base_type(), declNode::base_type(), and callNode::base_type().

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

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.

Implemented in unitNode, declNode, subdeclNode, procNode, primNode, tdefNode, ptrNode, arrayNode, funcNode, structNode, unionNode, enumNode, suespecNode, constNode, idNode, binaryNode, unaryNode, castNode, commaNode, ternaryNode, callNode, initializerNode, blockNode, basicblockNode, exprstmtNode, labelNode, caseNode, ifNode, switchNode, whileNode, doNode, forNode, gotoNode, continueNode, breakNode, returnNode, attribNode, operandNode, conditiongotoNode, threeAddrNode, textNode, metaexprNode, and metastmtNode.

Referenced by whileNode::change(), unaryNode::change(), threeAddrNode::change(), ternaryNode::change(), switchNode::change(), subdeclNode::change(), returnNode::change(), ptrNode::change(), operandNode::change(), metastmtNode::change(), metaexprNode::change(), initializerNode::change(), ifNode::change(), idNode::change(), funcNode::change(), forNode::change(), exprstmtNode::change(), doNode::change(), declNode::change(), constNode::change(), conditiongotoNode::change(), commaNode::change(), castNode::change(), caseNode::change(), callNode::change(), binaryNode::change(), attribNode::change(), arrayNode::change(), ref_clone_changer::clone(), TreeFixer::fix(), and AllocSizeChanger::size().

virtual Node* Node::clone   const [pure virtual, inherited]
 

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

Implemented in unitNode, declNode, subdeclNode, procNode, primNode, tdefNode, ptrNode, arrayNode, funcNode, structNode, unionNode, enumNode, suespecNode, constNode, idNode, binaryNode, unaryNode, castNode, commaNode, ternaryNode, callNode, initializerNode, blockNode, basicblockNode, exprstmtNode, labelNode, caseNode, ifNode, switchNode, whileNode, doNode, forNode, gotoNode, continueNode, breakNode, returnNode, attribNode, operandNode, conditiongotoNode, threeAddrNode, textNode, metaexprNode, and metastmtNode.

Referenced by ref_clone_changer::at_node().

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

virtual void typeNode::dataflow FlowVal   v,
FlowProblem   fp
[inline, 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 1982 of file ast.h.

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

typeNode * typeNode::deep_base_type  
 

Definition at line 57 of file typenode.cc.

References is_derived(), and type().

Referenced by finish(), and declNode::inherit_type().

bool typeNode::equal_to typeNode *    first,
typeNode *    second,
bool    strict_toplevel,
bool    strict_recursive
[static]
 

Type comparison.

This static method compares two types, descending into the subtypes and following typedefs as necessary. The two boolean arguments control how strict the algorithm is with respect to type qualifiers. Passing true requires all type qualifiers to be the same. Passing false only requires those type qualifiers that affect compatibility to be the same. (Was TypeEqualQualified in type.c)

This routine relies on the qualified_equal_to() methods on each kind of typeNode to perform the appropriate comparison and dispatch to the sub-type when necessary.

See also:
qualified_equal_to()
Parameters:
first the first type
second the second type
strict_toplevel pass true to require strict comparison of top-level types
strict_recursive pass true to require strict comparson of sub-types
Returns:
true, if the types pass the equality test

Definition at line 215 of file typenode.cc.

References Array, NONE, Ptr, qualified_equal_to(), Node::typ(), Type_qualifiers, and unwind_tdefs().

Referenced by operator<=(), operator==(), ptrNode::qualified_equal_to(), funcNode::qualified_equal_to(), and arrayNode::qualified_equal_to().

void typeNode::finish  
 

Reimplemented in primNode.

Definition at line 116 of file typenode.cc.

References add_type_qualifiers(), Node::coord(), deep_base_type(), Func, INLINE, remove_type_qualifiers(), CBZ::SyntaxError(), Node::typ(), type_qualifiers(), Type_qualifiers, and CBZ::Warning().

Referenced by declNode::finish(), and finish_and().

typeNode * typeNode::finish_and  
 

Reimplemented in primNode.

Definition at line 137 of file typenode.cc.

References finish().

typeNode * typeNode::follow_tdefs  
 

Follow typedefs.

Follow the chain of typedefs from this type, returning the underlying (non-typedef) type.

Returns:
the type at the end of the typedef chain

Definition at line 167 of file typenode.cc.

References tdefNode::def(), Tdef, and Node::typ().

Referenced by UnificationBasedPtr::at_call(), UnificationBasedPtr::at_initializer(), Linker::at_threeAddr(), Pointers::eval(), lir_gen_walker::field_offset(), no_tdef_type(), declNode::no_tdef_type(), exprNode::no_tdef_type(), operandNode::noncast_type(), and Unify_Size::sizeOfAssign().

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* typeNode::get_type   [inline]
 

Return this typeNode's subtype, and set it to be empty.

Definition at line 1761 of file ast.h.

typeNode * typeNode::integral_promotions typeNode *    old_type [static]
 

Integral promotions.

This method is used during parsing to convert smaller types (char, short, bit-fields and enums) into integers according to the rules in ANSI 6.2.1.1. In addition, our version converts float into double.

See also:
exprNode::integral_promotions()
Parameters:
old_type the original small type to be promoted
Returns:
the resulting integral type

Definition at line 288 of file typenode.cc.

References primNode::basic(), basic_type::is_char(), basic_type::is_float(), basic_type::is_int(), basic_type::is_short(), basic_type::is_unsigned(), Prim, and Node::typ().

Referenced by exprNode::integral_promotions(), and usual_arithmetic_conversions().

virtual bool typeNode::is_aggregate   const [inline, virtual]
 

Reimplemented in arrayNode, and structNode.

Definition at line 1956 of file ast.h.

Referenced by AllocToMemWalker::at_decl(), InitializerDismantle::at_decl(), lir_gen_walker::gen_global_decl(), arch_info::get_data_align(), and LirUtil::getTypeString().

virtual bool typeNode::is_arithmetic   const [inline, virtual]
 

Reimplemented in primNode, and enumNode.

Definition at line 1954 of file ast.h.

Referenced by semcheck_expr_visitor::check_binary(), and semcheck_expr_visitor::check_unary().

virtual bool typeNode::is_char   const [inline, virtual]
 

Reimplemented in primNode.

Definition at line 1947 of file ast.h.

Referenced by LIR::Call(), arrayNode::is_string(), and Register::setType().

virtual bool typeNode::is_derived   const [inline, virtual]
 

Reimplemented in ptrNode, arrayNode, and funcNode.

Definition at line 1957 of file ast.h.

Referenced by deep_base_type(), set_base_type(), and declNode::set_type().

virtual bool typeNode::is_ellipsis   const [inline, virtual]
 

Reimplemented in primNode.

Definition at line 1951 of file ast.h.

Referenced by UnificationBasedPtr::at_decl(), lir_gen_walker::gen_arg_decl(), memoryBlock::generate_su_field_name(), LirUtil::getTypeString(), memoryBlock::name(), Pointers::pass_parameters(), and UnificationBasedPtr::print_ecr().

virtual bool typeNode::is_float   const [inline, virtual]
 

Reimplemented in primNode.

Definition at line 1949 of file ast.h.

Referenced by dummy_reg_alloc::allocate_real_for_virtual(), storage_alloc::assign_arg_register(), AllocToMemWalker::at_operand(), LIR::BitwiseAND(), LIR::BitwiseNOT(), LIR::BitwiseOR(), LIR::BitwiseRotateLeft(), LIR::BitwiseRotateRight(), LIR::BitwiseShiftLeft(), LIR::BitwiseShiftRight(), LIR::BitwiseXOR(), LIR::Call(), asm_gen_walker::doCallerSave(), Register::getRegRetVal(), briggs_reg_alloc::interfere(), LIR::Mod(), and Register::setType().

virtual bool typeNode::is_int   const [inline, virtual]
 

Reimplemented in primNode, and enumNode.

Definition at line 1948 of file ast.h.

Referenced by LIR::Call(), and Register::setType().

virtual bool typeNode::is_integer   const [inline, virtual]
 

Reimplemented in primNode, and enumNode.

Definition at line 1953 of file ast.h.

Referenced by storage_alloc::assign_arg_register(), semcheck_expr_visitor::at_binary(), AllocToMemWalker::at_operand(), semcheck_expr_visitor::check_binary(), semcheck_expr_visitor::check_unary(), asm_gen_walker::doCallerSave(), Register::getRegRetVal(), and briggs_reg_alloc::interfere().

virtual bool typeNode::is_pointer   const [inline, virtual]
 

Reimplemented in ptrNode, arrayNode, and funcNode.

Definition at line 1958 of file ast.h.

Referenced by storage_alloc::assign_arg_register(), AllocToMemWalker::at_operand(), LIR::Call(), semcheck_expr_visitor::check_binary(), asm_gen_walker::doCallerSave(), arch_info::findType(), lir_gen_walker::gen_global_decl(), arch_info::get_data_align(), arch_info::get_data_size(), Register::getRegRetVal(), LirUtil::getTypeString(), briggs_reg_alloc::interfere(), DismantleUtil::new_temp_decl(), and Register::setType().

virtual bool typeNode::is_scalar   const [inline, virtual]
 

Reimplemented in primNode, ptrNode, arrayNode, and enumNode.

Definition at line 1955 of file ast.h.

Referenced by InitializerDismantle::at_decl(), semcheck_expr_visitor::check_binary(), semcheck_expr_visitor::check_unary(), lir_gen_walker::gen_call_assignment(), and lir_gen_walker::gen_simple_assignment().

virtual bool typeNode::is_void   const [inline, virtual]
 

Reimplemented in primNode.

Definition at line 1950 of file ast.h.

Referenced by UnificationBasedPtr::at_call(), ExpressionDismantle::at_call(), ExpressionDismantle::at_cast(), UnificationBasedPtr::at_proc(), ReturnDismantle::at_proc(), TernaryDismantle::at_ternary(), semcheck_expr_visitor::check_binary(), lir_gen_walker::gen_arg_decl(), Register::getRegRetVal(), LirUtil::getTypeString(), and funcNode::is_void_args().

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.

typeNode * typeNode::no_tdef_type  
 

Definition at line 156 of file typenode.cc.

References follow_tdefs(), and type().

Referenced by Pointers::assignment_operator(), id_lookup_walker::at_binary(), semcheck_expr_visitor::at_call(), UnificationBasedPtr::at_decl(), UnificationBasedPtr::at_initializer(), semcheck_expr_visitor::check_binary(), memoryModel::create_memory_object(), Pointers::dot_operator(), memoryModel::generate_array_elements_for(), InitializerDismantle::init_array(), Pointers::star_operator(), and memoryBlock::top_most_containers().

bool typeNode::operator!= typeNode &    second [inline]
 

Strict type inequality.

This is just a negation of the operator==

Parameters:
second the right type in the comparison
Returns:
true if the types are the same

Definition at line 1874 of file ast.h.

bool typeNode::operator<= typeNode &    second [inline]
 

Weaker type comparison.

Compare this type to the given type, masking off type qualifiers that don't affect compatibility of types.

See also:
Type_qualifiers
Parameters:
second the right type in the comparison
Returns:
true if the types are the same

Definition at line 1864 of file ast.h.

References equal_to().

bool typeNode::operator== typeNode &    second [inline]
 

Strict type comparison.

Compare this type to the given type, requiring all type qualifiers to be the same.

Parameters:
second the right type in the comparison
Returns:
true if the types are the same

Definition at line 1852 of file ast.h.

References equal_to().

void typeNode::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.

Definition at line 444 of file typenode.cc.

References output_type(), and type_qualifiers().

Referenced by unaryNode::output_expr(), operandNode::output_expr(), castNode::output_expr(), and threeAddrNode::output_stmt().

virtual void typeNode::output_type output_context   ct,
Node   par,
Assoc    context,
Type_qualifiers    q
[pure virtual]
 

Output a type.

Implemented in primNode, tdefNode, ptrNode, arrayNode, funcNode, sueNode, and suespecNode.

Referenced by output(), subdeclNode::output(), declNode::output(), ptrNode::output_type(), funcNode::output_type(), and arrayNode::output_type().

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

bool typeNode::qualified_equal_to typeNode *    other,
bool    strict_toplevel,
bool    strict_recursive
[virtual]
 

Virtual type comparison routine.

Each typeNode subclass overrides this routine to provide its specific type comparison. This is used by the static equal_to() method to perform general deep type comparison.

See also:
equal_to()
Parameters:
other the type to compare against
strict_toplevel pass true to require strict comparison of top-level types
strict_recursive pass true to require strict comparson of sub-types
Returns:
true, if the types pass the equality test

Reimplemented in primNode, ptrNode, arrayNode, funcNode, and sueNode.

Definition at line 247 of file typenode.cc.

References CBZ::Fail().

Referenced by equal_to().

void typeNode::remove_type_qualifiers Type_qualifiers    the_tq [inline]
 

Remove a type qualifier from this typeNode.

Definition at line 1794 of file ast.h.

References Type_qualifiers.

Referenced by finish().

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 typeNode::set_base_type typeNode *    base
 

Definition at line 86 of file typenode.cc.

References is_derived(), and type().

Referenced by declNode::modify_type(), and set_base_type_and().

typeNode * typeNode::set_base_type_and typeNode *    base
 

Definition at line 99 of file typenode.cc.

References set_base_type().

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 declNode::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(), equal_to(), Pointers::eval(), castNode::eval(), finish(), follow_tdefs(), memoryModel::generate_array_elements_for(), DefUseWalker::get_def(), DefUseWalker::get_uses(), Register::getRegRetVal(), NodeInfo::getType(), memoryModel::initialize_struct(), function_inline::inliner(), 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(), unwind_tdefs(), suespecNode::update(), usual_arithmetic_conversions(), exprNode::usual_arithmetic_conversions(), binaryNode::walk(), CBZ::WarnAboutPrecedence(), NodeInfo::writeCall(), NodeInfo::writeExpr(), NodeInfo::writeProc(), NodeInfo::writeStmt(), and NodeInfo::writeType().

void typeNode::type typeNode *    the_type [inline]
 

Set this typeNode's subtype.

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

Definition at line 1768 of file ast.h.

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

Return this typeNode's subtype.

Reimplemented from Node.

Definition at line 1756 of file ast.h.

Referenced by vcgASTWalker::at_array(), tree_visitor::at_array(), AllocSizeChanger::at_array(), semcheck_expr_visitor::at_binary(), UnificationBasedPtr::at_call(), ReturnDismantle::at_proc(), vcgASTWalker::at_ptr(), tree_visitor::at_ptr(), callNode::base_type(), LIR::Call(), NodeInfo::canonical(), ptrNode::change(), arrayNode::change(), semcheck_expr_visitor::check_binary(), semcheck_expr_visitor::check_unary(), UnificationBasedPtr::compatible_type(), deep_base_type(), UnificationBasedPtr::ecr(), Pointers::eval(), lir_gen_walker::field_offset(), lir_gen_walker::gen_binary_assignment(), memoryModel::generate_array_elements_for(), InitializerDismantle::init_array(), arrayNode::is_string(), UnificationBasedPtr::make_compatible(), DismantleUtil::new_temp_decl(), no_tdef_type(), operandNode::noncast_type(), ptrNode::output_type(), arrayNode::output_type(), ptrNode::qualified_equal_to(), funcNode::qualified_equal_to(), arrayNode::qualified_equal_to(), NodeInfo::readsuef(), funcNode::returns(), set_base_type(), Unify_Size::sizeOf(), Unify_ECR::Unify_ECR(), Unify_Structure::Unify_Structure(), ptrNode::walk(), arrayNode::walk(), and NodeInfo::writeType().

void typeNode::type_qualifiers Type_qualifiers    the_tq [inline]
 

Set this typeNode's type qualifiers.

Definition at line 1776 of file ast.h.

Type_qualifiers typeNode::type_qualifiers   const [inline]
 

Return this typeNode's type qualifiers.

Definition at line 1772 of file ast.h.

Referenced by identify_inlinees::at_threeAddr(), semcheck_expr_visitor::check_binary(), finish(), output(), type_qualifiers_name(), and unwind_tdefs().

string typeNode::type_qualifiers_name   [inline]
 

Return a string representation of this typeNode's type qualifiers.

Definition at line 1779 of file ast.h.

References type_qualifiers().

Referenced by tdefNode::output_type(), sueNode::output_type(), ptrNode::output_type(), primNode::output_type(), and funcNode::output_type().

string typeNode::type_qualifiers_name Type_qualifiers    tq [static]
 

Convert type qualifiers to string.

This method is used when generating C code to convert the type qualifiers into string form.

Parameters:
tq the type qualifiers to convert
Returns:
the string form of the type qualifiers

Definition at line 257 of file typenode.cc.

References CONST, INLINE, and VOLATILE.

Referenced by print_walker::at_array(), print_tree_visitor::at_array(), print_walker::at_func(), print_tree_visitor::at_func(), print_walker::at_prim(), print_tree_visitor::at_prim(), print_walker::at_ptr(), print_tree_visitor::at_ptr(), print_walker::at_suespec(), print_tree_visitor::at_suespec(), print_walker::at_tdef(), and print_tree_visitor::at_tdef().

typeNode * typeNode::unwind_tdefs Type_qualifiers   the_tq
 

Unwind typedefs.

Definition at line 194 of file typenode.cc.

References tdefNode::def(), Tdef, Node::typ(), Type_qualifiers, and type_qualifiers().

Referenced by equal_to().

pair< typeNode *, typeNode * > typeNode::usual_arithmetic_conversions typeNode *    left,
typeNode *    right
[static]
 

Usual arithmetic conversions.

From ANSI 6.2.1.5: Many binary operators that expect operands of arithmetic type cause conversions and yield result types in a similar way. The purpose is to yield a common type, which is also the type of the result.

This method takes the types of the left and right operands and returns a pair of types indicating the conversions of the two operands, respectively. When necessary, these conversion include the integral promotions.

See also:
integral_promotions()

exprNode::usual_arithmetic_conversions()

Parameters:
left the type of the left operand
right the type of the right operand
Returns:
a pair of converted types for the left and right, respectively

Definition at line 319 of file typenode.cc.

References basic_type::Double, basic_type::Float, integral_promotions(), basic_type::LongDouble, Prim, basic_type::SLong, Node::typ(), basic_type::UInt, and basic_type::ULong.

Referenced by exprNode::usual_arithmetic_conversions().

virtual typeNode* typeNode::usual_unary_conversion_type   [inline, virtual]
 

Usual unary conversion type.

The purpose of this method escapes me. The constNode class seems to use it, but all it does is return itself. No other typeNode overrides it.

Definition at line 1968 of file ast.h.

Referenced by funcNode::check_conversions(), and constNode::usual_unary_conversion_type().

void typeNode::verify_sue_complete  
 

Definition at line 147 of file typenode.cc.

References sue_complete_walker::check().

Referenced by declNode::finish().

virtual void Node::visit Visitor   the_visitor [pure virtual, inherited]
 

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.

Implemented in unitNode, declNode, subdeclNode, procNode, primNode, tdefNode, ptrNode, arrayNode, funcNode, structNode, unionNode, enumNode, suespecNode, constNode, idNode, binaryNode, unaryNode, castNode, commaNode, ternaryNode, callNode, initializerNode, blockNode, basicblockNode, exprstmtNode, labelNode, caseNode, ifNode, switchNode, whileNode, doNode, forNode, gotoNode, continueNode, breakNode, returnNode, attribNode, operandNode, conditiongotoNode, threeAddrNode, textNode, metaexprNode, and metastmtNode.

Referenced by tree_visitor::at_array(), tree_visitor::at_attrib(), tree_visitor::at_binary(), semcheck_expr_visitor::at_binary(), tree_visitor::at_block(), tree_visitor::at_call(), semcheck_expr_visitor::at_call(), tree_visitor::at_case(), tree_visitor::at_cast(), semcheck_expr_visitor::at_cast(), tree_visitor::at_comma(), tree_visitor::at_const(), tree_visitor::at_decl(), tree_visitor::at_do(), tree_visitor::at_exprstmt(), tree_visitor::at_for(), tree_visitor::at_func(), tree_visitor::at_id(), tree_visitor::at_if(), tree_visitor::at_initializer(), tree_visitor::at_ptr(), tree_visitor::at_return(), tree_visitor::at_switch(), tree_visitor::at_ternary(), semcheck_expr_visitor::at_ternary(), tree_visitor::at_unary(), semcheck_expr_visitor::at_unary(), tree_visitor::at_while(), semcheck_expr_visitor::check(), and print_tree_visitor::print().

virtual void Node::walk Walker   the_walker [pure virtual, inherited]
 

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.

Implemented in unitNode, declNode, subdeclNode, procNode, primNode, tdefNode, ptrNode, arrayNode, funcNode, structNode, unionNode, enumNode, suespecNode, constNode, idNode, binaryNode, unaryNode, castNode, commaNode, ternaryNode, callNode, initializerNode, blockNode, basicblockNode, exprstmtNode, labelNode, caseNode, ifNode, switchNode, whileNode, doNode, forNode, gotoNode, continueNode, breakNode, returnNode, attribNode, operandNode, conditiongotoNode, threeAddrNode, textNode, metaexprNode, and metastmtNode.

Referenced by enum_value_walker::assign(), vcgASTWalker::at_binary(), gcWalker::at_binary(), RequiresGatherer::at_tdef(), sue_complete_walker::check(), semcheck_expr_visitor::check(), init_flowproblem_walker::cleanup(), ref_clone_changer::clone(), NodeLocator::findCall(), NodeLocator::findDecl(), NodeLocator::findExprOrStmt(), set_container_walker::fixup(), init_flowproblem_walker::init(), df_number_walker::number(), print_walker::print(), renumber_walker::renum(), whileNode::walk(), unaryNode::walk(), threeAddrNode::walk(), ternaryNode::walk(), switchNode::walk(), subdeclNode::walk(), returnNode::walk(), ptrNode::walk(), operandNode::walk(), metaexprNode::walk(), initializerNode::walk(), ifNode::walk(), idNode::walk(), funcNode::walk(), forNode::walk(), exprstmtNode::walk(), doNode::walk(), declNode::walk(), constNode::walk(), conditiongotoNode::walk(), commaNode::walk(), castNode::walk(), caseNode::walk(), callNode::walk(), binaryNode::walk(), attribNode::walk(), and arrayNode::walk().


Member Data Documentation

int typeNode::_alloc_align [private]
 

The word alignment necessary for this type.

This field contains -1 until the AllocSizeWalker (in the backend) has been run on the AST.

Definition at line 1725 of file ast.h.

int typeNode::_alloc_size [private]
 

The size of memory necessary for this type.

This field contains -1 until the AllocSizeWalker (in the backend) has been run on the AST.

Definition at line 1718 of file ast.h.

TREE typeNode* typeNode::_type [private]
 

The sub-type.

This field holds the sub-type for compound types such as array, pointer, and function declaration.

Definition at line 1704 of file ast.h.

Type_qualifiers typeNode::_type_qualifiers [private]
 

Type qualifiers.

The type qualifiers for this type

Definition at line 1710 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