Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
5542b51b
Commit
5542b51b
authored
Feb 20, 2016
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jsre: expose Do
parent
b34b130f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
completion.go
jsre/completion.go
+3
-1
jsre.go
jsre/jsre.go
+8
-8
No files found.
jsre/completion.go
View file @
5542b51b
...
@@ -27,7 +27,9 @@ import (
...
@@ -27,7 +27,9 @@ import (
// evaluated, callers need to make sure that evaluating line does not have side effects.
// evaluated, callers need to make sure that evaluating line does not have side effects.
func
(
jsre
*
JSRE
)
CompleteKeywords
(
line
string
)
[]
string
{
func
(
jsre
*
JSRE
)
CompleteKeywords
(
line
string
)
[]
string
{
var
results
[]
string
var
results
[]
string
jsre
.
do
(
func
(
vm
*
otto
.
Otto
)
{
results
=
getCompletions
(
vm
,
line
)
})
jsre
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
results
=
getCompletions
(
vm
,
line
)
})
return
results
return
results
}
}
...
...
jsre/jsre.go
View file @
5542b51b
...
@@ -214,8 +214,8 @@ loop:
...
@@ -214,8 +214,8 @@ loop:
self
.
loopWg
.
Done
()
self
.
loopWg
.
Done
()
}
}
//
do schedules the given function on the
event loop.
//
Do executes the given function on the JS
event loop.
func
(
self
*
JSRE
)
d
o
(
fn
func
(
*
otto
.
Otto
))
{
func
(
self
*
JSRE
)
D
o
(
fn
func
(
*
otto
.
Otto
))
{
done
:=
make
(
chan
bool
)
done
:=
make
(
chan
bool
)
req
:=
&
evalReq
{
fn
,
done
}
req
:=
&
evalReq
{
fn
,
done
}
self
.
evalQueue
<-
req
self
.
evalQueue
<-
req
...
@@ -235,7 +235,7 @@ func (self *JSRE) Exec(file string) error {
...
@@ -235,7 +235,7 @@ func (self *JSRE) Exec(file string) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
self
.
d
o
(
func
(
vm
*
otto
.
Otto
)
{
_
,
err
=
vm
.
Run
(
code
)
})
self
.
D
o
(
func
(
vm
*
otto
.
Otto
)
{
_
,
err
=
vm
.
Run
(
code
)
})
return
err
return
err
}
}
...
@@ -247,19 +247,19 @@ func (self *JSRE) Bind(name string, v interface{}) error {
...
@@ -247,19 +247,19 @@ func (self *JSRE) Bind(name string, v interface{}) error {
// Run runs a piece of JS code.
// Run runs a piece of JS code.
func
(
self
*
JSRE
)
Run
(
code
string
)
(
v
otto
.
Value
,
err
error
)
{
func
(
self
*
JSRE
)
Run
(
code
string
)
(
v
otto
.
Value
,
err
error
)
{
self
.
d
o
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Run
(
code
)
})
self
.
D
o
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Run
(
code
)
})
return
v
,
err
return
v
,
err
}
}
// Get returns the value of a variable in the JS environment.
// Get returns the value of a variable in the JS environment.
func
(
self
*
JSRE
)
Get
(
ns
string
)
(
v
otto
.
Value
,
err
error
)
{
func
(
self
*
JSRE
)
Get
(
ns
string
)
(
v
otto
.
Value
,
err
error
)
{
self
.
d
o
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Get
(
ns
)
})
self
.
D
o
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Get
(
ns
)
})
return
v
,
err
return
v
,
err
}
}
// Set assigns value v to a variable in the JS environment.
// Set assigns value v to a variable in the JS environment.
func
(
self
*
JSRE
)
Set
(
ns
string
,
v
interface
{})
(
err
error
)
{
func
(
self
*
JSRE
)
Set
(
ns
string
,
v
interface
{})
(
err
error
)
{
self
.
d
o
(
func
(
vm
*
otto
.
Otto
)
{
err
=
vm
.
Set
(
ns
,
v
)
})
self
.
D
o
(
func
(
vm
*
otto
.
Otto
)
{
err
=
vm
.
Set
(
ns
,
v
)
})
return
err
return
err
}
}
...
@@ -288,7 +288,7 @@ func (self *JSRE) loadScript(call otto.FunctionCall) otto.Value {
...
@@ -288,7 +288,7 @@ func (self *JSRE) loadScript(call otto.FunctionCall) otto.Value {
// EvalAndPrettyPrint evaluates code and pretty prints the result to
// EvalAndPrettyPrint evaluates code and pretty prints the result to
// standard output.
// standard output.
func
(
self
*
JSRE
)
EvalAndPrettyPrint
(
code
string
)
(
err
error
)
{
func
(
self
*
JSRE
)
EvalAndPrettyPrint
(
code
string
)
(
err
error
)
{
self
.
d
o
(
func
(
vm
*
otto
.
Otto
)
{
self
.
D
o
(
func
(
vm
*
otto
.
Otto
)
{
var
val
otto
.
Value
var
val
otto
.
Value
val
,
err
=
vm
.
Run
(
code
)
val
,
err
=
vm
.
Run
(
code
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -302,7 +302,7 @@ func (self *JSRE) EvalAndPrettyPrint(code string) (err error) {
...
@@ -302,7 +302,7 @@ func (self *JSRE) EvalAndPrettyPrint(code string) (err error) {
// Compile compiles and then runs a piece of JS code.
// Compile compiles and then runs a piece of JS code.
func
(
self
*
JSRE
)
Compile
(
filename
string
,
src
interface
{})
(
err
error
)
{
func
(
self
*
JSRE
)
Compile
(
filename
string
,
src
interface
{})
(
err
error
)
{
self
.
d
o
(
func
(
vm
*
otto
.
Otto
)
{
_
,
err
=
compileAndRun
(
vm
,
filename
,
src
)
})
self
.
D
o
(
func
(
vm
*
otto
.
Otto
)
{
_
,
err
=
compileAndRun
(
vm
,
filename
,
src
)
})
return
err
return
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment