parent
82e424189e
commit
e30a08103d
10 changed files with 20 additions and 23 deletions
|
|
@ -434,8 +434,8 @@ type
|
||||||
# instantiation and prior to this it has the potential to
|
# instantiation and prior to this it has the potential to
|
||||||
# be any type.
|
# be any type.
|
||||||
|
|
||||||
tyOpt
|
tyOptDeprecated
|
||||||
# Builtin optional type
|
# deadcode: was `tyOpt`, Builtin optional type
|
||||||
|
|
||||||
tyVoid
|
tyVoid
|
||||||
# now different from tyEmpty, hurray!
|
# now different from tyEmpty, hurray!
|
||||||
|
|
@ -658,7 +658,7 @@ type
|
||||||
mNewString, mNewStringOfCap, mParseBiggestFloat,
|
mNewString, mNewStringOfCap, mParseBiggestFloat,
|
||||||
mMove, mWasMoved, mDestroy,
|
mMove, mWasMoved, mDestroy,
|
||||||
mDefault, mUnown, mAccessEnv, mReset,
|
mDefault, mUnown, mAccessEnv, mReset,
|
||||||
mArray, mOpenArray, mRange, mSet, mSeq, mOpt, mVarargs,
|
mArray, mOpenArray, mRange, mSet, mSeq, mVarargs,
|
||||||
mRef, mPtr, mVar, mDistinct, mVoid, mTuple,
|
mRef, mPtr, mVar, mDistinct, mVoid, mTuple,
|
||||||
mOrdinal,
|
mOrdinal,
|
||||||
mInt, mInt8, mInt16, mInt32, mInt64,
|
mInt, mInt8, mInt16, mInt32, mInt64,
|
||||||
|
|
@ -1492,7 +1492,7 @@ proc isGCedMem*(t: PType): bool {.inline.} =
|
||||||
t.kind == tyProc and t.callConv == ccClosure
|
t.kind == tyProc and t.callConv == ccClosure
|
||||||
|
|
||||||
proc propagateToOwner*(owner, elem: PType; propagateHasAsgn = true) =
|
proc propagateToOwner*(owner, elem: PType; propagateHasAsgn = true) =
|
||||||
const HaveTheirOwnEmpty = {tySequence, tyOpt, tySet, tyPtr, tyRef, tyProc}
|
const HaveTheirOwnEmpty = {tySequence, tySet, tyPtr, tyRef, tyProc}
|
||||||
owner.flags = owner.flags + (elem.flags * {tfHasMeta, tfTriggersCompileTime})
|
owner.flags = owner.flags + (elem.flags * {tfHasMeta, tfTriggersCompileTime})
|
||||||
if tfNotNil in elem.flags:
|
if tfNotNil in elem.flags:
|
||||||
if owner.kind in {tyGenericInst, tyGenericBody, tyGenericInvocation}:
|
if owner.kind in {tyGenericInst, tyGenericBody, tyGenericInvocation}:
|
||||||
|
|
@ -1505,7 +1505,7 @@ proc propagateToOwner*(owner, elem: PType; propagateHasAsgn = true) =
|
||||||
if mask != {} and propagateHasAsgn:
|
if mask != {} and propagateHasAsgn:
|
||||||
let o2 = owner.skipTypes({tyGenericInst, tyAlias, tySink})
|
let o2 = owner.skipTypes({tyGenericInst, tyAlias, tySink})
|
||||||
if o2.kind in {tyTuple, tyObject, tyArray,
|
if o2.kind in {tyTuple, tyObject, tyArray,
|
||||||
tySequence, tyOpt, tySet, tyDistinct, tyOpenArray, tyVarargs}:
|
tySequence, tySet, tyDistinct, tyOpenArray, tyVarargs}:
|
||||||
o2.flags.incl mask
|
o2.flags.incl mask
|
||||||
owner.flags.incl mask
|
owner.flags.incl mask
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ proc getTypeForward(m: BModule, typ: PType; sig: SigHash): Rope =
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
result = getTypePre(m, typ, sig)
|
result = getTypePre(m, typ, sig)
|
||||||
if result != nil: return
|
if result != nil: return
|
||||||
let concrete = typ.skipTypes(abstractInst + {tyOpt})
|
let concrete = typ.skipTypes(abstractInst)
|
||||||
case concrete.kind
|
case concrete.kind
|
||||||
of tySequence, tyTuple, tyObject:
|
of tySequence, tyTuple, tyObject:
|
||||||
result = getTypeName(m, typ, sig)
|
result = getTypeName(m, typ, sig)
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ proc mapType(typ: PType): TJSTypeKind =
|
||||||
of tyBool: result = etyBool
|
of tyBool: result = etyBool
|
||||||
of tyFloat..tyFloat128: result = etyFloat
|
of tyFloat..tyFloat128: result = etyFloat
|
||||||
of tySet: result = etyObject # map a set to a table
|
of tySet: result = etyObject # map a set to a table
|
||||||
of tyString, tySequence, tyOpt: result = etySeq
|
of tyString, tySequence: result = etySeq
|
||||||
of tyObject, tyArray, tyTuple, tyOpenArray, tyVarargs, tyUncheckedArray:
|
of tyObject, tyArray, tyTuple, tyOpenArray, tyVarargs, tyUncheckedArray:
|
||||||
result = etyObject
|
result = etyObject
|
||||||
of tyNil: result = etyNull
|
of tyNil: result = etyNull
|
||||||
|
|
@ -210,6 +210,7 @@ proc mapType(typ: PType): TJSTypeKind =
|
||||||
else: result = etyNone
|
else: result = etyNone
|
||||||
of tyProc: result = etyProc
|
of tyProc: result = etyProc
|
||||||
of tyCString: result = etyString
|
of tyCString: result = etyString
|
||||||
|
of tyOptDeprecated: doAssert false
|
||||||
|
|
||||||
proc mapType(p: PProc; typ: PType): TJSTypeKind =
|
proc mapType(p: PProc; typ: PType): TJSTypeKind =
|
||||||
result = mapType(typ)
|
result = mapType(typ)
|
||||||
|
|
@ -1041,7 +1042,7 @@ proc genAsgnAux(p: PProc, x, y: PNode, noCopyNeeded: bool) =
|
||||||
|
|
||||||
# we don't care if it's an etyBaseIndex (global) of a string, it's
|
# we don't care if it's an etyBaseIndex (global) of a string, it's
|
||||||
# still a string that needs to be copied properly:
|
# still a string that needs to be copied properly:
|
||||||
if x.typ.skipTypes(abstractInst).kind in {tySequence, tyOpt, tyString}:
|
if x.typ.skipTypes(abstractInst).kind in {tySequence, tyString}:
|
||||||
xtyp = etySeq
|
xtyp = etySeq
|
||||||
case xtyp
|
case xtyp
|
||||||
of etySeq:
|
of etySeq:
|
||||||
|
|
@ -1086,7 +1087,7 @@ proc genFastAsgn(p: PProc, n: PNode) =
|
||||||
# See bug #5933. So we try to be more compatible with the C backend semantics
|
# See bug #5933. So we try to be more compatible with the C backend semantics
|
||||||
# here for 'shallowCopy'. This is an educated guess and might require further
|
# here for 'shallowCopy'. This is an educated guess and might require further
|
||||||
# changes later:
|
# changes later:
|
||||||
let noCopy = n[0].typ.skipTypes(abstractInst).kind in {tySequence, tyOpt, tyString}
|
let noCopy = n[0].typ.skipTypes(abstractInst).kind in {tySequence, tyString}
|
||||||
genAsgnAux(p, n[0], n[1], noCopyNeeded=noCopy)
|
genAsgnAux(p, n[0], n[1], noCopyNeeded=noCopy)
|
||||||
|
|
||||||
proc genSwap(p: PProc, n: PNode) =
|
proc genSwap(p: PProc, n: PNode) =
|
||||||
|
|
@ -1697,7 +1698,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope =
|
||||||
result = putToSeq("null", indirect)
|
result = putToSeq("null", indirect)
|
||||||
of tySequence, tyString:
|
of tySequence, tyString:
|
||||||
result = putToSeq("[]", indirect)
|
result = putToSeq("[]", indirect)
|
||||||
of tyCString, tyOpt, tyProc:
|
of tyCString, tyProc:
|
||||||
result = putToSeq("null", indirect)
|
result = putToSeq("null", indirect)
|
||||||
of tyStatic:
|
of tyStatic:
|
||||||
if t.n != nil:
|
if t.n != nil:
|
||||||
|
|
|
||||||
|
|
@ -703,7 +703,7 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyNone, tyEmpty, tyVoid: discard
|
of tyNone, tyEmpty, tyVoid: discard
|
||||||
of tyPointer, tySet, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCString,
|
of tyPointer, tySet, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCString,
|
||||||
tyPtr, tyOpt, tyUncheckedArray, tyVar, tyLent:
|
tyPtr, tyUncheckedArray, tyVar, tyLent:
|
||||||
defaultOp(c, t, body, x, y)
|
defaultOp(c, t, body, x, y)
|
||||||
of tyRef:
|
of tyRef:
|
||||||
if c.g.config.selectedGC in {gcArc, gcOrc}:
|
if c.g.config.selectedGC in {gcArc, gcOrc}:
|
||||||
|
|
@ -785,6 +785,7 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
|
||||||
of tyOrdinal, tyRange, tyInferred,
|
of tyOrdinal, tyRange, tyInferred,
|
||||||
tyGenericInst, tyAlias, tySink:
|
tyGenericInst, tyAlias, tySink:
|
||||||
fillBody(c, lastSon(t), body, x, y)
|
fillBody(c, lastSon(t), body, x, y)
|
||||||
|
of tyOptDeprecated: doAssert false
|
||||||
|
|
||||||
proc produceSymDistinctType(g: ModuleGraph; c: PContext; typ: PType;
|
proc produceSymDistinctType(g: ModuleGraph; c: PContext; typ: PType;
|
||||||
kind: TTypeAttachedOp; info: TLineInfo): PSym =
|
kind: TTypeAttachedOp; info: TLineInfo): PSym =
|
||||||
|
|
|
||||||
|
|
@ -1814,7 +1814,6 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
result = semContainer(c, n, tySequence, "seq", prev)
|
result = semContainer(c, n, tySequence, "seq", prev)
|
||||||
if optSeqDestructors in c.config.globalOptions:
|
if optSeqDestructors in c.config.globalOptions:
|
||||||
incl result.flags, tfHasAsgn
|
incl result.flags, tfHasAsgn
|
||||||
of mOpt: result = semContainer(c, n, tyOpt, "opt", prev)
|
|
||||||
of mVarargs: result = semVarargs(c, n, prev)
|
of mVarargs: result = semVarargs(c, n, prev)
|
||||||
of mTypeDesc, mType, mTypeOf:
|
of mTypeDesc, mType, mTypeOf:
|
||||||
result = makeTypeDesc(c, semTypeNode(c, n[1], nil))
|
result = makeTypeDesc(c, semTypeNode(c, n[1], nil))
|
||||||
|
|
|
||||||
|
|
@ -608,10 +608,6 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
result = "seq"
|
result = "seq"
|
||||||
if t.len > 0:
|
if t.len > 0:
|
||||||
result &= "[" & typeToString(t[0]) & ']'
|
result &= "[" & typeToString(t[0]) & ']'
|
||||||
of tyOpt:
|
|
||||||
result = "opt"
|
|
||||||
if t.len > 0:
|
|
||||||
result &= "opt[" & typeToString(t[0]) & ']'
|
|
||||||
of tyOrdinal:
|
of tyOrdinal:
|
||||||
result = "ordinal"
|
result = "ordinal"
|
||||||
if t.len > 0:
|
if t.len > 0:
|
||||||
|
|
@ -1150,7 +1146,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
of tyGenericInvocation, tyGenericBody, tySequence, tyOpenArray, tySet, tyRef,
|
of tyGenericInvocation, tyGenericBody, tySequence, tyOpenArray, tySet, tyRef,
|
||||||
tyPtr, tyVar, tyLent, tySink, tyUncheckedArray, tyArray, tyProc, tyVarargs,
|
tyPtr, tyVar, tyLent, tySink, tyUncheckedArray, tyArray, tyProc, tyVarargs,
|
||||||
tyOrdinal, tyCompositeTypeClass, tyUserTypeClass, tyUserTypeClassInst,
|
tyOrdinal, tyCompositeTypeClass, tyUserTypeClass, tyUserTypeClassInst,
|
||||||
tyAnd, tyOr, tyNot, tyAnything, tyOpt, tyOwned:
|
tyAnd, tyOr, tyNot, tyAnything, tyOwned:
|
||||||
cycleCheck()
|
cycleCheck()
|
||||||
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
if a.kind == tyUserTypeClass and a.n != nil: return a.n == b.n
|
||||||
result = sameChildrenAux(a, b, c)
|
result = sameChildrenAux(a, b, c)
|
||||||
|
|
@ -1173,6 +1169,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
cycleCheck()
|
cycleCheck()
|
||||||
result = sameTypeAux(a.lastSon, b.lastSon, c)
|
result = sameTypeAux(a.lastSon, b.lastSon, c)
|
||||||
of tyNone: result = false
|
of tyNone: result = false
|
||||||
|
of tyOptDeprecated: doAssert false
|
||||||
|
|
||||||
proc sameBackendType*(x, y: PType): bool =
|
proc sameBackendType*(x, y: PType): bool =
|
||||||
var c = initSameTypeClosure()
|
var c = initSameTypeClosure()
|
||||||
|
|
@ -1365,7 +1362,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
result = t
|
result = t
|
||||||
else:
|
else:
|
||||||
result = typeAllowedAux(marker, lastSon(t), kind, flags-{taHeap})
|
result = typeAllowedAux(marker, lastSon(t), kind, flags-{taHeap})
|
||||||
of tySequence, tyOpt:
|
of tySequence:
|
||||||
if t[0].kind != tyEmpty:
|
if t[0].kind != tyEmpty:
|
||||||
result = typeAllowedAux(marker, t[0], kind, flags+{taHeap})
|
result = typeAllowedAux(marker, t[0], kind, flags+{taHeap})
|
||||||
elif kind in {skVar, skLet}:
|
elif kind in {skVar, skLet}:
|
||||||
|
|
@ -1408,6 +1405,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
|
||||||
result = typeAllowedAux(marker, t.lastSon, kind, flags+{taHeap})
|
result = typeAllowedAux(marker, t.lastSon, kind, flags+{taHeap})
|
||||||
else:
|
else:
|
||||||
result = t
|
result = t
|
||||||
|
of tyOptDeprecated: doAssert false
|
||||||
|
|
||||||
proc typeAllowed*(t: PType, kind: TSymKind; flags: TTypeAllowedFlags = {}): PType =
|
proc typeAllowed*(t: PType, kind: TSymKind; flags: TTypeAllowedFlags = {}): PType =
|
||||||
# returns 'nil' on success and otherwise the part of the type that is
|
# returns 'nil' on success and otherwise the part of the type that is
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,6 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
|
||||||
of tyLent: result = mapTypeToBracket("lent", mBuiltinType, t, info)
|
of tyLent: result = mapTypeToBracket("lent", mBuiltinType, t, info)
|
||||||
of tySink: result = mapTypeToBracket("sink", mBuiltinType, t, info)
|
of tySink: result = mapTypeToBracket("sink", mBuiltinType, t, info)
|
||||||
of tySequence: result = mapTypeToBracket("seq", mSeq, t, info)
|
of tySequence: result = mapTypeToBracket("seq", mSeq, t, info)
|
||||||
of tyOpt: result = mapTypeToBracket("opt", mOpt, t, info)
|
|
||||||
of tyProc:
|
of tyProc:
|
||||||
if inst:
|
if inst:
|
||||||
result = newNodeX(nkProcTy)
|
result = newNodeX(nkProcTy)
|
||||||
|
|
@ -298,6 +297,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo;
|
||||||
if t.n != nil:
|
if t.n != nil:
|
||||||
result.add t.n.copyTree
|
result.add t.n.copyTree
|
||||||
of tyOwned: result = mapTypeToBracket("owned", mBuiltinType, t, info)
|
of tyOwned: result = mapTypeToBracket("owned", mBuiltinType, t, info)
|
||||||
|
of tyOptDeprecated: doAssert false
|
||||||
|
|
||||||
proc opMapTypeToAst*(cache: IdentCache; t: PType; info: TLineInfo): PNode =
|
proc opMapTypeToAst*(cache: IdentCache; t: PType; info: TLineInfo): PNode =
|
||||||
result = mapTypeToAstX(cache, t, info, inst=false, allowRecursionX=true)
|
result = mapTypeToAstX(cache, t, info, inst=false, allowRecursionX=true)
|
||||||
|
|
|
||||||
|
|
@ -1820,8 +1820,6 @@ proc getNullValue(typ: PType, info: TLineInfo; conf: ConfigRef): PNode =
|
||||||
result.add getNullValue(t[i], info, conf)
|
result.add getNullValue(t[i], info, conf)
|
||||||
of tySet:
|
of tySet:
|
||||||
result = newNodeIT(nkCurly, info, t)
|
result = newNodeIT(nkCurly, info, t)
|
||||||
of tyOpt:
|
|
||||||
result = newNodeIT(nkNilLit, info, t)
|
|
||||||
of tySequence:
|
of tySequence:
|
||||||
result = newNodeIT(nkBracket, info, t)
|
result = newNodeIT(nkBracket, info, t)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ type
|
||||||
ntyError,
|
ntyError,
|
||||||
ntyBuiltinTypeClass, ntyUserTypeClass, ntyUserTypeClassInst,
|
ntyBuiltinTypeClass, ntyUserTypeClass, ntyUserTypeClassInst,
|
||||||
ntyCompositeTypeClass, ntyInferred, ntyAnd, ntyOr, ntyNot,
|
ntyCompositeTypeClass, ntyInferred, ntyAnd, ntyOr, ntyNot,
|
||||||
ntyAnything, ntyStatic, ntyFromExpr, ntyOpt, ntyVoid
|
ntyAnything, ntyStatic, ntyFromExpr, ntyOptDeprecated, ntyVoid
|
||||||
|
|
||||||
TNimTypeKinds* {.deprecated.} = set[NimTypeKind]
|
TNimTypeKinds* {.deprecated.} = set[NimTypeKind]
|
||||||
NimSymKind* = enum
|
NimSymKind* = enum
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ type
|
||||||
tyAnythingHidden,
|
tyAnythingHidden,
|
||||||
tyStaticHidden,
|
tyStaticHidden,
|
||||||
tyFromExprHidden,
|
tyFromExprHidden,
|
||||||
tyOpt,
|
tyOptDeprecated,
|
||||||
tyVoidHidden
|
tyVoidHidden
|
||||||
|
|
||||||
TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
|
TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue