summary refs log tree commit diff stats
path: root/compiler/jsgen.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #21317; 1.6.4 regression; etyBaseIndex should return fat pointers ↵ringabout2023-02-011-3/+4
| | | | | [backport 1.6] (#21320) fixes #21317; regression; etyBaseIndex should return fat pointers
* JS backend properly extends string with `setLen` (#21087)Jake Leahy2022-12-131-1/+3
| | | | | * Add test case * Extend string with '0' when setting length to be longer
* Refactor JS sourcemap generator (#21053)Jake Leahy2022-12-131-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Parse the new line format * Fix pattern Didn't have space after the path * Remove duplicate sources Sources would sometimes double up with a new line at the end * Remove unused variable * Refactor sourcemap.nim Removes the multiple translations needed, now goes from single high level type to the final SourceMap Adds documentation for procs * Line numbers line up properly now Files aren't linking correctly though * Files now link up correctly Lines are sometimes off but overall seems pretty good Just need to implement parser * Add column info to output Add sourceMappingURL to rope directly to prevent copy * Properly handle columns * Remove debug lines * Add testcase * Finish testcase * Use the outdir folder instead of the folder the test is in to find the sourcemap Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Fix #18079 Illegal storage access compiling call with nested ref/deref (#20738)Bung2022-11-041-0/+7
| | | | | | * add test case * refactoring transformAddrDeref and fix #18079 * fix jsgen
* fixes #20572 (#20585)Andreas Rumpf2022-10-171-1/+1
| | | | | * fixes #20572 * added a test case
* fix #8821 JS codegen can produce extreme switch statements with case … ↵Bung2022-10-141-6/+1
| | | | | | | (#20548) * fix #8821 JS codegen can produce extreme switch statements with case a of range * remove totalRange
* refactorings (#20536)Andreas Rumpf2022-10-101-1/+1
| | | | | | | * refactoring * refactoring: removed unused macroUsagesSection * enum instead of bool for better readability
* DAA and 'out' parameters (#20506)Andreas Rumpf2022-10-061-2/+2
| | | | | | | | | | | * DAA and 'out' parameters * progress * documented strictDefs and out parameters * docs, tests and a bugfix * fixes silly regression
* add default field support for object in ARC/ORC (#20480)ringabout2022-10-041-2/+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>
* 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
* allow more simple expressions in js (#20270)Amjad Ben Hedhili2022-09-271-1/+3
| | | | | | | | * make it match ccgexprs.nim `isSimpleExpr` * x in {1, 2} * r[].x and r.x when r is ref type * float(x) Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* Compute small nim string lit at CT (#20439)Amjad Ben Hedhili2022-09-271-3/+18
| | | | | * Reduces runtime overhead for small strings. * Avoids including `makeNimstrLit` in the output when all strings are small enough.
* no ropes WIP (#20433)Andreas Rumpf2022-09-271-71/+68
| | | | | | | | | | | | | * 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
* Represent more types as JS `TypedArray`s (#20411)Amjad Ben Hedhili2022-09-261-2/+8
| | | | | | | * Represent `array[N, char]` as JS `UInt8Array(N)` * Add support distinct and range types * Add support for bools and enums
* Shorten JS block code (#20370)Amjad Ben Hedhili2022-09-191-4/+4
|
* fix #20233 Float ranges in case statement in JS crash compiler (#20349)Bung2022-09-141-18/+55
|
* Replace `if` by `case` in JS `isSimpleExpr` (#20267)Amjad Ben Hedhili2022-09-061-5/+7
| | | use case stmt
* support cstring in `case` (#20130)metagn2022-09-011-3/+5
| | | | | | | | | | | | | | | * implement case for cstring for now just converts to string on C backend * custom implementation for cstring * remove leftover * revert even more * add nil + fix packages weird variant literal bug * update docs
* fixes #20227; skip distinct types for genObjConstr [JS backend] (#20229)ringabout2022-08-241-1/+2
| | | fixes #20227; skip distinct types for genObjConstr
* fixes #20219; ignore comment/empty node in stmtListExpr (#20249)ringabout2022-08-241-0/+4
|
* top-down type inference, implements rfc 149 (#20091)metagn2022-08-241-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * micro implementation of rfc 149 refs https://github.com/nim-lang/RFCs/issues/149 * number/array/seq literals, more statements * try fix number literal alias issue * renew expectedType with if/case/try branch types * fix (nerf) index type handling and float typed int * use typeAllowed * tweaks + const test (tested locally) [skip ci] * fill out more of the checklist * more literals, change @ order, type conversions Not copying the full call tree before the typedesc call check in `semIndirectOp` is also a small performance improvement. * disable self-conversion warning * revert type conversions (maybe separate op later) * deal with CI for now (seems unrelated), try enums * workaround CI different way * proper fix * again * see sizes * lol * overload selection, simplify int literal -> float * range, new @ solution, try use fitNode for nil * use new magic * try fix ranges, new magic, deal with #20193 * add documentation, support templates Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* bootstrap the compiler with nimPreviewSlimSystem (#20176)ringabout2022-08-091-0/+4
| | | | | * bootstrap the compiler with nimPreviewSlimSystem * threads
* Fix global destructor injection for JS backend (#19797)quantimnot2022-05-231-5/+25
| | | | | | | | | | | | | | * Fix global destructor injection for JS backend * Moved global destructors injection before the final call to transform and generate JS code. It had previously been after and thus not no JS was generated for them. * Added some internal documentation of `jsgen`. * Enable a current destructor test to cover the JS backend as well. * Fixes the JS aspect of #17237. * Fixed global destructor injection order for JS backend Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* remove tmpFramePtr when optStackTrace is absent (#19649)flywind2022-03-261-4/+0
|
* remove unnecessary framePtr code (#19645)flywind2022-03-251-3/+6
|
* Fix #18662 (#19534)Evan Typanski2022-02-281-1/+3
|
* Optimize lent in JS [backport:1.6] (#19393)hlaaftana2022-01-171-15/+36
| | | | | | | * Optimize lent in JS [backport:1.6] * addr on lent doesn't work anymore, don't use it * use unsafeAddr in test again for older versions
* Fixed generic distinct conversions for 'var' (#18837)Jason Beetham2021-10-261-62/+76
| | | | | | | | | | | | | | | * SameTypeAux now properly traverses generic distincts * Smarter traversal of distincts * Removed redundant check * Fixed nkConv for jsgen * Added test for non distinct nkConv * using skiptypes for distinct now * Fixed genaddr for nkconv
* correct effect tracking for .borrowed procs [backport] (#18882)Andreas Rumpf2021-09-231-1/+1
| | | | | | | | | | | * correct effect tracking for .borrowed procs [backport] * progress * fix error message in a test * correctly fix it Co-authored-by: narimiran <narimiran@disroot.org>
* fix for js strict mode (#18799)Sven Keller2021-09-041-1/+1
| | | | | | | | * Assignments, which would accidentally create global variables, instead throw an error in strict mode * Assignment to a getter-only property Co-authored-by: Sven Keller <s.keller@cortona.de>
* allow building 1.4.0 from devel (#18708)Timothee Cour2021-08-181-0/+1
| | | | | * allow building 1.4.0 from devel * changelog
* properly fix #10053 ; `FieldDefect` msg now shows discriminant value + ↵Timothee Cour2021-08-131-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lineinfo, in all backends (c,vm,js) (#11955) * fix #10053 FieldError for vm * fixup * FieldError now also shows runtime value of discriminant * fix field error reporting in vm * also report culprit line info in err msg * fix errors for newruntime 2 * fix for js * fixup * PRTEMP4 * works * works * works perfect * refactor * std/private/repr_impl * suppport --gc:arc * cleanup * refactor * simplify * simplify * simplify * fixup * move out compiler.vmgen.genCustom * fixup * fixup * add tests * revert compiler/debugutils.nim * simplify reprDiscriminant * fixup * lib/std/private/repr_impl.nim -> lib/system/repr_impl.nim * try to fix D20210812T165220 * honor --declaredlocs * control toFileLineCol via --declaredlocs
* Remove unused imports, and deprecated function usage (#18663)Kyle Brown2021-08-111-1/+1
| | | | | | | * clean up imports and slice to remove delete * revert buggy code * Replace "delete" with setlen to remove depreciation warning
* fixes #18469 (#18544)Andreas Rumpf2021-07-201-10/+0
| | | | | * fixes #18469 * Update compiler/injectdestructors.nim
* make -d:nimFpRoundtrips work consistently in vm vs rt, fix #18400, etc (#18531)Timothee Cour2021-07-201-6/+1
| | | | | | * compiler/vmhooks: add getVar to allow vmops with var params * addFloat vmops with var param * cgen now renders float32 literals in c backend using roundtrip float to string
* ORC: support for custom =trace procs (#18459)Andreas Rumpf2021-07-091-1/+1
| | | | | | | | | | | * ORC: support custom =trace procs (WIP) * Update tests/arc/tcustomtrace.nim Co-authored-by: Clyybber <darkmine956@gmail.com> * =trace is now documented and seems to work * make test green Co-authored-by: Clyybber <darkmine956@gmail.com>
* fixes #18319 (#18375)Andreas Rumpf2021-06-281-2/+12
|
* followup #18362: make `UnusedImport` work robustly (#18366)Timothee Cour2021-06-271-2/+0
| | | | * warnDuplicateModuleImport => hintDuplicateModuleImport * improve DuplicateModuleImport msg, add test
* jsgen improve spacing (#18048)Juan Carlos2021-05-201-30/+30
| | | | * Fix inconsistent spacings in generated JS of jsgen
* js generates spurious >>> on shr (#17767)Sivchari2021-04-211-2/+1
| | | | | * js generates spurious >>> on shr * Add shr arithmetic test * fix variables from const to let during testing
* CIs: attempt to use csources_v1 (#16282)Andreas Rumpf2021-04-211-1/+1
| | | | | | | | * 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
* cString => cSourceString; tyCString => tyCstring so that error msgs show ↵Timothee Cour2021-04-171-10/+10
| | | | cstring, not cString (#17744)
* iterable[T] (#17196)Timothee Cour2021-04-111-1/+1
| | | | | | | | * fix failing test toSeq in manual which now works * changelog * reject proc fn(a: iterable) * add iterable to spec * remove MCS/UFCS limitation that now works
* fixes #11225; generic sandwich problems; [backport:1.2] (#17255)Andreas Rumpf2021-03-091-1/+2
| | | | | * fixes #11225; generic sandwich problems; [backport:1.2] * progress * delegating these symbols must be done via 'bind'
* fix #17264 [backport:1.4] (#17266)flywind2021-03-051-2/+2
| | | | | * fix #17264 * fix vm * fix js and add tests
* new-style concepts implementation, WIP (#15251)Andreas Rumpf2021-02-241-1/+1
| | | | | | | | | | | | | * fixes #15210 [backport:1.2] * make tests green * make ordinal work * makes Swapable test compile * make Indexable example work * concepts: 'self' is now 'Self' * concepts: make Dictionary example compile * document the new concept implementation * concepts: make typeDesc work properly * concepts: allow documentation comments (d'oh)
* fix #17076 (#17081)flywind2021-02-181-1/+5
|
* JS: fix div uint64 no truncation (#16899)flywind2021-02-151-1/+4
|
* array literals uses typed arrays; fix a jsgen bug (#16850)flywind2021-02-151-16/+39
| | | | | | | * array litterals uses typed arrays * Update compiler/jsgen.nim Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* [backport:1.4] JS cstring null fixes (#16979)hlaaftana2021-02-111-3/+19
| | | | | * [backport:1.4] JS cstring null fixes * fix JS move string * make it look cleaner