added system.default in order to prevent the abstraction inversion that 'template default(T): untyped = (var x: T; x)' causes
This commit is contained in:
parent
2dc8a32324
commit
142a2d3551
7 changed files with 50 additions and 11 deletions
|
|
@ -910,6 +910,15 @@ proc genBindSym(c: PCtx; n: PNode; dest: var TDest) =
|
|||
c.gABC(n, opcNDynBindSym, dest, x, n.len)
|
||||
c.freeTempRange(x, n.len)
|
||||
|
||||
proc fitsRegister*(t: PType): bool =
|
||||
assert t != nil
|
||||
t.skipTypes(abstractInst-{tyTypeDesc}).kind in {
|
||||
tyRange, tyEnum, tyBool, tyInt..tyUInt64, tyChar}
|
||||
|
||||
proc ldNullOpcode(t: PType): TOpcode =
|
||||
assert t != nil
|
||||
if fitsRegister(t): opcLdNullReg else: opcLdNull
|
||||
|
||||
proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||
case m
|
||||
of mAnd: c.genAndOr(n, opcFJmp, dest)
|
||||
|
|
@ -1129,9 +1138,13 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
|||
of mReset:
|
||||
unused(c, n, dest)
|
||||
var d = c.genx(n.sons[1])
|
||||
# XXX use ldNullOpcode() here?
|
||||
c.gABx(n, opcLdNull, d, c.genType(n.sons[1].typ))
|
||||
c.gABx(n, opcNodeToReg, d, d)
|
||||
c.genAsgnPatch(n.sons[1], d)
|
||||
of mDefault:
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
c.gABx(n, ldNullOpcode(n.typ), dest, c.genType(n.typ))
|
||||
of mOf, mIs:
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
var tmp = c.genx(n.sons[1])
|
||||
|
|
@ -1332,11 +1345,6 @@ const
|
|||
tyFloat, tyFloat32, tyFloat64, tyFloat128,
|
||||
tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64}
|
||||
|
||||
proc fitsRegister*(t: PType): bool =
|
||||
assert t != nil
|
||||
t.skipTypes(abstractInst-{tyTypeDesc}).kind in {
|
||||
tyRange, tyEnum, tyBool, tyInt..tyUInt64, tyChar}
|
||||
|
||||
proc unneededIndirection(n: PNode): bool =
|
||||
n.typ.skipTypes(abstractInstOwned-{tyTypeDesc}).kind == tyRef
|
||||
|
||||
|
|
@ -1766,10 +1774,6 @@ proc getNullValue(typ: PType, info: TLineInfo; conf: ConfigRef): PNode =
|
|||
globalError(conf, info, "cannot create null element for: " & $t.kind)
|
||||
result = newNodeI(nkEmpty, info)
|
||||
|
||||
proc ldNullOpcode(t: PType): TOpcode =
|
||||
assert t != nil
|
||||
if fitsRegister(t): opcLdNullReg else: opcLdNull
|
||||
|
||||
proc genVarSection(c: PCtx; n: PNode) =
|
||||
for a in n:
|
||||
if a.kind == nkCommentStmt: continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue