aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum/javascript_runtime.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-10 04:24:24 +0800
committerobscuren <geffobscura@gmail.com>2014-06-10 04:24:24 +0800
commitaa8a86f0a61286b3d0709316215ce6e9d3833f25 (patch)
tree97aa0aae649463bf8bc0701555ab8d42f9d5a77c /ethereum/javascript_runtime.go
parent98811f11e5d7ccf6e053b46b9ca2ed897140ce47 (diff)
parentd929c634749c3c2db9f3290e635a763eba211656 (diff)
downloadgo-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.tar
go-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.tar.gz
go-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.tar.bz2
go-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.tar.lz
go-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.tar.xz
go-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.tar.zst
go-tangerine-aa8a86f0a61286b3d0709316215ce6e9d3833f25.zip
Merge branch 'release/poc5-rc12'poc5-rc12
Diffstat (limited to 'ethereum/javascript_runtime.go')
-rw-r--r--ethereum/javascript_runtime.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/ethereum/javascript_runtime.go b/ethereum/javascript_runtime.go
index 93297f604..b05d39232 100644
--- a/ethereum/javascript_runtime.go
+++ b/ethereum/javascript_runtime.go
@@ -10,6 +10,7 @@ import (
"github.com/obscuren/otto"
"io/ioutil"
"os"
+ "path"
"path/filepath"
)
@@ -25,6 +26,20 @@ type JSRE struct {
objectCb map[string][]otto.Value
}
+func (jsre *JSRE) LoadExtFile(path string) {
+ result, err := ioutil.ReadFile(path)
+ if err == nil {
+ jsre.vm.Run(result)
+ } else {
+ ethutil.Config.Log.Debugln("Could not load file:", path)
+ }
+}
+
+func (jsre *JSRE) LoadIntFile(file string) {
+ assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "ethereal", "assets", "ext")
+ jsre.LoadExtFile(path.Join(assetPath, file))
+}
+
func NewJSRE(ethereum *eth.Ethereum) *JSRE {
re := &JSRE{
ethereum,
@@ -39,6 +54,10 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
// Init the JS lib
re.vm.Run(jsLib)
+ // Load extra javascript files
+ re.LoadIntFile("string.js")
+ re.LoadIntFile("big.js")
+
// We have to make sure that, whoever calls this, calls "Stop"
go re.mainLoop()