preparations for 0.8.12

This commit is contained in:
Araq
2011-07-10 15:48:13 +02:00
parent 2565ff8dde
commit 5b96eaa953
81 changed files with 2355 additions and 826 deletions

0
compiler/ccgthreadvars.nim Normal file → Executable file
View File

View File

@@ -52,12 +52,12 @@ proc CloseScope*(tab: var TSymTab) =
if (tab.tos > len(tab.stack)): InternalError("CloseScope")
var it: TTabIter
var s = InitTabIter(it, tab.stack[tab.tos-1])
while s != nil:
while s != nil:
if sfForward in s.flags:
LocalError(s.info, errImplOfXexpected, getSymRepr(s))
elif ({sfUsed, sfInInterface} * s.flags == {}) and
(optHints in s.options): # BUGFIX: check options in s!
if not (s.kind in {skForVar, skParam, skMethod, skUnknown}):
elif {sfUsed, sfInInterface} * s.flags == {} and optHints in s.options:
# BUGFIX: check options in s!
if s.kind notin {skForVar, skParam, skMethod, skUnknown, skGenericParam}:
Message(s.info, hintXDeclaredButNotUsed, getSymRepr(s))
s = NextIter(it, tab.stack[tab.tos-1])
astalgo.rawCloseScope(tab)

View File

@@ -522,6 +522,7 @@ proc rawMessage*(msg: TMsgKind, args: openarray[string]) =
of warnMin..warnMax:
if not (optWarns in gOptions): return
if not (msg in gNotes): return
writeContext(unknownLineInfo())
frmt = rawWarningFormat
inc(gWarnCounter)
of hintMin..hintMax:
@@ -552,6 +553,7 @@ proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string,
lastError = info
of warnMin..warnMax:
ignoreMsg = optWarns notin gOptions or msg notin gNotes
if not ignoreMsg: writeContext(info)
frmt = posWarningFormat
inc(gWarnCounter)
of hintMin..hintMax:

View File

@@ -1,7 +1,7 @@
#
#
# The Nimrod Compiler
# (c) Copyright 2010 Andreas Rumpf
# (c) Copyright 2011 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
@@ -15,6 +15,6 @@ const
defaultAsmMarkerSymbol* = '!'
VersionMajor* = 0
VersionMinor* = 8
VersionPatch* = 11
VersionPatch* = 12
VersionAsString* = $VersionMajor & "." & $VersionMinor & "." & $VersionPatch

View File

@@ -19,6 +19,8 @@ proc instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable) =
var q = a.sym
if not (q.typ.kind in {tyTypeDesc, tyGenericParam}): continue
var s = newSym(skType, q.name, getCurrOwner())
s.info = q.info
incl(s.flags, sfUsed)
var t = PType(IdTableGet(pt, q.typ))
if t == nil:
LocalError(a.info, errCannotInstantiateX, s.name.s)

View File

@@ -205,7 +205,7 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
incl(result.flags, sfGlobal)
else:
result = semIdentWithPragma(c, kind, n, {})
proc semVar(c: PContext, n: PNode): PNode =
var b: PNode
result = copyNode(n)

36
compiler/semthreads.nim Normal file → Executable file
View File

@@ -112,7 +112,7 @@ proc analyseSym(c: PProcCtx, n: PNode): TThreadOwner =
if sfGlobal in v.flags:
if sfThreadVar in v.flags:
result = toMine
elif containsTyRef(v.typ):
elif containsGarbageCollectedRef(v.typ):
result = toTheirs
of skTemp, skForVar: result = toNil
of skConst: result = toMine
@@ -126,7 +126,8 @@ proc analyseSym(c: PProcCtx, n: PNode): TThreadOwner =
proc lvalueSym(n: PNode): PNode =
result = n
while result.kind in {nkDotExpr, nkBracketExpr, nkDerefExpr, nkHiddenDeref}:
while result.kind in {nkDotExpr, nkCheckedFieldExpr,
nkBracketExpr, nkDerefExpr, nkHiddenDeref}:
result = result.sons[0]
proc writeAccess(c: PProcCtx, n: PNode, owner: TThreadOwner) =
@@ -138,7 +139,18 @@ proc writeAccess(c: PProcCtx, n: PNode, owner: TThreadOwner) =
var lastOwner = analyseSym(c, a)
case lastOwner
of toNil:
c.mapping[v.id] = owner # fine, toNil can be overwritten
# fine, toNil can be overwritten
var newOwner: TThreadOwner
if sfGlobal in v.flags:
newOwner = owner
elif containsTyRef(v.typ):
# ``var local = gNode`` --> ok, but ``local`` is theirs!
newOwner = owner
else:
# ``var local = gString`` --> string copy: ``local`` is mine!
newOwner = toMine
# XXX BUG what if the tuple contains both ``tyRef`` and ``tyString``?
c.mapping[v.id] = newOwner
of toVoid, toUndefined: InternalError(n.info, "writeAccess")
of toTheirs: Message(n.info, warnWriteToForeignHeap)
of toMine:
@@ -146,7 +158,7 @@ proc writeAccess(c: PProcCtx, n: PNode, owner: TThreadOwner) =
Message(n.info, warnDifferentHeaps)
else:
# we could not backtrack to a concrete symbol, but that's fine:
var lastOwner = analyseSym(c, n)
var lastOwner = analyse(c, n)
case lastOwner
of toNil: nil # fine, toNil can be overwritten
of toVoid, toUndefined: InternalError(n.info, "writeAccess")
@@ -178,7 +190,7 @@ proc analyseCall(c: PProcCtx, n: PNode): TThreadOwner =
pushInfoContext(n.info)
result = analyse(newCtx, prc.ast.sons[codePos])
if prc.ast.sons[codePos].kind == nkEmpty and
{sfNoSideEffect, sfThread} * prc.flags == {}:
{sfNoSideEffect, sfThread, sfImportc} * prc.flags == {}:
Message(n.info, warnAnalysisLoophole, renderTree(n))
if prc.typ.sons[0] != nil:
if prc.ast.len > resultPos:
@@ -228,7 +240,7 @@ template aggregateOwner(result, ana: expr) =
var a = ana # eval once
if result != a:
if result == toNil: result = a
else: Message(n.info, warnDifferentHeaps)
elif a != toNil: Message(n.info, warnDifferentHeaps)
proc analyseArgs(c: PProcCtx, n: PNode, start = 1) =
for i in start..n.len-1: discard analyse(c, n[i])
@@ -241,7 +253,14 @@ proc analyseOp(c: PProcCtx, n: PNode): TThreadOwner =
else:
var prc = n[0].sym
case prc.magic
of mNone: result = analyseCall(c, n)
of mNone:
if sfSystemModule in prc.owner.flags:
# System module proc does no harm :-)
analyseArgs(c, n)
if prc.typ.sons[0] == nil: result = toVoid
else: result = toNil
else:
result = analyseCall(c, n)
of mNew, mNewFinalize, mNewSeq, mSetLengthStr, mSetLengthSeq,
mAppendSeqElem, mReset, mAppendStrCh, mAppendStrStr:
writeAccess(c, n[1], toMine)
@@ -260,8 +279,7 @@ proc analyseOp(c: PProcCtx, n: PNode): TThreadOwner =
analyseArgs(c, n)
result = toMine
else:
# don't recurse, but check args; NOTE: This is essential that
# ``mCreateThread`` is handled here to avoid the recursion
# don't recurse, but check args:
analyseArgs(c, n)
if prc.typ.sons[0] == nil: result = toVoid
else: result = toNil