diff --git a/compiler/commands.nim b/compiler/commands.nim index 46ade667e..6ca212ddb 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -490,10 +490,10 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; of "oldnewlines": case arg.normalize of "on": - options.gOldNewlines = true + conf.oldNewlines = true defineSymbol(conf.symbols, "nimOldNewlines") of "off": - options.gOldNewlines = false + conf.oldNewlines = false undefSymbol(conf.symbols, "nimOldNewlines") else: localError(conf, info, errOnOrOffExpectedButXFound % arg) @@ -671,19 +671,19 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; trackDirty(conf, arg, info) of "suggest": expectNoArg(conf, switch, arg, pass, info) - gIdeCmd = ideSug + conf.ideCmd = ideSug of "def": expectNoArg(conf, switch, arg, pass, info) - gIdeCmd = ideDef + conf.ideCmd = ideDef of "eval": expectArg(conf, switch, arg, pass, info) gEvalExpr = arg of "context": expectNoArg(conf, switch, arg, pass, info) - gIdeCmd = ideCon + conf.ideCmd = ideCon of "usages": expectNoArg(conf, switch, arg, pass, info) - gIdeCmd = ideUse + conf.ideCmd = ideUse of "stdout": expectNoArg(conf, switch, arg, pass, info) incl(gGlobalOptions, optStdout) diff --git a/compiler/configuration.nim b/compiler/configuration.nim index f7b9803e7..5164fd6df 100644 --- a/compiler/configuration.nim +++ b/compiler/configuration.nim @@ -18,7 +18,13 @@ const type TMsgKind* = enum - errUnknown, errInternal, errIllFormedAstX, errCannotOpenFile, errGenerated, + errUnknown, errInternal, errIllFormedAstX, errCannotOpenFile, + errXExpected, + errGridTableNotImplemented, + errGeneralParseError, + errNewSectionExpected, + errInvalidDirectiveX, + errGenerated, errUser, warnCannotOpenFile, warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, @@ -47,6 +53,11 @@ const errInternal: "internal error: $1", errIllFormedAstX: "illformed AST: $1", errCannotOpenFile: "cannot open '$1'", + errXExpected: "'$1' expected", + errGridTableNotImplemented: "grid table is not implemented", + errGeneralParseError: "general parse error", + errNewSectionExpected: "new section expected", + errInvalidDirectiveX: "invalid directive: '$1'", errGenerated: "$1", errUser: "$1", warnCannotOpenFile: "cannot open '$1'", diff --git a/compiler/docgen.nim b/compiler/docgen.nim index e1a70a23e..a21c8073f 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -16,7 +16,7 @@ import wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast, packages/docutils/rst, packages/docutils/rstgen, times, packages/docutils/highlite, sempass2, json, xmltree, cgi, - typesrenderer, astalgo, modulepaths + typesrenderer, astalgo, modulepaths, configuration type TSections = array[TSymKind, Rope] @@ -53,36 +53,40 @@ proc attachToType(d: PDoc; p: PSym): PSym = if params.len > 0: check(0) for i in 2..= gcRefc -template preciseStack*(): bool = gPreciseStack +proc importantComments*(conf: ConfigRef): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools} +proc usesNativeGC*(conf: ConfigRef): bool {.inline.} = gSelectedGC >= gcRefc +template preciseStack*(conf: ConfigRef): bool = gPreciseStack -template compilationCachePresent*: untyped = +template compilationCachePresent*(conf: ConfigRef): untyped = gSymbolFiles in {enabledSf, writeOnlySf} # {optCaasEnabled, optSymbolFiles} * gGlobalOptions != {} -template optPreserveOrigSource*: untyped = +template optPreserveOrigSource*(conf: ConfigRef): untyped = optEmbedOrigSrc in gGlobalOptions const @@ -264,7 +264,6 @@ const # additional configuration variables: var - gConfigVars* = newStringTable(modeStyleInsensitive) gDllOverrides = newStringTable(modeCaseInsensitive) gModuleOverrides* = newStringTable(modeStyleInsensitive) gPrefixDir* = "" # Overrides the default prefix dir in getPrefixDir proc. @@ -283,10 +282,10 @@ var const oKeepVariableNames* = true -template compilingLib*: bool = +template compilingLib*(conf: ConfigRef): bool = gGlobalOptions * {optGenGuiApp, optGenDynLib} != {} -proc mainCommandArg*: string = +proc mainCommandArg*(conf: ConfigRef): string = ## This is intended for commands like check or parse ## which will work on the main project file unless ## explicitly given a specific file argument @@ -296,13 +295,13 @@ proc mainCommandArg*: string = result = gProjectName proc existsConfigVar*(conf: ConfigRef; key: string): bool = - result = hasKey(gConfigVars, key) + result = hasKey(conf.configVars, key) proc getConfigVar*(conf: ConfigRef; key: string): string = - result = gConfigVars.getOrDefault key + result = conf.configVars.getOrDefault key proc setConfigVar*(conf: ConfigRef; key, val: string) = - gConfigVars[key] = val + conf.configVars[key] = val proc getOutFile*(conf: ConfigRef; filename, ext: string): string = if options.outFile != "": result = options.outFile diff --git a/compiler/typesrenderer.nim b/compiler/typesrenderer.nim index 4a9b8d1a9..4d75d5d05 100644 --- a/compiler/typesrenderer.nim +++ b/compiler/typesrenderer.nim @@ -17,7 +17,6 @@ proc renderPlainSymbolName*(n: PNode): string = ## Use this on documentation name nodes to extract the *raw* symbol name, ## without decorations, parameters, or anything. That can be used as the base ## for the HTML hyperlinks. - result = "" case n.kind of nkPostfix, nkAccQuoted: result = renderPlainSymbolName(n[n.len-1]) @@ -28,7 +27,8 @@ proc renderPlainSymbolName*(n: PNode): string = of nkPragmaExpr: result = renderPlainSymbolName(n[0]) else: - internalError(n.info, "renderPlainSymbolName() with " & $n.kind) + result = "" + #internalError(n.info, "renderPlainSymbolName() with " & $n.kind) assert(not result.isNil) proc renderType(n: PNode): string = @@ -105,7 +105,8 @@ proc renderParamTypes(found: var seq[string], n: PNode) = for i in 0 ..< typePos: found.add(typeStr) else: - internalError(n.info, "renderParamTypes(found,n) with " & $n.kind) + found.add($n) + #internalError(n.info, "renderParamTypes(found,n) with " & $n.kind) proc renderParamTypes*(n: PNode, sep = defaultParamSeparator): string = ## Returns the types contained in `n` joined by `sep`.