code cleanup: there is no tyOptRef
This commit is contained in:
parent
15c208cd29
commit
721bf7188b
14 changed files with 36 additions and 47 deletions
|
|
@ -365,7 +365,7 @@ type
|
|||
tyInt, tyInt8, tyInt16, tyInt32, tyInt64, # signed integers
|
||||
tyFloat, tyFloat32, tyFloat64, tyFloat128,
|
||||
tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64,
|
||||
tyOptAsRef, tySink, tyLent,
|
||||
tyOwned, tySink, tyLent,
|
||||
tyVarargs,
|
||||
tyUncheckedArray
|
||||
# An array with boundaries [0,+∞]
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ proc scopeMangledParam(p: BProc; param: PSym) =
|
|||
|
||||
const
|
||||
irrelevantForBackend = {tyGenericBody, tyGenericInst, tyGenericInvocation,
|
||||
tyDistinct, tyRange, tyStatic, tyAlias, tySink, tyInferred}
|
||||
tyDistinct, tyRange, tyStatic, tyAlias, tySink,
|
||||
tyInferred, tyOwned}
|
||||
|
||||
proc typeName(typ: PType): Rope =
|
||||
let typ = typ.skipTypes(irrelevantForBackend)
|
||||
|
|
@ -145,7 +146,7 @@ proc mapType(conf: ConfigRef; typ: PType): TCTypeKind =
|
|||
doAssert typ.isResolvedUserTypeClass
|
||||
return mapType(conf, typ.lastSon)
|
||||
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal,
|
||||
tyTypeDesc, tyAlias, tySink, tyInferred:
|
||||
tyTypeDesc, tyAlias, tySink, tyInferred, tyOwned:
|
||||
result = mapType(conf, lastSon(typ))
|
||||
of tyEnum:
|
||||
if firstOrd(conf, typ) < 0:
|
||||
|
|
@ -158,7 +159,7 @@ proc mapType(conf: ConfigRef; typ: PType): TCTypeKind =
|
|||
of 8: result = ctInt64
|
||||
else: result = ctInt32
|
||||
of tyRange: result = mapType(conf, typ.sons[0])
|
||||
of tyPtr, tyVar, tyLent, tyRef, tyOptAsRef:
|
||||
of tyPtr, tyVar, tyLent, tyRef:
|
||||
var base = skipTypes(typ.lastSon, typedescInst)
|
||||
case base.kind
|
||||
of tyOpenArray, tyArray, tyVarargs, tyUncheckedArray: result = ctPtrToArray
|
||||
|
|
@ -633,7 +634,7 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
|||
excl(check, t.id)
|
||||
return
|
||||
case t.kind
|
||||
of tyRef, tyOptAsRef, tyPtr, tyVar, tyLent:
|
||||
of tyRef, tyPtr, tyVar, tyLent:
|
||||
var star = if t.kind == tyVar and tfVarIsPtr notin origTyp.flags and
|
||||
compileToCpp(m): "&" else: "*"
|
||||
var et = origTyp.skipTypes(abstractInst).lastSon
|
||||
|
|
@ -844,7 +845,7 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
|||
of 1, 2, 4, 8: addf(m.s[cfsTypes], "typedef NU$2 $1;$n", [result, rope(s*8)])
|
||||
else: addf(m.s[cfsTypes], "typedef NU8 $1[$2];$n",
|
||||
[result, rope(getSize(m.config, t))])
|
||||
of tyGenericInst, tyDistinct, tyOrdinal, tyTypeDesc, tyAlias, tySink,
|
||||
of tyGenericInst, tyDistinct, tyOrdinal, tyTypeDesc, tyAlias, tySink, tyOwned,
|
||||
tyUserTypeClass, tyUserTypeClassInst, tyInferred:
|
||||
result = getTypeDescAux(m, lastSon(t), check)
|
||||
else:
|
||||
|
|
@ -1219,7 +1220,7 @@ proc genTypeInfo(m: BModule, t: PType; info: TLineInfo): Rope =
|
|||
if m.config.selectedGC >= gcMarkAndSweep:
|
||||
let markerProc = genTraverseProc(m, origType, sig)
|
||||
addf(m.s[cfsTypeInit3], "$1.marker = $2;$n", [result, markerProc])
|
||||
of tyRef, tyOptAsRef:
|
||||
of tyRef:
|
||||
genTypeInfoAux(m, t, t, result, info)
|
||||
if m.config.selectedGC >= gcMarkAndSweep:
|
||||
let markerProc = genTraverseProc(m, origType, sig)
|
||||
|
|
|
|||
|
|
@ -194,14 +194,13 @@ proc mapType(typ: PType): TJSTypeKind =
|
|||
tyAnd, tyOr, tyNot, tyAnything, tyVoid:
|
||||
result = etyNone
|
||||
of tyGenericInst, tyInferred, tyAlias, tyUserTypeClass, tyUserTypeClassInst,
|
||||
tySink:
|
||||
tySink, tyOwned:
|
||||
result = mapType(typ.lastSon)
|
||||
of tyStatic:
|
||||
if t.n != nil: result = mapType(lastSon t)
|
||||
else: result = etyNone
|
||||
of tyProc: result = etyProc
|
||||
of tyCString: result = etyString
|
||||
of tyOptAsRef: doAssert(false, "mapType")
|
||||
|
||||
proc mapType(p: PProc; typ: PType): TJSTypeKind =
|
||||
result = mapType(typ)
|
||||
|
|
|
|||
|
|
@ -269,9 +269,8 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
|||
tyTypeDesc, tyGenericInvocation, tyForward:
|
||||
internalError(c.graph.config, c.info, "assignment requested for type: " & typeToString(t))
|
||||
of tyOrdinal, tyRange, tyInferred,
|
||||
tyGenericInst, tyStatic, tyVar, tyLent, tyAlias, tySink:
|
||||
tyGenericInst, tyStatic, tyVar, tyLent, tyAlias, tySink, tyOwned:
|
||||
liftBodyAux(c, lastSon(t), body, x, y)
|
||||
of tyOptAsRef: internalError(c.graph.config, "liftBodyAux")
|
||||
|
||||
proc newProcType(info: TLineInfo; owner: PSym): PType =
|
||||
result = newType(tyProc, owner)
|
||||
|
|
|
|||
|
|
@ -1854,6 +1854,7 @@ proc processMagicType(c: PContext, m: PSym) =
|
|||
case m.name.s
|
||||
of "lent": setMagicType(c.config, m, tyLent, c.config.target.ptrSize)
|
||||
of "sink": setMagicType(c.config, m, tySink, szUncomputedSize)
|
||||
of "owned": setMagicType(c.config, m, tyOwned, c.config.target.ptrSize)
|
||||
else: localError(c.config, m.info, errTypeExpected)
|
||||
else: localError(c.config, m.info, errTypeExpected)
|
||||
|
||||
|
|
|
|||
|
|
@ -1054,7 +1054,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
|||
result = a.sym.position == b.sym.position
|
||||
of tyGenericInvocation, tyGenericBody, tySequence,
|
||||
tyOpenArray, tySet, tyRef, tyPtr, tyVar, tyLent, tySink, tyUncheckedArray,
|
||||
tyArray, tyProc, tyVarargs, tyOrdinal, tyTypeClasses, tyOpt:
|
||||
tyArray, tyProc, tyVarargs, tyOrdinal, tyTypeClasses, tyOpt, tyOwned:
|
||||
cycleCheck()
|
||||
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
||||
result = sameChildrenAux(a, b, c)
|
||||
|
|
@ -1077,7 +1077,6 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
|||
cycleCheck()
|
||||
result = sameTypeAux(a.lastSon, b.lastSon, c)
|
||||
of tyNone: result = false
|
||||
of tyOptAsRef: result = false
|
||||
|
||||
proc sameBackendType*(x, y: PType): bool =
|
||||
var c = initSameTypeClosure()
|
||||
|
|
@ -1275,7 +1274,11 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
|||
# for now same as error node; we say it's a valid type as it should
|
||||
# prevent cascading errors:
|
||||
result = nil
|
||||
of tyOptAsRef: result = t
|
||||
of tyOwned:
|
||||
if t.len == 1 and t.sons[0].kind in {tyRef, tyPtr}:
|
||||
result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
|
||||
else:
|
||||
result = t
|
||||
|
||||
proc typeAllowed*(t: PType, kind: TSymKind; flags: TTypeAllowedFlags = {}): PType =
|
||||
# returns 'nil' on success and otherwise the part of the type that is
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
|
|||
result.add atomicType("static", mNone)
|
||||
if t.n != nil:
|
||||
result.add t.n.copyTree
|
||||
of tyOptAsRef: assert(false, "mapTypeToAstX")
|
||||
of tyOwned: result = mapTypeToBracket("owned", mBuiltinType, t, info)
|
||||
|
||||
proc opMapTypeToAst*(cache: IdentCache; t: PType; info: TLineInfo): PNode =
|
||||
result = mapTypeToAstX(cache, t, info, inst=false, allowRecursionX=true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue