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

84 Commits

Author SHA1 Message Date
Igor Kharin
1864a88fa0 Implement strings without value16
This fixes #68

Some changes over the original patch, removing references to utf8string.String:

* (better) This removes a dependency on a non-standard (though solid) package
* (better) utf8string.String has mutable parts
* (worse) utf8string.String has a smarter consecutive access approach (by
  remembering where the last access was)
* (?) _stringWide allocates a []rune if charAt or charCodeAt access is needed (though
  it will only do this once for the string object)
2014-05-18 12:38:15 -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
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
61a011e711 Add Object.getOwnPropertyNames (sdgoij) 2013-06-04 20:07:16 -07:00
Robert Krimen
716c307c8d Add Date.toDateString, Date.toTimeString 2013-06-04 19:56:03 -07:00
Robert Krimen
f3d41e0b0c Fix Object built-in attribute defaults (true, false, true) 2013-06-03 18:36:24 -07:00
Robert Krimen
32164a41c9 Fix Date built-in attribute defaults (true, false, true) 2013-06-03 18:36:24 -07:00
Robert Krimen
55565afada Fix global built-in attribute defaults (true, false, true) 2013-06-03 18:36:06 -07:00
Robert Krimen
c6e033bf6c Fix Array initialization (in the case of [,...], etc.) 2013-06-02 16:41:34 -07:00
Robert Krimen
1b469aefc1 Add Object.keys (sdgoij) 2013-06-02 16:13:45 -07:00
Robert Krimen
baf3318f30 Add Error.prototype.message 2013-06-02 15:03:33 -07:00
Robert Krimen
599d565e55 Use defineOwnProperty (not put) for Array (literal) initialization 2013-06-01 23:11:13 -07:00
Robert Krimen
d2eaa4aab6 Add Object.seal (sdgoij) 2013-05-18 15:56:52 -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
d1d4d939ea Add Object.isSealed & Object.isFrozen 2013-05-05 10:35:32 -07:00
Robert Krimen
683e3956aa Add Object.isExtensible & Object.preventExtensions...
...and fix the deep implementation of defineOwnProperty
so that they can work (more or less) properly
2013-05-03 22:24:51 +02:00
Robert Krimen
6c5259a651 Add Object.toLocaleString 2013-05-02 21:06:22 +02:00
Robert Krimen
596af0a836 Fix RegExp.prototype.toString .length & .prototype 2013-05-02 20:23:07 +02:00
Robert Krimen
bc84827b09 Fix RegExp.prototype.test .length & .prototype 2013-05-02 20:23:07 +02:00
Robert Krimen
fc569ab73a Fix RegExp.prototype.exec .length & .prototype 2013-05-02 20:23:07 +02:00
Robert Krimen
b078bacaf7 Set the prototype of Math to the global object prototype 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
5c5dfbf501 Use RegExp.source (not RegExp.toString) when doing new RegExp(RegExp) 2013-05-02 20:23:06 +02:00
Robert Krimen
74a8739188 Cannot supply flags when constructing one RegExp from another 2013-05-02 20:23:06 +02:00
Robert Krimen
4c85422172 Make encodeURI correspond to the 15.1.3.3 algorithm and encodeURIComponent ito 15.1.3.4 2013-05-02 20:23:06 +02:00
Robert Krimen
83d4565b22 Make decodeURI correspond to the 15.1.3.1 algorithm and decodeURIComponent ito 15.1.3.2 2013-05-02 20:23:06 +02:00
Robert Krimen
b477d8eaed Fix isNaN/isFinite .length & .prototype 2013-04-30 00:18:00 +02:00
Robert Krimen
16030f4b6f Make parseInt behavior correspond to the 15.1.2.3 algorithm 2013-04-30 00:18:00 +02:00
Robert Krimen
b5e40f8a85 Make parseInt behavior correspond to the 15.1.2.2 algorithm 2013-04-28 17:33:00 +02:00
Robert Krimen
2ec9b0843c eval is not a constructor 2013-04-28 11:29:20 +02:00
Robert Krimen
6a4e5a904e eval.prototype === undefined 2013-04-28 11:25:06 +02:00
Robert Krimen
2c4c22ca81 eval.length === 1 2013-04-28 11:24:39 +02:00
Robert Krimen
cc112ca544 Set the prototype of the global object to be the object prototype 2013-04-28 11:00:21 +02:00
Robert Krimen
0da0545485 Add Array.isArray 2013-04-17 11:05:32 -07:00
Robert Krimen
fa871c8828 Add Date.toGMTString 2013-04-16 23:02:51 -07:00
Robert Krimen
d223d7576f Add Date.toLocale*String 2013-04-16 23:00:24 -07:00
Robert Krimen
9281104552 Add Date.setYear 2013-04-16 22:44:15 -07:00
Robert Krimen
d5497fbe89 Add Date.getYear 2013-04-16 22:37:17 -07:00
Robert Krimen
a5ae851516 Add Date.UTC 2013-04-16 22:32:14 -07:00
Robert Krimen
b6fdebf8ee Add Date.parse 2013-04-16 22:22:39 -07:00
Robert Krimen
896c393235 Add Math.abs 2013-03-17 22:17:21 -07:00
Robert Krimen
8486fe2d1c Add escape/unescape 2013-03-17 22:06:08 -07:00
Robert Krimen
7b0eac16f9 Add Number.toPrecision 2013-03-07 08:42:48 -08:00
Robert Krimen
e5f0da1420 Add Number.toExponential 2013-03-07 08:34:12 -08:00
Robert Krimen
2e7e3e17fd Add Number.toFixed 2013-03-07 08:22:23 -08:00
Robert Krimen
f3da7237f2 Add Object.getPrototypeOf 2013-03-05 12:03:33 -08:00
Robert Krimen
fef122900f Add Function.bind 2013-03-01 13:08:10 -08:00