mirror of https://gitlab.com/basile.b/dexed.git
added more symbol to the list
+ class/struct ctor/dtor + anon enum, first member used as ident + mixin template decl not as template but as mixin + test as runnable with <CFF> using the version ident automatically set by CE + libdparse FR: line/col for static ctor/dtor
This commit is contained in:
parent
a954f31417
commit
173acc0c8e
|
@ -24,7 +24,7 @@ void main(string[] args)
|
||||||
slb.visit(decl);
|
slb.visit(decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
version(none)
|
version(runnable_module)
|
||||||
{
|
{
|
||||||
int level = -1;
|
int level = -1;
|
||||||
void print(Symbol * s)
|
void print(Symbol * s)
|
||||||
|
@ -37,12 +37,14 @@ void main(string[] args)
|
||||||
|
|
||||||
level--;
|
level--;
|
||||||
}
|
}
|
||||||
print(&slb.root);
|
print(slb.root);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto str = slb.serialize;
|
||||||
|
write(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto str = slb.serialize;
|
|
||||||
write(str);
|
|
||||||
|
|
||||||
slb.destruct;
|
slb.destruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ enum SymbolType
|
||||||
_function, // X
|
_function, // X
|
||||||
_interface, // X
|
_interface, // X
|
||||||
_import, // X
|
_import, // X
|
||||||
_mixin,
|
_mixin, // X (template decl)
|
||||||
_struct, // X
|
_struct, // X
|
||||||
_template, // X
|
_template, // X
|
||||||
_union, // X
|
_union, // X
|
||||||
|
@ -170,6 +172,7 @@ class SymbolListBuilder : ASTVisitor
|
||||||
static if
|
static if
|
||||||
(
|
(
|
||||||
is(DT == const(EponymousTemplateDeclaration)) ||
|
is(DT == const(EponymousTemplateDeclaration)) ||
|
||||||
|
is(DT == const(AnonymousEnumMember)) ||
|
||||||
is(DT == const(AliasInitializer)) ||
|
is(DT == const(AliasInitializer)) ||
|
||||||
is(DT == const(ClassDeclaration)) ||
|
is(DT == const(ClassDeclaration)) ||
|
||||||
is(DT == const(Declarator)) ||
|
is(DT == const(Declarator)) ||
|
||||||
|
@ -209,21 +212,47 @@ class SymbolListBuilder : ASTVisitor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO-cfeature: anonymous enum, accept visitor and add Symbol based on the 1st member name.
|
/// visitor implementation for special cases.
|
||||||
|
final void otherVisitorImpl(SymbolType st, string name, size_t line, size_t col)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
auto result = construct!Symbol;
|
||||||
|
result.name = name;
|
||||||
|
result.line = cast(int) line;
|
||||||
|
result.col = cast(int) col;
|
||||||
|
result.type = st;
|
||||||
|
parent.subs ~= result;
|
||||||
|
}
|
||||||
|
|
||||||
final override void visit(const AliasDeclaration decl)
|
final override void visit(const AliasDeclaration decl)
|
||||||
{
|
{
|
||||||
// old alias syntax not supported by this method
|
// old alias syntax not supported by this method
|
||||||
// why is initializers an array ?
|
// why is initializers an array ?
|
||||||
if (decl.initializers.length == 1)
|
if (decl.initializers.length > 0)
|
||||||
namedVisitorImpl!(AliasInitializer, SymbolType._alias)(decl.initializers[0]);
|
namedVisitorImpl!(AliasInitializer, SymbolType._alias)(decl.initializers[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override void visit(const AnonymousEnumDeclaration decl)
|
||||||
|
{
|
||||||
|
if (decl.members.length > 0)
|
||||||
|
namedVisitorImpl!(AnonymousEnumMember, SymbolType._enum)(decl.members[0]);
|
||||||
|
}
|
||||||
|
|
||||||
final override void visit(const ClassDeclaration decl)
|
final override void visit(const ClassDeclaration decl)
|
||||||
{
|
{
|
||||||
namedVisitorImpl!(ClassDeclaration, SymbolType._class)(decl);
|
namedVisitorImpl!(ClassDeclaration, SymbolType._class)(decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override void visit(const Constructor decl)
|
||||||
|
{
|
||||||
|
otherVisitorImpl(SymbolType._function, "this", decl.line, decl.column);
|
||||||
|
}
|
||||||
|
|
||||||
|
final override void visit(const Destructor decl)
|
||||||
|
{
|
||||||
|
otherVisitorImpl(SymbolType._function, "~this", decl.line, decl.column);
|
||||||
|
}
|
||||||
|
|
||||||
final override void visit(const EnumDeclaration decl)
|
final override void visit(const EnumDeclaration decl)
|
||||||
{
|
{
|
||||||
namedVisitorImpl!(EnumDeclaration, SymbolType._enum)(decl);
|
namedVisitorImpl!(EnumDeclaration, SymbolType._enum)(decl);
|
||||||
|
@ -258,20 +287,17 @@ class SymbolListBuilder : ASTVisitor
|
||||||
modules ~= ".";
|
modules ~= ".";
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
count++;
|
otherVisitorImpl(SymbolType._import, modules[0..$-1].join,
|
||||||
auto result = construct!Symbol;
|
si.identifierChain.identifiers[0].line,
|
||||||
result.name = modules[0..$-1].join;
|
si.identifierChain.identifiers[0].column
|
||||||
result.line = cast(int) si.identifierChain.identifiers[0].line;
|
);
|
||||||
result.col = cast(int) si.identifierChain.identifiers[0].column;
|
|
||||||
result.type = SymbolType._import;
|
|
||||||
parent.subs ~= result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final override void visit(const MixinTemplateDeclaration decl)
|
final override void visit(const MixinTemplateDeclaration decl)
|
||||||
{
|
{
|
||||||
namedVisitorImpl!(TemplateDeclaration, SymbolType._template)(decl.templateDeclaration);
|
namedVisitorImpl!(TemplateDeclaration, SymbolType._mixin)(decl.templateDeclaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
final override void visit(const StructDeclaration decl)
|
final override void visit(const StructDeclaration decl)
|
||||||
{
|
{
|
||||||
|
@ -293,6 +319,17 @@ class SymbolListBuilder : ASTVisitor
|
||||||
foreach(elem; decl.declarators)
|
foreach(elem; decl.declarators)
|
||||||
namedVisitorImpl!(Declarator, SymbolType._variable, false)(elem);
|
namedVisitorImpl!(Declarator, SymbolType._variable, false)(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Disabled: line and column are not available
|
||||||
|
final override void visit(const StaticConstructor decl)
|
||||||
|
{
|
||||||
|
otherVisitorImpl(SymbolType._function, "static this", decl.line, decl.column);
|
||||||
|
}
|
||||||
|
|
||||||
|
final override void visit(const StaticDestructor decl)
|
||||||
|
{
|
||||||
|
otherVisitorImpl(SymbolType._function, "static ~this", decl.line, decl.column);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
//----
|
//----
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue