10 // ////////////////////////////////////////////////////////////////////////// //
11 void registerPrims () {
12 VM
["write"] = (Real
[] args
) {
13 import std
.stdio
: stdout
;
14 foreach (Real v
; args
[VM
.Slot
.Argument0
..$]) {
15 if (v
.isString
) stdout
.write(getDynStr(v
.getStrId
)); else stdout
.write(v
);
19 VM
["writeln"] = (Real
[] args
) {
20 import std
.stdio
: stdout
;
21 foreach (Real v
; args
[VM
.Slot
.Argument0
..$]) {
22 if (v
.isString
) stdout
.write(getDynStr(v
.getStrId
)); else stdout
.write(v
);
28 VM
["string_length"] = (string s
) => s
.length
;
32 // ////////////////////////////////////////////////////////////////////////// //
33 void main (string
[] args
) {
34 bool measureTime
= false;
38 funcs
= cliProcessArgs
!(
39 "--time", (fname
) { measureTime
= true; },
42 if (funcs
.length
> 0) {
45 writeln(funcs
.length
, " function", (funcs
.length
> 1 ?
"s" : ""), " parsed");
46 foreach (auto fn
; funcs
) compile(fn
);
47 if (measureTime
) writeln("executing...");
48 auto stt
= MonoTime
.currTime
;
49 auto res
= VM
.exec("main");
50 auto dur
= (MonoTime
.currTime
-stt
).total
!"msecs";
52 if (measureTime
) writeln("total execution took ", dur
, " milliseconds");