00001
00002
00003 #ifndef decl_read_h
00004 #define decl_read_h
00005
00006 #include <vector>
00007 #include <utility>
00008 #include "type_rep.h"
00009
00010
00011
00012
00013
00014
00015 class Ptree;
00016 class Abstract_scope;
00017 class Block_scope;
00029 class Declaration_reader {
00030 Abstract_scope* current_scope;
00031 Block_scope* block_scope;
00032 public:
00033 typedef std::vector<std::pair<Type, Ptree*> > Arg_vec;
00034
00035 virtual void declare_variable(Type type, Ptree* name, Ptree* initializer,
00036 Ptree* bitsize) = 0;
00037
00038 Abstract_scope* get_scope() const { return current_scope; }
00039 Arg_vec* get_args() const { return function_args; }
00040 private:
00041 Arg_vec* function_args;
00042
00043 public:
00044
00045
00048 Declaration_reader(Abstract_scope* scope);
00049
00056 Declaration_reader(Abstract_scope* scope, Arg_vec* args);
00057
00058 virtual ~Declaration_reader();
00059
00104 void parse_declarator(Type type, Ptree* tree);
00105
00110 void parse_declarator_list(Type type, Ptree* list);
00111
00114 Ptree* parse_declarator_get_name(Ptree* tree);
00115
00116 private:
00117 void parse_declarator_internal(Type type, Ptree* tree, Ptree* initializer, Ptree* bitsize, Abstract_scope* scope);
00118 };
00119
00120 class Function_declaration_reader : public Declaration_reader {
00121 Function_type_maker maker;
00122 bool had_void_arg, had_parameter;
00123 Arg_vec* args;
00124 public:
00125 Function_type_maker& get_maker() { return maker; }
00126
00127 public:
00128
00129
00137 Function_declaration_reader(Abstract_scope* s, Arg_vec* args);
00138
00139 void declare_variable(Type type, Ptree* name, Ptree* initializer, Ptree* bitsize);
00140
00141 void add_ellipsis();
00142 };
00143
00149 bool parse_abstract_declarator(Ptree* tree, Abstract_scope* scope, Type* t);
00150
00153 Ptree* get_name_from_declarator(Ptree* tree, Abstract_scope* scope);
00154
00155 #endif // decl_read_h