diff options
30 files changed, 307 insertions, 114 deletions
diff --git a/compiler/aliases.nim b/compiler/aliases.nim index d68c9360a..3f3d45ff7 100644 --- a/compiler/aliases.nim +++ b/compiler/aliases.nim @@ -16,9 +16,9 @@ type TAnalysisResult* = enum arNo, arMaybe, arYes -proc isPartOfAux(a, b: PType, marker: var TIntSet): TAnalysisResult +proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult -proc isPartOfAux(n: PNode, b: PType, marker: var TIntSet): TAnalysisResult = +proc isPartOfAux(n: PNode, b: PType, marker: var IntSet): TAnalysisResult = result = arNo case n.kind of nkRecList: @@ -39,7 +39,7 @@ proc isPartOfAux(n: PNode, b: PType, marker: var TIntSet): TAnalysisResult = result = isPartOfAux(n.sym.typ, b, marker) else: internalError(n.info, "isPartOfAux()") -proc isPartOfAux(a, b: PType, marker: var TIntSet): TAnalysisResult = +proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult = result = arNo if a == nil or b == nil: return if containsOrIncl(marker, a.id): return diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index ad5393dbd..8918888a3 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -245,13 +245,13 @@ proc lineInfoToStr(info: TLineInfo): PRope = toRope(toLinenumber(info)), toRope(toColumn(info))]) -proc treeToYamlAux(n: PNode, marker: var TIntSet, +proc treeToYamlAux(n: PNode, marker: var IntSet, indent, maxRecDepth: int): PRope -proc symToYamlAux(n: PSym, marker: var TIntSet, +proc symToYamlAux(n: PSym, marker: var IntSet, indent, maxRecDepth: int): PRope -proc typeToYamlAux(n: PType, marker: var TIntSet, +proc typeToYamlAux(n: PType, marker: var IntSet, indent, maxRecDepth: int): PRope -proc strTableToYaml(n: TStrTable, marker: var TIntSet, indent: int, +proc strTableToYaml(n: TStrTable, marker: var IntSet, indent: int, maxRecDepth: int): PRope = var istr = spaces(indent + 2) result = toRope("[") @@ -277,7 +277,7 @@ proc ropeConstr(indent: int, c: openArray[PRope]): PRope = inc(i, 2) appf(result, "$N$1}", [spaces(indent)]) -proc symToYamlAux(n: PSym, marker: var TIntSet, indent: int, +proc symToYamlAux(n: PSym, marker: var IntSet, indent: int, maxRecDepth: int): PRope = if n == nil: result = toRope("null") @@ -298,7 +298,7 @@ proc symToYamlAux(n: PSym, marker: var TIntSet, indent: int, flagsToStr(n.options), toRope("position"), toRope(n.position)]) -proc typeToYamlAux(n: PType, marker: var TIntSet, indent: int, +proc typeToYamlAux(n: PType, marker: var IntSet, indent: int, maxRecDepth: int): PRope = if n == nil: result = toRope("null") @@ -326,7 +326,7 @@ proc typeToYamlAux(n: PType, marker: var TIntSet, indent: int, toRope("align"), toRope(n.align), toRope("sons"), result]) -proc treeToYamlAux(n: PNode, marker: var TIntSet, indent: int, +proc treeToYamlAux(n: PNode, marker: var IntSet, indent: int, maxRecDepth: int): PRope = if n == nil: result = toRope("null") @@ -677,7 +677,7 @@ proc nextIdentIter(ti: var TIdentIter, tab: TStrTable): PSym = ti.h = nextTry(h, high(tab.data)) proc nextIdentExcluding*(ti: var TIdentIter, tab: TStrTable, - excluding: TIntSet): PSym = + excluding: IntSet): PSym = var h: THash = ti.h and high(tab.data) var start = h result = tab.data[h] @@ -693,7 +693,7 @@ proc nextIdentExcluding*(ti: var TIdentIter, tab: TStrTable, if result != nil and contains(excluding, result.id): result = nil proc firstIdentExcluding*(ti: var TIdentIter, tab: TStrTable, s: PIdent, - excluding: TIntSet): PSym = + excluding: IntSet): PSym = ti.h = s.h ti.name = s if tab.counter == 0: result = nil diff --git a/compiler/babelcmd.nim b/compiler/babelcmd.nim index d67b1dab5..b09637330 100644 --- a/compiler/babelcmd.nim +++ b/compiler/babelcmd.nim @@ -43,7 +43,7 @@ proc `<.`(a, b: string): bool = if a[i] == '.': inc i if b[j] == '.': inc j -proc addPackage(packages: PStringTable, p: string) = +proc addPackage(packages: StringTableRef, p: string) = let x = versionSplitPos(p) let name = p.substr(0, x-1) if x < p.len: @@ -53,7 +53,7 @@ proc addPackage(packages: PStringTable, p: string) = else: packages[name] = latest -iterator chosen(packages: PStringTable): string = +iterator chosen(packages: StringTableRef): string = for key, val in pairs(packages): let res = if val == latest: key else: key & '-' & val yield res diff --git a/compiler/ccgmerge.nim b/compiler/ccgmerge.nim index 69c41ff59..9aca4b0f7 100644 --- a/compiler/ccgmerge.nim +++ b/compiler/ccgmerge.nim @@ -83,7 +83,7 @@ proc writeTypeCache(a: TIdTable, s: var string) = inc i s.add('}') -proc writeIntSet(a: TIntSet, s: var string) = +proc writeIntSet(a: IntSet, s: var string) = var i = 0 for x in items(a): if i == 10: @@ -200,7 +200,7 @@ proc readTypeCache(L: var TBaseLexer, result: var TIdTable) = idTablePut(result, newFakeType(key), value.toRope) inc L.bufpos -proc readIntSet(L: var TBaseLexer, result: var TIntSet) = +proc readIntSet(L: var TBaseLexer, result: var IntSet) = if ^L.bufpos != '{': internalError("ccgmerge: '{' expected") inc L.bufpos while ^L.bufpos != '}': diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 8c2e99339..4cb6a9977 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -162,7 +162,7 @@ proc mapReturnType(typ: PType): TCTypeKind = if skipTypes(typ, typedescInst).kind == tyArray: result = ctPtr else: result = mapType(typ) -proc getTypeDescAux(m: BModule, typ: PType, check: var TIntSet): PRope +proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): PRope proc needsComplexAssignment(typ: PType): bool = result = containsGarbageCollectedRef(typ) @@ -228,7 +228,7 @@ proc fillResult(param: PSym) = incl(param.loc.flags, lfIndirect) param.loc.s = OnUnknown -proc getParamTypeDesc(m: BModule, t: PType, check: var TIntSet): PRope = +proc getParamTypeDesc(m: BModule, t: PType, check: var IntSet): PRope = when false: if t.Kind in {tyRef, tyPtr, tyVar}: var b = skipTypes(t.lastson, typedescInst) @@ -243,7 +243,7 @@ proc paramStorageLoc(param: PSym): TStorageLoc = result = OnUnknown proc genProcParams(m: BModule, t: PType, rettype, params: var PRope, - check: var TIntSet, declareEnvironment=true) = + check: var IntSet, declareEnvironment=true) = params = nil if (t.sons[0] == nil) or isInvalidReturnType(t.sons[0]): rettype = ~"void" @@ -370,7 +370,7 @@ proc mangleRecFieldName(field: PSym, rectype: PType): PRope = proc genRecordFieldsAux(m: BModule, n: PNode, accessExpr: PRope, rectype: PType, - check: var TIntSet): PRope = + check: var IntSet): PRope = var ae, uname, sname, a: PRope k: PNode @@ -419,11 +419,11 @@ proc genRecordFieldsAux(m: BModule, n: PNode, appf(result, "$1 $2;$n", [getTypeDescAux(m, fieldType, check), sname]) else: internalError(n.info, "genRecordFieldsAux()") -proc getRecordFields(m: BModule, typ: PType, check: var TIntSet): PRope = +proc getRecordFields(m: BModule, typ: PType, check: var IntSet): PRope = result = genRecordFieldsAux(m, typ.n, nil, typ, check) proc getRecordDesc(m: BModule, typ: PType, name: PRope, - check: var TIntSet): PRope = + check: var IntSet): PRope = # declare the record: var hasField = false @@ -461,7 +461,7 @@ proc getRecordDesc(m: BModule, typ: PType, name: PRope, app(result, "};" & tnl) proc getTupleDesc(m: BModule, typ: PType, name: PRope, - check: var TIntSet): PRope = + check: var IntSet): PRope = result = ropef("$1 $2 {$n", [structOrUnion(typ), name]) var desc: PRope = nil for i in countup(0, sonsLen(typ) - 1): @@ -474,7 +474,7 @@ proc getTupleDesc(m: BModule, typ: PType, name: PRope, proc pushType(m: BModule, typ: PType) = add(m.typeStack, typ) -proc getTypeDescAux(m: BModule, typ: PType, check: var TIntSet): PRope = +proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): PRope = # returns only the type's name var name, rettype, desc, recdesc: PRope diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim index ea8f32974..508f98074 100644 --- a/compiler/cgendata.nim +++ b/compiler/cgendata.nim @@ -101,10 +101,10 @@ type # without extension) typeCache*: TIdTable # cache the generated types forwTypeCache*: TIdTable # cache for forward declarations of types - declaredThings*: TIntSet # things we have declared in this .c file - declaredProtos*: TIntSet # prototypes we have declared in this .c file + declaredThings*: IntSet # things we have declared in this .c file + declaredProtos*: IntSet # prototypes we have declared in this .c file headerFiles*: TLinkedList # needed headers to include - typeInfoMarker*: TIntSet # needed for generating type information + typeInfoMarker*: IntSet # needed for generating type information initProc*: BProc # code for init procedure postInitProc*: BProc # code to be executed after the init proc preInitProc*: BProc # code executed before the init proc diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim index 1d0cb82ad..6703b1ba5 100644 --- a/compiler/cgmeth.nim +++ b/compiler/cgmeth.nim @@ -115,7 +115,7 @@ proc relevantCol(methods: TSymSeq, col: int): bool = if not sameType(t2, t): return true -proc cmpSignatures(a, b: PSym, relevantCols: TIntSet): int = +proc cmpSignatures(a, b: PSym, relevantCols: IntSet): int = for col in countup(1, sonsLen(a.typ) - 1): if contains(relevantCols, col): var aa = skipTypes(a.typ.sons[col], skipPtrs) @@ -124,7 +124,7 @@ proc cmpSignatures(a, b: PSym, relevantCols: TIntSet): int = if (d != high(int)): return d -proc sortBucket(a: var TSymSeq, relevantCols: TIntSet) = +proc sortBucket(a: var TSymSeq, relevantCols: IntSet) = # we use shellsort here; fast and simple var n = len(a) var h = 1 @@ -143,7 +143,7 @@ proc sortBucket(a: var TSymSeq, relevantCols: TIntSet) = a[j] = v if h == 1: break -proc genDispatcher(methods: TSymSeq, relevantCols: TIntSet): PSym = +proc genDispatcher(methods: TSymSeq, relevantCols: IntSet): PSym = var base = lastSon(methods[0].ast).sym result = base var paramLen = sonsLen(base.typ) diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 28288ed39..938cc5df2 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -14,7 +14,7 @@ import # We need to use a PStringTable here as defined symbols are always guaranteed # to be style insensitive. Otherwise hell would break lose. -var gSymbols: PStringTable +var gSymbols: StringTableRef proc defineSymbol*(symbol: string) = gSymbols[symbol] = "true" diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 5c851118d..4e576867b 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -23,7 +23,7 @@ type id: int # for generating IDs toc, section: TSections indexValFilename: string - seenSymbols: PStringTable # avoids duplicate symbol generation for HTML. + seenSymbols: StringTableRef # avoids duplicate symbol generation for HTML. PDoc* = ref TDocumentor ## Alias to type less. @@ -55,7 +55,7 @@ proc parseRst(text, filename: string, result = rstParse(text, filename, line, column, hasToc, rstOptions, docgenFindFile, compilerMsgHandler) -proc newDocumentor*(filename: string, config: PStringTable): PDoc = +proc newDocumentor*(filename: string, config: StringTableRef): PDoc = new(result) initRstGenerator(result[], (if gCmd != cmdRst2tex: outHtml else: outLatex), options.gConfigVars, filename, {roSupportRawDirective}, @@ -411,7 +411,7 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) = setIndexTerm(d[], symbolOrId, name, linkTitle, xmltree.escape(plainDocstring.docstringSummary)) -proc genJSONItem(d: PDoc, n, nameNode: PNode, k: TSymKind): PJsonNode = +proc genJSONItem(d: PDoc, n, nameNode: PNode, k: TSymKind): JsonNode = if not isVisible(nameNode): return var name = getName(d, nameNode) @@ -471,7 +471,7 @@ proc generateDoc*(d: PDoc, n: PNode) = of nkFromStmt, nkImportExceptStmt: traceDeps(d, n.sons[0]) else: discard -proc generateJson(d: PDoc, n: PNode, jArray: PJsonNode = nil): PJsonNode = +proc generateJson(d: PDoc, n: PNode, jArray: JsonNode = nil): JsonNode = case n.kind of nkCommentStmt: if n.comment != nil and startsWith(n.comment, "##"): diff --git a/compiler/importer.nim b/compiler/importer.nim index 538957887..159dfa6a5 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -113,7 +113,7 @@ proc importSymbol(c: PContext, n: PNode, fromMod: PSym) = e = nextIdentIter(it, fromMod.tab) else: rawImportSymbol(c, s) -proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: TIntSet) = +proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) = var i: TTabIter var s = initTabIter(i, fromMod.tab) while s != nil: @@ -126,10 +126,10 @@ proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: TIntSet) = s = nextIter(i, fromMod.tab) proc importAllSymbols*(c: PContext, fromMod: PSym) = - var exceptSet: TIntSet + var exceptSet: IntSet importAllSymbolsExcept(c, fromMod, exceptSet) -proc importForwarded(c: PContext, n: PNode, exceptSet: TIntSet) = +proc importForwarded(c: PContext, n: PNode, exceptSet: IntSet) = if n.isNil: return case n.kind of nkExportStmt: @@ -164,7 +164,7 @@ proc myImportModule(c: PContext, n: PNode): PSym = proc evalImport(c: PContext, n: PNode): PNode = result = n - var emptySet: TIntSet + var emptySet: IntSet for i in countup(0, sonsLen(n) - 1): var m = myImportModule(c, n.sons[i]) if m != nil: diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index c97adffb1..652f439a9 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -71,8 +71,8 @@ type TGlobals = object typeInfo, code: PRope forwarded: seq[PSym] - generatedSyms: TIntSet - typeInfoGenerated: TIntSet + generatedSyms: IntSet + typeInfoGenerated: IntSet PGlobals = ref TGlobals PProc = ref TProc diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index 2a9b1e886..b0595a7a7 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -140,12 +140,12 @@ type fn: PSym # function that belongs to this scope; # if up.fn != fn then we cross function boundaries. # This is an important case to consider. - vars: TIntSet # variables belonging to this environment + vars: IntSet # variables belonging to this environment TOuterContext = object fn: PSym # may also be a module! head: PEnv - capturedVars, processed: TIntSet + capturedVars, processed: IntSet localsToAccess: TIdNodeTable lambdasToEnv: TIdTable # PSym->PEnv mapping diff --git a/compiler/lexer.nim b/compiler/lexer.nim index e0b3b76ce..c2587efad 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -21,10 +21,10 @@ import const MaxLineLength* = 80 # lines longer than this lead to a warning - numChars*: TCharSet = {'0'..'9', 'a'..'z', 'A'..'Z'} - SymChars*: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'} - SymStartChars*: TCharSet = {'a'..'z', 'A'..'Z', '\x80'..'\xFF'} - OpChars*: TCharSet = {'+', '-', '*', '/', '\\', '<', '>', '!', '?', '^', '.', + numChars*: set[char] = {'0'..'9', 'a'..'z', 'A'..'Z'} + SymChars*: set[char] = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'} + SymStartChars*: set[char] = {'a'..'z', 'A'..'Z', '\x80'..'\xFF'} + OpChars*: set[char] = {'+', '-', '*', '/', '\\', '<', '>', '!', '?', '^', '.', '|', '=', '%', '&', '$', '@', '~', ':', '\x80'..'\xFF'} # don't forget to update the 'highlite' module if these charsets should change @@ -229,7 +229,7 @@ proc lexMessagePos(L: var TLexer, msg: TMsgKind, pos: int, arg = "") = var info = newLineInfo(L.fileIdx, L.lineNumber, pos - L.lineStart) msgs.message(info, msg, arg) -proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: TCharSet) = +proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: set[char]) = var pos = L.bufpos # use registers for pos, buf var buf = L.buf while true: @@ -246,7 +246,7 @@ proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: TCharSet) = inc(pos) L.bufpos = pos -proc matchTwoChars(L: TLexer, first: char, second: TCharSet): bool = +proc matchTwoChars(L: TLexer, first: char, second: set[char]): bool = result = (L.buf[L.bufpos] == first) and (L.buf[L.bufpos + 1] in second) proc isFloatLiteral(s: string): bool = diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 9fecdba6b..9bad9de91 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -40,11 +40,8 @@ proc considerQuotedIdent*(n: PNode): PIdent = template addSym*(scope: PScope, s: PSym) = strTableAdd(scope.symbols, s) -proc addUniqueSym*(scope: PScope, s: PSym): TResult = - if strTableIncl(scope.symbols, s): - result = Failure - else: - result = Success +proc addUniqueSym*(scope: PScope, s: PSym): bool = + result = not strTableIncl(scope.symbols, s) proc openScope*(c: PContext): PScope {.discardable.} = result = PScope(parent: c.currentScope, @@ -117,7 +114,7 @@ type mode*: TOverloadIterMode symChoiceIndex*: int scope*: PScope - inSymChoice: TIntSet + inSymChoice: IntSet proc getSymRepr*(s: PSym): string = case s.kind @@ -150,14 +147,14 @@ proc wrongRedefinition*(info: TLineInfo, s: string) = localError(info, errAttemptToRedefine, s) proc addDecl*(c: PContext, sym: PSym) = - if c.currentScope.addUniqueSym(sym) == Failure: + if not c.currentScope.addUniqueSym(sym): wrongRedefinition(sym.info, sym.name.s) proc addPrelimDecl*(c: PContext, sym: PSym) = discard c.currentScope.addUniqueSym(sym) proc addDeclAt*(scope: PScope, sym: PSym) = - if scope.addUniqueSym(sym) == Failure: + if not scope.addUniqueSym(sym): wrongRedefinition(sym.info, sym.name.s) proc addInterfaceDeclAux(c: PContext, sym: PSym) = diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 43b3b6c8e..58e12bfed 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -567,7 +567,7 @@ var gErrorMax*: int = 1 # stop after gErrorMax errors when useCaas: - var stdoutSocket*: TSocket + var stdoutSocket*: Socket proc unknownLineInfo*(): TLineInfo = result.line = int16(-1) diff --git a/compiler/rodread.nim b/compiler/rodread.nim index acccc1abb..3cc37fb98 100644 --- a/compiler/rodread.nim +++ b/compiler/rodread.nim @@ -137,7 +137,7 @@ type line: int # only used for debugging, but is always in the code moduleID: int syms: TIdTable # already processed symbols - memfile: TMemFile # unfortunately there is no point in time where we + memfile: MemFile # unfortunately there is no point in time where we # can close this! XXX methods*: TSymSeq origFile: string diff --git a/compiler/sem.nim b/compiler/sem.nim index be71ebef8..5f2e77781 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -340,7 +340,7 @@ type TSemGenericFlags = set[TSemGenericFlag] proc semGenericStmt(c: PContext, n: PNode, flags: TSemGenericFlags, - ctx: var TIntSet): PNode + ctx: var IntSet): PNode include semtypes, semtempl, semgnrc, semstmts, semexprs diff --git a/compiler/semasgn.nim b/compiler/semasgn.nim new file mode 100644 index 000000000..2c77bff7b --- /dev/null +++ b/compiler/semasgn.nim @@ -0,0 +1,196 @@ +# +# +# The Nim Compiler +# (c) Copyright 2014 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module implements lifting for assignments and ``deepCopy``. + +# included from sem.nim + +type + TLiftCtx = object + c: PContext + info: TLineInfo # for construction + result: PNode + kind: TTypeAttachedOp + +type + TFieldInstCtx = object # either 'tup[i]' or 'field' is valid + tupleType: PType # if != nil we're traversing a tuple + tupleIndex: int + field: PSym + replaceByFieldName: bool + +proc instFieldLoopBody(c: TFieldInstCtx, n: PNode, forLoop: PNode): PNode = + case n.kind + of nkEmpty..pred(nkIdent), succ(nkIdent)..nkNilLit: result = n + of nkIdent: + result = n + var L = sonsLen(forLoop) + if c.replaceByFieldName: + if n.ident.id == forLoop[0].ident.id: + let fieldName = if c.tupleType.isNil: c.field.name.s + elif c.tupleType.n.isNil: "Field" & $c.tupleIndex + else: c.tupleType.n.sons[c.tupleIndex].sym.name.s + result = newStrNode(nkStrLit, fieldName) + return + # other fields: + for i in ord(c.replaceByFieldName)..L-3: + if n.ident.id == forLoop[i].ident.id: + var call = forLoop.sons[L-2] + var tupl = call.sons[i+1-ord(c.replaceByFieldName)] + if c.field.isNil: + result = newNodeI(nkBracketExpr, n.info) + result.add(tupl) + result.add(newIntNode(nkIntLit, c.tupleIndex)) + else: + result = newNodeI(nkDotExpr, n.info) + result.add(tupl) + result.add(newSymNode(c.field, n.info)) + break + else: + if n.kind == nkContinueStmt: + localError(n.info, errGenerated, + "'continue' not supported in a 'fields' loop") + result = copyNode(n) + newSons(result, sonsLen(n)) + for i in countup(0, sonsLen(n)-1): + result.sons[i] = instFieldLoopBody(c, n.sons[i], forLoop) + +proc liftBodyObj(c: TLiftCtx; typ, x, y: PNode) = + case typ.kind + of nkSym: + var fc: TFieldInstCtx # either 'tup[i]' or 'field' is valid + fc.field = typ.sym + fc.replaceByFieldName = c.m == mFieldPairs + openScope(c.c) + inc c.c.inUnrolledContext + let body = instFieldLoopBody(fc, lastSon(forLoop), forLoop) + father.add(semStmt(c.c, body)) + dec c.c.inUnrolledContext + closeScope(c.c) + of nkNilLit: discard + of nkRecCase: + let L = forLoop.len + let call = forLoop.sons[L-2] + if call.len > 2: + localError(forLoop.info, errGenerated, + "parallel 'fields' iterator does not work for 'case' objects") + return + # iterate over the selector: + asgnForObjectFields(c, typ[0], forLoop, father) + # we need to generate a case statement: + var caseStmt = newNodeI(nkCaseStmt, c.info) + # generate selector: + var access = newNodeI(nkDotExpr, forLoop.info, 2) + access.sons[0] = call.sons[1] + access.sons[1] = newSymNode(typ.sons[0].sym, forLoop.info) + caseStmt.add(semExprWithType(c.c, access)) + # copy the branches over, but replace the fields with the for loop body: + for i in 1 .. <typ.len: + var branch = copyTree(typ[i]) + let L = branch.len + branch.sons[L-1] = newNodeI(nkStmtList, forLoop.info) + semForObjectFields(c, typ[i].lastSon, forLoop, branch[L-1]) + caseStmt.add(branch) + father.add(caseStmt) + of nkRecList: + for t in items(typ): liftBodyObj(c, t, x, y) + else: + illFormedAst(typ) + +proc newAsgnCall(op: PSym; x, y: PNode): PNode = + result = newNodeI(nkCall, x.info) + result.add(newSymNode(op)) + result.add x + result.add y + +proc newAsgnStmt(le, ri: PNode): PNode = + result = newNodeI(nkAsgn, le.info, 2) + result.sons[0] = le + result.sons[1] = ri + +proc newDestructorCall(op: PSym; x: PNode): PNode = + result = newNodeIT(nkCall, x.info, op.typ.sons[0]) + result.add(newSymNode(op)) + result.add x + +proc newDeepCopyCall(op: PSym; x, y: PNode): PNode = + result = newAsgnStmt(x, newDestructorCall(op, y)) + +proc considerOverloadedOp(c: TLiftCtx; t: PType; x, y: PNode): bool = + let op = t.attachedOps[c.kind] + if op != nil: + markUsed(c.info, op) + case c.kind + of attachedDestructor: + c.result.add newDestructorCall(op, x) + of attachedAsgn: + c.result.add newAsgnCall(op, x, y) + of attachedDeepCopy: + c.result.add newDeepCopyCall(op, x, y) + result = true + +proc defaultOp(c: TLiftCtx; t: PType; x, y: PNode) = + if c.kind != attachedDestructor: + c.result.add newAsgnStmt(x, y) + +proc liftBodyAux(c: TLiftCtx; t: PType; x, y: PNode) = + const hasAttachedOp: array[TTypeAttachedOp, TTypeIter] = [ + (proc (t: PType, closure: PObject): bool = + t.attachedOp[attachedDestructor] != nil), + (proc (t: PType, closure: PObject): bool = + t.attachedOp[attachedAsgn] != nil), + (proc (t: PType, closure: PObject): bool = + t.attachedOp[attachedDeepCopy] != nil)] + case t.kind + of tyNone, tyEmpty: discard + of tyPointer, tySet, tyBool, tyChar, tyEnum, tyInt..tyUInt64, tyCString: + defaultOp(c, t, x, y) + of tyPtr, tyString: + if not considerOverloadedOp(c, t, x, y): + defaultOp(c, t, x, y) + of tyArrayConstr, tyArray, tySequence: + if iterOverType(lastSon(t), hasAttachedOp[c.kind], nil): + # generate loop and call the attached Op: + + else: + defaultOp(c, t, x, y) + of tyObject: + liftBodyObj(c, t.n, x, y) + of tyTuple: + liftBodyTup(c, t, x, y) + of tyRef: + # we MUST not check for acyclic here as a DAG might still share nodes: + + of tyProc: + if t.callConv != ccClosure or c.kind != attachedDeepCopy: + defaultOp(c, t, x, y) + else: + # a big problem is that we don't know the enviroment's type here, so we + # have to go through some indirection; we delegate this to the codegen: + call = newNodeI(nkCall, n.info, 2) + call.typ = t + call.sons[0] = newSymNode(createMagic("deepCopy", mDeepCopy)) + call.sons[1] = y + c.result.add newAsgnStmt(x, call) + of tyVarargs, tyOpenArray: + localError(c.info, errGenerated, "cannot copy openArray") + of tyFromExpr, tyIter, tyProxy, tyBuiltInTypeClass, tyUserTypeClass, + tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot, tyAnything, + tyMutable, tyGenericParam, tyGenericBody, tyNil, tyExpr, tyStmt, + tyTypeDesc, tyGenericInvokation, tyBigNum, tyConst, tyForward: + internalError(c.info, "assignment requested for type: " & typeToString(t)) + of tyDistinct, tyOrdinal, tyRange, + tyGenericInst, tyFieldAccessor, tyStatic, tyVar: + liftBodyAux(c, lastSon(t)) + +proc liftBody(c: PContext; typ: PType; info: TLineInfo): PNode = + var a: TLiftCtx + a.info = info + a.result = newNodeI(nkStmtList, info) + liftBodyAux(a, typ) diff --git a/compiler/semdata.nim b/compiler/semdata.nim index c57ce2c26..667556222 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -57,7 +57,7 @@ type # can access private object fields instCounter*: int # to prevent endless instantiations - ambiguousSymbols*: TIntSet # ids of all ambiguous symbols (cannot + ambiguousSymbols*: IntSet # ids of all ambiguous symbols (cannot # store this info in the syms themselves!) inTypeClass*: int # > 0 if we are in a user-defined type class inGenericContext*: int # > 0 if we are in a generic type @@ -83,10 +83,10 @@ type semInferredLambda*: proc(c: PContext, pt: TIdTable, n: PNode): PNode semGenerateInstance*: proc (c: PContext, fn: PSym, pt: TIdTable, info: TLineInfo): PSym - includedFiles*: TIntSet # used to detect recursive include files + includedFiles*: IntSet # used to detect recursive include files userPragmas*: TStrTable evalContext*: PEvalContext - unknownIdents*: TIntSet # ids of all unknown identifiers to prevent + unknownIdents*: IntSet # ids of all unknown identifiers to prevent # naming it multiple times generics*: seq[TInstantiationPair] # pending list of instantiated generics to compile lastGenericIdx*: int # used for the generics stack diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index b310e0869..e2d05e15d 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1816,7 +1816,7 @@ proc semTuplePositionsConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = addSonSkipIntLit(typ, n.sons[i].typ) result.typ = typ -proc checkInitialized(n: PNode, ids: TIntSet, info: TLineInfo) = +proc checkInitialized(n: PNode, ids: IntSet, info: TLineInfo) = case n.kind of nkRecList: for i in countup(0, sonsLen(n) - 1): diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 8d8067195..aa811e08c 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -28,7 +28,7 @@ proc getIdentNode(n: PNode): PNode = proc semGenericStmtScope(c: PContext, n: PNode, flags: TSemGenericFlags, - ctx: var TIntSet): PNode = + ctx: var IntSet): PNode = openScope(c) result = semGenericStmt(c, n, flags, ctx) closeScope(c) @@ -67,7 +67,7 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode = else: result = newSymNode(s, n.info) proc lookup(c: PContext, n: PNode, flags: TSemGenericFlags, - ctx: var TIntSet): PNode = + ctx: var IntSet): PNode = result = n let ident = considerQuotedIdent(n) var s = searchInScopes(c, ident).skipAlias(n) @@ -89,7 +89,7 @@ proc newDot(n, b: PNode): PNode = result.add(b) proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags, - ctx: var TIntSet): PNode = + ctx: var IntSet): PNode = assert n.kind == nkDotExpr let luf = if withinMixin notin flags: {checkUndeclared} else: {} @@ -114,7 +114,7 @@ proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags, result = newDot(result, sym) proc semGenericStmt(c: PContext, n: PNode, - flags: TSemGenericFlags, ctx: var TIntSet): PNode = + flags: TSemGenericFlags, ctx: var IntSet): PNode = result = n if gCmd == cmdIdeTools: suggestStmt(c, n) case n.kind diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 880e37fef..9d81a0771 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -71,7 +71,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule): PNode = addSon(result, newSymNode(a, n.info)) a = nextOverloadIter(o, c, n) -proc semBindStmt(c: PContext, n: PNode, toBind: var TIntSet): PNode = +proc semBindStmt(c: PContext, n: PNode, toBind: var IntSet): PNode = for i in 0 .. < n.len: var a = n.sons[i] # If 'a' is an overloaded symbol, we used to use the first symbol @@ -91,7 +91,7 @@ proc semBindStmt(c: PContext, n: PNode, toBind: var TIntSet): PNode = illFormedAst(a) result = newNodeI(nkEmpty, n.info) -proc semMixinStmt(c: PContext, n: PNode, toMixin: var TIntSet): PNode = +proc semMixinStmt(c: PContext, n: PNode, toMixin: var IntSet): PNode = for i in 0 .. < n.len: toMixin.incl(considerQuotedIdent(n.sons[i]).id) result = newNodeI(nkEmpty, n.info) @@ -106,7 +106,7 @@ proc replaceIdentBySym(n: var PNode, s: PNode) = type TemplCtx {.pure, final.} = object c: PContext - toBind, toMixin, toInject: TIntSet + toBind, toMixin, toInject: IntSet owner: PSym proc getIdentNode(c: var TemplCtx, n: PNode): PNode = diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index c3d34f2ba..a0fe81db3 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -461,9 +461,9 @@ proc semCaseBranch(c: PContext, t, branch: PNode, branchIndex: int, swap(branch.sons[L-2], branch.sons[L-1]) checkForOverlap(c, t, i, branchIndex) -proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int, +proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int, father: PNode, rectype: PType) -proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int, +proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int, father: PNode, rectype: PType) = var a = copyNode(n) checkMinSonsLen(n, 2) @@ -498,7 +498,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int, localError(a.info, errNotAllCasesCovered) addSon(father, a) -proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int, +proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int, father: PNode, rectype: PType) = if n == nil: return case n.kind @@ -524,7 +524,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int, else: illFormedAst(n) if c.inGenericContext > 0: # use a new check intset here for each branch: - var newCheck: TIntSet + var newCheck: IntSet assign(newCheck, check) var newPos = pos var newf = newNodeI(nkRecList, n.info) @@ -578,7 +578,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int, of nkEmpty: discard else: illFormedAst(n) -proc addInheritedFieldsAux(c: PContext, check: var TIntSet, pos: var int, +proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int, n: PNode) = case n.kind of nkRecCase: @@ -597,7 +597,7 @@ proc addInheritedFieldsAux(c: PContext, check: var TIntSet, pos: var int, inc(pos) else: internalError(n.info, "addInheritedFieldsAux()") -proc addInheritedFields(c: PContext, check: var TIntSet, pos: var int, +proc addInheritedFields(c: PContext, check: var IntSet, pos: var int, obj: PType) = if (sonsLen(obj) > 0) and (obj.sons[0] != nil): addInheritedFields(c, check, pos, obj.sons[0]) @@ -847,7 +847,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, prev: PType, kind: TSymKind): PType = var res: PNode - cl: TIntSet + cl: IntSet checkMinSonsLen(n, 1) result = newOrPrevType(tyProc, prev, c) result.callConv = lastOptionEntry(c).defaultCC diff --git a/compiler/service.nim b/compiler/service.nim index 8e1c9cf1b..f0eeb0ed5 100644 --- a/compiler/service.nim +++ b/compiler/service.nim @@ -84,9 +84,9 @@ proc serve*(action: proc (){.nimcall.}) = of "tcp", "": when useCaas: var server = socket() - if server == invalidSocket: osError(osLastError()) + if server == invalidSocket: raiseOSError(osLastError()) let p = getConfigVar("server.port") - let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort + let port = if p.len > 0: parseInt(p).Port else: 6000.Port server.bindAddr(port, getConfigVar("server.address")) var inp = "".TaintedString server.listen() diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 588628c9a..26277eb50 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1319,7 +1319,7 @@ proc incrIndexType(t: PType) = inc t.sons[0].n.sons[1].intVal proc matchesAux(c: PContext, n, nOrig: PNode, - m: var TCandidate, marker: var TIntSet) = + m: var TCandidate, marker: var IntSet) = template checkConstraint(n: expr) {.immediate, dirty.} = if not formal.constraint.isNil: if matchNodeKinds(formal.constraint, n): diff --git a/compiler/types.nim b/compiler/types.nim index c810dc025..adc03a13e 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -160,9 +160,9 @@ proc enumHasHoles(t: PType): bool = while b.kind in {tyConst, tyMutable, tyRange, tyGenericInst}: b = b.sons[0] result = b.kind == tyEnum and tfEnumHasHoles in b.flags -proc iterOverTypeAux(marker: var TIntSet, t: PType, iter: TTypeIter, +proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter, closure: RootRef): bool -proc iterOverNode(marker: var TIntSet, n: PNode, iter: TTypeIter, +proc iterOverNode(marker: var IntSet, n: PNode, iter: TTypeIter, closure: RootRef): bool = if n != nil: case n.kind @@ -174,7 +174,7 @@ proc iterOverNode(marker: var TIntSet, n: PNode, iter: TTypeIter, result = iterOverNode(marker, n.sons[i], iter, closure) if result: return -proc iterOverTypeAux(marker: var TIntSet, t: PType, iter: TTypeIter, +proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter, closure: RootRef): bool = result = false if t == nil: return @@ -195,10 +195,10 @@ proc iterOverType(t: PType, iter: TTypeIter, closure: RootRef): bool = result = iterOverTypeAux(marker, t, iter, closure) proc searchTypeForAux(t: PType, predicate: TTypePredicate, - marker: var TIntSet): bool + marker: var IntSet): bool proc searchTypeNodeForAux(n: PNode, p: TTypePredicate, - marker: var TIntSet): bool = + marker: var IntSet): bool = result = false case n.kind of nkRecList: @@ -220,7 +220,7 @@ proc searchTypeNodeForAux(n: PNode, p: TTypePredicate, else: internalError(n.info, "searchTypeNodeForAux()") proc searchTypeForAux(t: PType, predicate: TTypePredicate, - marker: var TIntSet): bool = + marker: var IntSet): bool = # iterates over VALUE types! result = false if t == nil: return @@ -256,7 +256,7 @@ proc isObjectWithTypeFieldPredicate(t: PType): bool = tfFinal notin t.flags proc analyseObjectWithTypeFieldAux(t: PType, - marker: var TIntSet): TTypeFieldResult = + marker: var IntSet): TTypeFieldResult = var res: TTypeFieldResult result = frNone if t == nil: return @@ -310,8 +310,8 @@ proc containsHiddenPointer(typ: PType): bool = # that need to be copied deeply) result = searchTypeFor(typ, isHiddenPointer) -proc canFormAcycleAux(marker: var TIntSet, typ: PType, startId: int): bool -proc canFormAcycleNode(marker: var TIntSet, n: PNode, startId: int): bool = +proc canFormAcycleAux(marker: var IntSet, typ: PType, startId: int): bool +proc canFormAcycleNode(marker: var IntSet, n: PNode, startId: int): bool = result = false if n != nil: result = canFormAcycleAux(marker, n.typ, startId) @@ -324,7 +324,7 @@ proc canFormAcycleNode(marker: var TIntSet, n: PNode, startId: int): bool = result = canFormAcycleNode(marker, n.sons[i], startId) if result: return -proc canFormAcycleAux(marker: var TIntSet, typ: PType, startId: int): bool = +proc canFormAcycleAux(marker: var IntSet, typ: PType, startId: int): bool = result = false if typ == nil: return if tfAcyclic in typ.flags: return @@ -353,9 +353,9 @@ proc canFormAcycle(typ: PType): bool = var marker = initIntSet() result = canFormAcycleAux(marker, typ, typ.id) -proc mutateTypeAux(marker: var TIntSet, t: PType, iter: TTypeMutator, +proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator, closure: RootRef): PType -proc mutateNode(marker: var TIntSet, n: PNode, iter: TTypeMutator, +proc mutateNode(marker: var IntSet, n: PNode, iter: TTypeMutator, closure: RootRef): PNode = result = nil if n != nil: @@ -369,7 +369,7 @@ proc mutateNode(marker: var TIntSet, n: PNode, iter: TTypeMutator, for i in countup(0, sonsLen(n) - 1): addSon(result, mutateNode(marker, n.sons[i], iter, closure)) -proc mutateTypeAux(marker: var TIntSet, t: PType, iter: TTypeMutator, +proc mutateTypeAux(marker: var IntSet, t: PType, iter: TTypeMutator, closure: RootRef): PType = result = nil if t == nil: return @@ -1012,10 +1012,10 @@ type TTypeAllowedFlags = set[TTypeAllowedFlag] -proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind, +proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, flags: TTypeAllowedFlags = {}): bool -proc typeAllowedNode(marker: var TIntSet, n: PNode, kind: TSymKind, +proc typeAllowedNode(marker: var IntSet, n: PNode, kind: TSymKind, flags: TTypeAllowedFlags = {}): bool = result = true if n != nil: @@ -1039,7 +1039,7 @@ proc matchType*(a: PType, pattern: openArray[tuple[k:TTypeKind, i:int]], a = a.sons[i] result = a.kind == last -proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind, +proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, flags: TTypeAllowedFlags = {}): bool = assert(kind in {skVar, skLet, skConst, skParam, skResult}) # if we have already checked the type, return true, because we stop the diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 831e2ddce..acf5277c6 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -9,7 +9,7 @@ import ast, types, msgs, osproc, streams, options -proc readOutput(p: PProcess): string = +proc readOutput(p: Process): string = result = "" var output = p.outputStream discard p.waitForExit diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index f685a97e1..b21d51c93 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -66,8 +66,8 @@ proc getArgument*(n: PRstNode): string # ----------------------------- scanner part -------------------------------- const - SymChars: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'} - SmileyStartChars: TCharSet = {':', ';', '8'} + SymChars: set[char] = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF'} + SmileyStartChars: set[char] = {':', ';', '8'} Smilies = { ":D": "icon_e_biggrin", ":-D": "icon_e_biggrin", @@ -111,7 +111,7 @@ const type TTokType = enum tkEof, tkIndent, tkWhite, tkWord, tkAdornment, tkPunct, tkOther - TToken{.final.} = object # a RST token + TToken = object # a RST token kind*: TTokType # the type of the token ival*: int # the indentation or parsed integer value symbol*: string # the parsed symbol as string @@ -125,7 +125,7 @@ type skipPounds*: bool -proc getThing(L: var TLexer, tok: var TToken, s: TCharSet) = +proc getThing(L: var TLexer, tok: var TToken, s: set[char]) = tok.kind = tkWord tok.line = L.line tok.col = L.col diff --git a/lib/packages/docutils/rstast.nim b/lib/packages/docutils/rstast.nim index 7b781ad6a..52af672df 100644 --- a/lib/packages/docutils/rstast.nim +++ b/lib/packages/docutils/rstast.nim @@ -286,7 +286,7 @@ proc renderRstToRst*(n: PRstNode, result: var string) = var d: TRenderContext renderRstToRst(d, n, result) -proc renderRstToJsonNode(node: PRstNode): PJsonNode = +proc renderRstToJsonNode(node: PRstNode): JsonNode = result = %[ (key: "kind", val: %($node.kind)), @@ -295,7 +295,7 @@ proc renderRstToJsonNode(node: PRstNode): PJsonNode = if node.text != nil: result.add("text", %node.text) if node.sons != nil and len(node.sons) > 0: - var accm = newSeq[PJsonNode](len(node.sons)) + var accm = newSeq[JsonNode](len(node.sons)) for i, son in node.sons: accm[i] = renderRstToJsonNode(son) result.add("sons", %accm) diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index e1bf1f649..02b0afd2f 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -35,7 +35,7 @@ type outHtml, # output is HTML outLatex # output is Latex - TTocEntry{.final.} = object + TTocEntry = object n*: PRstNode refname*, header*: string @@ -44,7 +44,7 @@ type TRstGenerator* = object of RootObj target*: TOutputTarget - config*: PStringTable + config*: StringTableRef splitAfter*: int # split too long entries in the TOC tocPart*: seq[TTocEntry] hasToc*: bool @@ -57,21 +57,21 @@ type currentSection: string ## \ ## Stores the empty string or the last headline/overline found in the rst ## document, so it can be used as a prettier name for term index generation. - seenIndexTerms: TTable[string, int] ## \ + seenIndexTerms: Table[string, int] ## \ ## Keeps count of same text index terms to generate different identifiers ## for hyperlinks. See renderIndexTerm proc for details. PDoc = var TRstGenerator ## Alias to type less. proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, - config: PStringTable, filename: string, + config: StringTableRef, filename: string, options: TRstParseOptions, findFile: TFindFileHandler, msgHandler: TMsgHandler) = ## Initializes a ``TRstGenerator``. ## ## You need to call this before using a ``TRstGenerator`` with any other - ## procs in this module. Pass a non ``nil`` ``PStringTable`` value as + ## procs in this module. Pass a non ``nil`` ``StringTableRef`` value as ## `config` with parameters used by the HTML output generator. If you don't ## know what to use, pass the results of the `defaultConfig() ## <#defaultConfig>_` proc. @@ -341,13 +341,13 @@ proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) = [id, term]) type - TIndexEntry {.pure, final.} = object + TIndexEntry = object keyword: string link: string linkTitle: string ## If not nil, contains a prettier text for the href linkDesc: string ## If not nil, the title attribute of the final href - TIndexedDocs {.pure, final.} = TTable[TIndexEntry, seq[TIndexEntry]] ## \ + TIndexedDocs = Table[TIndexEntry, seq[TIndexEntry]] ## \ ## Contains the index sequences for doc types. ## ## The key is a *fake* TIndexEntry which will contain the title of the @@ -1048,10 +1048,10 @@ proc formatNamedVars*(frmt: string, varnames: openArray[string], if i-1 >= start: add(result, substr(frmt, start, i - 1)) -proc defaultConfig*(): PStringTable = +proc defaultConfig*(): StringTableRef = ## Returns a default configuration for embedded HTML generation. ## - ## The returned ``PStringTable`` contains the paramters used by the HTML + ## The returned ``StringTableRef`` contains the paramters used by the HTML ## engine to build the final output. For information on what these parameters ## are and their purpose, please look up the file ``config/nimdoc.cfg`` ## bundled with the compiler. @@ -1113,7 +1113,7 @@ $content # ---------- forum --------------------------------------------------------- proc rstToHtml*(s: string, options: TRstParseOptions, - config: PStringTable): string = + config: StringTableRef): string = ## Converts an input rst string into embeddable HTML. ## ## This convenience proc parses any input string using rst markup (it doesn't |