symlist, use iz mem utils to format function names.

This commit is contained in:
Basile Burg 2017-12-06 16:06:28 +01:00
parent fa5d8861e8
commit e1453c0ebf
3 changed files with 13 additions and 11 deletions

View File

@ -4,9 +4,9 @@ import
std.stdio, std.array, std.traits, std.conv, std.json, std.format,
std.algorithm;
import
iz.memory;
iz.memory, iz.containers;
import
dparse.lexer, dparse.ast, dparse.parser;
dparse.lexer, dparse.ast, dparse.parser, dparse.formatter : Formatter;
import
common;
@ -74,6 +74,8 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
static JSONValue* jarray;
}
static Array!(char) funcNameApp;
static Formatter!(typeof(&funcNameApp)) fmtVisitor;
static uint utc;
this(bool deep)
@ -94,6 +96,7 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
json = parseJSON("[]");
jarray = &json;
}
fmtVisitor = construct!(typeof(fmtVisitor))(&funcNameApp);
}
static void addAstErrors(AstErrors errors)
@ -156,10 +159,9 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
if (dt.parameters && dt.parameters.parameters &&
dt.parameters.parameters.length)
{
import dparse.formatter : fmtNode = format;
Appender!string app;
fmtNode(&app, dt.parameters);
pasStream.put(format("name='%s%s'\r", dt.name.text, app.data));
funcNameApp.length = 0;
fmtVisitor.format(dt.parameters);
pasStream.put(format("name='%s%s'\r", dt.name.text, funcNameApp[]));
}
else pasStream.put(format("name='%s'\r", dt.name.text));
}
@ -187,9 +189,9 @@ class SymbolListBuilder(ListFmt Fmt): ASTVisitor
dt.parameters.parameters.length)
{
import dparse.formatter : fmtNode = format;
Appender!string app;
fmtNode(&app, dt.parameters);
item["name"] = JSONValue(dt.name.text ~ app.data);
funcNameApp.length = 0;
fmtVisitor.format(dt.parameters);
item["name"] = JSONValue(dt.name.text ~ app.funcNameApp[]);
}
else item["name"] = JSONValue(dt.name.text);
}

2
etc/iz

@ -1 +1 @@
Subproject commit f5143575b7984001e71e8c1d88db9478167c410b
Subproject commit fbf5056f7b59da4ac60df8722ee0ce42a6bc2e1c

@ -1 +1 @@
Subproject commit 7887ba3665a05a54e511850d009f8f999f89d97d
Subproject commit a2b492d8c7a84881657de85939d9c6b14f867d5b