MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / typeToString

Function typeToString

pcsx2-qt/Debugger/SymbolTree/TypeString.cpp:102–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102QString typeToString(const ccc::ast::Node* type, const ccc::SymbolDatabase& database)
103{
104 QString suffix;
105
106 // Traverse through arrays, pointers and references, and build a string
107 // to be appended to the end of the type name.
108 bool done_finding_arrays_pointers = false;
109 while (!done_finding_arrays_pointers)
110 {
111 switch (type->descriptor)
112 {
113 case ccc::ast::ARRAY:
114 {
115 const ccc::ast::Array& array = type->as<ccc::ast::Array>();
116 suffix.prepend(QString("[%1]").arg(array.element_count));
117 type = array.element_type.get();
118 break;
119 }
120 case ccc::ast::POINTER_OR_REFERENCE:
121 {
122 const ccc::ast::PointerOrReference& pointer_or_reference = type->as<ccc::ast::PointerOrReference>();
123 suffix.prepend(pointer_or_reference.is_pointer ? '*' : '&');
124 type = pointer_or_reference.value_type.get();
125 break;
126 }
127 default:
128 {
129 done_finding_arrays_pointers = true;
130 break;
131 }
132 }
133 }
134
135 // Determine the actual type name, or at the very least the node type.
136 QString name;
137 switch (type->descriptor)
138 {
139 case ccc::ast::BUILTIN:
140 {
141 const ccc::ast::BuiltIn& built_in = type->as<ccc::ast::BuiltIn>();
142 name = ccc::ast::builtin_class_to_string(built_in.bclass);
143 break;
144 }
145 case ccc::ast::TYPE_NAME:
146 {
147 const ccc::ast::TypeName& type_name = type->as<ccc::ast::TypeName>();
148 const ccc::DataType* data_type = database.data_types.symbol_from_handle(type_name.data_type_handle);
149 if (data_type)
150 {
151 name = QString::fromStdString(data_type->name());
152 }
153 break;
154 }
155 default:
156 {
157 name = ccc::ast::node_type_to_string(*type);
158 }
159 }

Callers 3

setEditorDataMethod · 0.85
dataMethod · 0.85

Calls 7

builtin_class_to_stringFunction · 0.85
node_type_to_stringFunction · 0.85
prependMethod · 0.80
argMethod · 0.80
symbol_from_handleMethod · 0.80
getMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected