1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00
Commit Graph

63 Commits

Author SHA1 Message Date
Robert Krimen
6c7c425424 Fix toReflectValue to handle Struct, Map, Slice, etc.
This fixes #79
2014-06-04 18:08:42 -07:00
Robert Krimen
9cd045ef04 Simplification & refactor of (parts of) the runtime
* Proper lowercasing for internal stuff
* *Environment => *_stash
* ExecutionContext => _scope
* Simpler & shallower call/construct mechanics
* Remove unnecessary fields & methods
* Better scoping (no more stack): []*_scope => _scope.outer
* Some speed improvements

In preparation for #66
2014-05-27 22:05:35 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Robert Krimen
bf7b16f4a3 Add internal compilation step
* Streamline what we get from "otto/parser"
* Get rid of some "otto/parser" cruft
* FunctionExpression => FunctionLiteral
* The debugger statement (debugger) should do nothing (not panic)
* Fix aspects of function expression call evaluation
2014-04-19 14:05:51 -07:00
Robert Krimen
ad8a97c028 New parser
* Faster, more straightforward, etc.
* More advanced object literals (get ..., set ...)
* More tests using JavaScript from the wild (http://cdnjs.com/)
2014-04-10 20:42:25 -07:00
Robert Krimen
0c82879349 Stop checking against 1.0.3 for release 2014-03-16 09:05:28 -07:00
Robert Krimen
6f0e24ae2d Fix Array.prototype.reduce, .reduceRight
Fix false-positives in underscore testing
Fix test (missing document because we're not in a browser)
2014-03-13 22:39:17 +01:00
Robert Krimen
c55510cb36 Inline context initialization & improve _object.value
* Context setup is now done via _newContext.
* _newContext is a function that resides in inline.go. _newContext is very flat,
resulting in almost no function calls (a 180 from the earlier status quo).
* inline.go is a Go source file that is built by Perl (via inline).
* Lots of crufty functions removed (along with all of their TODO & FIXME).
* In addition, before, the underlying value of _object.value was a pointer to
something. This made for extra work, since the type of _object.value is interface{},
which is already something of a pointer. Now, the underlying value of _object.value
in Function, Date, RegExp, ..., is a struct value.
* type_function.go was streamlined, removing superfluous struct fields and methods.
* There is now less "digging" to get to the actual value of a function, which is important
when makings lots of calls.

Before (without inline):

    PASS
    BenchmarkNew        2000           1067871 ns/op
    ok      github.com/robertkrimen/otto    3.336s
    PASS
    BenchmarkNew        2000           1077644 ns/op
    ok      github.com/robertkrimen/otto    3.367s

After (with inline):

    PASS
    BenchmarkNew       10000            364418 ns/op
    ok      github.com/robertkrimen/otto    4.616s
    PASS
    BenchmarkNew       10000            307241 ns/op
    ok      github.com/robertkrimen/otto    4.051s

This (partially) fixes #22
2013-06-09 18:28:18 -07:00
Robert Krimen
506ba2768f Tidy tests (make release, make check, etc.) 2013-06-06 19:57:12 -07:00
Robert Krimen
15539ede6c Add Object.freeze (sdgoij) 2013-05-12 14:54:47 -07:00
Robert Krimen
7e2b4f2063 Rewrite of property handling to be more robust and compliant
* No more _stash
* Now using a "virtual table" system via _objectClass
* Make Array.concat GoArray compatible (via .isArray())

Fix #16
2013-05-12 14:14:51 -07:00
Robert Krimen
2e20275e07 Add check for testing against the release version of Go 2013-05-05 10:23:18 -07:00
Robert Krimen
cfd5635e46 Fix iterator evaluation to return the proper result if a break happens 2013-04-27 22:03:12 +02:00
Robert Krimen
cc243b17d7 Can now attach a label to a block and have it break properly 2013-04-27 15:52:46 +02:00
Robert Krimen
8ab608b974 Makefile for building of otto/otto*
Fix stray dbg(...) in runtime
2013-04-26 09:27:49 +02:00
Robert Krimen
16a30ee951 Differentiate between direct and indirect eval 2013-02-27 21:23:21 -08:00
Robert Krimen
321cc0dca8 Add _argumentsStash, with better conforming arguments behavior:
1. Can not delete a function parameter
    2. Deleting the index of an arguments object simply
       removes the link to that function parameter
2013-02-24 14:28:07 -08:00
Robert Krimen
840fde7610 Switch function environment to be declarative...
...instead of object.
Also, make sure arguments passed through to function are not deletable.
2013-02-23 14:47:18 -08:00
Robert Krimen
393b9384a5 Fit number (exponent/decimal) formatting to ECMA-262 (slightly better) 2013-02-22 11:50:04 -08:00
Robert Krimen
a24b29ebfe Fix toString(-0) 2013-02-21 19:02:29 -08:00
Robert Krimen
3c9faa2810 Fix String.char*At to look at utf16 version 2013-02-21 14:25:04 -08:00
Robert Krimen
bf322e56ee Fix subtle range bug in String.substring (uint => int64)
Was looking for negative in the following calculation:

uint(0) - uint(3) => uint(0)
2013-02-20 16:24:01 -08:00
Robert Krimen
4e4e89c894 Fix bug in String.slice with a (go) slice bounds violation
Basically, check that start is less than length before trying
to take a slice.

Also, rename valueToArrayIndex to valueToRangeIndex to reflect
the fact that it does not always return a value that is valid
index (value could be length)
2013-02-20 15:58:43 -08:00
Robert Krimen
d297d3c508 Add Number.toString 2013-02-05 11:36:07 -08:00
Robert Krimen
15aadd333c Upgrade underscore to 1.4.4, including tests 2013-02-04 21:58:47 -08:00
Robert Krimen
a879744c20 Add Go <=> JavaScript type interaction
Via reflection for struct, map, and slice/array
Fix #10
2013-02-04 10:31:44 -08:00
Robert Krimen
8044e8ae38 Adjust Makefile (test-synopsis) 2013-01-25 10:46:58 -08:00
Robert Krimen
3696636fce Move test262 & more into a separate distribution 2013-01-25 10:14:14 -08:00
Robert Krimen
a13a891d92 Minor .test262 adjustments 2013-01-24 23:56:48 -08:00
Robert Krimen
668d0fc6a7 Fix broken (panicking) RegExp transformations
Transformations would panic on some edge (error) cases:

    \u0z
    \x_
2012-12-28 15:50:37 -08:00
Robert Krimen
bff799a0e1 Test for correct endIndex when submatching 2012-11-11 16:23:51 -08:00
Robert Krimen
1b39f1b6cc Calculate endIndex from last place of match, not last place of last submatch 2012-11-09 15:36:08 -08:00
Robert Krimen
845172c82c endIndex needs to be an offset from lastIndex 2012-11-07 15:46:21 -08:00
Robert Krimen
d9765234a4 Fix to not bypass finally on continue, break, return, etc. 2012-11-06 17:58:31 -08:00
Robert Krimen
a4de862caa Test condition in case of continue in do-while 2012-11-06 17:27:12 -08:00
Robert Krimen
26f8a53978 Accept out-of-range +/-Infinity (instead of NaNing) 2012-11-06 11:06:45 -08:00
Robert Krimen
68943ba1e4 More (complex) RegExp => RE2 transforming and tests
The unescaping of that which does not need escaping
2012-10-20 23:32:30 -07:00
Robert Krimen
cd4f36ce98 Fix not skipping /* & // after encountering them 2012-10-20 13:45:58 -07:00
Robert Krimen
3a6dcf46ef Don't expose re2 regular expression via //.source 2012-10-20 12:55:29 -07:00
Robert Krimen
f842eda638 Add a String.substr implementation
This will fix #6
2012-10-19 13:26:22 -07:00
Robert Krimen
1728c036d4 Partial rewrite of lexer
- Better identifier scanning
- Less repetition in decoding the stream (cached in readIn)
- Method privitization
2012-10-19 12:24:53 -07:00
Robert Krimen
24e71588dd Add String.fromCharCode 2012-10-18 10:58:23 -07:00
Robert Krimen
7982fa0fac Fix scanning \r, \b, \f, \v as \t
Copy and paste error of epic proportions?

This will fix #5
2012-10-17 18:57:48 -07:00
Robert Krimen
ed98144c35 Remarks on UTF-8/16 2012-10-17 11:54:04 -07:00
Robert Krimen
a780c85861 Fill out switch, for, for-in labelling
This and the previous commit fix #4
2012-10-16 23:11:35 -07:00
Robert Krimen
58cf2a4b67 Add break capability to switch 2012-10-16 22:57:25 -07:00
Robert Krimen
d4c606a2a0 Add test262 testing environment
http://test262.ecmascript.org/
2012-10-16 10:07:04 -07:00
Robert Krimen
a12391834e Sometimes RegExp captures can fail, detect this
Fix #2 (In .exec so far)
2012-10-14 21:45:38 -07:00
Robert Krimen
7dfbf6ab13 Better regular expression syntax checking
And a limitation elaboration
2012-10-12 18:55:41 -07:00
Robert Krimen
c57edbfe2b Alter Object.Call to be more in line with .Get, .Set 2012-10-11 17:57:51 -07:00