Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
f540a3683f
17 changed files with 218 additions and 43 deletions
|
|
@ -601,8 +601,18 @@ proc generateHeaders(m: BModule) =
|
|||
addf(m.s[cfsHeaders], "#include \"$1\"$N", [rope(it)])
|
||||
else:
|
||||
addf(m.s[cfsHeaders], "#include $1$N", [rope(it)])
|
||||
add(m.s[cfsHeaders], "#undef LANGUAGE_C" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef MIPSEB" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef MIPSEL" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef PPC" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef R3000" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef R4000" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef i386" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef linux" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef mips" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef near" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef powerpc" & tnl)
|
||||
add(m.s[cfsHeaders], "#undef unix" & tnl)
|
||||
|
||||
proc initFrame(p: BProc, procname, filename: Rope): Rope =
|
||||
discard cgsym(p.module, "nimFrame")
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ proc isCastable(dst, src: PType): bool =
|
|||
result = false
|
||||
elif typeAllowed(dst, skParam) != nil:
|
||||
result = false
|
||||
elif dst.kind == tyProc and dst.callConv == ccClosure:
|
||||
result = src.kind == tyProc and src.callConv == ccClosure
|
||||
else:
|
||||
result = (dstSize >= srcSize) or
|
||||
(skipTypes(dst, abstractInst).kind in IntegralTypes) or
|
||||
|
|
@ -227,7 +229,10 @@ proc semCast(c: PContext, n: PNode): PNode =
|
|||
if tfHasMeta in targetType.flags:
|
||||
localError(n.sons[0].info, errCastToANonConcreteType, $targetType)
|
||||
if not isCastable(targetType, castedExpr.typ):
|
||||
localError(n.info, errExprCannotBeCastToX, $targetType)
|
||||
let tar = $targetType
|
||||
let alt = typeToString(targetType, preferDesc)
|
||||
let msg = if tar != alt: tar & "=" & alt else: tar
|
||||
localError(n.info, errExprCannotBeCastToX, msg)
|
||||
result = newNodeI(nkCast, n.info)
|
||||
result.typ = targetType
|
||||
addSon(result, copyTree(n.sons[0]))
|
||||
|
|
|
|||
|
|
@ -88,7 +88,8 @@ proc sameInstantiation(a, b: TInstantiation): bool =
|
|||
if a.concreteTypes.len == b.concreteTypes.len:
|
||||
for i in 0..a.concreteTypes.high:
|
||||
if not compareTypes(a.concreteTypes[i], b.concreteTypes[i],
|
||||
flags = {ExactTypeDescValues}): return
|
||||
flags = {ExactTypeDescValues,
|
||||
ExactGcSafety}): return
|
||||
result = true
|
||||
|
||||
proc genericCacheGet(genericSym: PSym, entry: TInstantiation;
|
||||
|
|
|
|||
|
|
@ -218,12 +218,11 @@ proc listGcUnsafety(s: PSym; onlyWarning: bool; cycleCheck: var IntSet) =
|
|||
message(s.info, msgKind,
|
||||
"'$#' is not GC-safe as it calls '$#'" %
|
||||
[s.name.s, u.name.s])
|
||||
of skParam:
|
||||
of skParam, skForVar:
|
||||
message(s.info, msgKind,
|
||||
"'$#' is not GC-safe as it performs an indirect call via '$#'" %
|
||||
[s.name.s, u.name.s])
|
||||
else:
|
||||
internalAssert u.kind == skUnknown
|
||||
message(u.info, msgKind,
|
||||
"'$#' is not GC-safe as it performs an indirect call here" % s.name.s)
|
||||
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ proc instCopyType*(cl: var TReplTypeVars, t: PType): PType =
|
|||
proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||
# tyGenericInvocation[A, tyGenericInvocation[A, B]]
|
||||
# is difficult to handle:
|
||||
const eqFlags = eqTypeFlags + {tfGcSafe}
|
||||
var body = t.sons[0]
|
||||
if body.kind != tyGenericBody: internalError(cl.info, "no generic body")
|
||||
var header: PType = t
|
||||
|
|
@ -252,7 +253,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
|||
else:
|
||||
result = searchInstTypes(t)
|
||||
|
||||
if result != nil and eqTypeFlags*result.flags == eqTypeFlags*t.flags: return
|
||||
if result != nil and eqFlags*result.flags == eqFlags*t.flags: return
|
||||
for i in countup(1, sonsLen(t) - 1):
|
||||
var x = t.sons[i]
|
||||
if x.kind in {tyGenericParam}:
|
||||
|
|
@ -267,7 +268,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
|||
if header != t:
|
||||
# search again after first pass:
|
||||
result = searchInstTypes(header)
|
||||
if result != nil and eqTypeFlags*result.flags == eqTypeFlags*t.flags: return
|
||||
if result != nil and eqFlags*result.flags == eqFlags*t.flags: return
|
||||
else:
|
||||
header = instCopyType(cl, t)
|
||||
|
||||
|
|
|
|||
|
|
@ -139,6 +139,9 @@ proc getProcHeader*(sym: PSym; prefer: TPreferedDesc = preferName): string =
|
|||
add(result, ')')
|
||||
if n.sons[0].typ != nil:
|
||||
result.add(": " & typeToString(n.sons[0].typ, prefer))
|
||||
result.add "[declared in "
|
||||
result.add($sym.info)
|
||||
result.add "]"
|
||||
|
||||
proc elemType*(t: PType): PType =
|
||||
assert(t != nil)
|
||||
|
|
@ -688,6 +691,7 @@ type
|
|||
ExactTypeDescValues
|
||||
ExactGenericParams
|
||||
ExactConstraints
|
||||
ExactGcSafety
|
||||
AllowCommonBase
|
||||
|
||||
TTypeCmpFlags* = set[TTypeCmpFlag]
|
||||
|
|
@ -976,6 +980,8 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
|||
cycleCheck()
|
||||
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
||||
result = sameChildrenAux(a, b, c) and sameFlags(a, b)
|
||||
if result and ExactGcSafety in c.flags:
|
||||
result = a.flags * {tfThread} == b.flags * {tfThread}
|
||||
if result and a.kind == tyProc:
|
||||
result = ((IgnoreCC in c.flags) or a.callConv == b.callConv) and
|
||||
((ExactConstraints notin c.flags) or sameConstraints(a.n, b.n))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue