prepare for upcoming parsing change of unary operators

This commit is contained in:
Araq 2015-03-22 02:13:53 +01:00
commit a541be8935
8 changed files with 97 additions and 97 deletions

View file

@ -143,7 +143,7 @@ proc importForwarded(c: PContext, n: PNode, exceptSet: IntSet) =
of nkExportExceptStmt: of nkExportExceptStmt:
localError(n.info, errGenerated, "'export except' not implemented") localError(n.info, errGenerated, "'export except' not implemented")
else: else:
for i in 0 ..safeLen(n)-1: for i in 0..safeLen(n)-1:
importForwarded(c, n.sons[i], exceptSet) importForwarded(c, n.sons[i], exceptSet)
proc importModuleAs(n: PNode, realModule: PSym): PSym = proc importModuleAs(n: PNode, realModule: PSym): PSym =

View file

@ -120,7 +120,7 @@ proc freezeMutableRope*(r: PRope) {.inline.} =
r.length = r.data.len r.length = r.data.len
var var
cache: array[0..2048*2 -1, PRope] cache: array[0..2048*2 - 1, PRope]
proc resetRopeCache* = proc resetRopeCache* =
for i in low(cache)..high(cache): for i in low(cache)..high(cache):

View file

@ -228,7 +228,7 @@ proc semArrayIndex(c: PContext, n: PNode): PType =
if not isOrdinalType(e.typ.lastSon): if not isOrdinalType(e.typ.lastSon):
localError(n[1].info, errOrdinalTypeExpected) localError(n[1].info, errOrdinalTypeExpected)
result = makeRangeWithStaticExpr(c, e) result = makeRangeWithStaticExpr(c, e)
if c.inGenericContext >0: result.flags.incl tfUnresolved if c.inGenericContext > 0: result.flags.incl tfUnresolved
elif e.kind in nkCallKinds and hasGenericArguments(e): elif e.kind in nkCallKinds and hasGenericArguments(e):
if not isOrdinalType(e.typ): if not isOrdinalType(e.typ):
localError(n[1].info, errOrdinalTypeExpected) localError(n[1].info, errOrdinalTypeExpected)

View file

@ -434,7 +434,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
result = "int literal(" & $t.n.intVal & ")" result = "int literal(" & $t.n.intVal & ")"
of tyGenericBody, tyGenericInst, tyGenericInvocation: of tyGenericBody, tyGenericInst, tyGenericInvocation:
result = typeToString(t.sons[0]) & '[' result = typeToString(t.sons[0]) & '['
for i in countup(1, sonsLen(t) -1 -ord(t.kind != tyGenericInvocation)): for i in countup(1, sonsLen(t)-1-ord(t.kind != tyGenericInvocation)):
if i > 1: add(result, ", ") if i > 1: add(result, ", ")
add(result, typeToString(t.sons[i], preferGenericArg)) add(result, typeToString(t.sons[i], preferGenericArg))
add(result, ']') add(result, ']')

View file

@ -734,14 +734,14 @@ proc basename*(a: NimNode): NimNode =
of nnkIdent: return a of nnkIdent: return a
of nnkPostfix, nnkPrefix: return a[1] of nnkPostfix, nnkPrefix: return a[1]
else: else:
quit "Do not know how to get basename of ("& treeRepr(a) &")\n"& repr(a) quit "Do not know how to get basename of (" & treeRepr(a) & ")\n" & repr(a)
proc `basename=`*(a: NimNode; val: string) {.compileTime.}= proc `basename=`*(a: NimNode; val: string) {.compileTime.}=
case a.kind case a.kind
of nnkIdent: macros.`ident=`(a, !val) of nnkIdent: macros.`ident=`(a, !val)
of nnkPostfix, nnkPrefix: a[1] = ident(val) of nnkPostfix, nnkPrefix: a[1] = ident(val)
else: else:
quit "Do not know how to get basename of ("& treeRepr(a)& ")\n"& repr(a) quit "Do not know how to get basename of (" & treeRepr(a) & ")\n" & repr(a)
proc postfix*(node: NimNode; op: string): NimNode {.compileTime.} = proc postfix*(node: NimNode; op: string): NimNode {.compileTime.} =
newNimNode(nnkPostfix).add(ident(op), node) newNimNode(nnkPostfix).add(ident(op), node)

View file

@ -181,7 +181,7 @@ iterator filter*[T](seq1: seq[T], pred: proc(item: T): bool {.closure.}): T =
## for n in filter(numbers, proc (x: int): bool = x mod 2 == 0): ## for n in filter(numbers, proc (x: int): bool = x mod 2 == 0):
## echo($n) ## echo($n)
## # echoes 4, 8, 4 in separate lines ## # echoes 4, 8, 4 in separate lines
for i in countup(0, len(seq1) -1): for i in countup(0, len(seq1)-1):
var item = seq1[i] var item = seq1[i]
if pred(item): yield seq1[i] if pred(item): yield seq1[i]

View file

@ -192,7 +192,7 @@ proc `[]`*[A, B](t: Table[A, B], key: A): B =
proc mget*[A, B](t: var Table[A, B], key: A): var B = proc mget*[A, B](t: var Table[A, B], key: A): var B =
## retrieves the value at ``t[key]``. The value can be modified. ## retrieves the value at ``t[key]``. The value can be modified.
## If `key` is not in `t`, the ``EInvalidKey`` exception is raised. ## If `key` is not in `t`, the ``KeyError`` exception is raised.
var hc: THash var hc: THash
var index = rawGet(t, key, hc) var index = rawGet(t, key, hc)
if index >= 0: result = t.data[index].val if index >= 0: result = t.data[index].val

View file

@ -1,16 +1,16 @@
version 0.10.4 version 0.10.4
============== ==============
- improve the parser; deal with echo $foo gotcha
- improve GC-unsafety warnings - improve GC-unsafety warnings
- make 'nil' work for 'add' and 'len' - make 'nil' work for 'add' and 'len'
- disallow negative indexing
- improve the parser; deal with echo $foo gotcha
- add "all threads are blocked" detection to 'spawn' - add "all threads are blocked" detection to 'spawn'
version 1.0 version 1.0
=========== ===========
- disallow negative indexing
- figure out why C++ bootstrapping is so much slower - figure out why C++ bootstrapping is so much slower
- nimsuggest: auto-completion needs to work in 'class' macros - nimsuggest: auto-completion needs to work in 'class' macros
- improve the docs for inheritance - improve the docs for inheritance