diff options
Diffstat (limited to 'compiler/procfind.nim')
-rw-r--r-- | compiler/procfind.nim | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/compiler/procfind.nim b/compiler/procfind.nim index 7e8cd3b8a..f7dc6c379 100644 --- a/compiler/procfind.nim +++ b/compiler/procfind.nim @@ -14,14 +14,14 @@ import ast, astalgo, msgs, semdata, types, trees, strutils proc equalGenericParams(procA, procB: PNode): bool = - if len(procA) != len(procB): return false - for i in 0 ..< len(procA): - if procA.sons[i].kind != nkSym: + if procA.len != procB.len: return false + for i in 0..<procA.len: + if procA[i].kind != nkSym: return false - if procB.sons[i].kind != nkSym: + if procB[i].kind != nkSym: return false - let a = procA.sons[i].sym - let b = procB.sons[i].sym + let a = procA[i].sym + let b = procB[i].sym if a.name.id != b.name.id or not sameTypeOrNil(a.typ, b.typ, {ExactTypeDescValues}): return if a.ast != nil and b.ast != nil: @@ -40,11 +40,11 @@ proc searchForProcOld*(c: PContext, scope: PScope, fn: PSym): PSym = # not kept in the AST .. while result != nil: if result.kind == fn.kind and isGenericRoutine(result): - let genR = result.ast.sons[genericParamsPos] - let genF = fn.ast.sons[genericParamsPos] + let genR = result.ast[genericParamsPos] + let genF = fn.ast[genericParamsPos] if exprStructuralEquivalent(genR, genF) and - exprStructuralEquivalent(result.ast.sons[paramsPos], - fn.ast.sons[paramsPos]) and + exprStructuralEquivalent(result.ast[paramsPos], + fn.ast[paramsPos]) and equalGenericParams(genR, genF): return result = nextIdentIter(it, scope.symbols) @@ -95,15 +95,14 @@ proc searchForProc*(c: PContext, scope: PScope, fn: PSym): PSym = when false: proc paramsFitBorrow(child, parent: PNode): bool = - var length = len(child) result = false - if length == len(parent): - for i in 1 ..< length: - var m = child.sons[i].sym - var n = parent.sons[i].sym + if child.len == parent.len: + for i in 1..<child.len: + var m = child[i].sym + var n = parent[i].sym assert((m.kind == skParam) and (n.kind == skParam)) if not compareTypes(m.typ, n.typ, dcEqOrDistinctOf): return - if not compareTypes(child.sons[0].typ, parent.sons[0].typ, + if not compareTypes(child[0].typ, parent[0].typ, dcEqOrDistinctOf): return result = true @@ -116,7 +115,7 @@ when false: while result != nil: # watchout! result must not be the same as fn! if (result.Kind == fn.kind) and (result.id != fn.id): - if equalGenericParams(result.ast.sons[genericParamsPos], - fn.ast.sons[genericParamsPos]): + if equalGenericParams(result.ast[genericParamsPos], + fn.ast[genericParamsPos]): if paramsFitBorrow(fn.typ.n, result.typ.n): return result = NextIdentIter(it, scope.symbols) |