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
5516efdf
Commit
5516efdf
authored
Apr 27, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed old code
parent
21f8806e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
68 deletions
+0
-68
asm.go
ethchain/asm.go
+0
-68
No files found.
ethchain/asm.go
View file @
5516efdf
...
...
@@ -4,55 +4,8 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethutil"
"math/big"
"regexp"
)
func
CompileInstr
(
s
interface
{})
([]
byte
,
error
)
{
switch
s
.
(
type
)
{
case
string
:
str
:=
s
.
(
string
)
isOp
:=
IsOpCode
(
str
)
if
isOp
{
return
[]
byte
{
OpCodes
[
str
]},
nil
}
num
:=
new
(
big
.
Int
)
_
,
success
:=
num
.
SetString
(
str
,
0
)
// Assume regular bytes during compilation
if
!
success
{
num
.
SetBytes
([]
byte
(
str
))
}
else
{
// tmp fix for 32 bytes
n
:=
ethutil
.
BigToBytes
(
num
,
256
)
return
n
,
nil
}
return
num
.
Bytes
(),
nil
case
int
:
num
:=
ethutil
.
BigToBytes
(
big
.
NewInt
(
int64
(
s
.
(
int
))),
256
)
return
num
,
nil
case
[]
byte
:
return
ethutil
.
BigD
(
s
.
([]
byte
))
.
Bytes
(),
nil
}
return
nil
,
nil
}
// Script compilation functions
// Compiles strings to machine code
func
Assemble
(
instructions
...
interface
{})
(
script
[]
byte
)
{
//script = make([]string, len(instructions))
for
_
,
val
:=
range
instructions
{
instr
,
_
:=
CompileInstr
(
val
)
//script[i] = string(instr)
script
=
append
(
script
,
instr
...
)
}
return
}
func
Disassemble
(
script
[]
byte
)
(
asm
[]
string
)
{
pc
:=
new
(
big
.
Int
)
for
{
...
...
@@ -104,24 +57,3 @@ func Disassemble(script []byte) (asm []string) {
return
}
func
PreProcess
(
data
string
)
(
mainInput
,
initInput
string
)
{
// Regexp for parsing anything between brackets
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