optimizations for system.compiles
This commit is contained in:
parent
1c6f14deee
commit
8413772063
3 changed files with 25 additions and 16 deletions
|
|
@ -69,6 +69,10 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
||||||
InternalError(n.info, "x.state is not csMatch")
|
InternalError(n.info, "x.state is not csMatch")
|
||||||
#writeMatches(best)
|
#writeMatches(best)
|
||||||
#writeMatches(alt)
|
#writeMatches(alt)
|
||||||
|
if c.inCompilesContext > 0:
|
||||||
|
# quick error message for performance of 'compiles' built-in:
|
||||||
|
LocalError(n.Info, errAmbiguousCallXYZ, "")
|
||||||
|
else:
|
||||||
var args = "("
|
var args = "("
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i > 1: add(args, ", ")
|
if i > 1: add(args, ", ")
|
||||||
|
|
|
||||||
|
|
@ -608,6 +608,10 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
initCandidate(m, t)
|
initCandidate(m, t)
|
||||||
matches(c, n, nOrig, m)
|
matches(c, n, nOrig, m)
|
||||||
if m.state != csMatch:
|
if m.state != csMatch:
|
||||||
|
if c.inCompilesContext > 0:
|
||||||
|
# speed up error generation:
|
||||||
|
GlobalError(n.Info, errTypeMismatch, "")
|
||||||
|
else:
|
||||||
var msg = msgKindToString(errTypeMismatch)
|
var msg = msgKindToString(errTypeMismatch)
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i > 1: add(msg, ", ")
|
if i > 1: add(msg, ", ")
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ proc getNotFoundError*(c: PContext, n: PNode): string =
|
||||||
# Gives a detailed error message; this is separated from semOverloadedCall,
|
# Gives a detailed error message; this is separated from semOverloadedCall,
|
||||||
# as semOverlodedCall is already pretty slow (and we need this information
|
# as semOverlodedCall is already pretty slow (and we need this information
|
||||||
# only in case of an error).
|
# only in case of an error).
|
||||||
|
if c.InCompilesContext > 0: return ""
|
||||||
result = msgKindToString(errTypeMismatch)
|
result = msgKindToString(errTypeMismatch)
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
#debug(n.sons[i].typ)
|
#debug(n.sons[i].typ)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue