11 // ////////////////////////////////////////////////////////////////////////// //
12 void registerPrims () {
13 VM
["write"] = (Real
[] args
) {
14 import std
.stdio
: stdout
;
15 foreach (Real v
; args
[VM
.Slot
.Argument0
..$]) {
16 if (v
.isString
) stdout
.write(getDynStr(v
.getStrId
)); else stdout
.write(v
);
20 VM
["writeln"] = (Real
[] args
) {
21 import std
.stdio
: stdout
;
22 foreach (Real v
; args
[VM
.Slot
.Argument0
..$]) {
23 if (v
.isString
) stdout
.write(getDynStr(v
.getStrId
)); else stdout
.write(v
);
29 VM
["string_length"] = (string s
) => s
.length
;
33 // ////////////////////////////////////////////////////////////////////////// //
34 void main (string
[] args
) {
35 bool measureTime
= false;
40 cliLoadGmkScripts
= false;
42 funcs
= cliProcessArgs
!(
43 "--time", (fname
) { measureTime
= true; },
44 "--norun", (fname
) { doRun
= false; },
50 if (funcs
.length
> 0) {
53 writeln(funcs
.length
, " function", (funcs
.length
> 1 ?
"s" : ""), " parsed");
54 foreach (auto fn
; funcs
) compile(fn
);
56 if (measureTime
) writeln("executing...");
57 auto stt
= MonoTime
.currTime
;
58 auto res
= VM
.exec("main");
59 auto dur
= (MonoTime
.currTime
-stt
).total
!"msecs";
61 if (measureTime
) writeln("total execution took ", dur
, " milliseconds");