better overloading capabilities for 'shallowCopy'; little bugfix for 'system.compiles'
This commit is contained in:
parent
087b8621d3
commit
8c62903429
2 changed files with 15 additions and 12 deletions
|
|
@ -1137,8 +1137,8 @@ proc semCompiles(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
msgs.gErrorMax = high(int)
|
msgs.gErrorMax = high(int)
|
||||||
|
|
||||||
# open a scope for temporary symbol inclusions:
|
# open a scope for temporary symbol inclusions:
|
||||||
openScope(c.tab)
|
|
||||||
let oldTos = c.tab.tos
|
let oldTos = c.tab.tos
|
||||||
|
openScope(c.tab)
|
||||||
let oldOwnerLen = len(gOwners)
|
let oldOwnerLen = len(gOwners)
|
||||||
let oldGenerics = c.generics
|
let oldGenerics = c.generics
|
||||||
let oldContextLen = msgs.getInfoContextLen()
|
let oldContextLen = msgs.getInfoContextLen()
|
||||||
|
|
@ -1153,7 +1153,6 @@ proc semCompiles(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
except ERecoverableError:
|
except ERecoverableError:
|
||||||
nil
|
nil
|
||||||
# undo symbol table changes (as far as it's possible):
|
# undo symbol table changes (as far as it's possible):
|
||||||
closeScope(c.tab)
|
|
||||||
c.generics = oldGenerics
|
c.generics = oldGenerics
|
||||||
c.InGenericContext = oldInGenericContext
|
c.InGenericContext = oldInGenericContext
|
||||||
c.InUnrolledContext = oldInUnrolledContext
|
c.InUnrolledContext = oldInUnrolledContext
|
||||||
|
|
@ -1165,6 +1164,17 @@ proc semCompiles(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
msgs.gErrorCounter = oldErrorCount
|
msgs.gErrorCounter = oldErrorCount
|
||||||
msgs.gErrorMax = oldErrorMax
|
msgs.gErrorMax = oldErrorMax
|
||||||
|
|
||||||
|
proc semShallowCopy(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
|
if sonsLen(n) == 3:
|
||||||
|
# XXX ugh this is really a hack: shallowCopy() can be overloaded only
|
||||||
|
# with procs that take not 2 parameters:
|
||||||
|
result = newNodeI(nkFastAsgn, n.info)
|
||||||
|
result.add(n[1])
|
||||||
|
result.add(n[2])
|
||||||
|
result = semAsgn(c, result)
|
||||||
|
else:
|
||||||
|
result = semDirectOp(c, n, flags)
|
||||||
|
|
||||||
proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
# this is a hotspot in the compiler!
|
# this is a hotspot in the compiler!
|
||||||
result = n
|
result = n
|
||||||
|
|
@ -1178,16 +1188,7 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
of mIs: result = semIs(c, setMs(n, s))
|
of mIs: result = semIs(c, setMs(n, s))
|
||||||
of mOf: result = semOf(c, setMs(n, s))
|
of mOf: result = semOf(c, setMs(n, s))
|
||||||
of mEcho: result = semEcho(c, setMs(n, s))
|
of mEcho: result = semEcho(c, setMs(n, s))
|
||||||
of mShallowCopy:
|
of mShallowCopy: result = semShallowCopy(c, n, flags)
|
||||||
if sonsLen(n) == 3:
|
|
||||||
# XXX ugh this is really a hack: shallowCopy() can be overloaded only
|
|
||||||
# with procs that take not 2 parameters:
|
|
||||||
result = newNodeI(nkFastAsgn, n.info)
|
|
||||||
result.add(n[1])
|
|
||||||
result.add(n[2])
|
|
||||||
result = semAsgn(c, result)
|
|
||||||
else:
|
|
||||||
result = semDirectOp(c, n, flags)
|
|
||||||
of mExpandToAst: result = semExpandToAst(c, n, s, flags)
|
of mExpandToAst: result = semExpandToAst(c, n, s, flags)
|
||||||
else: result = semDirectOp(c, n, flags)
|
else: result = semDirectOp(c, n, flags)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ proc semOrd(c: PContext, n: PNode): PNode =
|
||||||
result.typ = makeRangeType(c, firstOrd(n.sons[1].typ),
|
result.typ = makeRangeType(c, firstOrd(n.sons[1].typ),
|
||||||
lastOrd(n.sons[1].typ), n.info)
|
lastOrd(n.sons[1].typ), n.info)
|
||||||
|
|
||||||
|
proc semShallowCopy(c: PContext, n: PNode, flags: TExprFlags): PNode
|
||||||
proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
||||||
flags: TExprFlags): PNode =
|
flags: TExprFlags): PNode =
|
||||||
case n[0].sym.magic
|
case n[0].sym.magic
|
||||||
|
|
@ -55,5 +56,6 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
||||||
result.typ = getSysType(tyString)
|
result.typ = getSysType(tyString)
|
||||||
of mInstantiationInfo: result = semInstantiationInfo(c, n)
|
of mInstantiationInfo: result = semInstantiationInfo(c, n)
|
||||||
of mOrd: result = semOrd(c, n)
|
of mOrd: result = semOrd(c, n)
|
||||||
|
of mShallowCopy: result = semShallowCopy(c, n, flags)
|
||||||
else: result = n
|
else: result = n
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue