Various bug fixes to scopes
This commit is contained in:
parent
11f725e176
commit
1c54243d43
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -11,3 +11,4 @@ export arithmetics;
|
|||
export bitwise;
|
||||
export logical;
|
||||
export misc;
|
||||
export comparisons;
|
Loading…
Reference in New Issue