mirror of https://gitlab.com/basile.b/dexed.git
fix, cesyms, auto declarations were not detected
+ code to test as a runnable with the source + better handling of anon enum members
This commit is contained in:
parent
9a9f2d817d
commit
102a10f2e0
|
@ -44,7 +44,11 @@ void main(string[] args)
|
||||||
ubyte[] source;
|
ubyte[] source;
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
foreach(buff; stdin.byChunk(1024))
|
version(runnable_module)
|
||||||
|
{
|
||||||
|
source = cast(ubyte[]) read(__FILE__, size_t.max);
|
||||||
|
}
|
||||||
|
else foreach(buff; stdin.byChunk(1024))
|
||||||
source ~= buff;
|
source ~= buff;
|
||||||
}
|
}
|
||||||
else if (args.length == 2)
|
else if (args.length == 2)
|
||||||
|
@ -287,21 +291,7 @@ class SymbolListBuilder : ASTVisitor
|
||||||
/// returns a new symbol if the declarator is based on a Token named "name".
|
/// returns a new symbol if the declarator is based on a Token named "name".
|
||||||
final Symbol * addDeclaration(DT)(DT adt)
|
final Symbol * addDeclaration(DT)(DT adt)
|
||||||
{
|
{
|
||||||
static if
|
static if (__traits(hasMember, DT, "name"))
|
||||||
(
|
|
||||||
is(DT == const(EponymousTemplateDeclaration)) ||
|
|
||||||
is(DT == const(AnonymousEnumMember)) ||
|
|
||||||
is(DT == const(AliasInitializer)) ||
|
|
||||||
is(DT == const(ClassDeclaration)) ||
|
|
||||||
is(DT == const(Declarator)) ||
|
|
||||||
is(DT == const(EnumDeclaration)) ||
|
|
||||||
is(DT == const(FunctionDeclaration)) ||
|
|
||||||
is(DT == const(InterfaceDeclaration)) ||
|
|
||||||
is(DT == const(StructDeclaration)) ||
|
|
||||||
is(DT == const(TemplateDeclaration)) ||
|
|
||||||
is(DT == const(UnionDeclaration))
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
auto result = construct!Symbol;
|
auto result = construct!Symbol;
|
||||||
|
@ -311,8 +301,7 @@ class SymbolListBuilder : ASTVisitor
|
||||||
parent.subs ~= result;
|
parent.subs ~= result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else static assert(0, "addDeclaration no implemented for " ~ DT.stringof);
|
||||||
version(none) assert(0, "addDeclaration no implemented for " ~ DT.stringof);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// visitor implementation if the declarator is based on a Token named "name".
|
/// visitor implementation if the declarator is based on a Token named "name".
|
||||||
|
@ -349,10 +338,21 @@ class SymbolListBuilder : ASTVisitor
|
||||||
namedVisitorImpl!(AliasInitializer, SymbolType._alias)(decl.initializers[0]);
|
namedVisitorImpl!(AliasInitializer, SymbolType._alias)(decl.initializers[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override void visit(const AnonymousEnumMember decl)
|
||||||
|
{
|
||||||
|
namedVisitorImpl!(AnonymousEnumMember, SymbolType._enum)(decl);
|
||||||
|
}
|
||||||
|
|
||||||
final override void visit(const AnonymousEnumDeclaration decl)
|
final override void visit(const AnonymousEnumDeclaration decl)
|
||||||
{
|
{
|
||||||
if (decl.members.length) foreach(mem; decl.members)
|
decl.accept(this);
|
||||||
namedVisitorImpl!(AnonymousEnumMember, SymbolType._enum)(mem);
|
}
|
||||||
|
|
||||||
|
final override void visit(const AutoDeclaration decl)
|
||||||
|
{
|
||||||
|
otherVisitorImpl(SymbolType._enum, decl.identifiers[0].text,
|
||||||
|
decl.identifiers[0].line, decl.identifiers[0].column);
|
||||||
|
decl.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
final override void visit(const ClassDeclaration decl)
|
final override void visit(const ClassDeclaration decl)
|
||||||
|
@ -435,6 +435,8 @@ class SymbolListBuilder : ASTVisitor
|
||||||
{
|
{
|
||||||
foreach(elem; decl.declarators)
|
foreach(elem; decl.declarators)
|
||||||
namedVisitorImpl!(Declarator, SymbolType._variable, false)(elem);
|
namedVisitorImpl!(Declarator, SymbolType._variable, false)(elem);
|
||||||
|
if (decl.autoDeclaration)
|
||||||
|
visit(decl.autoDeclaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
final override void visit(const StaticConstructor decl)
|
final override void visit(const StaticConstructor decl)
|
||||||
|
|
Loading…
Reference in New Issue