parent
fc858927f0
commit
cefa16ae77
2 changed files with 17 additions and 9 deletions
|
|
@ -1827,7 +1827,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
of nkBind:
|
of nkBind:
|
||||||
Message(n.info, warnDeprecated, "bind")
|
Message(n.info, warnDeprecated, "bind")
|
||||||
result = semExpr(c, n.sons[0], flags)
|
result = semExpr(c, n.sons[0], flags)
|
||||||
of nkTypeOfExpr:
|
of nkTypeOfExpr, nkTupleTy, nkRefTy..nkEnumTy:
|
||||||
var typ = semTypeNode(c, n, nil).skipTypes({tyTypeDesc})
|
var typ = semTypeNode(c, n, nil).skipTypes({tyTypeDesc})
|
||||||
result = symNodeFromType(c, typ, n.info)
|
result = symNodeFromType(c, typ, n.info)
|
||||||
of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit:
|
of nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit:
|
||||||
|
|
|
||||||
|
|
@ -165,27 +165,34 @@ proc fixupProcTypeR(c: PContext, genericType: PType,
|
||||||
of tyOpenArray, tyArray, tySet, tySequence, tyTuple, tyProc,
|
of tyOpenArray, tyArray, tySet, tySequence, tyTuple, tyProc,
|
||||||
tyPtr, tyVar, tyRef, tyOrdinal, tyRange, tyVarargs:
|
tyPtr, tyVar, tyRef, tyOrdinal, tyRange, tyVarargs:
|
||||||
if genericType.sons == nil: return
|
if genericType.sons == nil: return
|
||||||
|
var head = 0
|
||||||
for i in 0 .. <genericType.sons.len:
|
for i in 0 .. <genericType.sons.len:
|
||||||
let changed = fixupProcTypeR(c, genericType.sons[i], inst)
|
let changed = fixupProcTypeR(c, genericType.sons[i], inst)
|
||||||
if changed != genericType.sons[i]:
|
if changed != genericType.sons[i]:
|
||||||
if result == genericType:
|
if result == genericType:
|
||||||
# the first detected change initializes the result
|
# the first detected change initializes the result
|
||||||
result = copyType(genericType, genericType.owner, true)
|
result = copyType(genericType, genericType.owner, false)
|
||||||
if genericType.n != nil:
|
if genericType.n != nil:
|
||||||
result.n = copyTree(genericType.n)
|
result.n = copyTree(genericType.n)
|
||||||
result.sons[i] = changed
|
if changed.kind == tyEmpty:
|
||||||
|
result.sons[i..i] = []
|
||||||
|
if result.n != nil: result.n.sons[i..i] = []
|
||||||
|
continue
|
||||||
|
let changed = changed.skipIntLit
|
||||||
|
result.sons[head] = changed
|
||||||
if result.n != nil:
|
if result.n != nil:
|
||||||
if result.n.kind == nkRecList:
|
if result.n.kind == nkRecList:
|
||||||
result.n.sons[i].typ = changed
|
result.n.sons[head].typ = changed
|
||||||
if result.n.kind == nkFormalParams:
|
if result.n.kind == nkFormalParams:
|
||||||
if i == 0:
|
if i == 0:
|
||||||
nil
|
nil
|
||||||
else:
|
else:
|
||||||
let origParam = result.n.sons[i].sym
|
let origParam = result.n.sons[head].sym
|
||||||
var param = copySym(origParam)
|
var param = copySym(origParam)
|
||||||
param.typ = changed
|
param.typ = changed
|
||||||
param.ast = origParam.ast
|
param.ast = origParam.ast
|
||||||
result.n.sons[i] = newSymNode(param)
|
result.n.sons[head] = newSymNode(param)
|
||||||
|
inc head
|
||||||
|
|
||||||
of tyGenericInvokation:
|
of tyGenericInvokation:
|
||||||
result = newTypeWithSons(c, tyGenericInvokation, genericType.sons)
|
result = newTypeWithSons(c, tyGenericInvokation, genericType.sons)
|
||||||
|
|
@ -198,6 +205,7 @@ proc fixupProcTypeR(c: PContext, genericType: PType,
|
||||||
proc fixupProcType(c: PContext, genericType: PType,
|
proc fixupProcType(c: PContext, genericType: PType,
|
||||||
inst: TInstantiation): PType =
|
inst: TInstantiation): PType =
|
||||||
result = copyType(genericType, genericType.owner, false)
|
result = copyType(genericType, genericType.owner, false)
|
||||||
|
result = fixupProcTypeR(c, result, inst)
|
||||||
for i in 0 .. <result.sons.len:
|
for i in 0 .. <result.sons.len:
|
||||||
result.sons[i] = fixupProcTypeR(c, result.sons[i], inst)
|
result.sons[i] = fixupProcTypeR(c, result.sons[i], inst)
|
||||||
|
|
||||||
|
|
@ -230,7 +238,7 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
|
||||||
var entry = TInstantiation.new
|
var entry = TInstantiation.new
|
||||||
entry.sym = result
|
entry.sym = result
|
||||||
instantiateGenericParamList(c, n.sons[genericParamsPos], pt, entry[])
|
instantiateGenericParamList(c, n.sons[genericParamsPos], pt, entry[])
|
||||||
result.typ = fixupProcType(c, fn.typ, entry[])
|
result.typ = fixupProcTypeR(c, fn.typ, entry[])
|
||||||
n.sons[genericParamsPos] = ast.emptyNode
|
n.sons[genericParamsPos] = ast.emptyNode
|
||||||
var oldPrc = GenericCacheGet(fn, entry[])
|
var oldPrc = GenericCacheGet(fn, entry[])
|
||||||
if oldPrc == nil:
|
if oldPrc == nil:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue