diff --git a/src/backend/vm.nim b/src/backend/vm.nim index 3601868..6eb3785 100644 --- a/src/backend/vm.nim +++ b/src/backend/vm.nim @@ -13,12 +13,12 @@ # limitations under the License. ## The Peon runtime environment -import std/monotimes import std/math import std/segfaults import std/strutils import std/sequtils import std/sets +import std/times import ../config @@ -1020,12 +1020,7 @@ proc dispatch*(self: PeonVM) = stdout.write(s.str[i]) stdout.write("\n") of SysClock64: - # Pushes the value of a monotonic clock - # onto the operand stack. This can be used - # to track system time accurately, but it - # cannot be converted to a date. The number - # is in seconds - self.push(cast[uint64](getMonoTime().ticks().float() / 1_000_000_000)) + self.push(cast[uint64](cpuTime())) of LogicalNot: self.push(uint64(not self.pop().bool)) else: diff --git a/src/frontend/compiler.nim b/src/frontend/compiler.nim index c17c9f1..cd55a3d 100644 --- a/src/frontend/compiler.nim +++ b/src/frontend/compiler.nim @@ -564,7 +564,11 @@ proc getStackPos(self: Compiler, name: Name): int = continue elif not variable.valueType.isNil() and variable.valueType.kind == Generic: continue - if name == variable: + elif variable.owner != self.currentModule: + continue + if variable.depth > self.scopeDepth: + continue + if name.ident == variable.ident: found = true break inc(result) @@ -1085,11 +1089,11 @@ proc endScope(self: Compiler) = self.error("cannot call endScope with scopeDepth < 0 (This is an internal error and most likely a bug)") discard self.scopeOwners.pop() dec(self.scopeDepth) - if not self.isMainModule: - return var names: seq[Name] = @[] var popCount = 0 for name in self.names: + if self.scopeDepth == -1 and not self.isMainModule: + continue if name.depth > self.scopeDepth: names.add(name) if not name.resolved: diff --git a/src/peon/stdlib/std.pn b/src/peon/stdlib/std.pn index 25de195..b5f40d2 100644 --- a/src/peon/stdlib/std.pn +++ b/src/peon/stdlib/std.pn @@ -11,3 +11,4 @@ export arithmetics; export bitwise; export logical; export misc; +export comparisons; \ No newline at end of file