don't allocate slots for argument aliases
[gaemu.git] / runner.d
blob9651e30c360a07bbadb63bc73318124795521a86
1 module runner 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 NodeFunc[] funcs;
16 bool dumpFileNames = false;
17 bool styleWarnings = false;
18 bool doScripts = true, doActions = true;
19 bool measureTime = false;
21 bool nomore = false;
22 string[] scargs;
23 foreach (string fname; args[1..$]) {
24 import std.file;
25 import std.path;
26 if (nomore) {
27 scargs ~= fname;
28 } else {
29 if (fname.length == 0) continue;
30 if (fname == "--") { nomore = true; continue; }
31 if (fname == "-d") { dumpFileNames = true; continue; }
32 if (fname == "-w") { styleWarnings = true; continue; }
33 if (fname == "-S") { doScripts = false; continue; }
34 if (fname == "-A") { doActions = false; continue; }
35 if (fname == "--time") { measureTime = true; continue; }
36 if (fname[0] == '@') {
37 if (fname.length < 2) assert(0, "gmk file?");
38 auto gmk = new Gmk(fname[1..$]);
39 funcs ~= gmkLoadScripts(gmk, doScripts:doScripts, doActions:doActions, warnings:false);
40 continue;
42 if (isDir(fname)) {
43 foreach (auto de; dirEntries(fname, "*.gm[lx]", SpanMode.breadth)) {
44 bool doit = true;
45 foreach (auto pt; pathSplitter(de.dirName)) {
46 if (pt.length && pt[0] == '_') { doit = false; break; }
48 if (doit) {
49 if (dumpFileNames) { import std.stdio; writeln("loading '", de.name, "'..."); }
50 funcs ~= loadScript(de.name, true);
53 } else {
54 if (dumpFileNames) { import std.stdio; writeln("loading '", fname, "'..."); }
55 funcs ~= loadScript(fname, true);
60 if (funcs.length > 0) {
61 writeln(funcs.length, " function", (funcs.length > 1 ? "s" : ""), " parsed");
62 foreach (auto fn; funcs) {
63 writeln("\n", fn.toString);
68 if (measureTime) writeln("executing...");
69 runScript("main", scargs);
70 if (measureTime) {
71 auto dur = (MonoTime.currTime-stt).total!"msecs";
72 writeln("total execution took ", dur, " milliseconds");