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

744 Commits

Author SHA1 Message Date
deoxxa
ccf93984d9 implement configurable stack trace limit 2016-05-08 18:13:57 +10:00
Conrad Pankoff
96f57ba9bb Merge pull request #190 from deoxxa/refactor-native-function-parameter-conversion
refactor native function parameter conversion
2016-05-08 10:38:42 +10:00
deoxxa
1fe0007dcb refactor native function parameter conversion
* add benchmarks and tests for native function calls
* improve conversion of various native function parameters
* add support for more types of native function parameters
* improve performance of most parameter types
2016-05-07 21:35:17 +10:00
Conrad Pankoff
ef01634c52 Merge pull request #141 from deoxxa/native-frames-in-stack
make call stacks aware of native functions
2016-05-07 20:56:01 +10:00
deoxxa
668c95f04e make call stacks aware of native functions
* add stackFramesToPop argument to error factories
* put native functions in their own stack frames
* add tests for native stack frames
* amend Context functionality to account for native frames
2016-05-07 20:55:09 +10:00
Conrad Pankoff
3a69c44018 Merge pull request #138 from deoxxa/source-maps
Source maps
2016-05-07 20:50:17 +10:00
deoxxa
bd5fb254e3 add source map support
This patch implements source map support in the parser, the runtime, the
script record, and the stack trace printing.

The library used to parse and use the source maps is gopkg.in/sourcemap.v1.
Unlike earlier versions of this patch, the consumer of otto does not need
parse the source map on their own - it's now handled similarly to parsing
JavaScript content.

To use a source map, the consumer must explicitly parse their source into
a `Script` object with `Otto.CompileWithSourceMap`. The script record
returned from that call will carry source map information with it, and
all location-related functions should reflect the original source
positions.
2016-05-02 19:34:04 +10:00
Conrad Pankoff
a55c9c9461 Merge pull request #176 from deoxxa/add-autocomplete-to-repl
add tab-complete to repl
2016-05-02 19:23:55 +10:00
Conrad Pankoff
353d16e612 Merge pull request #180 from deoxxa/error-stack-property
support the non-standard Error.stack property
2016-05-02 19:23:22 +10:00
deoxxa
c03dfd35cd support the non-standard Error.stack property
Popular runtimes (V8[1], SpiderMonkey[2], IE[3]) support a `stack`
property on Error objects to get the error's stack as a string.

This change adds support to otto for this same feature. It's implemented
in a similar way to V8, using a getter function. This avoids generating
the stack trace (which is done in a loop with string manipulation etc)
unless the user requests it. There's no standard, or even trend, for the
actual _content_ of `stack`, so we basically just copy what V8's traces
look like.

[1]: https://github.com/v8/v8/wiki/Stack%20Trace%20API
[2]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Error/stack
[3]: http://msdn.microsoft.com/en-us/library/windows/apps/hh699850.aspx
2016-05-02 19:22:56 +10:00
Conrad Pankoff
3b7f285a92 Merge pull request #181 from deoxxa/add-error-creator-functions
add error creator functions
2016-05-02 19:21:39 +10:00
Conrad Pankoff
4c50a9dc04 Merge pull request #173 from xl1/improve-array-sort
Improve performance to sort array with the same values
2016-04-30 15:22:05 +10:00
deoxxa
a7e69fb1ca add error creator functions
This change adds a handful of functions to `otto.Otto` type that make
it easier to create proper `Error` values from native code. Previously,
the only way to do this was to call the error's constructor from
JavaScript like `vm.Call("TypeError", "message")`. `Call` can fail for
various reasons, and also modifies the current call stack.

These new functions can't fail, and since they don't involve any
JavaScript execution, won't modify the call stack. The new functions
are:

* `MakeCustomError(name, message string) Value`
* `MakeRangeError(message string) Value`
* `MakeSyntaxError(message string) Value`
* `MakeTypeError(message string) Value`

`MakeCustomError` creates an `Error` object with a specific `name` value.
The other functions cover some common error types, and call specific
functions in the runtime to construct errors with the correct prototypes.
If we need to implement any other error types, it'll mostly be copy/paste.
2016-04-30 12:45:33 +10:00
xl1
c58b494b24 Fix buildinArray_sort 2016-04-30 03:13:39 +09:00
xl1
dab050291b Add tests for Array sort 2016-04-30 03:12:46 +09:00
deoxxa
9ce459fe6b amend docs on Keys/KeysByParent 2016-04-28 22:44:27 +10:00
deoxxa
03de7d5c8c make autocomplete an opt-in repl feature 2016-04-28 22:43:16 +10:00
Conrad Pankoff
d1eaa4b5e9 Merge pull request #168 from deoxxa/limit-stack-depth
add simple stack depth limit mechanism
2016-04-27 20:10:23 +10:00
Conrad Pankoff
e1cb3011d0 Merge pull request #169 from deoxxa/fix-crash-exporting-array
fixes #165 - crash exporting an array with undefined as the first element
2016-04-27 20:09:46 +10:00
Conrad Pankoff
e214185093 Merge pull request #151 from Fugiman/master
Have goSliceGetOwnProperty check methods as well
2016-04-27 17:07:52 +10:00
Fugiman
3b5f2fda57 Add test for go slice methods 2016-04-27 00:02:57 -07:00
Chris Gamble
8f5d15d409 Have goSliceGetOwnProperty check methods as well 2016-04-27 00:02:56 -07:00
deoxxa
c3d9ea142b add tab-complete to repl 2016-04-27 16:08:41 +10:00
deoxxa
6e7c8df250 add KeysByParent function for recursively getting object keys 2016-04-27 16:08:07 +10:00
Conrad Pankoff
b283580aea Merge pull request #164 from wolfgarnet/commentmapv2
Commentmapv2
2016-04-25 16:16:03 +10:00
Conrad Pankoff
445ff6b9d0 Merge pull request #174 from amasad/master
Export NewParser and Parser.Scan
2016-04-25 16:06:10 +10:00
Amjad Masad
cb833c2321 Expose Parser Interface with a Scan method 2016-04-24 23:01:26 -07:00
deoxxa
f271e0183c don't try to construct a common type array if there is no type 2016-04-25 11:58:49 +10:00
deoxxa
8dcf49dfe7 amend type sniffing to work with null 2016-04-25 11:58:30 +10:00
deoxxa
8e3ecbc5e3 avoid scope depth check for first stack frame 2016-04-25 11:39:17 +10:00
deoxxa
655561815b document SetStackDepthLimit tests 2016-04-25 11:36:59 +10:00
deoxxa
029a80224c document SetStackDepthLimit 2016-04-25 11:36:52 +10:00
xl1
804a9102ab Speed up builtinArray_sort for array with the same values 2016-04-24 04:52:56 +09:00
Steven Hartland
c619b8fa10 Merge pull request #172 from dop251/remove-redundant-rangeerror-prefixes-fix-tests
Fixed tests to match the updated error messages.
2016-04-05 23:39:28 +01:00
Dmitry Panov
25c2e92cec Fixed tests to match the updated error messages. 2016-04-05 19:10:38 +01:00
Steven Hartland
6c92cd134a Merge pull request #170 from deoxxa/remove-redundant-rangeerror-prefixes
remove redundant RangeError prefixes
2016-04-03 16:17:44 +01:00
deoxxa
17aaeb85c3 remove redundant RangeError prefixes 2016-04-04 00:34:33 +10:00
deoxxa
014e1807a9 remove redundant unnecessary error prefix 2016-04-04 00:32:44 +10:00
deoxxa
da054efc5f fixes #165 - crash exporting an array with undefined as the first element 2016-04-04 00:25:24 +10:00
deoxxa
c142472392 add simple stack depth limit mechanism 2016-04-04 00:07:41 +10:00
wolfgarnet
ab433a4a50 Improved comment map
* More precise
* Line break special cases supported
* Less intrusive
2016-02-22 15:16:41 +01:00
wolfgarnet
1003ce01cb DotExpression identifier as pointer 2016-02-19 13:15:14 +01:00
wolfgarnet
3b2178bf55 Added FunctionStatement 2016-02-19 13:14:42 +01:00
Conrad Pankoff
53221230c2 Merge pull request #149 from wolfgarnet/commentmap
Storing comments in a commentmap
2016-02-19 09:43:13 +11:00
Conrad Pankoff
9c8301a8b3 Merge pull request #163 from deoxxa/external-random-source
add support for an external Math.random() provider
2016-02-18 22:10:03 +11:00
deoxxa
fd1eddd0f9 add support for an external Math.random() provider 2016-02-18 22:08:25 +11:00
Steven Hartland
c21072f61b Merge pull request #157 from kazhuravlev/patch-1
Fix example
2016-01-29 12:10:11 +00:00
kazhuravlev
2bebd7b731 Fix example 2016-01-29 14:15:00 +03:00
Christian Wolfgang
d65b096ff3 [#148] Fixed style in lexer 2016-01-17 20:08:44 +01:00
wolfgarnet
54a2be367f [#148] Fixed style 2016-01-12 12:13:04 +01:00