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

expr_result.cc

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #include "expr_result.h"
00004 #include "expr_result_i.h"
00005 
00006 
00007 #line 126 "expr_result.cpp"
00008 
00009 void
00010 Expr_result::set_value(Ptree* value, Type t)
00011 {
00012     assert(t.is_valid());
00013 
00014     tree = value;
00015     obj_tree = 0;
00016     symbol = 0;
00017     if (t.get_kind() == Type::k_Reference) {
00018         type = t.get_basis_type();
00019         kind = k_LValue;
00020     } else {
00021         type = t;
00022         kind = k_RValue;
00023     }
00024 }
00025 
00026 #line 143 "expr_result.cpp"
00027 
00029 void
00030 Expr_result::convert_to_rvalue()
00031 {
00032     if (!type.is_valid()) {
00033         compile_error("attempt to access value of an expression without type");
00034     } else if (!is_lvalue()) {
00035         /* intentionally left blank */
00036     } else if (type.get_kind() != Type::k_Array && type.get_kind() != Type::k_Function) {
00037         if (!type.is_complete())
00038             compile_error("attempt to access object of incomplete type");
00039         if (!type.is_class_type())
00040             convert_to(type.get_unqualified_type());
00041         kind = k_RValue;
00042     }
00043 }
00044 
00045 #line 160 "expr_result.cpp"
00046 
00048 void
00049 Expr_result::convert_to_pointer()
00050 {
00051     if (!type.is_valid()) {
00052         compile_error("attempt to access value of an expression without type");
00053     } else if (type.get_kind() == Type::k_Array) {
00054         /* FIXME: the string-literal-to-unqualified-pointer conversion
00055            is NOT handled (yet) because it's deprecated. */
00056         convert_to(type.get_basis_type().make_pointer_type());
00057         kind = k_RValue;
00058     }
00059 }
00060 
00061 #line 174 "expr_result.cpp"
00062 
00064 void
00065 Expr_result::convert_to_fpointer()
00066 {
00067     if (!type.is_valid()) {
00068         compile_error("attempt to access value of an expression without type");
00069     } else if (type.get_kind() == Type::k_Function) {
00070         convert_to(type.make_pointer_type());
00071         kind = k_RValue;
00072     }
00073 }
00074 
00075 #line 194 "expr_result.cpp"
00076 
00077 /* Missing: 4.6 to 4.9 */
00078 
00080 void
00081 Expr_result::convert_to_bool()
00082 {
00083     do_std_conversions();
00084     if (type.is_arithmetic_type() || type.is_enum_type() || type.get_kind() == Type::k_Pointer || type.get_kind() == Type::k_Member) {
00085         convert_to(bool_type);
00086     } else {
00087         compile_error("unable to convert `" + type.get_human_readable_type() + "' to bool");
00088     }
00089 }
00090 
00091 #line 208 "expr_result.cpp"
00092 
00094 void
00095 Expr_result::adjust_reference()
00096 {
00097     if (type.get_kind() == Type::k_Reference) {
00098         convert_to(type.get_basis_type());
00099         kind = k_LValue;
00100     }
00101 }
00102 
00103 #line 218 "expr_result.cpp"
00104 
00107 void
00108 Expr_result::do_std_conversions()
00109 {
00110     convert_to_rvalue();
00111     convert_to_pointer();
00112     convert_to_fpointer();
00113 }
00114 
00115 #line 228 "expr_result.cpp"
00116 
00117 bool
00118 Expr_result::is_modifyable_lvalue() const
00119 {
00120     return kind == k_LValue && !type.is_qualified(Type::q_Const);
00121 }
00122 
00123 #line 234 "expr_result.cpp"
00124 
00126 bool
00127 Expr_result::is_npc() const
00128 {
00129     using namespace std;
00130 
00131     if (!type.is_int() || !tree)
00132         return false;
00133 
00134     /* only literal nulls allowed */
00135     if (Leaf* l = dynamic_cast<Leaf*>(tree)) {
00136         char* c = l->ToString();
00137         if (*c == '0' && c[strspn(c, "0xXuUlL")] == 0)
00138             return true;
00139     }
00140     return false;
00141 }

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