This commit is contained in:
Basile Burg 2017-05-02 21:30:02 +02:00
parent 2f0743449d
commit 0483b40ca9
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 10 additions and 6 deletions

View File

@ -10,18 +10,15 @@ import
import import
common; common;
private __gshared bool deep = void;
/** /**
* Serializes the symbols in the standard output * Serializes the symbols in the standard output
*/ */
void listSymbols(const(Module) mod, AstErrors errors, bool deep = true) void listSymbols(const(Module) mod, AstErrors errors, bool deep = true)
{ {
mixin(logCall); mixin(logCall);
symlist.deep = deep;
alias SL = SymbolListBuilder!(ListFmt.Pas); alias SL = SymbolListBuilder!(ListFmt.Pas);
SL.addAstErrors(errors); SL.addAstErrors(errors);
SL sl = construct!(SL); SL sl = construct!(SL)(deep);
sl.visit(mod); sl.visit(mod);
sl.serialize.writeln; sl.serialize.writeln;
} }
@ -65,6 +62,8 @@ mixin(makeSymbolTypeArray);
class SymbolListBuilder(ListFmt Fmt): ASTVisitor class SymbolListBuilder(ListFmt Fmt): ASTVisitor
{ {
private immutable bool _deep;
static if (Fmt == ListFmt.Pas) static if (Fmt == ListFmt.Pas)
{ {
static Appender!string pasStream; static Appender!string pasStream;
@ -77,6 +76,11 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
static uint utc; static uint utc;
this(bool deep)
{
_deep = deep;
}
alias visit = ASTVisitor.visit; alias visit = ASTVisitor.visit;
static this() static this()
@ -149,7 +153,7 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
pasStream.put(format("col=%d\r", dt.name.column)); pasStream.put(format("col=%d\r", dt.name.column));
pasStream.put(format("name='%s'\r", dt.name.text)); pasStream.put(format("name='%s'\r", dt.name.text));
pasStream.put("symType=" ~ symbolTypeStrings[st] ~ "\r"); pasStream.put("symType=" ~ symbolTypeStrings[st] ~ "\r");
static if (dig) if (deep) static if (dig) if (_deep)
{ {
pasStream.put("subs = <"); pasStream.put("subs = <");
dt.accept(this); dt.accept(this);
@ -164,7 +168,7 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
item["col"] = JSONValue(dt.name.column); item["col"] = JSONValue(dt.name.column);
item["name"] = JSONValue(dt.name.text); item["name"] = JSONValue(dt.name.text);
item["type"] = JSONValue(symbolTypeStrings[st]); item["type"] = JSONValue(symbolTypeStrings[st]);
static if (dig) if (deep) static if (dig) if (_deep)
{ {
JSONValue subs = parseJSON("[]"); JSONValue subs = parseJSON("[]");
const JSONValue* old = jarray; const JSONValue* old = jarray;