Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b3016505
Commit
b3016505
authored
May 26, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix parsing codes
parent
cb47ed68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
codeUtils.ts
libs/remix-debug/src/code/codeUtils.ts
+15
-4
No files found.
libs/remix-debug/src/code/codeUtils.ts
View file @
b3016505
'use strict'
'use strict'
import
Common
from
'@ethereumjs/common'
import
Common
from
'@ethereumjs/common'
import
{
getOpcodesForHF
}
from
'@ethereumjs/vm/dist/evm/opcodes'
import
{
getOpcodesForHF
}
from
'@ethereumjs/vm/dist/evm/opcodes'
import
getOpcodes
from
'./opcodes'
export
function
nameOpCodes
(
raw
,
hardfork
)
{
export
function
nameOpCodes
(
raw
,
hardfork
)
{
const
common
=
new
Common
({
chain
:
'mainnet'
,
hardfork
})
const
common
=
new
Common
({
chain
:
'mainnet'
,
hardfork
})
...
@@ -34,6 +35,12 @@ export function nameOpCodes (raw, hardfork) {
...
@@ -34,6 +35,12 @@ export function nameOpCodes (raw, hardfork) {
return
[
code
,
codeMap
]
return
[
code
,
codeMap
]
}
}
type
Opcode
=
{
name
:
String
,
pushData
?:
Array
<
number
>
in
?:
number
out
?:
number
}
/**
/**
* Parses code as a list of integers into a list of objects containing
* Parses code as a list of integers into a list of objects containing
* information about the opcode.
* information about the opcode.
...
@@ -44,15 +51,19 @@ export function parseCode (raw) {
...
@@ -44,15 +51,19 @@ export function parseCode (raw) {
const
code
=
[]
const
code
=
[]
for
(
let
i
=
0
;
i
<
raw
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
raw
.
length
;
i
++
)
{
let
opcode
const
opcode
:
Opcode
=
{
name
:
'INVALID'
}
try
{
try
{
opcode
=
opcodes
.
get
(
raw
[
i
]).
fullName
const
code
=
opcodes
.
get
(
raw
[
i
])
const
opcodeDetails
=
getOpcodes
(
raw
[
i
],
false
)
opcode
.
in
=
opcodeDetails
.
in
opcode
.
out
=
opcodeDetails
.
out
opcode
.
name
=
code
.
fullName
}
catch
(
e
)
{
}
catch
(
e
)
{
opcode
=
'INVALID'
opcode
.
name
=
'INVALID'
}
}
if
(
opcode
.
name
.
slice
(
0
,
4
)
===
'PUSH'
)
{
if
(
opcode
.
name
.
slice
(
0
,
4
)
===
'PUSH'
)
{
const
length
=
raw
[
i
]
-
0x5f
const
length
=
raw
[
i
]
-
0x5f
opcode
[
'pushData'
]
=
raw
.
slice
(
i
+
1
,
i
+
length
+
1
)
opcode
.
pushData
=
raw
.
slice
(
i
+
1
,
i
+
length
+
1
)
// in case pushdata extends beyond code
// in case pushdata extends beyond code
if
(
i
+
1
+
length
>
raw
.
length
)
{
if
(
i
+
1
+
length
>
raw
.
length
)
{
for
(
let
j
=
opcode
[
'pushData'
].
length
;
j
<
length
;
j
++
)
{
for
(
let
j
=
opcode
[
'pushData'
].
length
;
j
<
length
;
j
++
)
{
...
...
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