Commit Graph

52 Commits

Author SHA1 Message Date
metagn
d43672833a allow replacing captured syms in macro calls in generics (#23091)
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.

(cherry picked from commit 941659581a)
2024-05-02 10:02:06 +02:00
ringabout
7ee00d86b1 fixes overriden typo (#22044) 2023-06-08 08:02:11 +02:00
ringabout
afc30ca879 fixes #19863; move sha1, md5 to nimble packages for 2.0 (#21702)
* move sha1, md5 to nimble packages

* boot the compiler

* fixes tests

* build the documentation

* fixes docs

* lol, I forgot koch.nim

* add `nimHasChecksums` define

* clone checksums but maybe copying is better

* bump nimble hash

* use ChecksumsStableCommit

* fixes tests

* deprecate them

* fixes paths

* fixes koch
2023-05-02 10:49:17 +02:00
Andreas Rumpf
20b011de19 refactoring in preparation for better, simpler name mangling that wor… (#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
2023-04-24 06:52:37 +02:00
ringabout
a37a83cbff fixes #21617; createTypeBoundOps with PContext in order to instantiate generics (#21619)
* fixes #21617; createTypeBoundOps with PContext in order to instantiate generics

* keep idgen
2023-04-07 22:18:09 +02:00
Ikko Ashimine
a104aa4714 IC: fix typo in rodfiles.nim (#20989)
preceeded -> preceded
2022-12-01 14:26:59 -05:00
Andrey Makarov
3eef0491a8 fix a few "broken link" warnings (#20837) 2022-11-14 15:43:29 +08:00
ringabout
5602183234 'lock levels' are deprecated, now a noop (#20539)
* 'lock levels' are deprecated, now a noop

* fixes tests
2022-10-11 09:17:09 +02:00
Andreas Rumpf
7587371554 time to make IC work with ORC (here we go again...) (#20538)
works for me
2022-10-11 09:00:07 +02:00
Andreas Rumpf
08ae3467b9 refactorings (#20536)
* refactoring

* refactoring: removed unused macroUsagesSection

* enum instead of bool for better readability
2022-10-10 21:40:07 +02:00
Andreas Rumpf
ca1f3f36b9 no ropes WIP (#20433)
* refactorings in preparation for ropes elimination of the C code generator; mostly the usual ': Rope' -> 'result: var Rope' rewrite
* rewrote ccgcalls.nim
* refactored ccgexprs.nim
* ccgliterals: refactoring
* refactoring: code dealing with name mangling
* refactoring: getRecordFieldsAux
* ropes are strings (insert obscene joke here)
* optimize JS code gen
* optimizations and code improvements
* more optimizations
* final cleanups
2022-09-27 10:57:47 +02:00
ringabout
b6bfe38ff5 move formatfloat out of system (#20195)
* move formatfloat out of system

* fixes doc

* Update changelog.md

* careless

* fixes

* deprecate system/formatfloat

* better handling
2022-08-24 13:38:30 +02:00
Andrey Makarov
9f408ea943 Don't require blank line before Markdown code (#20215)
Fixes bug reported in https://github.com/nim-lang/Nim/pull/20189
affecting nimforum.
2022-08-15 18:37:45 -04:00
quantimnot
800cb006e7 Change styleCheck to ignore foreign packages (#19822)
* Change `styleCheck` to ignore foreign packages

* Symbols from foreign packages are now ignored.
* Fixed `styleCheck` violations in `compiler` package.
* Added symbol ownership to custom annotation pragmas.
* Minor refactors to cleanup style check callsites.
* Minor internal documentation of reasons why a symbol isn't checked.

Style violations were fixed in the compiler after thet were exposed by
the changes. The compiler wouldn't compile otherwise.

Symbol ownership for custom pragma annotations is needed for checking
the annotation's style. A NPE was raised otherwise.

Fixes #10201
See also nim-lang/RFCs#456

* Fix a misunderstanding about excluding field style checks

I had refactored the callsites of `styleCheckUse` to apply the DRY
principle, but I misunderstood the field access handling in a template
as a general case. This corrects it.

* Fix some `styleCheck` violations in `compiler/evalffi`

The violations were exposed in CI when the compiler was built with
libffi.

* Removed some uneeded transitionary code

* Add changelog entry

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
2022-07-14 14:20:40 +02:00
quantimnot
d30c6419a0 Refactor and doc package handling, module name mangling (#19821)
* Refactor and doc package handling, module name mangling

* Consolidate, de-duplicate and extend package handling
* Alter how duplicate module names of a package are handled
* Alter how module names are mangled
* Fix crash when another package is named 'stdlib' (test case added)
* Doc what defines a package in the manual

Modules with duplicate names within a package used to be given 'fake'
packages to resolve conflicts. That prevented the ability to discern if
a module belonged to the current project package or a foreign package.
They now have the proper package owner and the names are mangled in a
consistent manner to prevent codegen clashes.

All module names are now mangled the same. Stdlib was treated special
before, but now it is same as any other package. This fixes a crash
when a foreign package is named 'stdlib'.

Module mangling is altered for both file paths and symbols used by the
backends.

Removed an unused module name to package mapping that may have been
intended for IC. The mapping was removed because it wasn't being used
and was complicating the issue of package modules with duplicate names
not having the proper package owner assigned.

* Fix some tests

* Refactor `packagehandling`

* Remove `packagehandling.withPackageName` and its uses
* Move module path mangling from `packagehandling` to `modulepaths`
* Move `options.toRodFile` to `ic` to break import cycle

* Changed import style to match preferred style

Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
2022-05-30 18:52:19 +02:00
flywind
7f6e800caf move assertions out of system (#19599) 2022-03-23 20:34:53 +01:00
flywind
3d1bba04ab [minor]use addInt and addFloat (#18733)
* unify int and uint

* back

* minor
2021-08-24 17:16:12 +02:00
Andreas Rumpf
558644725d fixes #17943 (#18045)
* fixes #17943

* IC: test 'nim check --ic:on' for the full Nim compiler

* Update testament/testament.nim

Co-authored-by: Clyybber <darkmine956@gmail.com>

Co-authored-by: Clyybber <darkmine956@gmail.com>
2021-05-19 16:00:14 +02:00
Timothee Cour
d0485e326a bring back std/ prefix within compiler and ensure it works in bootstrap + bsd (#17902)
* [WIP] bring back std/ prefix within compiler and ensure it works in bootstrap + bsd

* refs https://github.com/nim-lang/Nim/pull/16282#discussion_r616846863
* sounds very similar to https://github.com/nim-lang/Nim/pull/14291
* more: vmops
* update tools/ci_generate.nim
* auto-generate freebsd.yml as well, to avoid duplication with openbsd.yml
* cleanup
* undo temporary CI removal
2021-04-30 22:27:53 +02:00
Andreas Rumpf
511b6d2449 typos (#17824) 2021-04-23 13:50:27 +02:00
Andreas Rumpf
a9b62de895 CIs: attempt to use csources_v1 (#16282)
* CIs: attempt to use csources_v1
* also updated the BSDs
* also updated azure pipelines
* std modules should not itself use the 'std/' import dir...
* compiler has to be careful with std/ for v1 booting
2021-04-21 07:41:33 +02:00
Andreas Rumpf
54fe44135e updated the documentation (#17796) 2021-04-20 15:24:20 +02:00
Andreas Rumpf
3b80f0dc8e IC navigator: added support for include files (#17784)
* ic fixed navigator crash when track wrong/missed

Also fixed an issue with getNimcacheDir not observing the outDir.

* closer, but not sure how to test[skip ci][ci skip]

* IC navigator: added support for include files

* update

* make posix happy via expandFilename

* update

Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
2021-04-19 22:37:09 +02:00
Andreas Rumpf
4b0b536419 ic refactoring (#17778)
* minor IC documentation update

* IC: refactoring: removed the 'shared' type and fields, these were a leftover from an earlier design
2021-04-19 11:48:06 +02:00
Saem Ghani
5042cb956b [ci skip] document compiler/ic/rodfiles.nim (#17771)
* [ci skip] document compiler/ic/rodfiles.nim

Why?
* understand how rodfile module works and a bit of the format
* leave notes behind for others
* rather than Araq guess what others need, he can fix what other glean
* possible model for making the compiler more aproachable

Bonus:
* might have found a minor bug in `loadSection`

* Update compiler/ic/rodfiles.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2021-04-19 07:40:08 +02:00
Andreas Rumpf
c7b77829fe IC: fixes a long standing bug about DCE set computations (#17763) 2021-04-18 23:38:07 +02:00
Timothee Cour
5c9c1988f6 -d:nimDebug: calls doAssert false instead of quit (#17739) 2021-04-17 11:49:54 +02:00
Andreas Rumpf
8e474fbb57 IC: yet another embarrassing omission (#17743)
* IC: yet another embarrassing omission

* VM: fewer hacks that kept IC from working
2021-04-17 01:12:12 +02:00
Andreas Rumpf
606288974f ic navigator tests (#17735)
* IC navigator: first basic test
2021-04-16 12:20:43 +02:00
Timothee Cour
8161b02897 import foo {.all.} reboot (#17706) 2021-04-16 09:16:39 +02:00
Andreas Rumpf
eff9d75379 IC: rodfiles: no floats (#17720) 2021-04-14 22:35:18 +02:00
Andreas Rumpf
67e28c07f9 IC: first steps towards 'nim check --def --ic:on' (#17714)
* IC: first steps towards 'nim check --def --ic:on'
* IC navigator: deduplicate output lines
* IC navigator: progress
* IC navigator: use a different nimcache entry
* IC navigator: special logic for templates/macros
* IC navigator: proper error messages
* IC navigator: prepare for testing code; document only what currently works somewhat
2021-04-14 16:44:37 +02:00
Andreas Rumpf
8e6b87a917 IC: code cleanup (#17708) 2021-04-13 10:43:16 +02:00
Andreas Rumpf
4f5709e326 IC: serialization bugfix (#17701) 2021-04-13 07:23:29 +02:00
Andreas Rumpf
4780b08b9d IC: integrity checking (#17695)
* IC: integrity checking: the plumbing code
* progress
* progress + bugfix (yes, the code already found a bug)
* implemented integrity checking
2021-04-11 17:37:32 +02:00
Andreas Rumpf
13b958eb45 IC: added basic test case for methods (#17679)
* IC: added basic test case for methods

* IC: better methods test
2021-04-09 06:59:25 +02:00
Timothee Cour
bbe4cf4703 followup custom literals (#17500) 2021-03-27 12:03:14 -07:00
Andreas Rumpf
cf5ce7616b IC: bugfix (#17533)
* cleanups
* IC: bugfix
2021-03-27 12:21:57 +01:00
Andreas Rumpf
e3e9742143 added a 'koch ic' command for easier adhoc testing of IC (#17508)
* added a 'koch ic' command for easier adhoc testing of IC
* IC: progress
* IC: enable generics test
* make tests green
2021-03-26 08:52:26 +01:00
Andreas Rumpf
d6a16020fe IC: backend: remember produced type information (#17440) 2021-03-23 08:52:00 +01:00
Andreas Rumpf
6c1c8f51b3 IC: green tests (#17311)
* IC: renamed to_packed_ast module to ic module

* IC: don't store the --forceBuild flag, makes it easier to test

* IC: enable hello world test

* Codegen: refactorings for IC; changed the name mangling algorithm

* fixed the HCR regressions

* life is too short for HCR

* tconvexhull is now allowed to use deepCopy

* IC exposed a stdlib bug, required a refactoring

* codegen: code cleanups

* IC: even if a module is outdated, its dependencies might come from disk

* IC: progress

* IC: better name mangling, module IDs are not stable

* IC: another refactoring helping with --ic:on --gc:arc

* disable arraymancer on Windows for the time being

* disable arraymancer altogether

* IC: make basic test work with 'nim cpp'

* IC: progress on --ic:on --gc:arc

* wip; name mangling for type info
2021-03-19 16:53:38 +01:00
Andreas Rumpf
6cb26d8010 IC: compilerprocs are handled correctly (#17265)
* IC: compilerprocs are handled correctly
* IC: special logic for .exportC'ed procs
* IC: 'hello world' compiles for the first round (2nd round fails)
* IC: hello world seems to work
2021-03-09 00:04:39 +01:00
Andreas Rumpf
8f1fa3e5b0 IC: further progress (#17150)
* IC: respect the -f switch

* IC: better rod file inspection

* progress
2021-03-05 09:58:55 +01:00
Timothee Cour
b1a3651ae4 fix UnusedImport for nim c compiler/nim (#17152) 2021-02-23 10:40:40 +01:00
Andreas Rumpf
fb80d2ff85 IC: bugfixes (WIP) (#16836)
* 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
2021-02-02 19:24:55 +01:00
Andreas Rumpf
25745ad195 IC: final implementation steps (#16801)
* removed dead code
* we need even more laziness for the generic caches
* make it bootstrap on older Nims
* wrote more deserialization code
* IC: replay required methods information
2021-01-25 20:52:26 +01:00
Andreas Rumpf
8241e55023 IC: next steps (#16729)
* IC: dead code elimination pass
* preparations for a different codegen strategy
* added documentation to the newly written code
* IC: backend code
* IC: backend adjustments
* optimized the compiler a bit
* IC: yet another massive refactoring
* fixes regressions
* cleanups
2021-01-23 08:06:15 +01:00
Andreas Rumpf
1fd4c666dc IC: next steps (#16705)
* code cleanups
* refactorings for IC
* more refactorings for IC
* IC: attach the 'nil' type to its module
* IC: refactorings and improvements
* IC: progress
* IC: more serialization fixes
* IC: embarrassing omission
* code cleanups
2021-01-14 17:30:41 +01:00
Andreas Rumpf
cf6dd57efe IC: next steps (#16632)
* removed dead code
* beginnings of a rodfile reader
* IC: record global VM state changes and pragma state changes
* IC: replay pragmas and VM state changes
* implemented rod load file simuation for easier, extensive testing
* critical bugfix
* IC: stress test logic; should also help with recursive module dependencies; WIP
* IC: loading from .rod files begins to work reliably
* removed ugly hacks
* yet another silly mistake
2021-01-12 09:36:51 +01:00
Andreas Rumpf
796498525a IC: next steps (#16550)
* 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
2021-01-07 20:26:40 +01:00