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

92 Commits

Author SHA1 Message Date
deoxxa
c142472392 add simple stack depth limit mechanism 2016-04-04 00:07:41 +10:00
deoxxa
089191042f more tests for Context method 2015-12-06 12:04:12 +11:00
Andrew Montgomery-Hurrell
45c7a8df39 Add Context method to aid debugging
This change introduces a Context method to otto that allows developers to get
information about the current execution context. The method returns a Context
struct that contains information such as the filename, line and column of the
current execution, the current value of this, the stacktrace and the available
symbols at the current context.
2015-12-05 18:03:36 +00:00
deoxxa
dea2645a65 comment the crazy test case for Eval 2015-12-05 21:03:55 +11:00
deoxxa
44a4b3115d support and test Eval() without an existing scope 2015-12-05 20:24:12 +11:00
deoxxa
9afbdc1417 add test for Eval function 2015-12-05 19:17:57 +11:00
Steven Hartland
8aa4915210 Merge pull request #92 from BiggerNoise/master
Test map[string]interface{} using Set & Call behave the same
2015-12-04 15:52:16 +00:00
Conrad Pankoff
89a9f14981 Merge pull request #139 from deoxxa/fix-bracket-parsing-with-new
fix parsing of statements like `new a["b"]`
2015-12-03 08:43:55 +11:00
deoxxa
33ac8bd28a fix parsing of statements like new a["b"] 2015-11-02 16:13:03 +11:00
Steven Hartland
40ef8d9463 Fix argument processing for call
Fix toValueArray causing "missing runtime" errors due to use of toValue instead of self.toValue which causeed issues with passing values to Otto.Call(...).
2015-02-12 15:11:55 +00:00
Andy Davis
0467f16538 add tests demonstrating the different behavior from Call & Run 2014-07-30 14:15:38 -05:00
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
de36a84a51 Fix cloning of _fnStash
This may help #71
2014-06-04 21:53:31 -07:00
Robert Krimen
98be5e74da go vet
This fixes #76

I cheated on some of these.
2014-05-28 21:46:08 -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
0917510923 Fix delete ... triggering property get() 2014-04-19 11:11:53 -07:00
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