summary refs log tree commit diff stats
path: root/compiler/ast.nim
Commit message (Collapse)AuthorAgeFilesLines
* remove unused magics: mIntToStr, mInt64ToStr, mFloatToStr (#23486)ringabout2024-04-091-2/+0
| | | mIntToStr, mInt64ToStr, mFloatToStr,
* adds ccMember CC fixes #23434 (#23457)Juan M Gómez2024-03-291-0/+1
|
* Adds support for custom ASTs in the Nim parser (#23417)Andreas Rumpf2024-03-181-198/+44
|
* refactoring: no inheritance for PType/PSym (#23403)Andreas Rumpf2024-03-141-44/+18
|
* compiler/ast.nim: fix a typo (#23340)litlighilit2024-02-231-1/+1
| | | | | | | constains -> constrains --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* allow replacing captured syms in macro calls in generics (#23091)metagn2023-12-181-1/+3
| | | | | | | | | | | | | | | | | | fixes #22605, separated from #22744 This marks symbol captures in macro calls in generic contexts as `nfOpenSym`, which means if there is a new symbol in the local instantiatied body during instantiation time, this symbol replaces the captured symbol. We have to be careful not to consider symbols outside of the instantiation body during instantiation, because this will leak symbols from the instantiation context scope rather than the original declaration scope. This is done by checking if the local context owner (maybe should be the symbol of the proc currently getting instantiated instead? not sure how to get this) is the same as or a parent owner of the owner of the replacement candidate symbol. This solution is distinct from the symchoice mechanisms which we originally assumed had to be related, if this assumption was wrong it would explain why this solution took so long to arrive at.
* types refactoring; WIP (#23086)Andreas Rumpf2023-12-171-3/+33
|
* type refactor: part 4 (#23077)Andreas Rumpf2023-12-151-1/+8
|
* Param match relax (#23033)Ryan McConnell2023-12-151-2/+4
| | | | | | | | | | | #23032 --------- Co-authored-by: Nikolay Nikolov <nickysn@gmail.com> Co-authored-by: Pylgos <43234674+Pylgos@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jason Beetham <beefers331@gmail.com>
* type graph refactor; part 3 (#23064)Andreas Rumpf2023-12-141-11/+71
|
* type refactoring: part 2 (#23059)Andreas Rumpf2023-12-131-22/+12
|
* Types: Refactorings; step 1 (#23055)Andreas Rumpf2023-12-121-20/+56
|
* forbides adding sons for `PType` (#23030)ringabout2023-12-041-7/+0
| | | I image `add` for `PType` to be used everythere
* 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