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

73 Commits

Author SHA1 Message Date
Robert Krimen
ddca88af9b Add compilation (Script, vm.Compile, etc.) 2014-04-13 15:04:32 -07:00
Robert Krimen
f04cfab02d Add ability to parse []byte, *bytes.Buffer, io.Reader 2014-04-11 18:07:57 -07:00
Robert Krimen
6e3ed1b99d Tighten test comparisons instead of squashing everything to a string 2014-04-11 18:06:18 -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
ec106f69e0 Add Object.Keys()
This fixes #62
2014-04-03 18:25:53 -07:00
Robert Krimen
aef9bfcb9a Fix "memory leak" by gelcapping panic values with _exception
Basically, the Go runtime sees the gelcap shell of the exception,
which dissolves (payload is set to nil) once we catch the error.

This prevents the Go runtime from hanging onto a heavy object for the
panic log (or whatever it is doing with the panic value).

This fixes #59
2014-02-21 18:24:07 -08:00
Robert Krimen
e01dde79ed More tests for .Copy()
This fixes #57
2014-02-16 21:41:16 -08:00
Tim Jurcka
dd88ce83b8 Call getter/setter if property is AccessorDescriptor
This fixes #36
This fixes #56
2014-02-12 21:52:42 -08:00
Robert Krimen
c3cd59909c Provide early warning of missing functionality (set:/get:)
This is a bandaid for #56
2014-02-10 21:15:40 -08:00
Robert Krimen
329e5afb2c Add objectLength 2014-02-01 11:09:14 -08:00
Robert Krimen
4a6c644125 Fix Object.defineProperties to only enumerate over enumerable 2014-01-20 08:56:10 -08:00
Robert Krimen
c47cf7be6e Improve arguments property handling
Also, fix an issue with double enumeration of arguments
2014-01-19 21:08:05 -08:00
Robert Krimen
ea621687a4 Add Otto.Copy() 2013-07-14 14:20:01 -07: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
baf3318f30 Add Error.prototype.message 2013-06-02 15:03:33 -07:00
Robert Krimen
18630616eb Remove throw behavior from Otto.Call 2013-05-19 21:08:32 -07:00
Robert Krimen
83c56dd73d Add Otto.Call 2013-05-19 19:03:05 -07:00
Robert Krimen
699232d49a Consolidate run/runSafe into _runtime 2013-05-18 16:18:17 -07:00
Robert Krimen
bdd28e5938 Revamp property mode bit fiddling (write, enumerate, configure) 2013-05-18 15:56:35 -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
9184233705 Bundle terst dependency (github.com/robertkrimen/terst) 2013-04-15 10:20:34 -07:00
Robert Krimen
260b2a48bf Fix (band-aid) Go/JavaScript cross-boundary error transformation 2013-03-06 12:07:26 -08:00
Robert Krimen
bada1b6b24 Fix passing the wrong value to calculateBinaryOperation
Was passing left instead of leftValue
2013-03-05 18:10:14 -08:00
Robert Krimen
283dffe841 Can delete an undefined reference 2013-03-05 17:49:15 -08:00
Robert Krimen
d1c4cf79ab Fix always passing in the global object as this for eval
Should be passing in the this of the parent execution context instead
2013-03-05 14:41:50 -08:00
Robert Krimen
16a30ee951 Differentiate between direct and indirect eval 2013-02-27 21:23:21 -08:00
Robert Krimen
809a0a0ba6 Split tests out of one big massive file 2013-02-05 08:56:08 -08:00
Robert Krimen
15aadd333c Upgrade underscore to 1.4.4, including tests 2013-02-04 21:58:47 -08:00
Robert Krimen
aaa90bf65c Fix HasInstace (instanceof) to return false
Should not TypeError panic on a non-Object
2013-02-04 15:21:00 -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
e5ff4cef59 Add delete to type_array 2013-02-04 07:30:53 -08:00
Robert Krimen
3240efeb62 Convert string to utf16 for length, indexing, etc.
This change is internal to String objects
2013-01-25 14:57:55 -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
2b5c4b6975 Safeguard RegExp.exec against non-RegExp 2012-11-21 18:27:36 -08:00
Robert Krimen
aef569f297 Fix to handle Infinity radix in parseInt properly 2012-11-15 15:15:26 -08:00
Robert Krimen
db913468da If a property is defined without a value (nil interface), define it as undefined 2012-11-14 15:48:19 -08:00
Robert Krimen
0498f06be0 Fix trying to delete non-reference 2012-11-14 11:09:52 -08:00
Robert Krimen
bff799a0e1 Test for correct endIndex when submatching 2012-11-11 16:23:51 -08:00
Robert Krimen
845172c82c endIndex needs to be an offset from lastIndex 2012-11-07 15:46:21 -08:00
Robert Krimen
9385f32241 Fix substring to have correct behavior 2012-11-06 20:03:22 -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
aa3109f8db typeof null === "object" 2012-11-05 13:57:18 -08: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
c1a21812fe Fix trying to call a non-function as a function 2012-10-22 14:29:14 -07:00
Robert Krimen
820c21423f Bypass a little bit more of the gauntlet (for now) 2012-10-20 23:52:34 -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