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
086acd12
Commit
086acd12
authored
Apr 12, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added pre processing of script data
parent
11651615
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
closure.go
ethchain/closure.go
+1
-1
vm.go
ethchain/vm.go
+3
-2
parsing.go
ethutil/parsing.go
+31
-0
No files found.
ethchain/closure.go
View file @
086acd12
...
@@ -69,7 +69,7 @@ func (c *Closure) Address() []byte {
...
@@ -69,7 +69,7 @@ func (c *Closure) Address() []byte {
return
c
.
object
.
Address
()
return
c
.
object
.
Address
()
}
}
type
DebugHook
func
(
op
OpCode
,
mem
*
Memory
,
stack
*
Stack
)
type
DebugHook
func
(
step
int
,
op
OpCode
,
mem
*
Memory
,
stack
*
Stack
)
func
(
c
*
Closure
)
Call
(
vm
*
Vm
,
args
[]
byte
,
hook
DebugHook
)
[]
byte
{
func
(
c
*
Closure
)
Call
(
vm
*
Vm
,
args
[]
byte
,
hook
DebugHook
)
[]
byte
{
c
.
Args
=
args
c
.
Args
=
args
...
...
ethchain/vm.go
View file @
086acd12
...
@@ -312,6 +312,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
...
@@ -312,6 +312,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
stack
.
Push
(
val
)
stack
.
Push
(
val
)
pc
.
Add
(
pc
,
big
.
NewInt
(
31
))
pc
.
Add
(
pc
,
big
.
NewInt
(
31
))
step
++
case
oPUSH20
:
case
oPUSH20
:
pc
.
Add
(
pc
,
ethutil
.
Big1
)
pc
.
Add
(
pc
,
ethutil
.
Big1
)
data
:=
closure
.
Gets
(
pc
,
big
.
NewInt
(
20
))
data
:=
closure
.
Gets
(
pc
,
big
.
NewInt
(
20
))
...
@@ -321,7 +322,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
...
@@ -321,7 +322,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
stack
.
Push
(
val
)
stack
.
Push
(
val
)
pc
.
Add
(
pc
,
big
.
NewInt
(
19
))
pc
.
Add
(
pc
,
big
.
NewInt
(
19
))
step
++
case
oPOP
:
case
oPOP
:
stack
.
Pop
()
stack
.
Pop
()
case
oDUP
:
case
oDUP
:
...
@@ -410,7 +411,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
...
@@ -410,7 +411,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) []byte {
pc
.
Add
(
pc
,
ethutil
.
Big1
)
pc
.
Add
(
pc
,
ethutil
.
Big1
)
if
hook
!=
nil
{
if
hook
!=
nil
{
hook
(
op
,
mem
,
stack
)
hook
(
step
-
1
,
op
,
mem
,
stack
)
}
}
}
}
}
}
...
...
ethutil/parsing.go
View file @
086acd12
...
@@ -3,6 +3,7 @@ package ethutil
...
@@ -3,6 +3,7 @@ package ethutil
import
(
import
(
_
"fmt"
_
"fmt"
"math/big"
"math/big"
"regexp"
)
)
// Op codes
// Op codes
...
@@ -132,3 +133,33 @@ func Assemble(instructions ...interface{}) (script []byte) {
...
@@ -132,3 +133,33 @@ func Assemble(instructions ...interface{}) (script []byte) {
return
return
}
}
/*
Prepocessing function that takes init and main apart:
init() {
// something
}
main() {
// main something
}
*/
func
PreProcess
(
data
string
)
(
mainInput
,
initInput
string
)
{
reg
:=
"
\\
(
\\
)
\\
s*{([
\\
d
\\
w
\\
W
\\
n
\\
s]+?)}"
mainReg
:=
regexp
.
MustCompile
(
"main"
+
reg
)
initReg
:=
regexp
.
MustCompile
(
"init"
+
reg
)
main
:=
mainReg
.
FindStringSubmatch
(
data
)
if
len
(
main
)
>
0
{
mainInput
=
main
[
1
]
}
else
{
mainInput
=
data
}
init
:=
initReg
.
FindStringSubmatch
(
data
)
if
len
(
init
)
>
0
{
initInput
=
init
[
1
]
}
return
}
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