Rework tree generation mode and API
Store tree nodes in congruent, compact arena array. Define handle types to refer to tree nodes rather than pointers to structure instances. Free tree with context.
This commit is contained in:
1 parent
dddb1b5089
commit
5fc712c6ee
39 files changed
+1349
-811
No files matched your search
@@ -378,19 +378,19 @@ def main() -> int
|
||||
context = p_context_new(input);
|
||||
size_t result = p_parse(context);
|
||||
assert_eq(P_SUCCESS, result);
|
||||
PModule * pmod = p_result(context);
|
||||
PModuleItems * pmis = pmod.pModuleItems;
|
||||
PFunctionDefinition *[] pfds;
|
||||
while (pmis !is null)
|
||||
PModule pmod = p_result(context);
|
||||
PModuleItems pmis = pmod.pModuleItems;
|
||||
PFunctionDefinition[] pfds;
|
||||
while (pmis.valid)
|
||||
{
|
||||
PModuleItem * pmi = pmis.pModuleItem;
|
||||
if (pmi is null)
|
||||
PModuleItem pmi = pmis.pModuleItem;
|
||||
if (!pmi.valid)
|
||||
{
|
||||
stderr.writeln("pmi is null!!!?");
|
||||
assert(0);
|
||||
}
|
||||
PFunctionDefinition * pfd = pmi.pFunctionDefinition;
|
||||
if (pfd !is null)
|
||||
PFunctionDefinition pfd = pmi.pFunctionDefinition;
|
||||
if (pfd.valid)
|
||||
{
|
||||
pfds = [pfd] ~ pfds;
|
||||
}
|
||||
@@ -405,5 +405,5 @@ def main() -> int
|
||||
stderr.writeln("Index ", i, ": expected ", expected[i].name, "/", expected[i].token, ", got ", pfds[i].name.pvalue.s, "/", pfds[i].returntype.pType.pTypeBase.pToken1.token);
|
||||
}
|
||||
}
|
||||
p_tree_delete(pmod);
|
||||
p_context_delete(context);
|
||||
}
|
||||
Reference in new issue
Block a user