00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "pent_include.h"
00022
00023 #include "Type.h"
00024
00025
00026
00027
00028
00029 const char * const Type::_namearr[] =
00030 { "void", "byte", "word", "dword",
00031 "string", "pid", "var", "list",
00032 "slist", "strptr", "invalid"
00033 };
00034
00035 void Type::print_unk(Console &o) const
00036 {
00037 o.Printf("(%s)", name());
00038 }
00039
00040
00041
00042
00043
00044
00045
00046
00047 void DataType::print_value_unk(Console &o) const
00048 {
00049 switch(_dtype)
00050 {
00051 case DT_NULL: break;
00052 case DT_BYTES:
00053 switch(_vtype.type())
00054 {
00055 case Type::T_BYTE: o.Printf("0x%0*Xh", 2, static_cast<sint8 >(_value)); break;
00056 case Type::T_WORD: o.Printf("0x%0*Xh", 4, static_cast<sint16>(_value)); break;
00057 case Type::T_DWORD: o.Printf("0x%0*Xh", 8, static_cast<sint32>(_value)); break;
00058 default: assert(false);
00059 }
00060 break;
00061 case DT_BP: o.Printf("%s", suc::print_bp(_value)); break;
00062
00063 case DT_BPADDR: o.Printf("addressof(%s)", suc::print_bp(_value)); break;
00064
00065
00066
00067 case DT_STRING: o.Printf("\"%s\"", _strvalue.c_str()); break;
00068 case DT_PID: o.Printf("pid"); break;
00069
00070
00071 case DT_GLOBAL: o.Printf("global %s(%04X, %02X)",
00072 "name", _value, _valueIndex); break;
00073 case DT_TEMP: o.Printf("temp"); break;
00074 default: assert(false); break;
00075 }
00076 }
00077
00078 void DataType::print_value_asm(Console &o) const
00079 {
00080 switch(_dtype)
00081 {
00082
00083 case DT_BYTES:
00084 switch(_vtype.type())
00085 {
00086 case Type::T_BYTE: o.Printf("%0*Xh", 2, static_cast<sint8 >(_value)); break;
00087 case Type::T_WORD: o.Printf("%0*Xh", 4, static_cast<sint16>(_value)); break;
00088 case Type::T_DWORD: o.Printf("%0*Xh", 8, static_cast<sint32>(_value)); break;
00089 default: assert(false);
00090 }
00091 break;
00092 case DT_BP:
00093 switch(_vtype.type())
00094 {
00095 case Type::T_WORD:
00096 case Type::T_DWORD: o.Printf("%s", suc::print_bp(_value)); break;
00097 default: assert(false);
00098 }
00099 break;
00100 case DT_BPADDR:
00101 switch(_vtype.type())
00102 {
00103 case Type::T_DWORD: o.Printf("%s", suc::print_bp(_value)); break;
00104 default: assert(false);
00105 }
00106 break;
00107 case DT_STRING:
00108 switch(_vtype.type())
00109 {
00110 case Type::T_STRING: o.Printf("\"%s\"", _strvalue.c_str()); break;
00111 default: assert(false);
00112 }
00113 break;
00114 case DT_PID:
00115 case DT_TEMP:
00116
00117 break;
00118 case DT_GLOBAL:
00119 switch(_vtype.type())
00120 {
00121 case Type::T_WORD: o.Printf("[%04X %02X]", _value, _valueIndex); break;
00122 default: assert(false);
00123 }
00124 break;
00125
00126 default: assert(false);
00127 }
00128 }
00129
00130 void DataType::print_value_bin(ODequeDataSource &o) const
00131 {
00132 switch(_dtype)
00133 {
00134
00135 case DT_BYTES:
00136 switch(_vtype.type())
00137 {
00138 case Type::T_BYTE: o.write1(static_cast<sint8 >(_value)); break;
00139 case Type::T_WORD: o.write2(static_cast<sint16>(_value)); break;
00140 case Type::T_DWORD: o.write4(static_cast<sint32>(_value)); break;
00141 default: assert(false);
00142 }
00143 break;
00144 case DT_BP:
00145 switch(_vtype.type())
00146 {
00147 case Type::T_WORD:
00148 case Type::T_DWORD: o.write1(_value); break;
00149 default: assert(false);
00150 }
00151 break;
00152 case DT_BPADDR:
00153 switch(_vtype.type())
00154 {
00155 case Type::T_DWORD: o.write1(_value); break;
00156 default: assert(false);
00157 }
00158 break;
00159 case DT_STRING:
00160 switch(_vtype.type())
00161 {
00162 case Type::T_STRING:
00163 o.write2(_strvalue.size());
00164 for(uint16 i = 0; i<_strvalue.size(); i++)
00165 o.write1(_strvalue[i]);
00166 break;
00167 default: assert(false);
00168 }
00169 break;
00170 case DT_PID:
00171 case DT_TEMP:
00172
00173 break;
00174 case DT_GLOBAL:
00175 assert(_vtype.type()==Type::T_WORD);
00176 o.write2(_value);
00177 o.write1(_valueIndex);
00178 break;
00179 default: assert(false);
00180 }
00181 }