00001
00002
00003 #include "variable.h"
00004 #include "variable_i.h"
00005
00006
00007 #line 33 "variable.cpp"
00008
00011 Variable_symbol::Variable_symbol(Type type, Storage_class_specifier storage,
00012 Ptree* initializer, Ptree* bitsize,
00013 Symbol::Status status)
00014 : Symbol(), type(type), storage_class(storage),
00015 initializer(initializer), bitsize(bitsize), has_addr(true),
00016 in_class(0)
00017 {
00018 set_status(status);
00019 }
00020
00021 #line 45 "variable.cpp"
00022
00025 Variable_symbol::Variable_symbol(Type type, Storage_class_specifier storage,
00026 Ptree* initializer, Ptree* bitsize,
00027 bool has_address)
00028 : Symbol(), type(type), storage_class(storage),
00029 initializer(initializer), bitsize(bitsize), has_addr(has_address),
00030 in_class(0)
00031 {
00032 set_status(st_Defined);
00033 }
00034
00035 #line 57 "variable.cpp"
00036
00037 Symbol::Kind
00038 Variable_symbol::get_kind() const
00039 {
00040 return k_Variable;
00041 }
00042
00043 #line 63 "variable.cpp"
00044
00045 void
00046 Variable_symbol::set_class(Class_symbol* csym)
00047 {
00048 assert(is_member_variable());
00049 in_class = csym;
00050 }
00051
00052 #line 76 "variable.cpp"
00053
00054 void
00055 Variable_symbol::define_variable(Storage_class_specifier storage,
00056 Ptree* initializer, Ptree* bitsize,
00057 Status status)
00058 {
00059 set_status(status);
00060 this->storage_class = storage;
00061 this->initializer = initializer;
00062 this->bitsize = bitsize;
00063 }
00064
00065 #line 87 "variable.cpp"
00066
00067 void
00068 Variable_symbol::dump(std::ostream& os)
00069 {
00070 Symbol::dump(os);
00071 os << ", type is `" << type.get_human_readable_type() << "'";
00072 if (initializer)
00073 os << ", has initializer";
00074 if (bitsize)
00075 os << ", has bitsize";
00076 if (!has_address())
00077 os << ", has no address";
00078 os << ", storage " << get_storage_specifier_name(storage_class);
00079 if (initializer && Symbol_table::has_dump_flag('i')) {
00080 os << "\n Initializer is:\n";
00081 print_annotated_tree(os, " | ", initializer, Symbol_table::has_dump_flag('c'));
00082 }
00083 }