Commit Graph

84 Commits

Author SHA1 Message Date
hlaaftana
81533a0014 [backport:1.4] JS cstring null fixes (#16979)
* [backport:1.4] JS cstring null fixes
* fix JS move string
* make it look cleaner
2021-02-11 17:04:32 +01:00
flywind
89a2390f8b fix printing negative zero in JS backend (#16505) 2020-12-29 15:50:22 +01:00
flywind
3f9a2ebea5 fix nim js cmp fails at CT (#16473) 2020-12-27 10:13:57 +01:00
Jonah Snider
fa1a04188f Avoid creating a holey array in makeNimstrLit for JS target (#16461)
* Avoid creating a holey array in makeNimstrLit
* Use array index instead of push
2020-12-27 09:33:51 +01:00
flywind
19e224866b add simple writeStackTrace for JS backend (#16016)
* add simple writeStackTrace for JS backend

* add testcase for writeStackTrace

* changelog
2020-11-24 19:45:06 +01:00
Miran
bbe49a14ae Correct all eggs (#15906)
* "eg" is a misspelled "egg", "e.g." is "exempli gratia"
* Also, "ie" is "i.e.".
2020-11-10 21:53:25 +01:00
Juan Carlos
4e7d383f29 Clean out jssys (#15442) 2020-10-01 11:21:27 +02:00
Timothee Cour
c28a057a6b fix js stacktraces, unify all file,line,col formatting into a single function (#14230)
* fix https://github.com/timotheecour/Nim/issues/135 ; unify all file,line,col formatting into a single function
2020-05-05 14:56:15 +02:00
hlaaftana
707367e1ca many bugfixes for js (#14158)
* 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
2020-04-29 20:55:09 +02:00
Jacek Sieka
7d6cbf290a Error -> Defect for defects (#13908)
* 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.
2020-04-28 19:56:01 +02:00
hlaaftana
cd9af6b804 StringStream & more stdlib modules support for JS/NimScript (#14095)
* StringStream & more stdlib modules support for JS/NimScript

* change back pegs test in line with #14134
2020-04-28 19:44:52 +02:00
Timothee Cour
bb982c644b $(a: float) now works consistently in nim js, avoiding printing floats as 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
2020-04-27 17:33:03 +02:00
Araq
a1beeb313f fixes #13032 2020-01-04 19:33:49 +01:00
Juan Carlos
b5bb581642 Improve Math.Trunc code emit on JS, had weird whitespaces and indents (#12549) 2019-10-30 14:12:17 +01:00
Andreas Rumpf
ba577c7e1b better tojsstr (#11954)
* JS: rewrote toJSStr
* JS: don't raise exceptions in primitives
2019-08-16 12:18:51 +02:00
Timothee Cour
511298242d fixes #10053 (#11951) 2019-08-15 15:55:48 +02:00
Arne Döring
e90d91f0e4 [refactoring] remove zeroExtend and friends from the compiler builtins. (#11531)
* remove zeroExtend and friends from the compiler builtins.
* fix jssys
2019-06-24 09:19:02 +02:00
Timothee Cour
942495611b revive #10228 (fix #9880) (#10610)
* 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`
2019-02-13 23:30:14 +01:00
rec
ba7d33b4e4 Guard against null exception (#10162) 2019-01-04 15:05:03 +01:00
rec
e3e5ae287f Fix fat pointers, object copying, magic double evals on JS (#9411) [backport]
* 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
2018-12-04 12:04:27 +01:00
recloser
2b03bed2db Fix printing and comparing uninitialized strings 2018-10-21 21:18:10 +02:00
LemonBoy
9ba80d2044 JS strings have no trailing zero anymore (#8936) 2018-09-11 11:45:02 +02:00
Andreas Rumpf
696c0c48c7 fixes merge conflict 2018-08-19 15:14:03 +02:00
Andreas Rumpf
7f49364fd0 make more tests green 2018-08-13 12:29:03 +02:00
Andreas Rumpf
32afdc09c6 WIP: strings/seqs based on destructors 2018-07-17 13:19:42 +02:00
Andreas Rumpf
74bf316619 more progress on destructor based strings 2018-07-13 21:15:47 +02:00
Araq
08637bc272 JS hotfix for the Internet Explorer up to version 11 2018-05-25 23:19:54 +02:00
treeform
35b0cc67e8 Remove PHP backend. (#7606)
* remove php

* fix

* keep nimphpext

* remove targetJS enum
2018-04-18 20:40:11 +02:00
treeform
b98cd3bf34 Fix cmpStrings in js mode (#7604) 2018-04-15 17:34:03 +02:00
Andreas Rumpf
fe18769fe1 fixes #6753 2017-11-22 12:58:03 +01:00
Yuriy Glukhov
d13535471b Fixed handling of surrogate pairs (#6332) 2017-09-05 16:42:41 +02:00
Araq
f127a7f7aa fixes #6096 2017-07-17 16:43:10 +02:00
andri lim
c245cfc1fd fixes #5986 js backend failed to compile try ... except new syntax (#6116) 2017-07-17 08:07:47 +02:00
Andreas Rumpf
3993718335 JS codegen: make 'echo' use console.log unless you define -d:nimOldEcho 2017-06-28 16:18:19 +02:00
Andreas Rumpf
56a5c249c9 JS codegen: produce better code for constant sets 2017-05-01 09:30:56 +02:00
Andreas Rumpf
1268ca79e5 fixes #5599 (#5610) 2017-03-26 09:30:59 +02:00
Yuriy Glukhov
99bbda28ee Store stack trace in exception 2016-09-04 22:57:10 +03:00
Yuriy Glukhov
f12f27c185 Fixed getCurrentException and getCurrentExceptionMsg. Closes #4635 2016-08-29 13:10:06 +03:00
Yuriy Glukhov
c1dd65c01a Reset framePtr on unhabdled exception. Dont reset on getStackTrace. 2016-08-27 18:10:13 +03:00
Yuriy Glukhov
90b0a771e4 Uncaught exceptions in JS now always propagate with better stack trace. 2016-08-27 16:52:08 +03:00
Andreas Rumpf
0834cd63d9 prepare Nim codebase for upcoming parser changes 2016-07-15 12:56:03 +02:00
nigredo-tori
85c41a1398 Fix toJSStr for control characters
fixes #4190
Add leading zero to encoded character if it is less than 0x10
2016-05-20 12:35:34 +06:00
Andreas Rumpf
746132d696 PHP codegen improvements 2016-05-13 00:47:18 +02:00
Hans Raaf
d3bae50c3c PHP codegen array constructor hack.
Because of PHP can't have refs for literal function parameters I
needed to come up with a hack such that the following code compiles with
PHP target.

```nim
type Foo = tuple[a: string, b: int]

var foo: array [0..2, Foo]

foo[0] = ("Test", 1)
foo[1] = ("Me", 2)

for x in foo:
  echo x.a
  echo x.b
```
2016-05-11 22:51:27 +02:00
Andreas Rumpf
b48e178969 JS target improvements 2016-04-29 17:56:06 +02:00
Hans Raaf
8c1dd215ac Fix for PHP mnewString() 2016-03-06 01:03:00 +01:00
Andreas Rumpf
92cf673f37 PHP codegen: use nimAt for PHP 5.3 compatibility 2016-03-04 21:59:58 +01:00
Andreas Rumpf
8ec7c0af20 php-codegen fixes 2016-02-06 19:58:28 +01:00
Andreas Rumpf
9b44ca17c2 PHP codegen can generate PHP classes 2016-02-06 15:39:56 +01:00
Andreas Rumpf
35567a1eb9 first version of an PHP codegen 2016-02-06 15:39:56 +01:00