one small optimization worth alot!
[gaemu.git] / frex.d
blobed709cbea9690307b93755b3b458903bbf472aa0
1 module frex is aliced;
3 import std.stdio;
5 import gmlparser;
6 import gmlparser.anal;
8 import ungmk;
9 import loader;
12 // ////////////////////////////////////////////////////////////////////////// //
13 void main (string[] args) {
14 bool dumpFileNames = false;
15 bool doScripts = true;
16 bool doActions = true;
18 NodeFunc[] funcs;
20 bool nomore = false;
21 string[] scargs;
22 foreach (string fname; args[1..$]) {
23 import std.file;
24 import std.path;
25 if (nomore) {
26 scargs ~= fname;
27 } else {
28 if (fname.length == 0) continue;
29 if (fname == "--") { nomore = true; continue; }
30 if (fname == "-d") { dumpFileNames = true; continue; }
31 if (fname == "-S") { doScripts = false; continue; }
32 if (fname == "-A") { doActions = false; continue; }
33 if (fname[0] == '@') {
34 if (fname.length < 2) assert(0, "gmk file?");
35 auto gmk = new Gmk(fname[1..$]);
36 funcs ~= gmkLoadScripts(gmk, doScripts:doScripts, doActions:doActions, warnings:false, checkReturns:false);
37 continue;
39 if (isDir(fname)) {
40 foreach (auto de; dirEntries(fname, "*.gm[lx]", SpanMode.breadth)) {
41 bool doit = true;
42 foreach (auto pt; pathSplitter(de.dirName)) {
43 if (pt.length && pt[0] == '_') { doit = false; break; }
45 if (doit) {
46 if (dumpFileNames) { import std.stdio; writeln("loading '", de.name, "'..."); }
47 funcs ~= loadScript(de.name, false);
50 } else {
51 if (dumpFileNames) { import std.stdio; writeln("loading '", fname, "'..."); }
52 funcs ~= loadScript(fname, false);
57 if (funcs.length > 0) {
58 writeln(funcs.length, " function", (funcs.length > 1 ? "s" : ""), " parsed");
59 foreach (auto fn; funcs) {
60 //x > view_xview[0]-16 && x < view_xview[0]+view_wview[0]+16 &&
61 //y > view_yview[0]-16 && y < view_yview[0]+view_hview[0]+16
63 writeln("\n", fn.toString);
64 visitNodes(fn.ebody, (n) {
65 import std.string : replace;
66 writeln(n.loc, ": (", typeid(n).name[14..$], "): ", n.toString.replace("\n", " "));
67 return VisitRes.Continue;
68 });
70 Node[] checks;
71 findFrozenChecks(ref checks, fn);
72 foreach (Node n; checks) {
73 import std.string : replace;
74 writeln(n.loc, ": frozen check");
75 writeln(" ", (cast(NodeIf)n).ec.toString.replace("\n", " "));