Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Declaration_reader Class Reference

#include <decl_read.h>

Inheritance diagram for Declaration_reader:

Inheritance graph
[legend]
Collaboration diagram for Declaration_reader:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< std::pair<
Type, Ptree * > > 
Arg_vec

Public Methods

virtual void declare_variable (Type type, Ptree *name, Ptree *initializer, Ptree *bitsize)=0
Abstract_scopeget_scope () const
Arg_vecget_args () const
 Declaration_reader (Abstract_scope *scope)
 Create a general Declaration_reader. More...

 Declaration_reader (Abstract_scope *scope, Arg_vec *args)
 Create a Declaration_reader which collects function parameters. More...

virtual ~Declaration_reader ()
void parse_declarator (Type type, Ptree *tree)
 Read a declarator, and call declare_variable for it. More...

void parse_declarator_list (Type type, Ptree *list)
 Read a declarator list. More...

Ptreeparse_declarator_get_name (Ptree *tree)
 A boiled-down version of parse_declarator: parse declarator, and just return its name. More...


Private Methods

void parse_declarator_internal (Type type, Ptree *tree, Ptree *initializer, Ptree *bitsize, Abstract_scope *scope)

Private Attributes

Abstract_scopecurrent_scope
Block_scopeblock_scope
Arg_vecfunction_args

Member Typedef Documentation

typedef std::vector<std::pair<Type, Ptree*> > Declaration_reader::Arg_vec
 

Definition at line 33 of file decl_read.h.

Referenced by Simple_declaration_reader::declare_variable(), get_args(), Simple_declaration_reader::Simple_declaration_reader(), and Annotator::visit_function().


Constructor & Destructor Documentation

Declaration_reader::Declaration_reader Abstract_scope   scope
 

Create a general Declaration_reader.

Names will be looked up in scope.

Definition at line 14 of file decl_read.cc.

References current_scope.

Declaration_reader::Declaration_reader Abstract_scope   scope,
Arg_vec   args
 

Create a Declaration_reader which collects function parameters.

This one only accepts one call to parse_declarator(), not parse_declarator_list().

Parameters:
scope  names will be looked up here
args  parameters will be stored there

Definition at line 29 of file decl_read.cc.

References current_scope, and function_args.

Declaration_reader::~Declaration_reader   [virtual]
 

Definition at line 39 of file decl_read.cc.


Member Function Documentation

virtual void Declaration_reader::declare_variable Type    type,
Ptree   name,
Ptree   initializer,
Ptree   bitsize
[pure virtual]
 

Implemented in Simple_declaration_reader, Typedef_name_reader, Typedef_declaration_reader, Function_declaration_reader, Ad_reader, and Name_decl_reader.

Referenced by parse_declarator_internal().

Arg_vec* Declaration_reader::get_args   const [inline]
 

Definition at line 39 of file decl_read.h.

References Arg_vec, and function_args.

Referenced by Simple_declaration_reader::declare_variable().

Abstract_scope* Declaration_reader::get_scope   const [inline]
 

Definition at line 38 of file decl_read.h.

Referenced by Typedef_declaration_reader::declare_variable(), and Simple_declaration_reader::declare_variable().

void Declaration_reader::parse_declarator Type    type,
Ptree   tree
 

Read a declarator, and call declare_variable for it.

Declarator syntax from standard: declarator: direct-declarator ptr-operator declarator

direct-declarator: declarator-id direct-declarator ( parameter-declaration-clause ) cv-qualifier-seq opt exception-specification opt direct-declarator [ constant-expression opt ] ( declarator )

ptr-operator: cv-qualifier-seq opt & opt nested-name-specifier * cv-qualifier-seq opt "abstract-declarator" is essentially the same except that it has no "declarator-id".

OpenC++ parses the above grammar and "flattens" it into one big list, including initializers and bitfields:

declarator ::= identifier // sublist if qualified identifier | "*" : declarator | "&" : declarator | cv-qualifier : declarator | [ namepart... "::" "*" ] : declarator | declarator : postfix-expression* initializer? // declarator | postfix-expression* initializer? // abstract declarator postfix-expression ::= "(" : list-with-function-args : ")" ++ cv-qualifier-seq-opt | "[" : expression-with-array-size-or-nil : "]" initializer ::= "=" : expression | [ "(" : expression-list : ")" ] | ":" : expression // bitfield

Definition at line 89 of file decl_read.cc.

References current_scope, and parse_declarator_internal().

Referenced by parse_abstract_declarator(), parse_declarator_internal(), parse_declarator_list(), and Annotator::visit_function().

Ptree * Declaration_reader::parse_declarator_get_name Ptree   tree
 

A boiled-down version of parse_declarator: parse declarator, and just return its name.

Definition at line 272 of file decl_read.cc.

References bogus_ptree_error(), Ptree::Car(), Ptree::Cdr(), Ptree::Eq(), Ptree::IsLeaf(), Ptree::Length(), Ptree::Nth(), and parse_qualifier().

void Declaration_reader::parse_declarator_internal Type    type,
Ptree   tree,
Ptree   initializer,
Ptree   bitsize,
Abstract_scope   scope
[private]
 

Definition at line 97 of file decl_read.cc.

References Function_declaration_reader::add_ellipsis(), bogus_ptree_error(), Ptree::Car(), Ptree::Cdr(), compile_error(), declare_variable(), Ptree::Eq(), Ptree::First(), function_args, Class_scope::get_class_symbol(), Type::get_kind(), Function_declaration_reader::get_maker(), Symbol_name::get_name(), Symbol_name::get_scope(), Type_symbol::get_type(), Symbol_name::is_template(), Ptree::IsLeaf(), Type::k_Reference, Ptree::Length(), Type::make_array_type(), Function_type_maker::make_function_type(), Type::make_member_type(), Type::make_pointer_type(), Type::make_reference_type(), Ptree::Nth(), parse_declarator(), parse_qualifier(), parse_type(), and Ptree::Second().

Referenced by parse_declarator().

void Declaration_reader::parse_declarator_list Type    type,
Ptree   list
 

Read a declarator list.

Syntax is decl-list ::= declarator | declarator "," decl-list

Definition at line 253 of file decl_read.cc.

References Ptree::Car(), Ptree::Cdr(), expect_ptree(), function_args, and parse_declarator().

Referenced by Annotator::visit_name_declaration(), and Annotator::visit_typedef().


Member Data Documentation

Block_scope* Declaration_reader::block_scope [private]
 

Definition at line 31 of file decl_read.h.

Abstract_scope* Declaration_reader::current_scope [private]
 

Definition at line 30 of file decl_read.h.

Referenced by Declaration_reader(), and parse_declarator().

Arg_vec* Declaration_reader::function_args [private]
 

Definition at line 41 of file decl_read.h.

Referenced by Declaration_reader(), get_args(), parse_declarator_internal(), and parse_declarator_list().


The documentation for this class was generated from the following files:
Generated on Mon Feb 10 17:35:28 2003 for VFiasco Semantics Compiler by doxygen1.2.15