diff --git a/src/backend/vm.nim b/src/backend/vm.nim index 99a5fee..5afaf4c 100644 --- a/src/backend/vm.nim +++ b/src/backend/vm.nim @@ -465,11 +465,16 @@ proc dispatch*(self: PeonVM) = # onto the call stack self.pushc(self.pop()) of PopRepl: + # Pops a peon object off the + # operand stack and prints it. + # Used in interactive REPL mode if self.frames.len() > 1: discard self.pop() continue echo self.pop() of GenericPrint: + # Prints the peon object at the top + # of the operand stack echo self.pop() of PopN: # Pops N elements off the call stack @@ -499,7 +504,6 @@ proc dispatch*(self: PeonVM) = else: discard self.pop() # Built-in operations on primitive types - # Note how of AddInt64: self.push(PeonObject(kind: Int64, long: self.pop().long + self.pop().long)) of SubInt64: @@ -595,6 +599,11 @@ proc dispatch*(self: PeonVM) = of LessThanInt64: self.push(PeonObject(kind: Bool, boolean: self.pop().long < self.pop().long)) of SysClock64: + # Pushes the value of a monotonic clock + # as a 64 bit float onto the operand stack. + # Used to track system runtime accurately, + # but cannot be converted to a date. The number + # is in seconds self.push(PeonObject(kind: Float64, `float`: getMonoTime().ticks().float() / 1_000_000_000)) else: discard diff --git a/tests/test.pn b/tests/test.pn index 4405153..436cce7 100644 --- a/tests/test.pn +++ b/tests/test.pn @@ -3,6 +3,11 @@ operator `+`(a, b: int): int { } +fn print(x: int) { + #pragma[magic: "GenericPrint"] +} + + fn getAdder(a, b: int): fn: int64 { var x = a; var y = b; @@ -13,7 +18,7 @@ fn getAdder(a, b: int): fn: int64 { } -var a = 5; -var b = 6; +var a = 1; +var b = 2; var adder = getAdder(a, b); -adder(); +print(adder());