summary refs log tree commit diff stats
path: root/lib/system/jssys.nim
Commit message (Collapse)AuthorAgeFilesLines
* rework `wasMoved`, `move` on the JS backend (#23577)ringabout2024-05-081-31/+0
| | | | | `reset`, `wasMoved` and `move` doesn't support primitive types, which generate `null` for these types. It is now produce `x = default(...)` in the backend. Ideally it should be done by ast2ir in the future
* fixes #4695; closure iterators support for JS backend (#23493)ringabout2024-04-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | fixes #4695 ref https://github.com/nim-lang/Nim/pull/15818 Since `nkState` is only for the main loop state labels and `nkGotoState` is used only for dispatching the `:state` (since https://github.com/nim-lang/Nim/pull/7770), it's feasible to rewrite the loop body into a single case-based dispatcher, which enables support for JS, VM backend. `nkState` Node is replaced by a label and Node pair and `nkGotoState` is only used for intermediary processing. Backends only need to implement `nkBreakState` and `closureIterSetupExc` to support closure iterators. pending https://github.com/nim-lang/Nim/pull/23484 <del> I also observed some performance boost for C backend in the release mode (not in the danger mode though, I suppose the old implementation is optimized into computed goto in the danger mode) </del> allPathsAsgnResult???
* fixes #23487; JS chckNilDisp is wrong (#23490)ringabout2024-04-131-1/+1
| | | | | fixes #23487 uses JSRef
* fixes #4299 #12492 #10849; lambda lifting for JS backend (#23484)ringabout2024-04-111-0/+12
| | | | | | | | fixes #4299 fixes #12492 fixes #10849 It binds `function` with `env`: `function.bind(:env)` to ease codegen for now
* Deprecate asm stmt for js target (#23149)ASVIEST2024-01-021-84/+84
| | | | | | | | | | | | | | | | | | | | | | | why ? - We already have an emit that does the same thing - The name asm itself is a bit confusing, you might think it's an alias for asm.js or something else. - The asm keyword is used differently on different compiler targets (it makes it inexpressive). - Does anyone (other than some compiler libraries) use asm instead of emit ? If yes, it's a bit strange to use asm somewhere and emit somewhere. By making the asm keyword for js target deprecated, there would be even less use of the asm keyword for js target, reducing the amount of confusion. - New users might accidentally use a non-universal approach via the asm keyword instead of emit, and then when they learn about asm, try to figure out what the differences are. see https://forum.nim-lang.org/t/10821 --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Initialize `newString` in js [backport:1.6] (#22745)Amjad Ben Hedhili2023-09-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | ```nim echo newString(8) ``` results in: ``` D:\User\test.js:25 var code_33556944 = c_33556931.toString(16); ^ TypeError: Cannot read properties of undefined (reading 'toString') at toJSStr (D:\User\test.js:25:50) at rawEcho (D:\User\test.js:70:16) at Object.<anonymous> (D:\User\test.js:101:1) at Module._compile (node:internal/modules/cjs/loader:1095:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 Node.js v17.0.1 Error: execution of an external program failed: '"C:\Program Files\nodejs\node.exe" --unhandled-rejections=strict D:\User\test.js' ```
* int64/uint64 as bigint in JS (#21613)metagn2023-04-111-13/+13
| | | | | | | | | | | * int64/uint64 as bigint in JS * fix CI * convert to compile option * fix lie * smaller diff, changelog entry
* remove legacy code (#21134)ringabout2022-12-261-22/+0
| | | | | * remove legacy code * fixes
* Added 'openArray[char]' overloads to 'std/parseutils' (#20527)Jason Beetham2022-10-241-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Fixed VM op to work with new 'opcSlice' * Corrected captureBetween's logic to work with openarray * js sys's parsefloat logic now uses openarray Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* [js] add testcase for array indexDefect and remove todo (#19838)flywind2022-06-101-4/+0
| | | | | | | | | * remove unused opcSubstr * [js] add testcase for array indexDefect * Revert "remove unused opcSubstr" This reverts commit cb461f2545234d62c1e0b83318f3e5495c97de52.
* remove unnecessary framePtr code (#19645)flywind2022-03-251-1/+2
|
* suggestion to respect typedarray type (#19257)Sven Keller2021-12-161-1/+27
| | | | | | | * suggestion to respect typedarray * Update jssys.nim Co-authored-by: Sven Keller <s.keller@cortona.de>
* make JS trunc polyfill opt-in, closes #16144 (#19183)hlaaftana2021-11-241-3/+3
|
* fix for js strict mode (#18799)Sven Keller2021-09-041-4/+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>
* properly fix #10053 ; `FieldDefect` msg now shows discriminant value + ↵Timothee Cour2021-08-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* make -d:nimFpRoundtrips work consistently in vm vs rt, fix #18400, etc (#18531)Timothee Cour2021-07-201-17/+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
* fix #7717 roundtrip float to string; fix `parseFloat` for js (#18248)Timothee Cour2021-06-131-48/+41
| | | | | | | * refs #7717 roundtrip float to string * make parseFloat more correct * improve float tests * improve float tests * cleanup
* close #18129 Add setCurrentException for JS backend (#18145)flywind2021-06-011-0/+3
| | | | | | | | | | | * [std/re] make interface consistent * tiny * revert * close #18129 add setCurrentException * changelog entry
* [backport:1.4] JS cstring null fixes (#16979)hlaaftana2021-02-111-1/+1
| | | | | * [backport:1.4] JS cstring null fixes * fix JS move string * make it look cleaner
* fix printing negative zero in JS backend (#16505)flywind2020-12-291-1/+3
|
* fix nim js cmp fails at CT (#16473)flywind2020-12-271-1/+6
|
* Avoid creating a holey array in makeNimstrLit for JS target (#16461)Jonah Snider2020-12-271-3/+2
| | | | * Avoid creating a holey array in makeNimstrLit * Use array index instead of push
* add simple writeStackTrace for JS backend (#16016)flywind2020-11-241-0/+5
| | | | | | | * add simple writeStackTrace for JS backend * add testcase for writeStackTrace * changelog
* Correct all eggs (#15906)Miran2020-11-101-1/+1
| | | | * "eg" is a misspelled "egg", "e.g." is "exempli gratia" * Also, "ie" is "i.e.".
* Clean out jssys (#15442)Juan Carlos2020-10-011-6/+0
|
* fix js stacktraces, unify all file,line,col formatting into a single ↵Timothee Cour2020-05-051-4/+5
| | | | | function (#14230) * fix https://github.com/timotheecour/Nim/issues/135 ; unify all file,line,col formatting into a single function
* many bugfixes for js (#14158)hlaaftana2020-04-291-9/+16
| | | | | | | | | | | | | * many bugfixes for js fixes #12672, fixes #14153, closes #14123, closes #11331, fixes #11783, fixes #13966, fixes #14087, fixes #14117, closes #12256. mostly fixes the fact that it was allowed to assign to newly created temp variables. additionally attempts to get rid of null initialized seqs/strings (though they might pop up here and there); this simplifies a lot of things and makes code size smaller. even if null seqs/strings pop up here and there it's still better than all those bugs existing. * formatting fixes * CI fixes * more CI fixes
* Error -> Defect for defects (#13908)Jacek Sieka2020-04-281-8/+8
| | | | | | | | | | | | | | * Error -> Defect for defects The distinction between Error and Defect is subjective, context-dependent and somewhat arbitrary, so when looking at an exception, it's hard to guess what it is - this happens often when looking at a `raises` list _without_ opening the corresponding definition and digging through layers of inheritance. With the help of a little consistency in naming, it's at least possible to start disentangling the two error types and the standard lib can set a good example here.
* StringStream & more stdlib modules support for JS/NimScript (#14095)hlaaftana2020-04-281-1/+1
| | | | | * StringStream & more stdlib modules support for JS/NimScript * change back pegs test in line with #14134
* `$(a: float)` now works consistently in nim js, avoiding printing floats as ↵Timothee Cour2020-04-271-0/+15
| | | | | | | | | ints (#14134) * fix https://github.com/timotheecour/Nim/issues/133; $(a: float) works in nim js like in other backends * fix tests * fix test for windows that prints 1.1e17 differently than other OS
* fixes #13032Araq2020-01-041-5/+5
|
* Improve Math.Trunc code emit on JS, had weird whitespaces and indents (#12549)Juan Carlos2019-10-301-10/+10
|
* better tojsstr (#11954)Andreas Rumpf2019-08-161-32/+39
| | | | | * JS: rewrote toJSStr * JS: don't raise exceptions in primitives
* fixes #10053 (#11951)Timothee Cour2019-08-151-1/+1
|
* [refactoring] remove zeroExtend and friends from the compiler builtins. (#11531)Arne Döring2019-06-241-16/+17
| | | | | * remove zeroExtend and friends from the compiler builtins. * fix jssys
* revive #10228 (fix #9880) (#10610)Timothee Cour2019-02-131-3/+5
| | | | | | * Make index out of bounds more useful by including the 'bounds'. * fixes #9880 index out of bounds (remaining cases); revives #10228 * change err msg to: `index 3 not in 0 .. 1`
* Guard against null exception (#10162)rec2019-01-041-1/+1
|
* Fix fat pointers, object copying, magic double evals on JS (#9411) [backport]rec2018-12-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a test for issue #9389 * Fixes #9389. * Make object contructors copy objects properly by checking whether the expressions passed to them don't need to be copied. * Make mArrToSeq implementation actually check if a copy needs to be made. * Avoid unnecessary copy in mChr impl * Assume set constructor elements need no copy * Add a test for issue #9410 * Add a test * fix passing fat pointers (#9410) * Enhance tests * More tests and fixes * Add more (failing) tests [ci skip] * Added equality operator for fat pointers, more tests and fixes * Fix printing uninitialized strings * Fix mInc, mDec double eval, add more tests * Tests * Refactored, fixed multiple evals, revamped the tests, added missing ops * Fix ups * Fix #9643 and #9644 * add pointer normalization
* Fix printing and comparing uninitialized stringsrecloser2018-10-211-0/+3
|
* JS strings have no trailing zero anymore (#8936)LemonBoy2018-09-111-14/+6
|
* fixes merge conflictAndreas Rumpf2018-08-191-1/+1
|\
| * make more tests greenAndreas Rumpf2018-08-131-1/+1
| |
* | WIP: strings/seqs based on destructorsAndreas Rumpf2018-07-171-1/+0
| |
* | more progress on destructor based stringsAndreas Rumpf2018-07-131-3/+1
|/
* JS hotfix for the Internet Explorer up to version 11Araq2018-05-251-1/+14
|
* Remove PHP backend. (#7606)treeform2018-04-181-323/+164
| | | | | | | | | | * remove php * fix * keep nimphpext * remove targetJS enum
* Fix cmpStrings in js mode (#7604)treeform2018-04-151-2/+2
|
* fixes #6753Andreas Rumpf2017-11-221-6/+6
|
* Fixed handling of surrogate pairs (#6332)Yuriy Glukhov2017-09-051-8/+17
|
* fixes #6096Araq2017-07-171-2/+2
|