bugfixes: objects still invalid for constants; fixed a typo concerning 'high' in eval context
This commit is contained in:
parent
5f018a5046
commit
7819b84475
8 changed files with 52 additions and 15 deletions
|
|
@ -641,7 +641,7 @@ proc evalHigh(c: PEvalContext, n: PNode): PNode =
|
||||||
result = evalAux(c, n.sons[1], {})
|
result = evalAux(c, n.sons[1], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
case skipTypes(n.sons[1].typ, abstractVar).kind
|
case skipTypes(n.sons[1].typ, abstractVar).kind
|
||||||
of tyOpenArray, tySequence: result = newIntNodeT(sonsLen(result), n)
|
of tyOpenArray, tySequence: result = newIntNodeT(sonsLen(result)-1, n)
|
||||||
of tyString: result = newIntNodeT(len(result.strVal) - 1, n)
|
of tyString: result = newIntNodeT(len(result.strVal) - 1, n)
|
||||||
else: InternalError(n.info, "evalHigh")
|
else: InternalError(n.info, "evalHigh")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,9 @@ proc instantiateBody(c: PContext, n: PNode, result: PSym) =
|
||||||
if result.kind in {skProc, skMethod, skConverter}:
|
if result.kind in {skProc, skMethod, skConverter}:
|
||||||
addResult(c, result.typ.sons[0], n.info)
|
addResult(c, result.typ.sons[0], n.info)
|
||||||
addResultNode(c, n)
|
addResultNode(c, n)
|
||||||
n.sons[bodyPos] = semStmtScope(c, n.sons[bodyPos])
|
var b = semStmtScope(c, n.sons[bodyPos])
|
||||||
if result.kind == skIterator:
|
# XXX Bad hack for tests/titer2 and tests/tactiontable
|
||||||
# XXX Bad hack for tests/titer2:
|
n.sons[bodyPos] = transform(c.module, b)
|
||||||
n.sons[bodyPos] = transform(c.module, n.sons[bodyPos])
|
|
||||||
#echo "code instantiated ", result.name.s
|
#echo "code instantiated ", result.name.s
|
||||||
excl(result.flags, sfForward)
|
excl(result.flags, sfForward)
|
||||||
popProcCon(c)
|
popProcCon(c)
|
||||||
|
|
|
||||||
|
|
@ -736,11 +736,12 @@ proc processTransf(context: PPassContext, n: PNode): PNode =
|
||||||
# Note: For interactive mode we cannot call 'passes.skipCodegen' and skip
|
# Note: For interactive mode we cannot call 'passes.skipCodegen' and skip
|
||||||
# this step! We have to rely that the semantic pass transforms too errornous
|
# this step! We have to rely that the semantic pass transforms too errornous
|
||||||
# nodes into an empty node.
|
# nodes into an empty node.
|
||||||
if passes.skipCodegen(n) or context.fromCache: return n
|
if passes.skipCodegen(n) or context.fromCache or nfTransf in n.flags: return n
|
||||||
var c = PTransf(context)
|
var c = PTransf(context)
|
||||||
pushTransCon(c, newTransCon(getCurrOwner(c)))
|
pushTransCon(c, newTransCon(getCurrOwner(c)))
|
||||||
result = PNode(transform(c, n))
|
result = PNode(transform(c, n))
|
||||||
popTransCon(c)
|
popTransCon(c)
|
||||||
|
incl(result.flags, nfTransf)
|
||||||
|
|
||||||
proc openTransf(module: PSym, filename: string): PPassContext =
|
proc openTransf(module: PSym, filename: string): PPassContext =
|
||||||
var n: PTransf
|
var n: PTransf
|
||||||
|
|
@ -762,6 +763,10 @@ proc transfPass(): TPass =
|
||||||
result.close = processTransf # we need to process generics too!
|
result.close = processTransf # we need to process generics too!
|
||||||
|
|
||||||
proc transform*(module: PSym, n: PNode): PNode =
|
proc transform*(module: PSym, n: PNode): PNode =
|
||||||
var c = openTransf(module, "")
|
if nfTransf in n.flags:
|
||||||
result = processTransf(c, n)
|
result = n
|
||||||
|
else:
|
||||||
|
var c = openTransf(module, "")
|
||||||
|
result = processTransf(c, n)
|
||||||
|
incl(result.flags, nfTransf)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,8 +280,8 @@ proc isGBCRef(t: PType): bool =
|
||||||
result = t.kind in {tyRef, tySequence, tyString}
|
result = t.kind in {tyRef, tySequence, tyString}
|
||||||
|
|
||||||
proc containsGarbageCollectedRef(typ: PType): bool =
|
proc containsGarbageCollectedRef(typ: PType): bool =
|
||||||
# returns true if typ contains a reference, sequence or string (all the things
|
# returns true if typ contains a reference, sequence or string (all the
|
||||||
# that are garbage-collected)
|
# things that are garbage-collected)
|
||||||
result = searchTypeFor(typ, isGBCRef)
|
result = searchTypeFor(typ, isGBCRef)
|
||||||
|
|
||||||
proc isTyRef(t: PType): bool =
|
proc isTyRef(t: PType): bool =
|
||||||
|
|
@ -869,10 +869,11 @@ proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind): bool =
|
||||||
result = typeAllowedAux(marker, t.sons[i], kind)
|
result = typeAllowedAux(marker, t.sons[i], kind)
|
||||||
if not result: break
|
if not result: break
|
||||||
of tyObject:
|
of tyObject:
|
||||||
|
if kind == skConst: return false
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in countup(0, sonsLen(t) - 1):
|
||||||
result = typeAllowedAux(marker, t.sons[i], skVar)
|
result = typeAllowedAux(marker, t.sons[i], kind)
|
||||||
if not result: break
|
if not result: break
|
||||||
if result and t.n != nil: result = typeAllowedNode(marker, t.n, skVar)
|
if result and t.n != nil: result = typeAllowedNode(marker, t.n, kind)
|
||||||
|
|
||||||
proc typeAllowed(t: PType, kind: TSymKind): bool =
|
proc typeAllowed(t: PType, kind: TSymKind): bool =
|
||||||
var marker = InitIntSet()
|
var marker = InitIntSet()
|
||||||
|
|
|
||||||
3
lib/pure/actors.cfg
Normal file
3
lib/pure/actors.cfg
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# to shut up the tester:
|
||||||
|
--threads:on
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ proc action3(arg: string) =
|
||||||
proc action4(arg: string) =
|
proc action4(arg: string) =
|
||||||
echo "action 4 ", arg
|
echo "action 4 ", arg
|
||||||
|
|
||||||
const
|
var
|
||||||
actionTable = {
|
actionTable = {
|
||||||
"A": action1,
|
"A": action1,
|
||||||
"B": action2,
|
"B": action2,
|
||||||
|
|
|
||||||
28
tests/reject/tactiontable2.nim
Normal file
28
tests/reject/tactiontable2.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
discard """
|
||||||
|
line: 21
|
||||||
|
errormsg: "invalid type: 'TTable'"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import tables
|
||||||
|
|
||||||
|
proc action1(arg: string) =
|
||||||
|
echo "action 1 ", arg
|
||||||
|
|
||||||
|
proc action2(arg: string) =
|
||||||
|
echo "action 2 ", arg
|
||||||
|
|
||||||
|
proc action3(arg: string) =
|
||||||
|
echo "action 3 ", arg
|
||||||
|
|
||||||
|
proc action4(arg: string) =
|
||||||
|
echo "action 4 ", arg
|
||||||
|
|
||||||
|
const
|
||||||
|
actionTable = {
|
||||||
|
"A": action1,
|
||||||
|
"B": action2,
|
||||||
|
"C": action3,
|
||||||
|
"D": action4}.toTable
|
||||||
|
|
||||||
|
actionTable["C"]("arg")
|
||||||
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -19,6 +19,7 @@ version 0.9.0
|
||||||
--> solve by implicit conversion from varargs to openarray
|
--> solve by implicit conversion from varargs to openarray
|
||||||
- change overloading resolution
|
- change overloading resolution
|
||||||
- implement closures; implement proper coroutines
|
- implement closures; implement proper coroutines
|
||||||
|
- implement ``partial`` pragma for partial evaluation
|
||||||
- implicit invokation of `items` seems nice
|
- implicit invokation of `items` seems nice
|
||||||
- we need to support iteration of 2 different data structures in parallel
|
- we need to support iteration of 2 different data structures in parallel
|
||||||
- make exceptions compatible with C++ exceptions
|
- make exceptions compatible with C++ exceptions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue