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

713 Commits

Author SHA1 Message Date
Conrad Pankoff
3e7ca9f192 Merge pull request #216 from hochhaus/master
Document that otto targets ES5
2016-09-19 11:00:42 +10:00
Andy Hochhaus
29f673c4d2 Document that otto targets ES5 2016-09-18 17:59:18 -07:00
Yohan BELLEGUIC
51bbfc0656 readme: fix "twoPlus" example function 2016-08-10 14:37:35 +02:00
Conrad Pankoff
7d9cbc2bef Merge pull request #210 from gagliardetto/patch-2
Add missing code highlighting
2016-07-29 08:04:12 +10:00
Slavomir
5bd804b3a8 Add missing code highlighting 2016-07-28 22:02:30 +02:00
Steven Hartland
c41cf547e0 Merge pull request #204 from xyproto/master
Only minor changes
2016-06-24 10:21:23 +01:00
Alexander F Rødseth
ab54b0b8c6 Use -- instead of -= 1, as recommended by golint 2016-06-24 09:53:49 +02:00
Alexander F Rødseth
e3f7ae2533 Consistent use of "value Value"/"vl Value" 2016-06-24 09:53:47 +02:00
Alexander F Rødseth
e2ef7653d2 Make it clearer that inline is a Perl script 2016-06-24 09:53:43 +02:00
Alexander F Rødseth
2a4ac54b0e Remove executable bit from source file 2016-06-24 09:53:35 +02:00
Conrad Pankoff
e1fe9ec568 Merge pull request #203 from uppfinnarn/newerror-nil-dereference
Fix for #202
2016-06-21 21:51:53 +10:00
uppfinnarn
cb827c7f40 Fix for #202 2016-06-21 13:49:50 +02:00
uppfinnarn
a87f62d034 Failing test for #202 2016-06-21 13:48:49 +02:00
Conrad Pankoff
610cd3ae86 Merge pull request #198 from deoxxa/fix-calling-go-functions-with-gostruct-arguments
fix calling go functions with goStructObject arguments
2016-05-30 13:32:50 +10:00
deoxxa
9597787793 fix calling go functions with goStructObject arguments 2016-05-30 13:30:33 +10:00
Conrad Pankoff
ef5bb303cc Merge pull request #192 from deoxxa/support-inline-source-maps
add support for inline source maps
2016-05-11 10:14:34 +10:00
deoxxa
99d478d5e8 add support for inline source maps 2016-05-08 21:17:26 +10:00
Conrad Pankoff
c562e464c6 Merge pull request #191 from deoxxa/implement-configurable-stack-trace-limit
implement configurable stack trace limit
2016-05-08 18:17:07 +10:00
deoxxa
b6c6f18e54 ensure we clone all required runtime properties 2016-05-08 18:13:57 +10:00
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