made compiler more robust for idetools support
This commit is contained in:
parent
735c005375
commit
b0c11d3efb
11 changed files with 94 additions and 53 deletions
|
|
@ -208,9 +208,10 @@ proc getModule(s: PSym): PSym =
|
||||||
|
|
||||||
proc getSymFromList(list: PNode, ident: PIdent, start: int = 0): PSym =
|
proc getSymFromList(list: PNode, ident: PIdent, start: int = 0): PSym =
|
||||||
for i in countup(start, sonsLen(list) - 1):
|
for i in countup(start, sonsLen(list) - 1):
|
||||||
if list.sons[i].kind != nkSym: InternalError(list.info, "getSymFromList")
|
if list.sons[i].kind == nkSym:
|
||||||
result = list.sons[i].sym
|
result = list.sons[i].sym
|
||||||
if result.name.id == ident.id: return
|
if result.name.id == ident.id: return
|
||||||
|
else: InternalError(list.info, "getSymFromList")
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
proc hashNode(p: PObject): THash =
|
proc hashNode(p: PObject): THash =
|
||||||
|
|
@ -576,7 +577,9 @@ proc StrTableContains(t: TStrTable, n: PSym): bool =
|
||||||
proc StrTableRawInsert(data: var TSymSeq, n: PSym) =
|
proc StrTableRawInsert(data: var TSymSeq, n: PSym) =
|
||||||
var h: THash = n.name.h and high(data)
|
var h: THash = n.name.h and high(data)
|
||||||
while data[h] != nil:
|
while data[h] != nil:
|
||||||
if data[h] == n: InternalError(n.info, "StrTableRawInsert: " & n.name.s)
|
if data[h] == n:
|
||||||
|
InternalError(n.info, "StrTableRawInsert: " & n.name.s)
|
||||||
|
return
|
||||||
h = nextTry(h, high(data))
|
h = nextTry(h, high(data))
|
||||||
assert(data[h] == nil)
|
assert(data[h] == nil)
|
||||||
data[h] = n
|
data[h] = n
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ proc pushStackFrame*(c: PEvalContext, t: PStackFrame) {.inline.} =
|
||||||
c.tos = t
|
c.tos = t
|
||||||
|
|
||||||
proc popStackFrame*(c: PEvalContext) {.inline.} =
|
proc popStackFrame*(c: PEvalContext) {.inline.} =
|
||||||
if c.tos == nil: InternalError("popStackFrame")
|
if c.tos != nil: c.tos = c.tos.next
|
||||||
c.tos = c.tos.next
|
else: InternalError("popStackFrame")
|
||||||
|
|
||||||
proc evalMacroCall*(c: PEvalContext, n: PNode, sym: PSym): PNode
|
proc evalMacroCall*(c: PEvalContext, n: PNode, sym: PSym): PNode
|
||||||
proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode
|
proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode
|
||||||
|
|
@ -315,11 +315,13 @@ proc evalCall(c: PEvalContext, n: PNode): PNode =
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
prc = result
|
prc = result
|
||||||
# bind the actual params to the local parameter of a new binding
|
# bind the actual params to the local parameter of a new binding
|
||||||
if prc.kind != nkSym: InternalError(n.info, "evalCall " & n.renderTree)
|
if prc.kind != nkSym:
|
||||||
|
InternalError(n.info, "evalCall " & n.renderTree)
|
||||||
|
return
|
||||||
d.prc = prc.sym
|
d.prc = prc.sym
|
||||||
if prc.sym.kind notin {skProc, skConverter, skMacro}:
|
if prc.sym.kind notin {skProc, skConverter, skMacro}:
|
||||||
InternalError(n.info, "evalCall")
|
InternalError(n.info, "evalCall")
|
||||||
|
return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
result = evalAux(c, n.sons[i], {})
|
result = evalAux(c, n.sons[i], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
|
|
@ -551,13 +553,13 @@ proc evalOr(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
|
||||||
if result.kind != nkIntLit: InternalError(n.info, "evalOr")
|
if result.kind != nkIntLit: InternalError(n.info, "evalOr")
|
||||||
if result.intVal == 0: result = evalAux(c, n.sons[2], {})
|
elif result.intVal == 0: result = evalAux(c, n.sons[2], {})
|
||||||
|
|
||||||
proc evalAnd(c: PEvalContext, n: PNode): PNode =
|
proc evalAnd(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
|
||||||
if result.kind != nkIntLit: InternalError(n.info, "evalAnd")
|
if result.kind != nkIntLit: InternalError(n.info, "evalAnd")
|
||||||
if result.intVal != 0: result = evalAux(c, n.sons[2], {})
|
elif result.intVal != 0: result = evalAux(c, n.sons[2], {})
|
||||||
|
|
||||||
proc evalNew(c: PEvalContext, n: PNode): PNode =
|
proc evalNew(c: PEvalContext, n: PNode): PNode =
|
||||||
#if c.mode == emOptimize: return raiseCannotEval(c, n.info)
|
#if c.mode == emOptimize: return raiseCannotEval(c, n.info)
|
||||||
|
|
@ -720,7 +722,9 @@ proc evalSetLengthSeq(c: PEvalContext, n: PNode): PNode =
|
||||||
result = evalAux(c, n.sons[2], {})
|
result = evalAux(c, n.sons[2], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
var b = result
|
var b = result
|
||||||
if a.kind != nkBracket: InternalError(n.info, "evalSetLengthSeq")
|
if a.kind != nkBracket:
|
||||||
|
InternalError(n.info, "evalSetLengthSeq")
|
||||||
|
return
|
||||||
var newLen = int(getOrdValue(b))
|
var newLen = int(getOrdValue(b))
|
||||||
var oldLen = sonsLen(a)
|
var oldLen = sonsLen(a)
|
||||||
setlen(a.sons, newLen)
|
setlen(a.sons, newLen)
|
||||||
|
|
@ -970,6 +974,7 @@ proc evalExpandToAst(c: PEvalContext, original: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
InternalError(macroCall.info,
|
InternalError(macroCall.info,
|
||||||
"ExpandToAst: expanded symbol is no macro or template")
|
"ExpandToAst: expanded symbol is no macro or template")
|
||||||
|
result = emptyNode
|
||||||
|
|
||||||
proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
var m = getMagic(n)
|
var m = getMagic(n)
|
||||||
|
|
@ -1080,7 +1085,7 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
result = newNodeIT(nkIntLit, n.info, n.typ)
|
result = newNodeIT(nkIntLit, n.info, n.typ)
|
||||||
case a.kind
|
case a.kind
|
||||||
of nkCharLit..nkInt64Lit: result.intVal = a.intVal
|
of nkCharLit..nkInt64Lit: result.intVal = a.intVal
|
||||||
else: InternalError(n.info, "no int value")
|
else: stackTrace(c, n, errFieldXNotFound, "intVal")
|
||||||
of mNFloatVal:
|
of mNFloatVal:
|
||||||
result = evalAux(c, n.sons[1], {})
|
result = evalAux(c, n.sons[1], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
|
|
@ -1088,15 +1093,15 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
result = newNodeIT(nkFloatLit, n.info, n.typ)
|
result = newNodeIT(nkFloatLit, n.info, n.typ)
|
||||||
case a.kind
|
case a.kind
|
||||||
of nkFloatLit..nkFloat64Lit: result.floatVal = a.floatVal
|
of nkFloatLit..nkFloat64Lit: result.floatVal = a.floatVal
|
||||||
else: InternalError(n.info, "no float value")
|
else: stackTrace(c, n, errFieldXNotFound, "floatVal")
|
||||||
of mNSymbol:
|
of mNSymbol:
|
||||||
result = evalAux(c, n.sons[1], {efLValue})
|
result = evalAux(c, n.sons[1], {efLValue})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
if result.kind != nkSym: InternalError(n.info, "no symbol")
|
if result.kind != nkSym: stackTrace(c, n, errFieldXNotFound, "symbol")
|
||||||
of mNIdent:
|
of mNIdent:
|
||||||
result = evalAux(c, n.sons[1], {})
|
result = evalAux(c, n.sons[1], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
if result.kind != nkIdent: InternalError(n.info, "no symbol")
|
if result.kind != nkIdent: stackTrace(c, n, errFieldXNotFound, "ident")
|
||||||
of mNGetType: result = evalAux(c, n.sons[1], {})
|
of mNGetType: result = evalAux(c, n.sons[1], {})
|
||||||
of mNStrVal:
|
of mNStrVal:
|
||||||
result = evalAux(c, n.sons[1], {})
|
result = evalAux(c, n.sons[1], {})
|
||||||
|
|
@ -1105,14 +1110,18 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
result = newNodeIT(nkStrLit, n.info, n.typ)
|
result = newNodeIT(nkStrLit, n.info, n.typ)
|
||||||
case a.kind
|
case a.kind
|
||||||
of nkStrLit..nkTripleStrLit: result.strVal = a.strVal
|
of nkStrLit..nkTripleStrLit: result.strVal = a.strVal
|
||||||
else: InternalError(n.info, "no string value")
|
else: stackTrace(c, n, errFieldXNotFound, "strVal")
|
||||||
of mNSetIntVal:
|
of mNSetIntVal:
|
||||||
result = evalAux(c, n.sons[1], {efLValue})
|
result = evalAux(c, n.sons[1], {efLValue})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
var a = result
|
var a = result
|
||||||
result = evalAux(c, n.sons[2], {})
|
result = evalAux(c, n.sons[2], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
a.intVal = result.intVal # XXX: exception handling?
|
if a.kind in {nkCharLit..nkInt64Lit} and
|
||||||
|
result.kind in {nkCharLit..nkInt64Lit}:
|
||||||
|
a.intVal = result.intVal
|
||||||
|
else:
|
||||||
|
stackTrace(c, n, errFieldXNotFound, "intVal")
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
of mNSetFloatVal:
|
of mNSetFloatVal:
|
||||||
result = evalAux(c, n.sons[1], {efLValue})
|
result = evalAux(c, n.sons[1], {efLValue})
|
||||||
|
|
@ -1120,7 +1129,11 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
var a = result
|
var a = result
|
||||||
result = evalAux(c, n.sons[2], {})
|
result = evalAux(c, n.sons[2], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
a.floatVal = result.floatVal # XXX: exception handling?
|
if a.kind in {nkFloatLit..nkFloat64Lit} and
|
||||||
|
result.kind in {nkFloatLit..nkFloat64Lit}:
|
||||||
|
a.floatVal = result.floatVal
|
||||||
|
else:
|
||||||
|
stackTrace(c, n, errFieldXNotFound, "floatVal")
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
of mNSetSymbol:
|
of mNSetSymbol:
|
||||||
result = evalAux(c, n.sons[1], {efLValue})
|
result = evalAux(c, n.sons[1], {efLValue})
|
||||||
|
|
@ -1128,7 +1141,10 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
var a = result
|
var a = result
|
||||||
result = evalAux(c, n.sons[2], {efLValue})
|
result = evalAux(c, n.sons[2], {efLValue})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
a.sym = result.sym # XXX: exception handling?
|
if a.kind == nkSym and result.kind == nkSym:
|
||||||
|
a.sym = result.sym
|
||||||
|
else:
|
||||||
|
stackTrace(c, n, errFieldXNotFound, "symbol")
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
of mNSetIdent:
|
of mNSetIdent:
|
||||||
result = evalAux(c, n.sons[1], {efLValue})
|
result = evalAux(c, n.sons[1], {efLValue})
|
||||||
|
|
@ -1136,7 +1152,10 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
var a = result
|
var a = result
|
||||||
result = evalAux(c, n.sons[2], {efLValue})
|
result = evalAux(c, n.sons[2], {efLValue})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
a.ident = result.ident # XXX: exception handling?
|
if a.kind == nkIdent and result.kind == nkIdent:
|
||||||
|
a.ident = result.ident
|
||||||
|
else:
|
||||||
|
stackTrace(c, n, errFieldXNotFound, "ident")
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
of mNSetType:
|
of mNSetType:
|
||||||
result = evalAux(c, n.sons[1], {efLValue})
|
result = evalAux(c, n.sons[1], {efLValue})
|
||||||
|
|
@ -1152,7 +1171,11 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
var a = result
|
var a = result
|
||||||
result = evalAux(c, n.sons[2], {})
|
result = evalAux(c, n.sons[2], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
a.strVal = result.strVal # XXX: exception handling?
|
|
||||||
|
if a.kind in {nkStrLit..nkTripleStrLit} and
|
||||||
|
result.kind in {nkStrLit..nkTripleStrLit}:
|
||||||
|
a.strVal = result.strVal
|
||||||
|
else: stackTrace(c, n, errFieldXNotFound, "strVal")
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
of mNNewNimNode:
|
of mNNewNimNode:
|
||||||
result = evalAux(c, n.sons[1], {})
|
result = evalAux(c, n.sons[1], {})
|
||||||
|
|
@ -1177,7 +1200,8 @@ proc evalMagicOrCall(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
|
||||||
if not (result.kind in {nkStrLit..nkTripleStrLit}):
|
if not (result.kind in {nkStrLit..nkTripleStrLit}):
|
||||||
InternalError(n.info, "no string node")
|
stackTrace(c, n, errFieldXNotFound, "strVal")
|
||||||
|
return
|
||||||
var a = result
|
var a = result
|
||||||
result = newNodeIT(nkIdent, n.info, n.typ)
|
result = newNodeIT(nkIdent, n.info, n.typ)
|
||||||
result.ident = getIdent(a.strVal)
|
result.ident = getIdent(a.strVal)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ proc getSymRepr*(s: PSym): string =
|
||||||
|
|
||||||
proc CloseScope*(tab: var TSymTab) =
|
proc CloseScope*(tab: var TSymTab) =
|
||||||
# check if all symbols have been used and defined:
|
# check if all symbols have been used and defined:
|
||||||
if tab.tos > len(tab.stack): InternalError("CloseScope")
|
if tab.tos > len(tab.stack):
|
||||||
|
InternalError("CloseScope")
|
||||||
|
return
|
||||||
var it: TTabIter
|
var it: TTabIter
|
||||||
var s = InitTabIter(it, tab.stack[tab.tos-1])
|
var s = InitTabIter(it, tab.stack[tab.tos-1])
|
||||||
var missingImpls = 0
|
var missingImpls = 0
|
||||||
|
|
@ -95,8 +97,8 @@ proc addDeclAt*(c: PContext, sym: PSym, at: Natural) =
|
||||||
proc AddInterfaceDeclAux(c: PContext, sym: PSym) =
|
proc AddInterfaceDeclAux(c: PContext, sym: PSym) =
|
||||||
if sfExported in sym.flags:
|
if sfExported in sym.flags:
|
||||||
# add to interface:
|
# add to interface:
|
||||||
if c.module == nil: InternalError(sym.info, "AddInterfaceDeclAux")
|
if c.module != nil: StrTableAdd(c.module.tab, sym)
|
||||||
StrTableAdd(c.module.tab, sym)
|
else: InternalError(sym.info, "AddInterfaceDeclAux")
|
||||||
#if getCurrOwner().kind == skModule: incl(sym.flags, sfGlobal)
|
#if getCurrOwner().kind == skModule: incl(sym.flags, sfGlobal)
|
||||||
|
|
||||||
proc addInterfaceDeclAt*(c: PContext, sym: PSym, at: Natural) =
|
proc addInterfaceDeclAt*(c: PContext, sym: PSym, at: Natural) =
|
||||||
|
|
@ -106,6 +108,7 @@ proc addInterfaceDeclAt*(c: PContext, sym: PSym, at: Natural) =
|
||||||
proc addOverloadableSymAt*(c: PContext, fn: PSym, at: Natural) =
|
proc addOverloadableSymAt*(c: PContext, fn: PSym, at: Natural) =
|
||||||
if fn.kind notin OverloadableSyms:
|
if fn.kind notin OverloadableSyms:
|
||||||
InternalError(fn.info, "addOverloadableSymAt")
|
InternalError(fn.info, "addOverloadableSymAt")
|
||||||
|
return
|
||||||
var check = StrTableGet(c.tab.stack[at], fn.name)
|
var check = StrTableGet(c.tab.stack[at], fn.name)
|
||||||
if check != nil and check.Kind notin OverloadableSyms:
|
if check != nil and check.Kind notin OverloadableSyms:
|
||||||
LocalError(fn.info, errAttemptToRedefine, fn.Name.s)
|
LocalError(fn.info, errAttemptToRedefine, fn.Name.s)
|
||||||
|
|
@ -138,7 +141,9 @@ proc lookUp*(c: PContext, n: PNode): PSym =
|
||||||
if result == nil:
|
if result == nil:
|
||||||
LocalError(n.info, errUndeclaredIdentifier, ident.s)
|
LocalError(n.info, errUndeclaredIdentifier, ident.s)
|
||||||
result = errorSym(n)
|
result = errorSym(n)
|
||||||
else: InternalError(n.info, "lookUp")
|
else:
|
||||||
|
InternalError(n.info, "lookUp")
|
||||||
|
return
|
||||||
if Contains(c.AmbiguousSymbols, result.id):
|
if Contains(c.AmbiguousSymbols, result.id):
|
||||||
LocalError(n.info, errUseQualifier, result.name.s)
|
LocalError(n.info, errUseQualifier, result.name.s)
|
||||||
if result.kind == skStub: loadStub(result)
|
if result.kind == skStub: loadStub(result)
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ proc CompileModule(filename: string, flags: TSymFlags): PSym =
|
||||||
rd = handleSymbolFile(result, f)
|
rd = handleSymbolFile(result, f)
|
||||||
if result.id < 0:
|
if result.id < 0:
|
||||||
InternalError("handleSymbolFile should have set the module\'s ID")
|
InternalError("handleSymbolFile should have set the module\'s ID")
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
result.id = getID()
|
result.id = getID()
|
||||||
processModule(result, f, nil, rd)
|
processModule(result, f, nil, rd)
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,10 @@ proc equalGenericParams(procA, procB: PNode): bool =
|
||||||
for i in countup(0, sonsLen(procA) - 1):
|
for i in countup(0, sonsLen(procA) - 1):
|
||||||
if procA.sons[i].kind != nkSym:
|
if procA.sons[i].kind != nkSym:
|
||||||
InternalError(procA.info, "equalGenericParams")
|
InternalError(procA.info, "equalGenericParams")
|
||||||
|
return
|
||||||
if procB.sons[i].kind != nkSym:
|
if procB.sons[i].kind != nkSym:
|
||||||
InternalError(procB.info, "equalGenericParams")
|
InternalError(procB.info, "equalGenericParams")
|
||||||
|
return
|
||||||
a = procA.sons[i].sym
|
a = procA.sons[i].sym
|
||||||
b = procB.sons[i].sym
|
b = procB.sons[i].sym
|
||||||
if (a.name.id != b.name.id) or not sameTypeOrNil(a.typ, b.typ): return
|
if (a.name.id != b.name.id) or not sameTypeOrNil(a.typ, b.typ): return
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,8 @@ proc ropef(frmt: TFormatStr, args: openarray[PRope]): PRope =
|
||||||
num = j
|
num = j
|
||||||
if j > high(args) + 1:
|
if j > high(args) + 1:
|
||||||
internalError("ropes: invalid format string $" & $(j))
|
internalError("ropes: invalid format string $" & $(j))
|
||||||
app(result, args[j - 1])
|
else:
|
||||||
|
app(result, args[j - 1])
|
||||||
of 'n':
|
of 'n':
|
||||||
if optLineDir notin gOptions: app(result, tnl)
|
if optLineDir notin gOptions: app(result, tnl)
|
||||||
inc i
|
inc i
|
||||||
|
|
@ -263,6 +264,7 @@ proc auxRopeEqualsFile(r: PRope, bin: var tfile, buf: Pointer): bool =
|
||||||
if r.data != nil:
|
if r.data != nil:
|
||||||
if r.length > bufSize:
|
if r.length > bufSize:
|
||||||
internalError("ropes: token too long")
|
internalError("ropes: token too long")
|
||||||
|
return
|
||||||
var readBytes = readBuffer(bin, buf, r.length)
|
var readBytes = readBuffer(bin, buf, r.length)
|
||||||
result = readBytes == r.length and
|
result = readBytes == r.length and
|
||||||
equalMem(buf, addr(r.data[0]), r.length) # BUGFIX
|
equalMem(buf, addr(r.data[0]), r.length) # BUGFIX
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,8 @@ proc addCodeForGenerics(c: PContext, n: PNode) =
|
||||||
if prc.kind in {skProc, skMethod, skConverter} and prc.magic == mNone:
|
if prc.kind in {skProc, skMethod, skConverter} and prc.magic == mNone:
|
||||||
if prc.ast == nil or prc.ast.sons[bodyPos] == nil:
|
if prc.ast == nil or prc.ast.sons[bodyPos] == nil:
|
||||||
InternalError(prc.info, "no code for " & prc.name.s)
|
InternalError(prc.info, "no code for " & prc.name.s)
|
||||||
addSon(n, prc.ast)
|
else:
|
||||||
|
addSon(n, prc.ast)
|
||||||
c.generics.lastGenericIdx = Len(c.generics.generics)
|
c.generics.lastGenericIdx = Len(c.generics.generics)
|
||||||
|
|
||||||
proc semExprNoFlags(c: PContext, n: PNode): PNode {.procvar.} =
|
proc semExprNoFlags(c: PContext, n: PNode): PNode {.procvar.} =
|
||||||
|
|
@ -160,7 +161,7 @@ proc semExprNoFlags(c: PContext, n: PNode): PNode {.procvar.} =
|
||||||
|
|
||||||
proc myOpen(module: PSym, filename: string): PPassContext =
|
proc myOpen(module: PSym, filename: string): PPassContext =
|
||||||
var c = newContext(module, filename)
|
var c = newContext(module, filename)
|
||||||
if (c.p != nil): InternalError(module.info, "sem.myOpen")
|
if c.p != nil: InternalError(module.info, "sem.myOpen")
|
||||||
c.semConstExpr = semConstExpr
|
c.semConstExpr = semConstExpr
|
||||||
c.semExpr = semExprNoFlags
|
c.semExpr = semExprNoFlags
|
||||||
c.semConstBoolExpr = semConstBoolExpr
|
c.semConstBoolExpr = semConstBoolExpr
|
||||||
|
|
@ -224,9 +225,8 @@ proc myClose(context: PPassContext, n: PNode): PNode =
|
||||||
var c = PContext(context)
|
var c = PContext(context)
|
||||||
closeScope(c.tab) # close module's scope
|
closeScope(c.tab) # close module's scope
|
||||||
rawCloseScope(c.tab) # imported symbols; don't check for unused ones!
|
rawCloseScope(c.tab) # imported symbols; don't check for unused ones!
|
||||||
if n == nil:
|
result = newNode(nkStmtList)
|
||||||
result = newNode(nkStmtList)
|
if n != nil:
|
||||||
else:
|
|
||||||
InternalError(n.info, "n is not nil") #result := n;
|
InternalError(n.info, "n is not nil") #result := n;
|
||||||
addCodeForGenerics(c, result)
|
addCodeForGenerics(c, result)
|
||||||
if c.module.ast != nil:
|
if c.module.ast != nil:
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
||||||
semRecordNodeAux(c, n.sons[0], check, pos, a, rectype)
|
semRecordNodeAux(c, n.sons[0], check, pos, a, rectype)
|
||||||
if a.sons[0].kind != nkSym:
|
if a.sons[0].kind != nkSym:
|
||||||
internalError("semRecordCase: dicriminant is no symbol")
|
internalError("semRecordCase: dicriminant is no symbol")
|
||||||
|
return
|
||||||
incl(a.sons[0].sym.flags, sfDiscriminant)
|
incl(a.sons[0].sym.flags, sfDiscriminant)
|
||||||
var covered: biggestInt = 0
|
var covered: biggestInt = 0
|
||||||
var typ = skipTypes(a.sons[0].Typ, abstractVar)
|
var typ = skipTypes(a.sons[0].Typ, abstractVar)
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,9 @@ template wholeSymTab(cond, section: expr) {.immediate.} =
|
||||||
|
|
||||||
proc suggestSymList(list: PNode, outputs: var int) =
|
proc suggestSymList(list: PNode, outputs: var int) =
|
||||||
for i in countup(0, sonsLen(list) - 1):
|
for i in countup(0, sonsLen(list) - 1):
|
||||||
if list.sons[i].kind != nkSym: InternalError(list.info, "getSymFromList")
|
if list.sons[i].kind == nkSym:
|
||||||
suggestField(list.sons[i].sym, outputs)
|
suggestField(list.sons[i].sym, outputs)
|
||||||
|
#else: InternalError(list.info, "getSymFromList")
|
||||||
|
|
||||||
proc suggestObject(n: PNode, outputs: var int) =
|
proc suggestObject(n: PNode, outputs: var int) =
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ proc getOpSym*(op: PNode): PSym =
|
||||||
result = nil
|
result = nil
|
||||||
else:
|
else:
|
||||||
if (sonsLen(op) <= 0): InternalError(op.info, "getOpSym")
|
if (sonsLen(op) <= 0): InternalError(op.info, "getOpSym")
|
||||||
if op.sons[0].Kind == nkSym: result = op.sons[0].sym
|
elif op.sons[0].Kind == nkSym: result = op.sons[0].sym
|
||||||
else: result = nil
|
else: result = nil
|
||||||
|
|
||||||
proc getMagic*(op: PNode): TMagic =
|
proc getMagic*(op: PNode): TMagic =
|
||||||
|
|
|
||||||
|
|
@ -121,11 +121,13 @@ proc getProcHeader(sym: PSym): string =
|
||||||
var n = sym.typ.n
|
var n = sym.typ.n
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
var p = n.sons[i]
|
var p = n.sons[i]
|
||||||
if p.kind != nkSym: InternalError("getProcHeader")
|
if p.kind == nkSym:
|
||||||
add(result, p.sym.name.s)
|
add(result, p.sym.name.s)
|
||||||
add(result, ": ")
|
add(result, ": ")
|
||||||
add(result, typeToString(p.sym.typ))
|
add(result, typeToString(p.sym.typ))
|
||||||
if i != sonsLen(n)-1: add(result, ", ")
|
if i != sonsLen(n)-1: add(result, ", ")
|
||||||
|
else:
|
||||||
|
InternalError("getProcHeader")
|
||||||
add(result, ')')
|
add(result, ')')
|
||||||
if n.sons[0].typ != nil: result.add(": " & typeToString(n.sons[0].typ))
|
if n.sons[0].typ != nil: result.add(": " & typeToString(n.sons[0].typ))
|
||||||
|
|
||||||
|
|
@ -680,12 +682,12 @@ proc sameTuple(a, b: PType, c: var TSameTypeClosure): bool =
|
||||||
if a.n != nil and b.n != nil and not c.ignoreTupleFields:
|
if a.n != nil and b.n != nil and not c.ignoreTupleFields:
|
||||||
for i in countup(0, sonsLen(a.n) - 1):
|
for i in countup(0, sonsLen(a.n) - 1):
|
||||||
# check field names:
|
# check field names:
|
||||||
if a.n.sons[i].kind != nkSym: InternalError(a.n.info, "sameTuple")
|
if a.n.sons[i].kind == nkSym and b.n.sons[i].kind == nkSym:
|
||||||
if b.n.sons[i].kind != nkSym: InternalError(b.n.info, "sameTuple")
|
var x = a.n.sons[i].sym
|
||||||
var x = a.n.sons[i].sym
|
var y = b.n.sons[i].sym
|
||||||
var y = b.n.sons[i].sym
|
result = x.name.id == y.name.id
|
||||||
result = x.name.id == y.name.id
|
if not result: break
|
||||||
if not result: break
|
else: InternalError(a.n.info, "sameTuple")
|
||||||
else:
|
else:
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
|
|
@ -1094,7 +1096,7 @@ proc getReturnType*(s: PSym): PType =
|
||||||
|
|
||||||
proc getSize(typ: PType): biggestInt =
|
proc getSize(typ: PType): biggestInt =
|
||||||
result = computeSize(typ)
|
result = computeSize(typ)
|
||||||
if result < 0: InternalError("getSize(" & $typ.kind & ')')
|
if result < 0: InternalError("getSize: " & $typ.kind)
|
||||||
|
|
||||||
|
|
||||||
proc containsGenericTypeIter(t: PType, closure: PObject): bool =
|
proc containsGenericTypeIter(t: PType, closure: PObject): bool =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue