diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 928caeacd0..cffee9c77d 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -1918,22 +1918,6 @@ proc genDiscriminantCheck(p: BProc, a, tmp: TLoc, objtype: PType, if p.config.exc == excGoto: raiseExit(p) -when false: - proc genCaseObjDiscMapping(p: BProc, e: PNode, t: PType, field: PSym; d: var TLoc) = - const ObjDiscMappingProcSlot = -5 - var theProc: PSym = nil - for idx, p in items(t.methods): - if idx == ObjDiscMappingProcSlot: - theProc = p - break - if theProc == nil: - theProc = genCaseObjDiscMapping(t, field, e.info, p.module.g.graph, p.module.idgen) - t.methods.add((ObjDiscMappingProcSlot, theProc)) - var call = newNodeIT(nkCall, e.info, getSysType(p.module.g.graph, e.info, tyUInt8)) - call.add newSymNode(theProc) - call.add e - expr(p, call, d) - proc asgnFieldDiscriminant(p: BProc, e: PNode) = var dotExpr = e.firstSon if dotExpr.kind == nkCheckedFieldExpr: dotExpr = dotExpr.firstSon diff --git a/compiler/enumtostr.nim b/compiler/enumtostr.nim index a21d744bea..9210e8db2e 100644 --- a/compiler/enumtostr.nim +++ b/compiler/enumtostr.nim @@ -49,65 +49,3 @@ proc genEnumToStrProc*(t: PType; info: TLineInfo; g: ModuleGraph; idgen: IdGener result.ast = n incl result.flagsImpl, {sfFromGeneric, sfNeverRaises} setHookDisamb(g, result, "$enumtostr", t) - -proc searchObjCaseImpl(obj: PNode; field: PSym): PNode = - case obj.kind - of nkSym: - result = nil - of nkElse, nkOfBranch: - result = searchObjCaseImpl(obj.lastSon, field) - else: - if obj.kind == nkRecCase and obj[0].kind == nkSym and obj[0].sym == field: - result = obj - else: - result = nil - for x in obj: - result = searchObjCaseImpl(x, field) - if result != nil: break - -proc searchObjCase(t: PType; field: PSym): PNode = - result = searchObjCaseImpl(t.n, field) - if result == nil and t.baseClass != nil: - result = searchObjCase(t.baseClass.skipTypes({tyAlias, tyGenericInst, tyRef, tyPtr}), field) - doAssert result != nil - -proc genCaseObjDiscMapping*(t: PType; field: PSym; info: TLineInfo; g: ModuleGraph; idgen: IdGenerator): PSym = - result = newSym(skProc, getIdent(g.cache, "objDiscMapping"), idgen, t.owner, info) - - let dest = newSym(skParam, getIdent(g.cache, "e"), idgen, result, info) - dest.typ = field.typ - - let res = newSym(skResult, getIdent(g.cache, "result"), idgen, result, info) - res.typ = getSysType(g, info, tyUInt8) - - result.typ = newType(tyProc, idgen, t.owner) - result.typ.n = newNodeI(nkFormalParams, info) - rawAddSon(result.typ, res.typ) - result.typ.n.add newNodeI(nkEffectList, info) - - result.typ.addParam dest - - var body = newNodeI(nkStmtList, info) - var caseStmt = newNodeI(nkCaseStmt, info) - caseStmt.add(newSymNode dest) - - let subObj = searchObjCase(t, field) - for i in 1..