summary refs log tree commit diff stats
path: root/compiler/lookups.nim
Commit message (Collapse)AuthorAgeFilesLines
* adjust spellSuggestSecretSauce logic to avoid too many matches for small ↵Timothee Cour2021-03-181-2/+8
| | | | symbols (#17410)
* semLambda removed, semProcAux reworked (#17379)Saem Ghani2021-03-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * simplified proc-like name ident to symbol code * wip - reworking generic param sem * wip - closer to removing nkEmpty generic params * it's hacky but tests pass * slowly tweaking semProcAux to take on semLambda * fix pragma superset check proto vs current * Set the symbol owner earlier * partial progress reworking proto found bug where default values between forward and impl lead to overload resolution issues. * simplified pragma handling and callConv checks Co-authored-by: Clyybber <Clyybber@users.noreply.github.com> * partially working * cgexprs issue * It works! * comment clean-up * clean-up asserts, comments, and other bits * add isGenericParams, inline isGeneric queries * seeing if this is sufficiently consistent * can use this approach or continue it in a further PR * commentary about nullary generics and clean-ups * fixed a mistake in PNode isGenericRoutine * Some small cleanups * Small cleanup * for func lambdas ensure we use lambda pragmas * add some basic compileTime func tests * [ci skip] remove comments Co-authored-by: Clyybber <Clyybber@users.noreply.github.com> Co-authored-by: Clyybber <darkmine956@gmail.com>
* followup #16067 --spellSuggest (#17401)Timothee Cour2021-03-171-3/+5
| | | | | | | * followup #16067 --spellSuggest * enable --spellSuggest by default * fixup
* fix #2844 #3911; add --spellsuggest to suggest symbols in scope with similar ↵Timothee Cour2021-03-161-32/+69
| | | | | | | spellings on undefined symbol error (#16067) * add --spellsuggest to suggest symbols in scope with similar spellings on undefined symbol errors * implement --spellsuggest with 0 arguments
* IC: bugfixes (WIP) (#16836)Andreas Rumpf2021-02-021-4/+17
| | | | | | | | * minor improvements * IC: added the required logic for compilerProcs * LazySym ftw * we need this testing logic * reimplement the old way we use for module package creation * fixes a regression; don't pick module names if you can avoid it
* IC: next steps (#16550)Andreas Rumpf2021-01-071-26/+30
| | | | | | | | | | | | | | | | | | * cleanups * ast.nim: cleanups * IC: no more sym.tab field, stored externally in the module graph * nimble compiles again * rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly * rodfiles: added compilerproc and export sections * rodfiles: added all the missing sections * rodfiles: track the missing information * IC: architecture for lazy loading of proc bodies * make tests green again * completed the lazy loading of proc bodies * symbol lookup integration, part 1 * symbol lookup integration, part 2 * symbol lookup integration, part 3 * make tcompilerapi work again * rodfiles: fixed config change handling
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-1/+1
| | | | | | | | | | | | | | | | | | | * reworked ID handling * the packed AST now has its own ID mechanism * basic serialization code works * extract rodfiles to its own module * rodfiles: store and compare configs * rodfiles: store dependencies * store config at the end * precise dependency tracking * dependency tracking for rodfiles * completed loading of PSym, PType, etc * removed dead code * bugfix: do not realloc seqs when taking addr into an element * make IC opt-in for now * makes tcompilerapi green again * final cleanups Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
* refactorings to prepare the compiler for IC (#15935)Andreas Rumpf2020-12-171-58/+243
| | | | | | | | | | | | | | * added ic specific Nim code; WIP * make the symbol import mechanism lazy; WIP * ensure that modules can be imported multiple times * ambiguity checking * handle converters and TR macros properly * make 'enum' test category green again * special logic for semi-pure enums * makes nimsuggest tests green again * fixes nimdata * makes nimpy green again * makes more important packages work
* cmdline: improve command processing (#16056)Timothee Cour2020-11-261-1/+1
|
* honor --declaredLocs in more places, including type mismatch errors; also ↵Timothee Cour2020-10-271-4/+6
| | | | | | | show `kind` with --declaredLocs (#15673) * honor --declaredLocs in more places, including type mismatch errors * fix tests * show declaration location also when type mismatch names clash
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-1/+1
| | | | | | | | | | | | | | | | | * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here)
* Fix forward declarations in shadow scope contexts (#15386)Clyybber2020-09-221-5/+7
| | | | | | | | | | | | | | | * Fix forward declarations in shadow scope contexts * Add testcase for #15385 * Less empty lines * Fix tests * Inline isShadowScope * Add original testcase (with reduced amount of iterations) * Add testcase without forward decl
* Fix #5691 (#15158)Clyybber2020-08-271-0/+22
| | | | | | | | * Fix #5691 * Cleanup and thoughts * Use scope approach * Seperate defined/declared/declaredInScope magics * Fix declaredInScope * Update spec accordingly
* Fix forward declaration issues in template/macro context (#15091)Clyybber2020-07-291-2/+1
| | | | | | | | | | | | | | | | | | | | | | | * Fix forward declaration issues in template/macro context * Correct forward declaration resolving for overloads * Remove old dead code * WIP consistent gensym ids * Minimize diff * Remove obsoleted hack * Add templInstCounter to give unique IDs to template instantiations * Remove obsoleted code * Eh, init in myOpen, not myProcess... * Remove optNimV019 * Add testcase for #13484
* Deprecate when declared(echo):echo (#13840)Juan Carlos2020-04-021-10/+9
|
* Cosmetic compiler cleanup (#12718)Clyybber2019-11-281-32/+32
| | | | | | | | | | | | | | | | | | * Cleanup compiler code base * Unify add calls * Unify len invocations * Unify range operators * Fix oversight * Remove {.procvar.} pragma * initCandidate -> newCandidate where reasonable * Unify safeLen calls
* Fix spellings (#12277) [backport]Federico Ceratto2019-09-271-1/+1
|
* Small ast.nim cleanup (#12156)Clyybber2019-09-091-1/+1
| | | | | * Remove sonsLen * Use Indexable
* [refactoring] remove unused imports in the compiler and in some stdlib modulesAraq2019-07-181-1/+1
|
* balance space around emdash --Julian Fondren2019-04-291-1/+1
|
* add indent to ambiguous-identifier outputJulian Fondren2019-04-281-1/+1
|
* re-include ambiguous identifier in ambiguous identifier outputJulian Fondren2019-04-281-1/+2
|
* re-include module in ambiguous identifier outputJulian Fondren2019-04-281-1/+1
|
* provide more useful ambiguous-identifier error outputJulian Fondren2019-04-281-3/+3
|
* fixes #10251 (#10255)Arne Döring2019-01-101-1/+1
|
* [error messages, stacktraces] fix #8794 #9270 #9767 #9768 (#9766)Timothee Cour2019-01-081-1/+1
| | | | | | | | | | | | | | | | | | | * fixes #8794 : `Error: undeclared field: 'foo'` should show type (+ where type is defined) (hard to guess in generic code) * fixes #9270: `--listFullPaths` not honored by `declared in foo.nim` messages * fixes #9767: VM stacktrace doesn't honor --excessiveStackTrace:on * fixes #9768: VM stacktrace misses column info, can lead to ambiguous or harder to read stacktraces * refactors some col+1 code to col + ColOffset (self documents code) * make getProcHeader show declared info location also for types and all routine kinds (including macros,templates) instead of just (rather arbitrarily) for iterator,proc,func,method * --listFullPaths now is honored in more places * fix typo system/except.nim => lib/system/excpt.nim * remove substr(foo, 0) hack in compiler/vm.nim which seems old and not applicable anymore
* Deprecate gc v2 (#10151)Neelesh Chandola2019-01-011-1/+1
| | | | | | * Deprecate gc v2 * warnDeprecated now has custom messages
* fixes #10101 (#10103)Timothee Cour2018-12-271-1/+1
|
* change approachAndrii Riabushenko2018-12-091-2/+1
|
* Fix hintXDeclaredButNotUsed for enum fields marked as usedAndrii Riabushenko2018-12-081-1/+2
|
* fixes #9764Araq2018-11-231-1/+1
|
* improve the error message for 'attempt to redefine X'; fixes #447Andreas Rumpf2018-09-171-11/+17
|
* fixes #8066Araq2018-08-311-1/+1
|
* better formatting for recursive module dependency (#8735)Timothee Cour2018-08-231-1/+1
|
* sfForward is also sfReorder for skModule symbols (#8692)LemonBoy2018-08-211-1/+1
| | | | | Take this into account while searching for undefined forward references. Fixes #8665
* WIP: disallow 'nil' for strings and seqsAndreas Rumpf2018-08-131-1/+1
|
* use slashes instead of dots for pathsAndreas Rumpf2018-08-061-1/+1
|
* baby steps for incremental compilationAndreas Rumpf2018-05-301-5/+9
|
* refactoring: remove idents.legacy global variable and pass the IdentCache ↵Andreas Rumpf2018-05-271-13/+13
| | | | around explicitly
* remove more global variables in the Nim compilerAndreas Rumpf2018-05-271-1/+1
|
* make tests green againAndreas Rumpf2018-05-181-13/+15
|
* preparations of making compiler/msgs.nim free of global variablesAndreas Rumpf2018-05-171-1/+1
|
* options.nim: no global variables anymoreAndreas Rumpf2018-05-131-4/+4
|
* lookups compiles againAndreas Rumpf2018-05-101-56/+53
|
* Cpp codegen: handling of imported exceptions. Fixes #3571 (#7360)cooldome2018-04-101-2/+0
|
* Static[T] fixes (#7333)zah2018-03-241-1/+2
| | | | | | | | | | | * fix the usage of unresolved static[T] parameters in proc signatures * fix tsametype and tmacrogenerics * Allow creating composite type classes with concepts and using them in type signatures * Allow integers to be used in ident concatenations * Support using imported C++ generic types in proc signatures * fixes #7230 * closes #7379 * re-enable some metatype tests
* fixes #6965Araq2017-12-281-3/+4
|
* fixes #1860; macro generating a wrong nkSymChoice nodeAndreas Rumpf2017-10-301-2/+10
|
* deprecated unary '<'Andreas Rumpf2017-10-291-1/+1
|
* first implementation of package level types that allow forwarding across ↵Andreas Rumpf2017-10-281-1/+1
| | | | module boundaries
string) = for k, f in walkDir(root): case k of pcFile, pcLinkToFile: if cmpIgnoreCase(ext, splitFile(f).ext) == 0: add(s, f) of pcDir: walkDirRecursively(s, f, ext) of pcLinkToDir: nil proc addFiles(s: var seq[string], dir, ext: string, patterns: seq[string]) = for p in items(patterns): if existsDir(dir / p): walkDirRecursively(s, dir / p, ext) else: add(s, dir / addFileExt(p, ext)) proc parseIniFile(c: var TConfigData) = var p: TCfgParser section: string # current section var input = newFileStream(c.infile, fmRead) if input != nil: open(p, input, c.infile) while true: var k = next(p) case k.kind of cfgEof: break of cfgSectionStart: section = normalize(k.section) case section of "project", "links", "tabs", "ticker", "documentation", "var": nil else: echo("[Warning] Skipping unknown section: " & section) of cfgKeyValuePair: var v = k.value % c.vars c.vars[k.key] = v case section of "project": case normalize(k.key) of "name": c.projectName = v of "title": c.projectTitle = v of "logo": c.logo = v of "authors": c.authors = v else: quit(errorStr(p, "unknown variable: " & k.key)) of "var": nil of "links": let valID = v.split(';') add(c.links, (k.key.replace('_', ' '), valID[1], valID[0])) of "tabs": add(c.tabs, (k.key, "", v)) of "ticker": c.ticker = v of "documentation": case normalize(k.key) of "doc": addFiles(c.doc, "doc", ".txt", split(v, {';'})) of "pdf": addFiles(c.pdf, "doc", ".txt", split(v, {';'})) of "srcdoc": addFiles(c.srcdoc, "lib", ".nim", split(v, {';'})) of "srcdoc2": addFiles(c.srcdoc2, "lib", ".nim", split(v, {';'})) of "webdoc": addFiles(c.webdoc, "lib", ".nim", split(v, {';'})) else: quit(errorStr(p, "unknown variable: " & k.key)) of "quotations": let vSplit = v.split('-') doAssert vSplit.len == 2 c.quotations[k.key.normalize] = (vSplit[0], vSplit[1]) else: nil of cfgOption: quit(errorStr(p, "syntax error")) of cfgError: quit(errorStr(p, k.msg)) close(p) if c.projectName.len == 0: c.projectName = changeFileExt(extractFilename(c.infile), "") if c.outdir.len == 0: c.outdir = splitFile(c.infile).dir else: quit("cannot open: " & c.infile) # ------------------- main ---------------------------------------------------- proc Exec(cmd: string) = echo(cmd) if os.execShellCmd(cmd) != 0: quit("external program failed") proc buildDoc(c: var TConfigData, destPath: string) = # call nim for the documentation: for d in items(c.doc): Exec("nimrod rst2html $# -o:$# --index:on $#" % [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d]) for d in items(c.srcdoc): Exec("nimrod doc $# -o:$# --index:on $#" % [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d]) for d in items(c.srcdoc2): Exec("nimrod doc2 $# -o:$# --index:on $#" % [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d]) Exec("nimrod buildIndex -o:$1/theindex.html $1" % [destPath]) proc buildPdfDoc(c: var TConfigData, destPath: string) = if os.execShellCmd("pdflatex -version") != 0: echo "pdflatex not found; no PDF documentation generated" else: for d in items(c.pdf): Exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d]) # call LaTeX twice to get cross references right: Exec("pdflatex " & changeFileExt(d, "tex")) Exec("pdflatex " & changeFileExt(d, "tex")) # delete all the crappy temporary files: var pdf = splitFile(d).name & ".pdf" moveFile(dest=destPath / pdf, source=pdf) removeFile(changeFileExt(pdf, "aux")) if existsFile(changeFileExt(pdf, "toc")): removeFile(changeFileExt(pdf, "toc")) removeFile(changeFileExt(pdf, "log")) removeFile(changeFileExt(pdf, "out")) removeFile(changeFileExt(d, "tex")) proc buildAddDoc(c: var TConfigData, destPath: string) = # build additional documentation (without the index): for d in items(c.webdoc): Exec("nimrod doc $# -o:$# $#" % [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d]) proc parseNewsTitles(inputFilename: string): seq[TRssItem] = # parses the file for titles and returns them as TRssItem blocks. let reYearMonthDayTitle = re(rYearMonthDayTitle) var input: TFile line = "" result = @[] if not open(input, inputFilename): quit("Could not read $1 for rss generation" % [inputFilename]) finally: input.close() while input.readline(line): if line =~ reYearMonthDayTitle: result.add(TRssItem(year: matches[0], month: matches[1], day: matches[2], title: matches[3])) proc genUUID(text: string): string = # Returns a valid RSS uuid, which is basically md5 with dashes and a prefix. result = getMD5(text) result.insert("-", 20) result.insert("-", 16) result.insert("-", 12) result.insert("-", 8) result.insert("urn:uuid:") proc genNewsLink(title: string): string = # Mangles a title string into an expected news.html anchor. result = title result.insert("Z") for i in 1..len(result)-1: let letter = result[i].toLower() if letter in validAnchorCharacters: result[i] = letter else: result[i] = '-' result.insert(rssNewsUrl & "#") proc generateRss(outputFilename: string, news: seq[TRssItem]) = # Given a list of rss items generates an rss overwriting destination. var output: TFile if not open(output, outputFilename, mode = fmWrite): quit("Could not write to $1 for rss generation" % [outputFilename]) finally: output.close() output.write("""<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> """) output.write(title("Nimrod website news")) output.write(link(href = rssUrl, rel = "self")) output.write(link(href = rssNewsUrl)) output.write(id(rssNewsUrl)) let now = getGMTime(getTime()) output.write(updatedDate($now.year, $(int(now.month) + 1), $now.monthday)) for rss in news: let joinedTitle = "$1-$2-$3 $4" % [rss.year, rss.month, rss.day, rss.title] output.write(entry( title(joinedTitle), id(genUUID(joinedTitle)), link(`type` = "text/html", rel = "alternate", href = genNewsLink(joinedTitle)), updatedDate(rss.year, rss.month, rss.day), "<author><name>Nimrod</name></author>", content(joinedTitle, `type` = "text"), )) output.write("""</feed>""") proc buildNewsRss(c: var TConfigData, destPath: string) = # generates an xml feed from the web/news.txt file let srcFilename = "web" / "news.txt" destFilename = destPath / changeFileExt(splitFile(srcFilename).name, "xml") generateRss(destFilename, parseNewsTitles(srcFilename)) proc main(c: var TConfigData) = const cmd = "nimrod rst2html --compileonly $1 -o:web/$2.temp web/$2.txt" if c.ticker.len > 0: try: c.ticker = readFile("web" / c.ticker) except EIO: quit("[Error] cannot open: " & c.ticker) for i in 0..c.tabs.len-1: var file = c.tabs[i].val let rss = if file in ["news", "index"]: extractFilename(rssUrl) else: "" Exec(cmd % [c.nimrodArgs, file]) var temp = "web" / changeFileExt(file, "temp") var content: string try: content = readFile(temp) except EIO: quit("[Error] cannot open: " & temp) var f: TFile var outfile = "web/upload/$#.html" % file if not existsDir("web/upload"): createDir("web/upload") if open(f, outfile, fmWrite): writeln(f, generateHTMLPage(c, file, content, rss)) close(f) else: quit("[Error] cannot write file: " & outfile) removeFile(temp) copyDir("web/assets", "web/upload/assets") buildNewsRss(c, "web/upload") buildAddDoc(c, "web/upload") buildDoc(c, "web/upload") buildDoc(c, "doc") buildPdfDoc(c, "doc") var c: TConfigData initConfigData(c) parseCmdLine(c) parseIniFile(c) main(c)