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

23 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
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
1f3aef2086 Fix Date.prototype.setTime
This fixes #58
2014-02-18 20:37:54 -08:00
Robert Krimen
ee02d532e6 Fully implement multi-argument setHours/setMinutes/setFullYear/... 2014-01-26 10:03:26 -08:00
Robert Krimen
f578229e36 Fix Date(...) to be different from new Date(...) 2014-01-25 11:14:38 -08:00
Tim Jurcka
0845d0253a Add Date.now()
This fixes #33
2013-07-14 14:19:21 -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
44fda5c7c3 Add Date.toJSON 2013-06-15 12:56:17 -07:00
Robert Krimen
a34c4d2d1f Add Date.toISOString (sdgoij) 2013-06-15 12:06:33 -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
716c307c8d Add Date.toDateString, Date.toTimeString 2013-06-04 19:56:03 -07:00
Robert Krimen
0084268e1f Constantize buildinDate_to*String layout 2013-06-04 19:42:36 -07:00
Robert Krimen
696272f7d6 Fix Local/UTC conversion discrepancy in newDateTime 2013-05-05 09:18:16 -07:00
Robert Krimen
01f5fae58f Date(...) => string (Not an object) 2013-04-20 19:09:27 -07:00
Robert Krimen
7624bc44fe Date() => string (Not an object) 2013-04-20 18:59:58 -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
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
ec902a6452 Split builtin.go out to builtin_*.go 2013-02-20 15:58:45 -08:00