diff --git a/compiler/ast.nim b/compiler/ast.nim index 1a686b2f6f..5f55c7ffa9 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -268,7 +268,6 @@ type tyVoid # now different from tyEmpty, hurray! tyIterable - tyStub static: # remind us when TTypeKind stops to fit in a single 64-bit word @@ -693,10 +692,15 @@ type PScope* = ref TScope + ItemState* = enum + Complete # completely in memory + Partial # partially in memory + PLib* = ref TLib TSym* {.acyclic.} = object # Keep in sync with PackedSym itemId*: ItemId # proc and type instantiations are cached in the generic symbol + state*: ItemState case kind*: TSymKind of routineKinds: #procInstCache*: seq[PInstantiation] @@ -771,6 +775,7 @@ type # Keep in sync with PackedType itemId*: ItemId kind*: TTypeKind # kind of type + state*: ItemState callConv*: TCallingConvention # for procs flags*: TTypeFlags # flags of the type sons: TTypeSeq # base types, etc. diff --git a/compiler/ast2nif.nim b/compiler/ast2nif.nim index a57bbd65af..aa552d61c4 100644 --- a/compiler/ast2nif.nim +++ b/compiler/ast2nif.nim @@ -192,7 +192,9 @@ proc writeType(w: var Writer; dest: var TokenBuf; typ: PType) proc writeSym(w: var Writer; dest: var TokenBuf; sym: PSym) proc typeToNifSym(w: var Writer; typ: PType): string = - result = "`t." + result = "`t" + result.addInt ord(typ.kind) + result.add '.' result.addInt typ.uniqueId.item result.add '.' result.add modname(w.moduleToNifSuffix, typ.uniqueId.module, w.infos.config) @@ -207,7 +209,7 @@ proc writeTypeDef(w: var Writer; dest: var TokenBuf; typ: PType) = dest.buildTree tdefTag: dest.addSymDef pool.syms.getOrIncl(w.typeToNifSym(typ)), NoLineInfo - dest.addIdent toNifTag(typ.kind) + #dest.addIdent toNifTag(typ.kind) writeFlags(dest, typ.flags) dest.addIdent toNifTag(typ.callConv) dest.addIntLit typ.size @@ -581,8 +583,13 @@ proc loadNode(c: var DecodeContext; n: var Cursor): PNode proc loadTypeStub(c: var DecodeContext; t: SymId): PType = let name = pool.syms[t] - assert name.startsWith("`t.") - var i = len("`t.") + assert name.startsWith("`t") + var i = len("`t") + var k = 0 + while i < name.len and name[i] in {'0'..'9'}: + k = k * 10 + name[i].ord - ord('0') + inc i + if i < name.len and name[i] == '.': inc i var itemId = 0'i32 while i < name.len and name[i] in {'0'..'9'}: itemId = itemId * 10'i32 + int32(name[i].ord - ord('0')) @@ -593,7 +600,7 @@ proc loadTypeStub(c: var DecodeContext; t: SymId): PType = result = c.types.getOrDefault(id)[0] if result == nil: let offs = c.getOffset(id.module, name) - result = PType(itemId: id, uniqueId: id, kind: tyStub) + result = PType(itemId: id, uniqueId: id, kind: TTypeKind(k), state: Partial) c.types[id] = (result, offs) proc loadTypeStub(c: var DecodeContext; n: var Cursor): PType = @@ -622,7 +629,7 @@ proc loadSymStub(c: var DecodeContext; t: SymId): PSym = result = c.syms.getOrDefault(id)[0] if result == nil: let offs = c.getOffset(module, symAsStr) - result = PSym(itemId: id, kind: skStub, name: c.cache.getIdent(sn.name), disamb: sn.count.int32) + result = PSym(itemId: id, kind: skStub, name: c.cache.getIdent(sn.name), disamb: sn.count.int32, state: Partial) c.syms[id] = (result, offs) proc loadSymStub(c: var DecodeContext; n: var Cursor): PSym = @@ -640,8 +647,8 @@ proc loadSymStub(c: var DecodeContext; n: var Cursor): PSym = else: raiseAssert "sym expected but got " & $n.kind -proc isStub*(t: PType): bool {.inline.} = t.kind == tyStub -proc isStub*(s: PSym): bool {.inline.} = s.kind == skStub +proc isStub*(t: PType): bool {.inline.} = t.state == Partial +proc isStub*(s: PSym): bool {.inline.} = s.state == Partial proc loadAtom[T](t: typedesc[set[T]]; n: var Cursor): set[T] = if n.kind == DotToken: @@ -681,7 +688,7 @@ proc loadLoc(c: var DecodeContext; n: var Cursor; loc: var TLoc) = loadField loc.snippet proc loadType*(c: var DecodeContext; t: PType) = - if t.kind != tyStub: return + if t.state != Partial: return var buf = createTokenBuf(30) var n = cursorFromIndexEntry(c, t.itemId.module, c.types[t.itemId][1], buf) @@ -692,7 +699,7 @@ proc loadType*(c: var DecodeContext; t: PType) = expect n, SymbolDef # ignore the type's name, we have already used it to create this PType's itemId! inc n - loadField t.kind + #loadField t.kind loadField t.flags loadField t.callConv loadField t.size diff --git a/compiler/ccgreset.nim b/compiler/ccgreset.nim index 0e4c73cd17..84478dd07e 100644 --- a/compiler/ccgreset.nim +++ b/compiler/ccgreset.nim @@ -112,7 +112,7 @@ proc specializeResetT(p: BProc, accessor: Rope, typ: PType) = tyGenericParam, tyOrdinal, tyOpenArray, tyForward, tyVarargs, tyUncheckedArray, tyError, tyBuiltInTypeClass, tyUserTypeClass, tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot, - tyAnything, tyStatic, tyFromExpr, tyConcept, tyVoid, tyIterable, tyStub: + tyAnything, tyStatic, tyFromExpr, tyConcept, tyVoid, tyIterable: discard proc specializeReset(p: BProc, a: TLoc) = diff --git a/compiler/expanddefaults.nim b/compiler/expanddefaults.nim index e343317e54..c520d8849f 100644 --- a/compiler/expanddefaults.nim +++ b/compiler/expanddefaults.nim @@ -124,7 +124,7 @@ proc expandDefault(t: PType; info: TLineInfo): PNode = result = newZero(t, info, nkBracket) of tyString: result = newZero(t, info, nkStrLit) - of tyNone, tyEmpty, tyUntyped, tyTyped, tyTypeDesc, tyStub, + of tyNone, tyEmpty, tyUntyped, tyTyped, tyTypeDesc, tyNil, tyGenericInvocation, tyError, tyBuiltInTypeClass, tyUserTypeClass, tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot, tyAnything, tyConcept, tyIterable, tyForward: diff --git a/compiler/icnif/enum2nif.nim b/compiler/icnif/enum2nif.nim index 1f77393c6a..b8626fe56d 100644 --- a/compiler/icnif/enum2nif.nim +++ b/compiler/icnif/enum2nif.nim @@ -469,7 +469,6 @@ proc toNifTag*(s: TTypeKind): string = of tyConcept: "concept" of tyVoid: "void" of tyIterable: "iterable" - of tyStub: "stub" proc parse*(t: typedesc[TTypeKind]; s: string): TTypeKind = @@ -539,7 +538,6 @@ proc parse*(t: typedesc[TTypeKind]; s: string): TTypeKind = of "concept": tyConcept of "void": tyVoid of "iterable": tyIterable - of "stub": tyStub else: tyNone diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 4d63d44acb..fd8ef583d0 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -219,7 +219,7 @@ proc mapType(typ: PType): TJSTypeKind = else: result = etyNone of tyProc: result = etyProc of tyCstring: result = etyString - of tyConcept, tyIterable, tyStub: + of tyConcept, tyIterable: raiseAssert "unreachable" proc mapType(p: PProc; typ: PType): TJSTypeKind = diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index 42b96aa1ca..5d8fbc179d 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -972,7 +972,7 @@ proc ownedClosureOp(c: var TLiftCtx; t: PType; body, x, y: PNode) = proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) = case t.kind - of tyNone, tyEmpty, tyVoid, tyStub: discard + of tyNone, tyEmpty, tyVoid: discard of tyPointer, tySet, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCstring, tyPtr, tyUncheckedArray, tyVar, tyLent: defaultOp(c, t, body, x, y) diff --git a/compiler/nifgen.nim b/compiler/nifgen.nim index c9d86b50f0..cf267ef14b 100644 --- a/compiler/nifgen.nim +++ b/compiler/nifgen.nim @@ -666,7 +666,6 @@ proc toNifTag(s: TTypeKind): string = of tyConcept: "concept" of tyVoid: "void" of tyIterable: "iterable" - of tyStub: "stub" proc atom(t: PType; c: var TranslationContext) = c.b.withTree toNifTag(t.kind): @@ -925,7 +924,7 @@ proc toNifType(t: PType; parent: PNode; c: var TranslationContext) = atom t, c, "err" of tyCompositeTypeClass: toNifType t.last, parent, c of tyInferred: toNifType t.skipModifier, parent, c - of tyAnything, tyStub: atom t, c + of tyAnything: atom t, c of tyStatic: c.typeHead t: if t.hasElementType: diff --git a/compiler/typeallowed.nim b/compiler/typeallowed.nim index 0529a6671f..80b532371c 100644 --- a/compiler/typeallowed.nim +++ b/compiler/typeallowed.nim @@ -201,7 +201,7 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, result = typeAllowedNode(marker, t.n, kind, c, flags) of tyEmpty: if kind in {skVar, skLet}: result = t - of tyError, tyStub: + of tyError: # for now same as error node; we say it's a valid type as it should # prevent cascading errors: result = nil diff --git a/compiler/types.nim b/compiler/types.nim index b26a949407..bd65c3f331 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -491,7 +491,7 @@ const "BuiltInTypeClass", "UserTypeClass", "UserTypeClassInst", "CompositeTypeClass", "inferred", "and", "or", "not", "any", "static", "TypeFromExpr", "concept", # xxx bugfix - "void", "iterable", "stub"] + "void", "iterable"] const preferToResolveSymbols = {preferName, preferTypeName, preferModuleInfo, preferGenericArg, preferResolved, preferMixed, preferInlayHint, preferInferredEffects} @@ -1344,8 +1344,6 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool = result = a.id == b.id and sameFlags(a, b) of tyError: result = b.kind == tyError - of tyStub: - result = false of tyTuple: withoutShallowFlags: cycleCheck() diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 882f030ee7..72eec34ead 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -97,7 +97,7 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; return atomicType(t.sym) case t.kind - of tyNone, tyStub: result = atomicType("none", mNone) + of tyNone: result = atomicType("none", mNone) of tyBool: result = atomicType("bool", mBool) of tyChar: result = atomicType("char", mChar) of tyNil: result = atomicType("nil", mNil)