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

31 Commits

Author SHA1 Message Date
Robert Krimen
e6768252c2 Improve error reporting
* Delay entering global scope on code evaluation, not runtime creation

This fixes #66
2014-06-12 21:27:32 -07:00
Robert Krimen
709a0aa7ff Value.string(), .float64(), .bool(), etc. 2014-06-06 21:29:40 -07:00
Robert Krimen
b813fe3676 Fix JSON.stringify treating large integers as float64
This fixes #80
2014-06-06 21:08:59 -07:00
Robert Krimen
918abeb8d8 The zero value of Value is now defined to be undefined
Previously, it was a publically accessible but invalid value (valueEmpty).

* Deprecate internal use of UndefinedValue(), NullValue(), FalseValue(), TrueValue()
* Guard against Empty, Result, Reference values from escaping the package
2014-05-28 21:23:32 -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
4ebf6416d0 Fix Uint32 Array/String indexing
Also, a bunch of toValue_* streamlining
And maybe a few miscellaneous tweaks
2013-06-22 15:49:22 +02: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
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
fb974ca5db Do not throw a TypeError when trying to set global, ignoreCase, source, etc. 2013-05-02 20:23:07 +02:00
Robert Krimen
36a7419812 After a successful global RegExp.exec match, index shift the result 2013-05-02 20:23:07 +02:00
Robert Krimen
b4a6286aa7 Use RegExp._RegExp.Flags when doing new RegExp(RegExp) 2013-05-02 20:23:07 +02:00
Robert Krimen
1628647e05 For RegExp.exec, return the rune index in the string, not the byte index 2013-05-02 20:23:06 +02:00
Robert Krimen
70e8c14c94 Fix broken multiline RegExp behavior
Was actually not being passed through, oops...
2013-05-02 20:23:06 +02:00
Robert Krimen
0420accca6 Include .input, .index in the result of a successful RegExp.exec(...) 2013-05-02 20:23:06 +02:00
Robert Krimen
5f5cc09fbc Fix broken RegExp syntax: \c 2013-05-02 20:23:06 +02:00
Robert Krimen
96601bf274 Reorganize (type_*) code layout 2013-02-04 07:41:38 -08:00
Robert Krimen
20d2e8bba6 gofmt
Ugh.
2013-01-25 09:59:42 -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
de3300c23b Improve handling of \c 2012-12-27 16:40:11 -08:00
Robert Krimen
2b5c4b6975 Safeguard RegExp.exec against non-RegExp 2012-11-21 18:27:36 -08:00
Robert Krimen
45e8942866 Expand \c replacement range to include a-z ([A-Za-z]) 2012-11-16 10:40:07 -08:00
Robert Krimen
8f9e999236 Throw proper SyntaxError if unable to parse a regular expression 2012-11-15 16:10:24 -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
6f5ca7cc0d Beef up _property, remove _defineProperty
Remove uneeded _valueProperty
Rename to propertyMode_{write,enumerate,configure}
.Can* => writeable, enumerable, configureable
Privatize _property
Get rid of _defineProperty
2012-10-27 08:59:38 -07:00
Robert Krimen
3c93384f5c Cleanup of stash, property, and object
Use octal to designate write/enumerate/configure (experimental)
Move extensibility responsibility into the stash
Rename propertyStash => objectStash (be congruent with arrayStash, etc.)
Get rid of a bunch of useless methods
Privatize everything ([A-Z] => [a-z_])
gofmt
2012-10-26 15:47:19 -07: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
3a6dcf46ef Don't expose re2 regular expression via //.source 2012-10-20 12:55:29 -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
4a8c7ffc00 Initial commit 2012-10-05 18:47:53 -07:00