aboutsummaryrefslogtreecommitdiffstats
path: root/jsre
diff options
context:
space:
mode:
authorDaniel A. Nagy <nagy.da@gmail.com>2015-05-08 23:55:53 +0800
committerDaniel A. Nagy <nagy.da@gmail.com>2015-05-08 23:55:53 +0800
commit62dd9833ec768e2026bccb1cf7a8ef4263b9286d (patch)
tree0a091d99afd7f8cf5e3a6d4522c30ceef8559a55 /jsre
parent3a01e3e39b9ce83ecb7444319407ee8bb00e3bf6 (diff)
parentc8fc4cebe63073fd77d5f553a4f0cec36a4ccb4b (diff)
downloadgo-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.tar
go-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.tar.gz
go-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.tar.bz2
go-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.tar.lz
go-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.tar.xz
go-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.tar.zst
go-tangerine-62dd9833ec768e2026bccb1cf7a8ef4263b9286d.zip
Merge branch 'develop' of github.com:ethereum/go-ethereum into develop
Diffstat (limited to 'jsre')
-rw-r--r--jsre/jsre.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/jsre/jsre.go b/jsre/jsre.go
index 6a7cb1b83..a6dd117a3 100644
--- a/jsre/jsre.go
+++ b/jsre/jsre.go
@@ -286,7 +286,7 @@ func (self *JSRE) loadScript(call otto.FunctionCall) otto.Value {
// uses the "prettyPrint" JS function to format a value
func (self *JSRE) PrettyPrint(v interface{}) (val otto.Value, err error) {
var method otto.Value
- v, err = self.vm.ToValue(v)
+ v, err = self.ToValue(v)
if err != nil {
return
}
@@ -297,8 +297,23 @@ func (self *JSRE) PrettyPrint(v interface{}) (val otto.Value, err error) {
return method.Call(method, v)
}
-// creates an otto value from a go type
+// creates an otto value from a go type (serialized version)
+func (self *JSRE) ToValue(v interface{}) (otto.Value, error) {
+ done := make(chan bool)
+ req := &evalReq{
+ fn: func(res *evalResult) {
+ res.result, res.err = self.vm.ToValue(v)
+ },
+ done: done,
+ }
+ self.evalQueue <- req
+ <-done
+ return req.res.result, req.res.err
+}
+
+// creates an otto value from a go type (non-serialized version)
func (self *JSRE) ToVal(v interface{}) otto.Value {
+
result, err := self.vm.ToValue(v)
if err != nil {
fmt.Println("Value unknown:", err)