fixes #127
This commit is contained in:
parent
b5d8e8bfaa
commit
04300542da
3 changed files with 30 additions and 6 deletions
|
|
@ -20,7 +20,8 @@ proc hasNoInit(call: PNode): bool {.inline.} =
|
||||||
|
|
||||||
proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc, pl: PRope) =
|
proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc, pl: PRope) =
|
||||||
var pl = pl
|
var pl = pl
|
||||||
var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
|
# getUniqueType() is too expensive here:
|
||||||
|
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||||
if typ.sons[0] != nil:
|
if typ.sons[0] != nil:
|
||||||
if isInvalidReturnType(typ.sons[0]):
|
if isInvalidReturnType(typ.sons[0]):
|
||||||
if sonsLen(ri) > 1: app(pl, ", ")
|
if sonsLen(ri) > 1: app(pl, ", ")
|
||||||
|
|
@ -124,7 +125,8 @@ proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
# this is a hotspot in the compiler
|
# this is a hotspot in the compiler
|
||||||
initLocExpr(p, ri.sons[0], op)
|
initLocExpr(p, ri.sons[0], op)
|
||||||
var pl = con(op.r, "(")
|
var pl = con(op.r, "(")
|
||||||
var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
|
# getUniqueType() is too expensive here:
|
||||||
|
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||||
assert(typ.kind == tyProc)
|
assert(typ.kind == tyProc)
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
for i in countup(1, length - 1):
|
for i in countup(1, length - 1):
|
||||||
|
|
@ -150,7 +152,8 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
var op: TLoc
|
var op: TLoc
|
||||||
initLocExpr(p, ri.sons[0], op)
|
initLocExpr(p, ri.sons[0], op)
|
||||||
var pl: PRope
|
var pl: PRope
|
||||||
var typ = ri.sons[0].typ
|
|
||||||
|
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||||
assert(typ.kind == tyProc)
|
assert(typ.kind == tyProc)
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
for i in countup(1, length - 1):
|
for i in countup(1, length - 1):
|
||||||
|
|
@ -201,7 +204,8 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||||
var op, a: TLoc
|
var op, a: TLoc
|
||||||
initLocExpr(p, ri.sons[0], op)
|
initLocExpr(p, ri.sons[0], op)
|
||||||
var pl: PRope = nil
|
var pl: PRope = nil
|
||||||
var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
|
# getUniqueType() is too expensive here:
|
||||||
|
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||||
assert(typ.kind == tyProc)
|
assert(typ.kind == tyProc)
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
|
|
@ -228,7 +232,8 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
|
||||||
var op, a: TLoc
|
var op, a: TLoc
|
||||||
initLocExpr(p, ri.sons[0], op)
|
initLocExpr(p, ri.sons[0], op)
|
||||||
var pl = toRope"["
|
var pl = toRope"["
|
||||||
var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
|
# getUniqueType() is too expensive here:
|
||||||
|
var typ = skipTypes(ri.sons[0].typ, abstractInst)
|
||||||
assert(typ.kind == tyProc)
|
assert(typ.kind == tyProc)
|
||||||
var length = sonsLen(ri)
|
var length = sonsLen(ri)
|
||||||
assert(sonsLen(typ) == sonsLen(typ.n))
|
assert(sonsLen(typ) == sonsLen(typ.n))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: "0false"
|
output: "0false12"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Test multiple generic instantiation of generic proc vars:
|
# Test multiple generic instantiation of generic proc vars:
|
||||||
|
|
@ -17,3 +17,20 @@ proc threadProcWrapper[TMsg]() =
|
||||||
threadProcWrapper[int]()
|
threadProcWrapper[int]()
|
||||||
threadProcWrapper[bool]()
|
threadProcWrapper[bool]()
|
||||||
|
|
||||||
|
type
|
||||||
|
TFilterProc[T,D] = proc (item: T, env:D): bool
|
||||||
|
|
||||||
|
proc filter[T,D](data: seq[T], env:D, pred: TFilterProc[T,D]): seq[T] =
|
||||||
|
result = @[]
|
||||||
|
for e in data:
|
||||||
|
if pred(e, env): result.add(e)
|
||||||
|
|
||||||
|
proc predTest(item: int, value: int): Bool =
|
||||||
|
return item <= value
|
||||||
|
|
||||||
|
proc test(data: seq[int], value: int): seq[int] =
|
||||||
|
return filter(data, value, predTest)
|
||||||
|
|
||||||
|
for x in items(test(@[1,2,3], 2)):
|
||||||
|
stdout.write(x)
|
||||||
|
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -1,6 +1,8 @@
|
||||||
version 0.9.0
|
version 0.9.0
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
- fix the installer
|
||||||
|
- implement 'gorge'
|
||||||
- make templates hygienic by default: try to gensym() everything in the 'block'
|
- make templates hygienic by default: try to gensym() everything in the 'block'
|
||||||
of a template
|
of a template
|
||||||
- ``bind`` for overloaded symbols does not work apparently
|
- ``bind`` for overloaded symbols does not work apparently
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue