# # # The Nim Compiler # (c) Copyright 2023 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. # import lineinfos, ast, types proc caseObjDefaultBranch*(obj: PNode; branch: Int128): int = result = 0 for i in 1 ..< obj.len: for j in 0 .. obj[i].len - 2: if obj[i][j].kind == nkRange: let x = getOrdValue(obj[i][j][0]) let y = getOrdValue(obj[i][j][1]) if branch >= x and branch <= y: return i elif getOrdValue(obj[i][j]) == branch: return i if obj[i].len == 1: # else branch return i return 1 template newZero(t: PType; info: TLineInfo; k = nkIntLit): PNode = newNodeIT(k, info, t) proc expandDefault*(t: PType; info: TLineInfo): PNode proc expandField(s: PSym; info: TLineInfo): PNode = result = newNodeIT(nkExprColonExpr, info, s.typ) result.add newSymNode(s) result.add expandDefault(s.typ, info) proc expandDefaultN(n: PNode; info: TLineInfo; res: PNode) = case n.kind of nkRecList: for i in 0..