parent
4005f0d0e4
commit
9874981e75
4 changed files with 8 additions and 7 deletions
|
|
@ -1276,7 +1276,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
||||||
of tyNil: result = allowsNilDeprecated(c, f)
|
of tyNil: result = allowsNilDeprecated(c, f)
|
||||||
else: discard
|
else: discard
|
||||||
of tyOrdinal:
|
of tyOrdinal:
|
||||||
if isOrdinalType(a):
|
if isOrdinalType(a, allowEnumWithHoles = optNimV1Emulation in c.c.config.globalOptions):
|
||||||
var x = if a.kind == tyOrdinal: a[0] else: a
|
var x = if a.kind == tyOrdinal: a[0] else: a
|
||||||
if f[0].kind == tyNone:
|
if f[0].kind == tyNone:
|
||||||
result = isGeneric
|
result = isGeneric
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ proc enumHasHoles*(t: PType): bool =
|
||||||
proc isOrdinalType*(t: PType, allowEnumWithHoles: bool = false): bool =
|
proc isOrdinalType*(t: PType, allowEnumWithHoles: bool = false): bool =
|
||||||
assert(t != nil)
|
assert(t != nil)
|
||||||
const
|
const
|
||||||
baseKinds = {tyChar,tyInt..tyInt64,tyUInt..tyUInt64,tyBool,tyEnum}
|
baseKinds = {tyChar, tyInt..tyInt64, tyUInt..tyUInt64, tyBool, tyEnum}
|
||||||
parentKinds = {tyRange, tyOrdinal, tyGenericInst, tyAlias, tySink, tyDistinct}
|
parentKinds = {tyRange, tyOrdinal, tyGenericInst, tyAlias, tySink, tyDistinct}
|
||||||
result = (t.kind in baseKinds and (not t.enumHasHoles or allowEnumWithHoles)) or
|
result = (t.kind in baseKinds and (not t.enumHasHoles or allowEnumWithHoles)) or
|
||||||
(t.kind in parentKinds and isOrdinalType(t.lastSon, allowEnumWithHoles))
|
(t.kind in parentKinds and isOrdinalType(t.lastSon, allowEnumWithHoles))
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#[
|
#[
|
||||||
|
|
||||||
|
- introduce Phi nodes to complete the SSA representation
|
||||||
- the analysis has to take 'break', 'continue' and 'raises' into account
|
- the analysis has to take 'break', 'continue' and 'raises' into account
|
||||||
- We need to map arrays to Z3 and test for something like 'forall(i, (i in 3..4) -> (a[i] > 3))'
|
- We need to map arrays to Z3 and test for something like 'forall(i, (i in 3..4) -> (a[i] > 3))'
|
||||||
- We need teach DrNim what 'inc', 'dec' and 'swap' mean, for example
|
- We need teach DrNim what 'inc', 'dec' and 'swap' mean, for example
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} =
|
||||||
yield res
|
yield res
|
||||||
if res == b: break
|
if res == b: break
|
||||||
dec(res, step)
|
dec(res, step)
|
||||||
elif T is IntLikeForCount:
|
elif T is IntLikeForCount and T is Ordinal:
|
||||||
var res = int(a)
|
var res = int(a)
|
||||||
while res >= int(b):
|
while res >= int(b):
|
||||||
yield T(res)
|
yield T(res)
|
||||||
|
|
@ -52,7 +52,7 @@ when defined(nimNewRoof):
|
||||||
## for i in countup(2, 9, 3):
|
## for i in countup(2, 9, 3):
|
||||||
## echo i # => 2; 5; 8
|
## echo i # => 2; 5; 8
|
||||||
mixin inc
|
mixin inc
|
||||||
when T is IntLikeForCount:
|
when T is IntLikeForCount and T is Ordinal:
|
||||||
var res = int(a)
|
var res = int(a)
|
||||||
while res <= int(b):
|
while res <= int(b):
|
||||||
yield T(res)
|
yield T(res)
|
||||||
|
|
@ -73,7 +73,7 @@ when defined(nimNewRoof):
|
||||||
## for i in 3 .. 7:
|
## for i in 3 .. 7:
|
||||||
## echo i # => 3; 4; 5; 6; 7
|
## echo i # => 3; 4; 5; 6; 7
|
||||||
mixin inc
|
mixin inc
|
||||||
when T is IntLikeForCount:
|
when T is IntLikeForCount and T is Ordinal:
|
||||||
var res = int(a)
|
var res = int(a)
|
||||||
while res <= int(b):
|
while res <= int(b):
|
||||||
yield T(res)
|
yield T(res)
|
||||||
|
|
@ -138,7 +138,7 @@ else: # not defined(nimNewRoof)
|
||||||
##
|
##
|
||||||
## for i in countup(2, 9, 3):
|
## for i in countup(2, 9, 3):
|
||||||
## echo i # => 2; 5; 8
|
## echo i # => 2; 5; 8
|
||||||
when T is IntLikeForCount:
|
when T is IntLikeForCount and T is Ordinal:
|
||||||
var res = int(a)
|
var res = int(a)
|
||||||
while res <= int(b):
|
while res <= int(b):
|
||||||
yield T(res)
|
yield T(res)
|
||||||
|
|
@ -159,7 +159,7 @@ else: # not defined(nimNewRoof)
|
||||||
## for i in 3 .. 7:
|
## for i in 3 .. 7:
|
||||||
## echo i # => 3; 4; 5; 6; 7
|
## echo i # => 3; 4; 5; 6; 7
|
||||||
mixin inc
|
mixin inc
|
||||||
when T is IntLikeForCount:
|
when T is IntLikeForCount and T is Ordinal:
|
||||||
var res = int(a)
|
var res = int(a)
|
||||||
while res <= int(b):
|
while res <= int(b):
|
||||||
yield T(res)
|
yield T(res)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue