summary refs log tree commit diff stats
path: root/compiler/ast.nim
Commit message (Collapse)AuthorAgeFilesLines
* IC: progress and refactorings (#22961)Andreas Rumpf2023-11-201-13/+21
|
* Inlay hints support (#22896)Nikolay Nikolov2023-11-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds inlay hints support to nimsuggest. It adds a new command to nimsuggest, called 'inlayHints'. Currently, it provides type information to 'var' and 'let' variables. In the future, inlay hints can also be added for 'const' and for function parameters. The protocol also reserves space for a tooltip field, which is not used, yet, but support for it can be added in the future, without further changing the protocol. The change includes refactoring to allow the 'inlayHints' command to return a completely different structure, compared to the other nimsuggest commands. This will allow other future commands to have custom return types as well. All the previous commands return the same structure as before, so perfect backwards compatibility is maintained. To use this feature, an update to the nim language server, as well as the VS code extension is needed. Related PRs: nimlangserver: https://github.com/nim-lang/langserver/pull/53 VS code extension: https://github.com/saem/vscode-nim/pull/134 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-2/+4
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* NIR: store sizes, alignments and offsets in the type graph; beginning… ↵Andreas Rumpf2023-10-161-1/+1
| | | | | (#22822) …s of a patent-pending new VM
* NIR: progress (#22817)Andreas Rumpf2023-10-121-1/+1
| | | | | | Done: - [x] Implement conversions to openArray/varargs. - [x] Implement index/range checking.
* NIR: Nim intermediate representation (#22777)Andreas Rumpf2023-10-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Theoretical Benefits / Plans: - Typed assembler-like language. - Allows for a CPS transformation. - Can replace the existing C backend by a new C backend. - Can replace the VM. - Can do more effective "not nil" checking and static array bounds checking. - Can be used instead of the DFA. - Easily translatable to LLVM. - Reasonably easy to produce native code from. - Tiny memory consumption. No pointers, no cry. **In very early stages of development.** Todo: - [x] Map Nim types to IR types. - [ ] Map Nim AST to IR instructions: - [x] Map bitsets to bitops. - [ ] Implement string cases. - [ ] Implement range and index checks. - [x] Implement `default(T)` builtin. - [x] Implement multi string concat. - [ ] Write some analysis passes. - [ ] Write a backend. - [x] Integrate into the compilation pipeline.
* refactor semtempl ident declarations, some special word use (#22693)metagn2023-09-141-2/+2
| | | | | | | | | `semtempl` is refactored to combine the uses of `getIdentNode`, `onlyReplaceParams`, `isTemplParam` and most of `replaceIdentBySym` into a single `getIdentReplaceParams` proc. This might fix possible problems with injections of `nkAccQuoted`. Some special word comparison in `ast` and `semtempl` are also made more efficient.
* Instantiates generics in the module that uses it (#22513)Juan M Gómez2023-09-091-1/+2
| | | | | | | | | | Attempts to move the generic instantiation to the module that uses it. This should decrease re-compilation times as the source module where the generic lives doesnt need to be recompiled --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Fix the problem where instances of generic objects with `sendable` pragmas ↵Pylgos2023-09-021-1/+1
| | | | | are not being cached (#22622) remove `tfSendable` from `eqTypeFlags`
* unpublic the sons field of PType; the precursor to PType refactorings (#22446)ringabout2023-08-111-3/+19
| | | | | | | | | | | * unpublic the sons field of PType * tiny fixes * fixes an omittance * fixes IC * fixes
* `initNodeTable` and friends now return (#22444)ringabout2023-08-111-23/+15
|
* replaces `doAssert false` with `raiseAssert` for unreachable branches, which ↵ringabout2023-08-101-1/+1
| | | | | works better with strictdefs (#22436) replaces `doAssert false` with `raiseAssert`, which works better with strictdefs
* fix #12938 index type of array in type section without static (#20529)Bung2023-08-091-0/+1
| | | | | | | | | | | | | * fix #12938 nim compiler assertion fail when literal integer is passed as template argument for array size * use new flag tfImplicitStatic * fix * fix #14193 * correct tfUnresolved add condition * clean test
* fix #20891 Illegal capture error of env its self (#22414)Bung2023-08-091-0/+6
| | | | | * fix #20891 Illegal capture error of env its self * fix innerClosure too earlier, make condition shorter
* fix #18823 Passing Natural to bitops.BitsRange[T] parameter in generi… ↵Bung2023-08-081-2/+4
| | | | | (#20683) * fix #18823 Passing Natural to bitops.BitsRange[T] parameter in generic proc is compile error
* [C++] Member pragma RFC (https://github.com/nim-lang/RFCs/issues/530) (#22272)Juan M Gómez2023-08-071-0/+2
| | | | | | | | | | * [C++] Member pragma RFC #530 rebase devel * changes the test so `echo` is not used before Nim is init * rebase devel * fixes Error: use explicit initialization of X for clarity [Uninit]
* use strictdefs for compiler (#22365)ringabout2023-08-061-0/+16
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* implement `ensureMove` (#22339)ringabout2023-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * implement `ensureMove` * use an additional flag * improve some logics * progress: fixes discard ensureMove * forbids nested expressions * improve error messages * checkpoint * fixes cursor * ADD MORE TESTS * fixes cursorinference again * tiny cleanup * improve error messages * fixes docs * implement comments add more tests * fixes js
* Expands codegenDecl to work in function params. fixes #22306 (#22307)Juan M Gómez2023-07-231-0/+1
| | | | | | | * Expands codegenDecl to work in function params. fixes #22306 * makes the test more concrete so T{lit} params dont match * adds sfCodegenDecl
* clean up nimfix leftover (#22087)ringabout2023-06-131-3/+0
|
* fix dot calls with resolved symbols in templates (#22076)metagn2023-06-121-2/+1
| | | | | | | | | | | | | * fix dot calls with resolved symbols in templates * make old code work * fix custom number literals test * remove leftover debug marker * enable "bug 9" test too * fix renderer, add test for #7085
* fixes overriden typo (#22044)ringabout2023-06-081-4/+4
|
* make runnableExamples a special word (#22024)metagn2023-06-061-5/+0
| | | | | * make runnableExamples a special word * fix imports
* lift the `=dup` hook (#21903)ringabout2023-06-021-3/+3
| | | | | | * fixes tests again * remove helper functions * fixes closures, owned refs * final cleanup
* privateAccess ignores non-objects (#21973)metagn2023-06-011-1/+1
| | | closes #21969
* implements: "Allow bycopy to work in params #21874" (#21877)Juan M Gómez2023-05-211-1/+2
| | | | | | | | | * implements: "Allow bycopy to work in params #21874" * Update compiler/pragmas.nim --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Cpp Vfunctions draft (#21790)Juan M Gómez2023-05-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * introduces virtual pragma, modifies proc def, prevents proc decl * marks virtual procs as infix * forward declare vfuncs inside the typedef * adds naked callConv to virtual * virtual proc error if not defined in the same top level scope as the type * first param is now this. extracts genvirtualheaderproc * WIP syntax * supports obj. Removes the need for the prefix * parameter count starts as this. Cleanup * clean up * sem tests * adds integration tests * uses constraint to store the virtual content * introduces genVirtualProcParams --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* isolation spec update; WIP (#21843)Andreas Rumpf2023-05-141-2/+3
| | | | | | | | | | | * isolation spec update; WIP * wip * docs update, WIP * progress * Update doc/manual.md
* make deprecated statement a no-op (#21836)metagn2023-05-121-2/+1
|
* implement `=dup` hook eliminating `wasMoved` and `=copy` pairs (#21586)ringabout2023-05-061-3/+4
| | | | | | | | | | | | | | | | | | | * import `=dup` hook eliminating `wasMoved` and `=copy` pairs * add dup * add a test for dup * fixes documentation * fixes signature * resolve comments * fixes tests * fixes tests * clean up
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-8/+18
| | | | | | | | | | | (#21667) * refactoring in preparation for better, simpler name mangling that works with IC flawlessly * use new disamb field * see if this makes tests green * make tests green again
* alias syntax fixes, improvements and tests (#21671)metagn2023-04-221-9/+2
| | | | | | | | | | | | | * alias syntax fixes, improvements and tests * even better, cannot use alias syntax with generics * more type tests, improve comment * fix again * consistent error message + make t5167_5 work * more comments, remove {.noalias.}
* fixes #3770; templates with untyped parameters resolve private fields ↵ringabout2023-03-211-2/+2
| | | | | | | | | wrongly in generics (#21554) * fixes #3770; templates with untyped parameters resolve private fields wrongly * add a test case for #3770 * rename to `nfSkipFieldChecking`
* fixes #19291; implements `wasMoved` hook (#21303)ringabout2023-03-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixes #19291; implements `wasMoved` hook * basics * checkpoint * finish `wasMoved` * add a test for #19291 * add documentation and changelog * work `attachedWasMoved` with generics * fixes optimizer * register `=wasMoved` * handle wasMoved magcis * check another round * some patches * try `op == nil` * nicer * generate `wasMoved` before `destroy` * try again * fixes tests * default wasMoved * Update tests/destructor/tv2_cast.nim * Update tests/destructor/tv2_cast.nim * Update tests/arc/topt_refcursors.nim
* Implemented basic macro expand functionality (#20579)Ivan Yonchovski2023-01-271-0/+8
| | | | | | | | | | | | | | | | | | * Implemented level based macro expand functionality - it can handle single macro call or expand whole function/proc/etc and it - In addition, I have altered the parser to provide the endInfo for the node. The usefulness of the `endInfo` is not limited to the `expandMacro` functionality but also it is useful for `ideOutline` functionality and I have altered the ideOutline functionality to use `endInfo`. Note `endInfo` most of the time is lost during the AST transformation thus in `nimsuggest.nim` I am using freshly parsed tree to get the location information. * Make sure we stop expanding correctly * Test CI * Fix tv3_outline.nim
* remove dead code in VM (#21296)ringabout2023-01-251-1/+1
| | | remove deadcode in VM
* generic `define` pragma + string alias (#20979)metagn2022-12-131-1/+1
| | | | | | | | | * generic `define` pragma + string alias * clean * add tests and document * remove char/float, minimize changelog
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-121-0/+3
| | | | | | | | | (#21065) * fix #15836 proc arg return type auto unexpectly match proc with concrete type * fix #16244 * add test case for #12869
* Revert "fix #15836 proc arg return type auto unexpectly match proc with ↵ringabout2022-12-091-3/+0
| | | | | | | concr…" (#21057) Revert "fix #15836 proc arg return type auto unexpectly match proc with concr… (#21044)" This reverts commit 0cd9bdcf9f6802421e0d8e4c28fc732012af605e.
* fix #15836 proc arg return type auto unexpectly match proc with concr… ↵Bung2022-12-091-0/+3
| | | | | (#21044) fix #15836 proc arg return type auto unexpectly match proc with concrete type
* fixes #20026; marks system procs which can raise defects (#20864)ringabout2022-11-221-0/+1
| | | | | | | | | * marks system procs which can raise defects * add tests * add more systemRaisesDefect * add comment
* fixes #20740; fixes pre-existing field visibility issues and removes ↵ringabout2022-11-031-1/+1
| | | | | `efSkipFieldVisibilityCheck` (#20741) fixes #20740 pre-existing field visibility and refactoring
* fixes #20572 (#20585)Andreas Rumpf2022-10-171-2/+1
| | | | | * fixes #20572 * added a test case
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-111-12/+0
| | | | | * 'lock levels' are deprecated, now a noop * fixes tests
* DAA and 'out' parameters (#20506)Andreas Rumpf2022-10-061-3/+6
| | | | | | | | | | | * DAA and 'out' parameters * progress * documented strictDefs and out parameters * docs, tests and a bugfix * fixes silly regression
* cleanup nfFirstWrite flags (#20500)Andreas Rumpf2022-10-051-2/+1
|
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fresh start * add cpp target * add result support * add nimPreviewRangeDefault * reduce * use orc * refactor common parts * add tuple support * add testcase for tuple * cleanup; fixes nimsuggest tests * there is something wrong with cpp * remove * add support for seqs * fixes style * addd initial distinct support * remove links * typo * fixes tuple defaults * add rangedefault * add cpp support * fixes one more bugs * add more hasDefaults * fixes ordinal types * add testcase for #16744 * add testcase for #3608 * fixes docgen * small fix * recursive * fixes * cleanup and remove tuple support * fixes nimsuggest * fixes generics procs * refactor * increases timeout * refactor hasDefault * zero default; disable i386 * add tuples back * fixes bugs * fixes tuple * add more tests * fix one more bug regarding tuples * more tests and cleanup * remove messy distinct types which must be initialized by original types * add tests * fixes zero default * fixes grammar * fixes tests * fixes tests * fixes tests * fixes comments * fixes and add testcase * undo default values for results Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
* pragma for sfCallsite instead of name check + better semantics, test (#20464)metagn2022-10-031-0/+6
| | | | | | | | | | | * pragma for sfCallsite instead of name check at every template definition Not documented because it seems to be for internal use? Should also make it possible to make comparisons and setops imports, but this doesn't have to be done. I can reuse a name like `cursor` for the pragma as well, added a new name just to be safe. * make sfCallsite recursive, add tests
* new move analyser2 (#20471)Andreas Rumpf2022-10-011-2/+4
| | | | | | | | * produce better code for closure environment creation * new 'first write' analysis; * scope based move analyser * code cleanup Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-1/+20
| | | | | | | | | | | | | | | | | | | | | | | * continue #9582 for consts, close #9331, fix #20114 also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc * changelog correctly * fix jsgen * update tgetimpl * fix sighashes * fix #19766, add comment about postfix * fix noRewrite LOL refs #16620 * fix changelog * fix destructors