summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
Commit message (Collapse)AuthorAgeFilesLines
* refactor: The popular 'r' field is now named 'snippet' (#23829)Andreas Rumpf2024-07-121-6/+6
|
* fixes #23790; roll back instCounter properly in case of exceptions (#23802)Alexander Kernozhitsky2024-07-061-1/+1
| | | fixes #23790
* Optimize closure iterator locals (#23787)Yuriy Glukhov2024-07-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pr redefines the relation between lambda lifting and closureiter transformation. Key takeaways: - Lambdalifting now has less distinction between closureiters and regular closures. Namely instead of lifting _all_ closureiter variables, it lifts only those variables it would also lift for simple closure, i.e. those not owned by the closure. - It is now closureiter transformation's responsibility to lift all the locals that need lifting and are not lifted by lambdalifting. So now we lift only those locals that appear in more than one state. The rest remains on stack, yay! - Closureiter transformation always relies on the closure env param created by lambdalifting. Special care taken to make lambdalifting create it even in cases when it's "too early" to lift. - Environments created by lambdalifting will contain `:state` only for closureiters, whereas previously any closure env contained it. IMO this is a more reasonable approach as it simplifies not only lambdalifting, but transf too (e.g. freshVarsForClosureIters is now gone for good). I tried to organize the changes logically by commits, so it might be easier to review this on per commit basis. Some ugliness: - Adding lifting to closureiters transformation I had to repeat this matching of `return result = value` node. I tried to understand why it is needed, but that was just another rabbit hole, so I left it for another time. @Araq your input is welcome. - In the last commit I've reused currently undocumented `liftLocals` pragma for symbols so that closureiter transformation will forcefully lift those even if they don't require lifting otherwise. This is needed for [yasync](https://github.com/yglukhov/yasync) or else it will be very sad. Overall I'm quite happy with the results, I'm seeing some noticeable code size reductions in my projects. Heavy closureiter/async users, please give it a go.
* Allow to `exportc` params. (#23396)Juan M Gómez2024-05-101-1/+1
| | | | By allowing `exportc` in params one can decide the name of a param or to dont mangle them.
* fixes #23525; an 'emit' pragma cannot be pushed (#23537)ringabout2024-04-241-0/+13
| | | fixes #23525
* adds ccMember CC fixes #23434 (#23457)Juan M Gómez2024-03-291-1/+1
|
* assume a module's usage if it contains a passC/passL/compile pragma w… ↵heterodoxic2024-02-191-1/+8
| | | | | | | | | | | | | | | | | | | | | (#23323) …hich conveys effects beyond its module scope for C/C++ codegen(suppresses current UnusedImport warning) Just a minor inconvenience working in the area of C/C++ integration I guess, but here we go: I noticed receiving ```UnusedImport``` warnings for modules having only ```passC```/```passL```/```compile``` pragmas around. I gather the compiler cannot actually infer those modules being unused as they *may* have consequences for the whole build process (as they did in my simple case). Thus, I hereby suggest adding the `sfUsed` flag to the respective module in order to suppress the compiler's warning. I reckon other pragmas should be put into consideration as well: I will keep up the investigation with PR followups.
* Asm syntax pragma (#23119)ASVIEST2023-12-251-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (Inspired by this pragma in nir asm PR) `inlineAsmSyntax` pragma allowing specify target inline assembler syntax in `asm` stmt. It prevents compiling code with different of the target CC inline asm syntax, i.e. it will not allow gcc inline asm code to be compiled with vcc. ```nim proc nothing() = asm {.inlineAsmSyntax: "gcc".} """ nop """ ``` The current C(C++) backend implementation cannot generate code for gcc and for vcc at the same time. For example, `{.inlineAsmSyntax: "vcc".}` with the ICC compiler will not generate code with intel asm syntax, even though ICC can use both gcc-like asm and vcc-like. For implement support for gcc and for vcc at the same time in ICC compiler, we need to refactor extccomp --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Types: Refactorings; step 1 (#23055)Andreas Rumpf2023-12-121-3/+3
|
* Ast stmt now saves its ast structure in the compiler (#23053)ASVIEST2023-12-121-0/+2
| | | | | | | see https://github.com/nim-lang/Nim/issues/23052 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Only suggest symbols that could be pragmas when typing a pragma (#23040)Jake Leahy2023-12-071-0/+5
| | | | | | Currently pragmas just fall through to `suggestSentinel` and show everything which isn't very useful. Now it filters for symbols that could be pragmas (templates with `{.pragma.}`, macros, user pragmas) and only shows them
* Don't process a user pragma if its invalid (#23041)Jake Leahy2023-12-071-1/+4
| | | | | | | | | | | | | | | When running `check`/`suggest` in a file with an invalid user pragma like ```nim {.pragma foo: test.} ``` It will continue to try and process it which leads to the compiler running into a `FieldDefect` ``` fatal.nim(53) sysFatal Error: unhandled exception: field 'sons' is not accessible for type 'TNode' using 'kind = nkIdent' [FieldDefect] ``` This makes it instead bail out trying to process the user pragma if its invalid
* fixes #23019; Regression from 2.0 to devel with raise an unlisted exc… ↵ringabout2023-12-051-1/+1
| | | | | | | | | | (#23034) …eption: Exception fixes #23019 I suppose `implicitPragmas` is called somewhere which converts `otherPragmas`.
* fixes #22913; fixes #12985 differently push-ing pragma exportc genera… ↵ringabout2023-11-191-1/+1
| | | | | | | | | | | (#22941) …tes invalid C identifiers fixes #22913 fixes #12985 differently `{.push.} now does not apply to generic instantiations`
* prepare for the enforcement of `std` prefix (#22873)ringabout2023-10-291-2/+4
| | | follow up https://github.com/nim-lang/Nim/pull/22851
* marking a field with noInit allows to skip constructor initialiser (#22802)Juan M Gómez2023-10-081-2/+2
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #22676; remove wMerge which is a noop for more than 8 years (#22678)ringabout2023-09-091-4/+1
| | | | | | | fixes #22676 If csource or CI forbids it, we can always fall back to adding it to the nonPragmaWords list. I doubt it was used outside of the system since it was used to implement & or something for magics.
* Instantiates generics in the module that uses it (#22513)Juan M Gómez2023-09-091-0/+1
| | | | | | | | | | 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>
* properly fold constants for dynlib pragma (#22575)metagn2023-08-281-1/+1
| | | fixes #12929
* unpublic the sons field of PType; the precursor to PType refactorings (#22446)ringabout2023-08-111-2/+2
| | | | | | | | | | | * unpublic the sons field of PType * tiny fixes * fixes an omittance * fixes IC * fixes
* [C++] Member pragma RFC (https://github.com/nim-lang/RFCs/issues/530) (#22272)Juan M Gómez2023-08-071-4/+6
| | | | | | | | | | * [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/+4
| | | | | | | | | | | | | | | * wip; use strictdefs for compiler * checkpoint * complete the chores * more fixes * first phase cleanup * Update compiler/bitsets.nim * cleanup
* Expands codegenDecl to work in function params. fixes #22306 (#22307)Juan M Gómez2023-07-231-1/+2
| | | | | | | * Expands codegenDecl to work in function params. fixes #22306 * makes the test more concrete so T{lit} params dont match * adds sfCodegenDecl
* implemented 'push quirky' switch for fine grained control over the ex… ↵Andreas Rumpf2023-07-231-3/+4
| | | | | | | (#22318) * implemented 'push quirky' switch for fine grained control over the exception handling overhead * documentation
* strictly typecheck expressions in bracketed `emit` (#22074)metagn2023-06-131-1/+1
| | | | | * strictly typecheck expressions in bracketed `emit` * use nim check in test
* Remove Deprecated Nimfix (#22062)Juan Carlos2023-06-101-5/+3
| | | | * Remove Deprecated Nimfix * Trailing whitespace cleanups
* fixes overriden typo (#22044)ringabout2023-06-081-3/+3
|
* Implements: [C++] constructor pragma improvement (fix #21921) (#21916)Juan M Gómez2023-05-301-1/+5
| | | | | | | | | | | | | | | * implements: [C++] constructor pragma improvement (fix #21921) t * fix test so it doesnt use echo in globals * Update compiler/ccgtypes.nim * Update lib/std/private/dragonbox.nim --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* implements: "Allow bycopy to work in params #21874" (#21877)Juan M Gómez2023-05-211-2/+4
| | | | | | | | | * implements: "Allow bycopy to work in params #21874" * Update compiler/pragmas.nim --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* implements allow byref to work in params #21873 (#21875)Juan M Gómez2023-05-211-2/+4
|
* Cpp Vfunctions draft (#21790)Juan M Gómez2023-05-171-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-1/+8
| | | | | | | | | | | * isolation spec update; WIP * wip * docs update, WIP * progress * Update doc/manual.md
* make deprecated statement a no-op (#21836)metagn2023-05-121-13/+2
|
* adds an experimental `mm:atomicArc` switch (#21798)ringabout2023-05-081-1/+1
|
* Fix some `styleCheck` bugs (#20095)quantimnot2023-05-061-1/+2
| | | | | | | | | | | refs #19822 Fixes these bugs: * Style check violations in generics defined in foreign packages are raised. * Builtin pragma usage style check violations in foreign packages are raised. * User pragma definition style check violations are not raised. Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* error on user pragma args (#21776)metagn2023-05-031-1/+5
| | | closes #20978
* implements #21747 (#21748)Juan M Gómez2023-05-021-1/+1
|
* refactoring in preparation for better, simpler name mangling that wor… ↵Andreas Rumpf2023-04-241-5/+5
| | | | | | | | | | | (#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
* change compile pragma to use mangled compile objects (#21678)Jaremy Creechley2023-04-171-2/+7
| | | change compile pragma to use mangle
* custom pragmas: correct error condition, remove outdated symkind whitelist ↵metagn2023-04-131-10/+18
| | | | | | | | | | | | | | | (#21653) * test not restricting custom pragma applied symbols fixes #21652 * fix other test * different patch * fix tests * actually test #18212 and other routines
* add a prepass for codeReordering (#21513)ringabout2023-03-171-1/+1
| | | | | | | * add a prepass for codeReordering * simplify * fixes
* fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now ↵ringabout2023-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parses the whole module at one time (#21379) * fixes #19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes #11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
* add deprecated warnings for `{.deadcodeelim: on.}` (#21277)ringabout2023-02-161-1/+2
|
* Check file exists in `{.compile.}` pragma (#21105)Jake Leahy2022-12-151-2/+5
| | | | | | | | | * Add test * Check file exists before adding it into compilation * Make error message look like other error messages i.e. following the format `error msg: file`
* generic `define` pragma + string alias (#20979)metagn2022-12-131-7/+16
| | | | | | | | | * generic `define` pragma + string alias * clean * add tests and document * remove char/float, minimize changelog
* fixes #20026; marks system procs which can raise defects (#20864)ringabout2022-11-221-1/+3
| | | | | | | | | * marks system procs which can raise defects * add tests * add more systemRaisesDefect * add comment
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-111-18/+1
| | | | | * 'lock levels' are deprecated, now a noop * fixes tests
* pragma for sfCallsite instead of name check + better semantics, test (#20464)metagn2022-10-031-1/+4
| | | | | | | | | | | * 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
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * 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
* no ropes WIP (#20433)Andreas Rumpf2022-09-271-2/+2
| | | | | | | | | | | | | * 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