finish codeparser improvements

pip_cmg now works with new nested entities approach
Getters now can access to bitfields
This commit is contained in:
2025-09-18 05:54:31 +03:00
parent af02684dc5
commit 7083b2c32b
15 changed files with 244 additions and 157 deletions

View File

@@ -20,27 +20,17 @@
#include "metainfo.h"
void makeClassInfo(Runtime & rt, const PICodeParser::Entity * e) {
rt.ts << "\n\t{\n\tClassInfo * ci = new ClassInfo();\n";
rt.ts << "\tci->type = \"" << e->type << "\";\n";
rt.ts << "\tci->name = \"" << e->name << "\";\n";
rt.ts << "\tci->has_name = " << (e->has_name ? "true" : "false") << ";\n";
if (!e->meta.isEmpty()) {
auto i = e->meta.makeIterator();
while (i.next())
rt.ts << "\tci->meta[\"" << i.key() << "\"] = PIString::fromUTF8(\"" << i.value() << "\");\n";
}
rt.ts << "\tci_ci[ci->name] = ci;\n";
if (e->parent_scope) {
rt.ts << "\tpci = "
<< "ci_ci.value(\"" << e->parent_scope->name << "\", 0);\n";
rt.ts << "\tif (pci) pci->children_info << ci;\n";
}
for (const PICodeParser::Entity * p: e->parents)
rt.ts << "\tci->parents << \"" << p->name << "\";\n";
if (!e->members.isEmpty()) rt.ts << "\n\tTypeInfo ti;\n";
void writeClassInfoMembers(Runtime & rt, const PICodeParser::Entity * e, PIString var_prefix) {
if (var_prefix.isNotEmpty() && !var_prefix.endsWith('.')) var_prefix += ".";
for (const PICodeParser::Member & m: e->members) {
rt.ts << "\tti = TypeInfo(\"" << m.name << "\", \"" << m.type << "\"";
auto type = findEntity(rt, m.type);
if (type) {
if (type->is_anonymous) {
writeClassInfoMembers(rt, type, var_prefix + m.name);
continue;
}
}
rt.ts << "\tti = TypeInfo(\"" << var_prefix << m.name << "\", \"" << m.type << "\"";
if (m.attributes != 0) {
bool fir = true;
rt.ts << ", ";
@@ -97,6 +87,29 @@ void makeClassInfo(Runtime & rt, const PICodeParser::Entity * e) {
}
rt.ts << "\tci->variables << ti;\n";
}
}
void makeClassInfo(Runtime & rt, const PICodeParser::Entity * e) {
rt.ts << "\n\t{\n\tClassInfo * ci = new ClassInfo();\n";
rt.ts << "\tci->type = \"" << e->type << "\";\n";
rt.ts << "\tci->name = \"" << e->name << "\";\n";
// rt.ts << "\tci->is_anonymous = " << (e->is_anonymous ? "true" : "false") << ";\n";
if (!e->meta.isEmpty()) {
auto i = e->meta.makeIterator();
while (i.next())
rt.ts << "\tci->meta[\"" << i.key() << "\"] = PIString::fromUTF8(\"" << i.value() << "\");\n";
}
rt.ts << "\tci_ci[ci->name] = ci;\n";
if (e->parent_scope) {
rt.ts << "\tpci = "
<< "ci_ci.value(\"" << e->parent_scope->name << "\", 0);\n";
rt.ts << "\tif (pci) pci->children_info << ci;\n";
}
for (const PICodeParser::Entity * p: e->parents)
rt.ts << "\tci->parents << \"" << p->name << "\";\n";
if (!e->members.isEmpty()) rt.ts << "\n\tTypeInfo ti;\n";
writeClassInfoMembers(rt, e);
PIString arg;
bool has_fi = false;
for (const PICodeParser::Member & m: e->functions) {