wip
This commit is contained in:
parent
1ae5ba2536
commit
30b098fcaf
6 changed files with 10 additions and 8 deletions
|
|
@ -165,7 +165,7 @@ proc genGotoState(p: BProc, n: PNode) =
|
||||||
statesCounter = n[1].intVal
|
statesCounter = n[1].intVal
|
||||||
let prefix = if n.len == 3 and n[2].kind == nkStrLit: n[2].strVal.rope
|
let prefix = if n.len == 3 and n[2].kind == nkStrLit: n[2].strVal.rope
|
||||||
else: rope"STATE"
|
else: rope"STATE"
|
||||||
for i in 0 .. statesCounter:
|
for i in 0i64 .. statesCounter:
|
||||||
lineF(p, cpsStmts, "case $2: goto $1$2;$n", [prefix, rope(i)])
|
lineF(p, cpsStmts, "case $2: goto $1$2;$n", [prefix, rope(i)])
|
||||||
lineF(p, cpsStmts, "}$n", [])
|
lineF(p, cpsStmts, "}$n", [])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
considerQuotedIdent(fn).id notin ctx.toMixin:
|
considerQuotedIdent(fn).id notin ctx.toMixin:
|
||||||
errorUndeclaredIdentifier(c, n.info, fn.renderTree)
|
errorUndeclaredIdentifier(c, n.info, fn.renderTree)
|
||||||
|
|
||||||
var first = ord(withinConcept in flags)
|
var first = int ord(withinConcept in flags)
|
||||||
var mixinContext = false
|
var mixinContext = false
|
||||||
if s != nil:
|
if s != nil:
|
||||||
incl(s.flags, sfUsed)
|
incl(s.flags, sfUsed)
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,9 @@ proc semTypeTraits(c: PContext, n: PNode): PNode =
|
||||||
proc semOrd(c: PContext, n: PNode): PNode =
|
proc semOrd(c: PContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
let parType = n.sons[1].typ
|
let parType = n.sons[1].typ
|
||||||
if isOrdinalType(parType) or parType.kind == tySet:
|
if isOrdinalType(parType):
|
||||||
|
discard
|
||||||
|
elif parType.kind == tySet:
|
||||||
result.typ = makeRangeType(c, firstOrd(parType), lastOrd(parType), n.info)
|
result.typ = makeRangeType(c, firstOrd(parType), lastOrd(parType), n.info)
|
||||||
else:
|
else:
|
||||||
localError(n.info, errOrdinalTypeExpected)
|
localError(n.info, errOrdinalTypeExpected)
|
||||||
|
|
|
||||||
|
|
@ -1004,7 +1004,7 @@ proc checkForMetaFields(n: PNode) =
|
||||||
case t.kind
|
case t.kind
|
||||||
of tySequence, tySet, tyArray, tyOpenArray, tyVar, tyPtr, tyRef,
|
of tySequence, tySet, tyArray, tyOpenArray, tyVar, tyPtr, tyRef,
|
||||||
tyProc, tyGenericInvocation, tyGenericInst, tyAlias:
|
tyProc, tyGenericInvocation, tyGenericInst, tyAlias:
|
||||||
let start = ord(t.kind in {tyGenericInvocation, tyGenericInst})
|
let start = int ord(t.kind in {tyGenericInvocation, tyGenericInst})
|
||||||
for i in start ..< t.sons.len:
|
for i in start ..< t.sons.len:
|
||||||
checkMeta(t.sons[i])
|
checkMeta(t.sons[i])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||||
if n.len < 1:
|
if n.len < 1:
|
||||||
result = newConstraint(c, kind)
|
result = newConstraint(c, kind)
|
||||||
else:
|
else:
|
||||||
let isCall = ord(n.kind in nkCallKinds+{nkBracketExpr})
|
let isCall = int ord(n.kind in nkCallKinds+{nkBracketExpr})
|
||||||
let n = if n[0].kind == nkBracket: n[0] else: n
|
let n = if n[0].kind == nkBracket: n[0] else: n
|
||||||
checkMinSonsLen(n, 1)
|
checkMinSonsLen(n, 1)
|
||||||
var t = semTypeNode(c, n.lastSon, nil)
|
var t = semTypeNode(c, n.lastSon, nil)
|
||||||
|
|
|
||||||
|
|
@ -1985,7 +1985,7 @@ iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
|
||||||
yield res
|
yield res
|
||||||
dec(res, step)
|
dec(res, step)
|
||||||
|
|
||||||
iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} =
|
iterator countup*[T](a, b: T, step = 1): T {.inline.} =
|
||||||
## Counts from ordinal value `a` up to `b` (inclusive) with the given
|
## Counts from ordinal value `a` up to `b` (inclusive) with the given
|
||||||
## step count. `S`, `T` may be any ordinal type, `step` may only
|
## step count. `S`, `T` may be any ordinal type, `step` may only
|
||||||
## be positive. **Note**: This fails to count to ``high(int)`` if T = int for
|
## be positive. **Note**: This fails to count to ``high(int)`` if T = int for
|
||||||
|
|
@ -2001,7 +2001,7 @@ iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} =
|
||||||
yield res
|
yield res
|
||||||
inc(res, step)
|
inc(res, step)
|
||||||
|
|
||||||
iterator `..`*[S, T](a: S, b: T): T {.inline.} =
|
iterator `..`*[T](a, b: T): T {.inline.} =
|
||||||
## An alias for `countup`.
|
## An alias for `countup`.
|
||||||
when T is IntLikeForCount:
|
when T is IntLikeForCount:
|
||||||
var res = int(a)
|
var res = int(a)
|
||||||
|
|
@ -3433,7 +3433,7 @@ template `..<`*(a, b: untyped): untyped =
|
||||||
## a shortcut for 'a..pred(b)'.
|
## a shortcut for 'a..pred(b)'.
|
||||||
a .. pred(b)
|
a .. pred(b)
|
||||||
|
|
||||||
iterator `..<`*[S,T](a: S, b: T): T =
|
iterator `..<`*[T](a, b: T): T =
|
||||||
var i = T(a)
|
var i = T(a)
|
||||||
while i < b:
|
while i < b:
|
||||||
yield i
|
yield i
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue