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

block.cc

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #include "block.h"
00004 #include "block_i.h"
00005 
00006 
00007 #line 38 "block.cpp"
00008 
00012 Block_scope::Block_scope(Function_signature* fsig)
00013     : Abstract_scope(fsig->get_function()->get_declared_scope()),
00014       use_parent(false),
00015       fun_prefix(Symbol_name::get_mangled_scope_from_symbol(fsig->get_function()->get_name())),
00016       block_prefix(Symbol_name::get_mangled_block_scope(fun_prefix)),
00017       this_type(fsig->get_this_type()),
00018       fsig(fsig)
00019 // Why the heck halluziniert Emacs hier unbalanced parantheses?
00020 { }
00021 
00022 #line 51 "block.cpp"
00023 
00030 Block_scope::Block_scope(Block_scope* parent, bool use_parent)
00031     : Abstract_scope(parent),
00032       use_parent(use_parent),
00033       fun_prefix(parent->fun_prefix),
00034       block_prefix(Symbol_name::get_mangled_block_scope(fun_prefix)),
00035       this_type(parent->get_this_type()),
00036       fsig(parent->fsig)
00037 { }
00038 
00039 #line 66 "block.cpp"
00040 
00041 
00042 Block_scope::~Block_scope()
00043 { }
00044 
00045 #line 70 "block.cpp"
00046 
00047 Variable_symbol*
00048 Block_scope::add_variable(Storage_class_specifier storage,
00049                           Type type, Ptree* name, Ptree* init,
00050                           Ptree* bitsize)
00051 {
00052     if (bitsize)
00053         compile_error("local variables can't have bitsize");
00054     if (!name && storage != s_Parameter)
00055         compile_error("you cannot declare nameless local variables");
00056     if (storage == s_None)
00057         storage = s_Auto;
00058     else if (storage == s_Auto || storage == s_Parameter || storage == s_Register || storage == s_Static)
00059             ;
00060     else if (storage == s_Extern)
00061         compile_error("FIXME: extern within a function");
00062     else
00063         compile_error("invalid storage class for local variable");
00064 
00065     /* process initializer */
00066     if (init)
00067         init = Init_handler(this, init, true).process_initializer(type.get_unqualified_type());
00068 
00069     /* since there is no way to predeclare a local variable, just
00070        add it to the symbol table. add_symbol will bomb out if
00071        something goes wrong. */
00072     Symbol_name sym_name (name, this, false);
00073     if (sym_name.is_template())
00074         compile_error("template variables are not allowed");
00075     if (sym_name.is_qualified())
00076         compile_error("can't define qualified ids in block scope");
00077 
00078     Variable_symbol* vsym = new Variable_symbol(type, storage, init, 0, Symbol::st_Defined);
00079     add_symbol(sym_name.get_name(), vsym);
00080 
00081     /* if it is a parameter, tell the function about it */
00082     if (storage == s_Parameter)
00083         fsig->add_parameter(vsym);
00084 
00085     return vsym;
00086 }
00087 
00088 #line 111 "block.cpp"
00089 
00090 Function_signature*
00091 Block_scope::add_function_decl(Storage_class_specifier storage,
00092                                Function_specifier_set fspec,
00093                                Type type, const Symbol_name& sym_name)
00094 {
00095     compile_error("geht auch noch nicht");
00096 }
00097 
00098 #line 119 "block.cpp"
00099 
00100 void
00101 Block_scope::add_function_implementation(Function_signature* fsig,
00102                                          Block_scope* scope,
00103                                          Ptree* defn,
00104                                          Ptree* initializer)
00105 {
00106     compile_error("geht erst recht nicht");
00107 }
00108 
00109 #line 128 "block.cpp"
00110 
00111 void
00112 Block_scope::add_symbol(std::string name, Symbol* sym)
00113 {
00114     /* FIXME: we should reject "for (int i = 0; ;) int i;". Therefore,
00115        we should look whether the parent defines this symbol. This makes
00116        problems when the inner scope defines "struct i" because then the
00117        outer "i" will no longer be found. We can't just dump the symbol
00118        in the parent's scope because that might be used by several
00119        child scopes: "if (int i = f()) { here } else { and_here }".
00120        A possible solution would move from looking up Symbol_pairs to
00121        Symbols. */
00122     Symbol_table::get_instance().add_symbol(get_unique_name(name),
00123                                             name.length(), sym);
00124 }
00125 
00126 #line 143 "block.cpp"
00127 
00128 std::string
00129 Block_scope::get_unique_name(std::string name)
00130 {
00131     return Symbol_name::get_mangled_symbol_name(block_prefix, name);
00132 }
00133 
00134 #line 149 "block.cpp"
00135 
00136 Type
00137 Block_scope::get_this_type() const
00138 {
00139     return this_type;
00140 }
00141 
00142 #line 161 "block.cpp"
00143 
00144 void
00145 Block_scope::set_this_type(Type t)
00146 {
00147     this_type = t;
00148 }
00149 
00150 #line 167 "block.cpp"
00151 
00152 Symbol_pair
00153 Block_scope::lookup_here(std::string name, bool for_decl)
00154 {
00155     if (Symbol_pair p = Symbol_table::get_instance().get_symbol(get_unique_name(name)))
00156         return p;
00157     if (use_parent)
00158         return get_parent()->lookup_here(name, for_decl);
00159     else
00160         return Symbol_pair();
00161 }

Generated on Mon Feb 10 17:32:44 2003 for VFiasco Semantics Compiler by doxygen1.2.15