Ernest Micklei
81094c6e94
add unit test for FunctionCall CallerLocation()
2015-03-01 21:17:39 +01:00
Ernest Micklei
9919b73823
add CallerLocation to FunctionCall
2015-03-01 08:49:14 +01:00
Dmitry Savintsev
b487603abe
minor spacing changes for gofmt compliance
2015-02-25 21:48:07 +01:00
Steven Hartland
1b2cc7f8c1
Merge pull request #7 from stevenh/call-params
...
Improve method call parameter processing
2015-02-19 14:08:14 +00:00
Steven Hartland
a30a6a7b53
Improve method call parameter processing
...
Add support for the final parameter to a variadic function to be a slice.
Add support for conversion of slice parameters.
Expand numeric conversion support to include all int and uint types as souce types. This allows the result of bitwise calculations (int32) to be passed in as parameters.
2015-02-19 11:45:35 +00:00
Steven Hartland
37d35189e7
Merge pull request #8 from stevenh/float-precision
...
Float precision
2015-02-19 11:36:50 +00:00
Steven Hartland
abcc601db6
Prevent loss of float precision
...
When automatically converting a float to int type ensure we don't loose any precision.
2015-02-19 11:33:21 +00:00
Steven Hartland
9cb5e6bc30
Merge pull request #6 from stevenh/array-types
...
Export arrays to common type if possible
2015-02-19 11:08:22 +00:00
Steven Hartland
72d92c8e19
Export arrays to common type if possible
...
If there is a common type for all values in an array export to a slice of that type otherwise return a slice of interfaces.
2015-02-17 23:18:23 +00:00
Robert Krimen
c2346f4ada
Merge pull request #103 from multiplay/multi-return
...
Support go multiple return values as an array
2015-02-15 16:28:43 -08:00
Robert Krimen
fa043cd6a1
Merge pull request #104 from multiplay/numeric-params
...
Automatic numeric parameter conversion
2015-02-15 16:13:10 -08:00
Steven Hartland
bbce143912
Merge pull request #1 from stevenh/numeric-params
...
Automatic numeric parameter conversion
2015-02-12 15:51:20 +00:00
Steven Hartland
4066dcefa9
Merge pull request #2 from stevenh/multi-return
...
Support go multiple return values as an array
2015-02-12 15:51:07 +00:00
Steven Hartland
b37428d05b
Merge pull request #3 from stevenh/arg-processing
...
Fix argument processing for call
2015-02-12 15:50:57 +00:00
Steven Hartland
c25bb49761
Automatic numeric parameter conversion
...
Javascript uses int64 (literals) and float64 (default) representations for numbers so to allow easy use of go funcs apply automatic conversion for function parameters where it is safe to do so.
2015-02-12 15:48:45 +00: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
Steven Hartland
81b01b9fac
Support go multiple return values as an array
...
Add support for go funcs which return multiple values by returning them as an array.
In the future this can be used along side destructuring assignment to provide a nice way to deal with multiple value returns e.g.
[val, err] = MyGoFunc()
2015-02-12 15:10:58 +00:00
Andy Davis
0467f16538
add tests demonstrating the different behavior from Call & Run
2014-07-30 14:15:38 -05:00
Tim Jurcka
f7dbb7c5b3
Merge branch 'master' into issue86
...
Conflicts:
bug_test.go
2014-07-03 10:43:52 +02:00
Robert Krimen
dea31a3d39
Fix behavior when breaking a loop into an outer block
...
This fixes #87
2014-07-02 21:33:53 -07:00
Tim Jurcka
c65402d4bf
Fix panic: in.value.(Value) != true
...
When copying a runtime which contains objects with property accessors ({g,s}etters)
—
$ go test -v -run=Test_issue86
=== RUN Test_issue86
~~~ FAIL: (Terst)
--- FAIL: Test_issue86 (0.00 seconds)
panic: in.value.(Value) != true [recovered]
panic: in.value.(Value) != true [recovered]
panic: in.value.(Value) != true
goroutine 20 [running]:
runtime.panic(0x2f5400, 0x2086ed7e0)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
testing.func·006()
/usr/local/go/src/pkg/testing/testing.go:416 +0x176
runtime.panic(0x2f5400, 0x2086ed7e0)
/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
_/Users/tim/repositories/github.com/sdgoij/otto/terst.func·001()
/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:475 +0xf5
runtime.panic(0x2f5400, 0x2086ed7e0)
/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).property(0x2087a6030, 0x2a0360, 0x2086ed5d0, 0x92, 0x0, 0x0, 0x0)
/Users/tim/repositories/github.com/sdgoij/otto/clone.go:146 +0x186
_/Users/tim/repositories/github.com/sdgoij/otto.objectClone(0x208779b60, 0x2087a8ba0, 0x2087a6030, 0x20878f4a0)
/Users/tim/repositories/github.com/sdgoij/otto/object_class.go:471 +0x279
_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).object(0x2087a6030, 0x208779b60, 0x208779b60)
/Users/tim/repositories/github.com/sdgoij/otto/clone.go:87 +0xf1
_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).value(0x2087a6030, 0x5, 0x336680, 0x208779b60, 0x0, 0x0, 0x0)
/Users/tim/repositories/github.com/sdgoij/otto/clone.go:121 +0xb6
_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).property(0x2087a6030, 0x341ea0, 0x2087a40a0, 0x48, 0x0, 0x0, 0x0)
/Users/tim/repositories/github.com/sdgoij/otto/clone.go:144 +0xbc
_/Users/tim/repositories/github.com/sdgoij/otto.objectClone(0x2086f0c00, 0x208779c80, 0x2087a6030, 0x20878f8e0)
/Users/tim/repositories/github.com/sdgoij/otto/object_class.go:471 +0x279
_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).object(0x2087a6030, 0x2086f0c00, 0x2087a60f0)
/Users/tim/repositories/github.com/sdgoij/otto/clone.go:87 +0xf1
_/Users/tim/repositories/github.com/sdgoij/otto.(*_runtime).clone(0x20873c000, 0x0)
/Users/tim/repositories/github.com/sdgoij/otto/clone.go:29 +0x1b9
_/Users/tim/repositories/github.com/sdgoij/otto.(*Otto).Copy(0x2086ed3c0, 0x75)
/Users/tim/repositories/github.com/sdgoij/otto/otto.go:471 +0x2b
_/Users/tim/repositories/github.com/sdgoij/otto.func·098()
/Users/tim/repositories/github.com/sdgoij/otto/bug_test.go:592 +0xf5
_/Users/tim/repositories/github.com/sdgoij/otto/terst.func·002()
/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:479 +0x21a
_/Users/tim/repositories/github.com/sdgoij/otto/terst.Terst(0x20873a1b0, 0x20878ff40, 0x1, 0x1)
/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:480 +0x196
_/Users/tim/repositories/github.com/sdgoij/otto.tt(0x20873a1b0, 0x20878ff40, 0x1, 0x1)
/Users/tim/repositories/github.com/sdgoij/otto/testing_test.go:19 +0x16a
_/Users/tim/repositories/github.com/sdgoij/otto.Test_issue86(0x20873a1b0)
/Users/tim/repositories/github.com/sdgoij/otto/bug_test.go:594 +0x72
testing.tRunner(0x20873a1b0, 0x6277f0)
/usr/local/go/src/pkg/testing/testing.go:422 +0x8b
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:504 +0x8db
goroutine 16 [chan receive]:
testing.RunTests(0x4baf48, 0x6273a0, 0x172, 0x172, 0x1)
/usr/local/go/src/pkg/testing/testing.go:505 +0x923
testing.Main(0x4baf48, 0x6273a0, 0x172, 0x172, 0x6219e0, 0x3, 0x3, 0x621aa0, 0x2, 0x2)
/usr/local/go/src/pkg/testing/testing.go:435 +0x84
main.main()
_/Users/tim/repositories/github.com/sdgoij/otto/_test/_testmain.go:795 +0x9c
goroutine 19 [finalizer wait]:
runtime.park(0x157e0, 0x629838, 0x626809)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x629838, 0x626809)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
exit status 2
FAIL _/Users/tim/repositories/github.com/sdgoij/otto 0.029s
2014-06-28 12:40:49 +02:00
linlexing
5dad38eb5d
Fix string representation of GREATER_OR_EQUAL
...
This fixes #82
2014-06-21 21:54:06 -07:00
Robert Krimen
ed456945de
Improve error reporting (again)
2014-06-21 21:16:58 -07: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
b813fe3676
Fix JSON.stringify treating large integers as float64
...
This fixes #80
2014-06-06 21:08:59 -07:00
Robert Krimen
de36a84a51
Fix cloning of _fnStash
...
This may help #71
2014-06-04 21:53:31 -07:00
Robert Krimen
6c7c425424
Fix toReflectValue to handle Struct, Map, Slice, etc.
...
This fixes #79
2014-06-04 18:08:42 -07:00
Robert Krimen
1a2fa0b815
Fix "Halting Problem" example
...
As discussed in #71 , the original example contains a race condition that could cause the goroutine to block forever.
2014-05-31 13:38:11 -07:00
Robert Krimen
f09ce5eac2
Add mutex locking for .Copy()
2014-05-30 20:27:30 -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
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
526d3b2fd5
Minor cloning adjustments
...
Mostly cosmetic.
2014-05-27 22:09:57 -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
b7dd9df181
Fix array-like handling in JSON.stringify
...
This fixes #73
2014-05-24 10:05:10 -07:00
Robert Krimen
ba678bc782
Use _runtime.toValue() instead of func toValue()
...
This fixes #72
2014-05-22 20:39:27 -07:00
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
6d506b4b2f
Update documention to mention natto
2014-04-26 22:49:27 -07:00
Robert Krimen
058fe32c29
terst
2014-04-26 22:19:01 -07:00
Robert Krimen
70f432f8d5
terst
2014-04-26 11:52:14 -07:00
Robert Krimen
a15d66ea64
Fix missing interrupt
2014-04-25 23:04:44 -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
8aca2c886a
Disable script marshalling/unmarshalling for now
2014-04-15 18:34:24 -07:00
Robert Krimen
142951ac5a
Add Script marshalling/unmarshalling
2014-04-13 19:47:23 -07:00
Robert Krimen
9561f66959
Tighten test comparisons instead of squashing everything to a string
2014-04-13 18:09:46 -07:00
Robert Krimen
7721396b67
Fix Date tests to always mock UTC
2014-04-13 15:07:29 -07:00
Robert Krimen
ddca88af9b
Add compilation (Script, vm.Compile, etc.)
2014-04-13 15:04:32 -07:00
Robert Krimen
7163cd7841
Skip unexported fields, begin json.Marshaler support
...
* The "reflect" package is willing to expose unexported fields in structs (a little suprising).
* Skip unexported fields when enumerating or trying to access (pretend they don't exist).
* Allow structs that implement json.Marshaler to work as expected in a JSON.stringify call.
If we let the runtime try to access unexported fields, it'll cause a panic.
This fixes #64
2014-04-12 11:53:04 -07:00