Add parents (de)serialization in pip_cmg #206
@@ -577,28 +577,36 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
|||||||
|
|
||||||
|
|
||||||
PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc) {
|
PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc) {
|
||||||
static const PIString s_ss = PIStringAscii(" ");
|
static const PIString s_ss = PIStringAscii(" ");
|
||||||
static const PIString s_M = PIStringAscii("$M");
|
static const PIString s_M = PIStringAscii("$M");
|
||||||
static const PIString s_class = PIStringAscii("class");
|
static const PIString s_class = PIStringAscii("class");
|
||||||
PIString cd = fc.trimmed().removeAll('\n').replaceAll('\t', ' ').replaceAll(s_ss, ' '), pn;
|
static const PIString s_public = PIStringAscii("public");
|
||||||
|
PIString cd = fc.trimmed().removeAll('\n').replaceAll('\t', ' ').replaceAll(s_ss, ' '), pn;
|
||||||
MetaMap meta;
|
MetaMap meta;
|
||||||
int ind = cd.find(s_M);
|
int ind = cd.find(s_M);
|
||||||
if (ind >= 0) {
|
if (ind >= 0) {
|
||||||
meta = tmp_meta.value(cd.takeMid(ind, 5));
|
meta = tmp_meta.value(cd.takeMid(ind, 5));
|
||||||
cd.replaceAll(s_ss, ' ');
|
cd.replaceAll(s_ss, ' ');
|
||||||
}
|
}
|
||||||
|
PIString typename_ = cd.left(6).trim();
|
||||||
|
bool is_class = typename_ == s_class;
|
||||||
|
ind = cd.find(':');
|
||||||
// piCout << "found class <****\n" << cd << "\n****>";
|
// piCout << "found class <****\n" << cd << "\n****>";
|
||||||
ind = cd.find(':');
|
|
||||||
PIVector<Entity *> parents;
|
PIVector<Entity *> parents;
|
||||||
if (ind > 0) {
|
if (ind > 0) {
|
||||||
PIStringList pl = cd.takeMid(ind + 1).trim().split(',');
|
PIStringList pl = cd.takeMid(ind + 1).trim().split(',');
|
||||||
cd.cutRight(1);
|
cd.cutRight(1);
|
||||||
Entity * pe = 0;
|
Entity * pe = 0;
|
||||||
for (const auto & p: pl) {
|
for (const auto & p: pl) {
|
||||||
if (p.contains(' '))
|
PIString access;
|
||||||
pn = p.mid(p.find(' ') + 1);
|
if (p.contains(' ')) {
|
||||||
else
|
access = p.left(p.find(' ')).trim();
|
||||||
|
pn = p.mid(p.find(' ') + 1);
|
||||||
|
} else {
|
||||||
pn = p;
|
pn = p;
|
||||||
|
}
|
||||||
|
bool is_public = access.isEmpty() ? !is_class : access == s_public;
|
||||||
|
if (!is_public) continue;
|
||||||
pe = findEntityByName(pn);
|
pe = findEntityByName(pn);
|
||||||
if (pe == 0)
|
if (pe == 0)
|
||||||
; //{piCout << "Error: can`t find" << pn;}
|
; //{piCout << "Error: can`t find" << pn;}
|
||||||
@@ -606,12 +614,10 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
|||||||
parents << pe;
|
parents << pe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PIString typename_ = cd.left(6).trim();
|
Visibility vis = cur_def_vis;
|
||||||
bool is_class = typename_ == s_class;
|
cur_def_vis = (is_class ? Private : Public);
|
||||||
Visibility vis = cur_def_vis;
|
PIString cn = cd.mid(6).trim();
|
||||||
cur_def_vis = (is_class ? Private : Public);
|
bool is_anonymous = cn.isEmpty();
|
||||||
PIString cn = cd.mid(6).trim();
|
|
||||||
bool is_anonymous = cn.isEmpty();
|
|
||||||
if (cn.isEmpty()) cn = PIStringAscii("<unnamed_") + PIString::fromNumber(anon_num++) + '>';
|
if (cn.isEmpty()) cn = PIStringAscii("<unnamed_") + PIString::fromNumber(anon_num++) + '>';
|
||||||
// piCout << "found " << typename_ << cn;
|
// piCout << "found " << typename_ << cn;
|
||||||
Entity * e = new Entity();
|
Entity * e = new Entity();
|
||||||
|
|||||||
Reference in New Issue
Block a user