Minor documentation additions
This commit is contained in:
parent
da651355b9
commit
f50dd66741
|
@ -465,11 +465,16 @@ proc dispatch*(self: PeonVM) =
|
||||||
# onto the call stack
|
# onto the call stack
|
||||||
self.pushc(self.pop())
|
self.pushc(self.pop())
|
||||||
of PopRepl:
|
of PopRepl:
|
||||||
|
# Pops a peon object off the
|
||||||
|
# operand stack and prints it.
|
||||||
|
# Used in interactive REPL mode
|
||||||
if self.frames.len() > 1:
|
if self.frames.len() > 1:
|
||||||
discard self.pop()
|
discard self.pop()
|
||||||
continue
|
continue
|
||||||
echo self.pop()
|
echo self.pop()
|
||||||
of GenericPrint:
|
of GenericPrint:
|
||||||
|
# Prints the peon object at the top
|
||||||
|
# of the operand stack
|
||||||
echo self.pop()
|
echo self.pop()
|
||||||
of PopN:
|
of PopN:
|
||||||
# Pops N elements off the call stack
|
# Pops N elements off the call stack
|
||||||
|
@ -499,7 +504,6 @@ proc dispatch*(self: PeonVM) =
|
||||||
else:
|
else:
|
||||||
discard self.pop()
|
discard self.pop()
|
||||||
# Built-in operations on primitive types
|
# Built-in operations on primitive types
|
||||||
# Note how
|
|
||||||
of AddInt64:
|
of AddInt64:
|
||||||
self.push(PeonObject(kind: Int64, long: self.pop().long + self.pop().long))
|
self.push(PeonObject(kind: Int64, long: self.pop().long + self.pop().long))
|
||||||
of SubInt64:
|
of SubInt64:
|
||||||
|
@ -595,6 +599,11 @@ proc dispatch*(self: PeonVM) =
|
||||||
of LessThanInt64:
|
of LessThanInt64:
|
||||||
self.push(PeonObject(kind: Bool, boolean: self.pop().long < self.pop().long))
|
self.push(PeonObject(kind: Bool, boolean: self.pop().long < self.pop().long))
|
||||||
of SysClock64:
|
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))
|
self.push(PeonObject(kind: Float64, `float`: getMonoTime().ticks().float() / 1_000_000_000))
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
|
@ -3,6 +3,11 @@ operator `+`(a, b: int): int {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn print(x: int) {
|
||||||
|
#pragma[magic: "GenericPrint"]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn getAdder(a, b: int): fn: int64 {
|
fn getAdder(a, b: int): fn: int64 {
|
||||||
var x = a;
|
var x = a;
|
||||||
var y = b;
|
var y = b;
|
||||||
|
@ -13,7 +18,7 @@ fn getAdder(a, b: int): fn: int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var a = 5;
|
var a = 1;
|
||||||
var b = 6;
|
var b = 2;
|
||||||
var adder = getAdder(a, b);
|
var adder = getAdder(a, b);
|
||||||
adder();
|
print(adder());
|
||||||
|
|
Loading…
Reference in New Issue