Various bug fixes to scopes
This commit is contained in:
parent
11f725e176
commit
1c54243d43
|
@ -13,12 +13,12 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
## The Peon runtime environment
|
## The Peon runtime environment
|
||||||
|
|
||||||
import std/monotimes
|
|
||||||
import std/math
|
import std/math
|
||||||
import std/segfaults
|
import std/segfaults
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import std/sets
|
import std/sets
|
||||||
|
import std/times
|
||||||
|
|
||||||
|
|
||||||
import ../config
|
import ../config
|
||||||
|
@ -1020,12 +1020,7 @@ proc dispatch*(self: PeonVM) =
|
||||||
stdout.write(s.str[i])
|
stdout.write(s.str[i])
|
||||||
stdout.write("\n")
|
stdout.write("\n")
|
||||||
of SysClock64:
|
of SysClock64:
|
||||||
# Pushes the value of a monotonic clock
|
self.push(cast[uint64](cpuTime()))
|
||||||
# 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))
|
|
||||||
of LogicalNot:
|
of LogicalNot:
|
||||||
self.push(uint64(not self.pop().bool))
|
self.push(uint64(not self.pop().bool))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -564,7 +564,11 @@ proc getStackPos(self: Compiler, name: Name): int =
|
||||||
continue
|
continue
|
||||||
elif not variable.valueType.isNil() and variable.valueType.kind == Generic:
|
elif not variable.valueType.isNil() and variable.valueType.kind == Generic:
|
||||||
continue
|
continue
|
||||||
if name == variable:
|
elif variable.owner != self.currentModule:
|
||||||
|
continue
|
||||||
|
if variable.depth > self.scopeDepth:
|
||||||
|
continue
|
||||||
|
if name.ident == variable.ident:
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
inc(result)
|
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)")
|
self.error("cannot call endScope with scopeDepth < 0 (This is an internal error and most likely a bug)")
|
||||||
discard self.scopeOwners.pop()
|
discard self.scopeOwners.pop()
|
||||||
dec(self.scopeDepth)
|
dec(self.scopeDepth)
|
||||||
if not self.isMainModule:
|
|
||||||
return
|
|
||||||
var names: seq[Name] = @[]
|
var names: seq[Name] = @[]
|
||||||
var popCount = 0
|
var popCount = 0
|
||||||
for name in self.names:
|
for name in self.names:
|
||||||
|
if self.scopeDepth == -1 and not self.isMainModule:
|
||||||
|
continue
|
||||||
if name.depth > self.scopeDepth:
|
if name.depth > self.scopeDepth:
|
||||||
names.add(name)
|
names.add(name)
|
||||||
if not name.resolved:
|
if not name.resolved:
|
||||||
|
|
|
@ -11,3 +11,4 @@ export arithmetics;
|
||||||
export bitwise;
|
export bitwise;
|
||||||
export logical;
|
export logical;
|
||||||
export misc;
|
export misc;
|
||||||
|
export comparisons;
|
Loading…
Reference in New Issue