remove remnants of tyIter

This commit is contained in:
Jacek Sieka 2016-10-24 21:10:48 +08:00
commit 6f7b891bdc
11 changed files with 22 additions and 26 deletions

View file

@ -347,7 +347,7 @@ type
tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64, tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64,
tyBigNum, tyBigNum,
tyConst, tyMutable, tyVarargs, tyConst, tyMutable, tyVarargs,
tyIter, # unused tyUnused # kept for enum ordinal compatibility
tyProxy # used as errornous type (for idetools) tyProxy # used as errornous type (for idetools)
tyBuiltInTypeClass #\ tyBuiltInTypeClass #\

View file

@ -122,7 +122,7 @@ proc mapType(typ: PType): TCTypeKind =
of tyOpenArray, tyArrayConstr, tyArray, tyVarargs: result = ctArray of tyOpenArray, tyArrayConstr, tyArray, tyVarargs: result = ctArray
of tyObject, tyTuple: result = ctStruct of tyObject, tyTuple: result = ctStruct
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal, of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal,
tyConst, tyMutable, tyIter, tyTypeDesc: tyConst, tyMutable, tyTypeDesc:
result = mapType(lastSon(typ)) result = mapType(lastSon(typ))
of tyEnum: of tyEnum:
if firstOrd(typ) < 0: if firstOrd(typ) < 0:
@ -711,8 +711,7 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): Rope =
of 1, 2, 4, 8: addf(m.s[cfsTypes], "typedef NU$2 $1;$n", [result, rope(s*8)]) 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", else: addf(m.s[cfsTypes], "typedef NU8 $1[$2];$n",
[result, rope(getSize(t))]) [result, rope(getSize(t))])
of tyGenericInst, tyDistinct, tyOrdinal, tyConst, tyMutable, of tyGenericInst, tyDistinct, tyOrdinal, tyConst, tyMutable, tyTypeDesc:
tyIter, tyTypeDesc:
result = getTypeDescAux(m, lastSon(t), check) result = getTypeDescAux(m, lastSon(t), check)
else: else:
internalError("getTypeDescAux(" & $t.kind & ')') internalError("getTypeDescAux(" & $t.kind & ')')

View file

@ -106,7 +106,7 @@ proc getUniqueType*(key: PType): PType =
of tyDistinct: of tyDistinct:
if key.deepCopy != nil: result = key if key.deepCopy != nil: result = key
else: result = getUniqueType(lastSon(key)) else: result = getUniqueType(lastSon(key))
of tyGenericInst, tyOrdinal, tyMutable, tyConst, tyIter, tyStatic: of tyGenericInst, tyOrdinal, tyMutable, tyConst, tyStatic:
result = getUniqueType(lastSon(key)) result = getUniqueType(lastSon(key))
#let obj = lastSon(key) #let obj = lastSon(key)
#if obj.sym != nil and obj.sym.name.s == "TOption": #if obj.sym != nil and obj.sym.name.s == "TOption":
@ -153,6 +153,7 @@ proc getUniqueType*(key: PType): PType =
else: else:
# ugh, we need the canon here: # ugh, we need the canon here:
result = slowSearch(key, k) result = slowSearch(key, k)
of tyUnused: internalError("getUniqueType")
proc tableGetType*(tab: TIdTable, key: PType): RootRef = proc tableGetType*(tab: TIdTable, key: PType): RootRef =
# returns nil if we need to declare this type # returns nil if we need to declare this type

View file

@ -151,7 +151,7 @@ proc mapType(typ: PType): TJSTypeKind =
of tyPointer: of tyPointer:
# treat a tyPointer like a typed pointer to an array of bytes # treat a tyPointer like a typed pointer to an array of bytes
result = etyBaseIndex result = etyBaseIndex
of tyRange, tyDistinct, tyOrdinal, tyConst, tyMutable, tyIter, tyProxy: of tyRange, tyDistinct, tyOrdinal, tyConst, tyMutable, tyProxy:
result = mapType(t.sons[0]) result = mapType(t.sons[0])
of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyChar: result = etyInt of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyChar: result = etyInt
of tyBool: result = etyBool of tyBool: result = etyBool
@ -171,6 +171,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 tyUnused: internalError("mapType")
proc mapType(p: PProc; typ: PType): TJSTypeKind = proc mapType(p: PProc; typ: PType): TJSTypeKind =
if p.target == targetPHP: result = etyObject if p.target == targetPHP: result = etyObject

View file

@ -221,7 +221,7 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
body.add newAsgnStmt(x, call) body.add newAsgnStmt(x, call)
of tyVarargs, tyOpenArray: of tyVarargs, tyOpenArray:
localError(c.info, errGenerated, "cannot copy openArray") localError(c.info, errGenerated, "cannot copy openArray")
of tyFromExpr, tyIter, tyProxy, tyBuiltInTypeClass, tyUserTypeClass, of tyFromExpr, tyProxy, tyBuiltInTypeClass, tyUserTypeClass,
tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot, tyAnything, tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot, tyAnything,
tyMutable, tyGenericParam, tyGenericBody, tyNil, tyExpr, tyStmt, tyMutable, tyGenericParam, tyGenericBody, tyNil, tyExpr, tyStmt,
tyTypeDesc, tyGenericInvocation, tyBigNum, tyConst, tyForward: tyTypeDesc, tyGenericInvocation, tyBigNum, tyConst, tyForward:
@ -229,6 +229,7 @@ proc liftBodyAux(c: var TLiftCtx; t: PType; body, x, y: PNode) =
of tyOrdinal, tyRange, of tyOrdinal, tyRange,
tyGenericInst, tyFieldAccessor, tyStatic, tyVar: tyGenericInst, tyFieldAccessor, tyStatic, tyVar:
liftBodyAux(c, lastSon(t), body, x, y) liftBodyAux(c, lastSon(t), body, x, y)
of tyUnused: internalError("liftBodyAux")
proc newProcType(info: TLineInfo; owner: PSym): PType = proc newProcType(info: TLineInfo; owner: PSym): PType =
result = newType(tyProc, owner) result = newType(tyProc, owner)

View file

@ -58,7 +58,7 @@ iterator instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable): PSym
for i, a in n.pairs: for i, a in n.pairs:
internalAssert a.kind == nkSym internalAssert a.kind == nkSym
var q = a.sym var q = a.sym
if q.typ.kind notin {tyTypeDesc, tyGenericParam, tyStatic, tyIter}+tyTypeClasses: if q.typ.kind notin {tyTypeDesc, tyGenericParam, tyStatic}+tyTypeClasses:
continue continue
let symKind = if q.typ.kind == tyStatic: skConst else: skType let symKind = if q.typ.kind == tyStatic: skConst else: skType
var s = newSym(symKind, q.name, getCurrOwner(), q.info) var s = newSym(symKind, q.name, getCurrOwner(), q.info)

View file

@ -24,7 +24,7 @@ proc semTypeOf(c: PContext; n: PNode): PNode =
result = newNodeI(nkTypeOfExpr, n.info) result = newNodeI(nkTypeOfExpr, n.info)
let typExpr = semExprWithType(c, n, {efInTypeof}) let typExpr = semExprWithType(c, n, {efInTypeof})
result.add typExpr result.add typExpr
result.typ = makeTypeDesc(c, typExpr.typ.skipTypes({tyTypeDesc, tyIter})) result.typ = makeTypeDesc(c, typExpr.typ.skipTypes({tyTypeDesc}))
type type
SemAsgnMode = enum asgnNormal, noOverloadedSubscript, noOverloadedAsgn SemAsgnMode = enum asgnNormal, noOverloadedSubscript, noOverloadedAsgn

View file

@ -549,8 +549,6 @@ proc procTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
of tyNil: of tyNil:
result = f.allowsNil result = f.allowsNil
of tyIter:
if tfIterator in f.flags: result = typeRel(c, f.base, a.base)
else: discard else: discard
proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} = proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} =
@ -1223,13 +1221,6 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
else: else:
result = isNone result = isNone
of tyIter:
if a.kind == tyIter or
(a.kind == tyProc and tfIterator in a.flags):
result = typeRel(c, f.base, a.base)
else:
result = isNone
of tyStmt: of tyStmt:
if aOrig != nil and tfOldSchoolExprStmt notin f.flags: if aOrig != nil and tfOldSchoolExprStmt notin f.flags:
put(c, f, aOrig) put(c, f, aOrig)
@ -1587,8 +1578,9 @@ proc prepareOperand(c: PContext; formal: PType; a: PNode): PNode =
elif a.typ.isNil: elif a.typ.isNil:
# XXX This is unsound! 'formal' can differ from overloaded routine to # XXX This is unsound! 'formal' can differ from overloaded routine to
# overloaded routine! # overloaded routine!
let flags = if formal.kind == tyIter: {efDetermineType, efWantIterator} let flags = {efDetermineType, efAllowStmt}
else: {efDetermineType, efAllowStmt} #if formal.kind == tyIter: {efDetermineType, efWantIterator}
#else: {efDetermineType, efAllowStmt}
#elif formal.kind == tyStmt: {efDetermineType, efWantStmt} #elif formal.kind == tyStmt: {efDetermineType, efWantStmt}
#else: {efDetermineType} #else: {efDetermineType}
result = c.semOperand(c, a, flags) result = c.semOperand(c, a, flags)

View file

@ -572,7 +572,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
addSep(prag) addSep(prag)
add(prag, "locks: " & $t.lockLevel) add(prag, "locks: " & $t.lockLevel)
if len(prag) != 0: add(result, "{." & prag & ".}") if len(prag) != 0: add(result, "{." & prag & ".}")
of tyVarargs, tyIter: of tyVarargs:
result = typeToStr[t.kind] % typeToString(t.sons[0]) result = typeToStr[t.kind] % typeToString(t.sons[0])
else: else:
result = typeToStr[t.kind] result = typeToStr[t.kind]
@ -965,7 +965,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
result = a.sym.position == b.sym.position result = a.sym.position == b.sym.position
of tyGenericInvocation, tyGenericBody, tySequence, of tyGenericInvocation, tyGenericBody, tySequence,
tyOpenArray, tySet, tyRef, tyPtr, tyVar, tyArrayConstr, tyOpenArray, tySet, tyRef, tyPtr, tyVar, tyArrayConstr,
tyArray, tyProc, tyConst, tyMutable, tyVarargs, tyIter, tyArray, tyProc, tyConst, tyMutable, tyVarargs,
tyOrdinal, tyTypeClasses, tyFieldAccessor: tyOrdinal, tyTypeClasses, tyFieldAccessor:
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
@ -980,6 +980,7 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
sameValue(a.n.sons[1], b.n.sons[1]) sameValue(a.n.sons[1], b.n.sons[1])
of tyGenericInst: discard of tyGenericInst: discard
of tyNone: result = false of tyNone: result = false
of tyUnused: internalError("sameFlags")
proc sameBackendType*(x, y: PType): bool = proc sameBackendType*(x, y: PType): bool =
var c = initSameTypeClosure() var c = initSameTypeClosure()
@ -1143,7 +1144,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind,
else: result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap}) else: result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
of tyPtr: of tyPtr:
result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap}) result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap})
of tyArrayConstr, tySet, tyConst, tyMutable, tyIter: of tyArrayConstr, tySet, tyConst, tyMutable:
for i in countup(0, sonsLen(t) - 1): for i in countup(0, sonsLen(t) - 1):
result = typeAllowedAux(marker, t.sons[i], kind, flags) result = typeAllowedAux(marker, t.sons[i], kind, flags)
if result != nil: break if result != nil: break
@ -1160,6 +1161,7 @@ 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 # for now same as error node; we say it's a valid type as it should
# prevent cascading errors: # prevent cascading errors:
result = nil result = nil
of tyUnused: internalError("typeAllowedAux")
proc typeAllowed*(t: PType, kind: TSymKind): PType = proc typeAllowed*(t: PType, kind: TSymKind): 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
@ -1311,7 +1313,7 @@ proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt =
if result < 0: return if result < 0: return
if a < maxAlign: a = maxAlign if a < maxAlign: a = maxAlign
result = align(result, a) result = align(result, a)
of tyGenericInst, tyDistinct, tyGenericBody, tyMutable, tyConst, tyIter: of tyGenericInst, tyDistinct, tyGenericBody, tyMutable, tyConst:
result = computeSizeAux(lastSon(typ), a) result = computeSizeAux(lastSon(typ), a)
of tyTypeDesc: of tyTypeDesc:
result = computeSizeAux(typ.base, a) result = computeSizeAux(typ.base, a)

View file

@ -270,7 +270,6 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
of tyConst: result = mapTypeToBracket("const", mNone, t, info) of tyConst: result = mapTypeToBracket("const", mNone, t, info)
of tyMutable: result = mapTypeToBracket("mutable", mNone, t, info) of tyMutable: result = mapTypeToBracket("mutable", mNone, t, info)
of tyVarargs: result = mapTypeToBracket("varargs", mVarargs, t, info) of tyVarargs: result = mapTypeToBracket("varargs", mVarargs, t, info)
of tyIter: result = mapTypeToBracket("iter", mNone, t, info)
of tyProxy: result = atomicType("error", mNone) of tyProxy: result = atomicType("error", mNone)
of tyBuiltInTypeClass: of tyBuiltInTypeClass:
result = mapTypeToBracket("builtinTypeClass", mNone, t, info) result = mapTypeToBracket("builtinTypeClass", mNone, t, info)
@ -292,6 +291,7 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
result.add atomicType("static", mNone) result.add atomicType("static", mNone)
if t.n != nil: if t.n != nil:
result.add t.n.copyTree result.add t.n.copyTree
of tyUnused: internalError("mapTypeToAstX")
proc opMapTypeToAst*(t: PType; info: TLineInfo): PNode = proc opMapTypeToAst*(t: PType; info: TLineInfo): PNode =
result = mapTypeToAstX(t, info, false, true) result = mapTypeToAstX(t, info, false, true)

View file

@ -92,7 +92,7 @@ type
ntyUInt, ntyUInt8, ntyUInt16, ntyUInt32, ntyUInt64, ntyUInt, ntyUInt8, ntyUInt16, ntyUInt32, ntyUInt64,
ntyBigNum, ntyBigNum,
ntyConst, ntyMutable, ntyVarargs, ntyConst, ntyMutable, ntyVarargs,
ntyIter, ntyUnused,
ntyError, ntyError,
ntyBuiltinTypeClass, ntyConcept, ntyConceptInst, ntyComposite, ntyBuiltinTypeClass, ntyConcept, ntyConceptInst, ntyComposite,
ntyAnd, ntyOr, ntyNot ntyAnd, ntyOr, ntyNot