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
cd997ee6
Commit
cd997ee6
authored
Jun 23, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
highlight the next opcode to be executed
parent
d5d79381
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
14 deletions
+60
-14
codeManager.ts
libs/remix-debug/src/code/codeManager.ts
+3
-1
VmDebugger.ts
libs/remix-debug/src/debugger/VmDebugger.ts
+2
-2
assembly-items.tsx
...mix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx
+45
-7
assembly-items.ts
libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts
+10
-4
No files found.
libs/remix-debug/src/code/codeManager.ts
View file @
cd997ee6
...
@@ -147,13 +147,15 @@ export class CodeManager {
...
@@ -147,13 +147,15 @@ export class CodeManager {
private
retrieveIndexAndTrigger
(
codeMananger
,
address
,
step
,
code
)
{
private
retrieveIndexAndTrigger
(
codeMananger
,
address
,
step
,
code
)
{
let
result
let
result
let
next
try
{
try
{
result
=
codeMananger
.
getInstructionIndex
(
address
,
step
)
result
=
codeMananger
.
getInstructionIndex
(
address
,
step
)
next
=
codeMananger
.
getInstructionIndex
(
address
,
step
+
1
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
console
.
log
(
error
)
return
console
.
log
(
error
)
}
}
try
{
try
{
codeMananger
.
event
.
trigger
(
'changed'
,
[
code
,
address
,
result
])
codeMananger
.
event
.
trigger
(
'changed'
,
[
code
,
address
,
result
,
next
])
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'dispatching event failed'
,
e
)
console
.
log
(
'dispatching event failed'
,
e
)
}
}
...
...
libs/remix-debug/src/debugger/VmDebugger.ts
View file @
cd997ee6
...
@@ -59,8 +59,8 @@ export class VmDebuggerLogic {
...
@@ -59,8 +59,8 @@ export class VmDebuggerLogic {
}
}
listenToCodeManagerEvents
()
{
listenToCodeManagerEvents
()
{
this
.
_codeManager
.
event
.
register
(
'changed'
,
(
code
,
address
,
index
)
=>
{
this
.
_codeManager
.
event
.
register
(
'changed'
,
(
code
,
address
,
index
,
nextIndex
)
=>
{
this
.
event
.
trigger
(
'codeManagerChanged'
,
[
code
,
address
,
index
])
this
.
event
.
trigger
(
'codeManagerChanged'
,
[
code
,
address
,
index
,
nextIndex
])
})
})
}
}
...
...
libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx
View file @
cd997ee6
...
@@ -4,24 +4,28 @@ import './styles/assembly-items.css'
...
@@ -4,24 +4,28 @@ import './styles/assembly-items.css'
export
const
AssemblyItems
=
({
registerEvent
})
=>
{
export
const
AssemblyItems
=
({
registerEvent
})
=>
{
const
[
assemblyItems
,
dispatch
]
=
useReducer
(
reducer
,
initialState
)
const
[
assemblyItems
,
dispatch
]
=
useReducer
(
reducer
,
initialState
)
const
[
absoluteSelectedIndex
,
setAbsoluteSelectedIndex
]
=
useState
(
0
)
const
[
selectedItem
,
setSelectedItem
]
=
useState
(
0
)
const
[
selectedItem
,
setSelectedItem
]
=
useState
(
0
)
const
[
nextSelectedItem
,
setNextSelectedItem
]
=
useState
(
1
)
const
refs
=
useRef
({})
const
refs
=
useRef
({})
const
asmItemsRef
=
useRef
(
null
)
const
asmItemsRef
=
useRef
(
null
)
useEffect
(()
=>
{
useEffect
(()
=>
{
registerEvent
&&
registerEvent
(
'codeManagerChanged'
,
(
code
,
address
,
index
)
=>
{
registerEvent
&&
registerEvent
(
'codeManagerChanged'
,
(
code
,
address
,
index
,
nextIndex
)
=>
{
dispatch
({
type
:
'FETCH_OPCODES_SUCCESS'
,
payload
:
{
code
,
address
,
index
}
})
dispatch
({
type
:
'FETCH_OPCODES_SUCCESS'
,
payload
:
{
code
,
address
,
index
,
nextIndex
}
})
})
})
},
[])
},
[])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
selectedItem
!==
assemblyItems
.
index
)
{
console
.
log
(
'useEffect'
,
assemblyItems
.
index
)
if
(
absoluteSelectedIndex
!==
assemblyItems
.
index
)
{
clearItems
()
indexChanged
(
assemblyItems
.
index
)
indexChanged
(
assemblyItems
.
index
)
nextIndexChanged
(
assemblyItems
.
nextIndex
)
}
}
},
[
assemblyItems
.
index
])
},
[
assemblyItems
.
opCodes
.
index
])
const
indexChanged
=
(
index
:
number
)
=>
{
const
clearItems
=
()
=>
{
if
(
index
<
0
)
return
let
currentItem
=
refs
.
current
[
selectedItem
]
?
refs
.
current
[
selectedItem
]
:
null
let
currentItem
=
refs
.
current
[
selectedItem
]
?
refs
.
current
[
selectedItem
]
:
null
if
(
currentItem
)
{
if
(
currentItem
)
{
...
@@ -30,15 +34,49 @@ export const AssemblyItems = ({ registerEvent }) => {
...
@@ -30,15 +34,49 @@ export const AssemblyItems = ({ registerEvent }) => {
if
(
currentItem
.
firstChild
)
{
if
(
currentItem
.
firstChild
)
{
currentItem
.
firstChild
.
removeAttribute
(
'style'
)
currentItem
.
firstChild
.
removeAttribute
(
'style'
)
}
}
}
currentItem
=
refs
.
current
[
nextSelectedItem
]
?
refs
.
current
[
nextSelectedItem
]
:
null
if
(
currentItem
)
{
currentItem
.
removeAttribute
(
'selected'
)
currentItem
.
removeAttribute
(
'style'
)
if
(
currentItem
.
firstChild
)
{
currentItem
.
firstChild
.
removeAttribute
(
'style'
)
}
}
}
const
indexChanged
=
(
index
:
number
)
=>
{
console
.
log
(
"index "
+
index
)
if
(
index
<
0
)
return
const
codeView
=
asmItemsRef
.
current
const
codeView
=
asmItemsRef
.
current
currentItem
=
codeView
.
children
[
index
]
const
currentItem
=
codeView
.
children
[
index
]
if
(
currentItem
)
{
currentItem
.
style
.
setProperty
(
'border-color'
,
'var(--primary)'
)
currentItem
.
style
.
setProperty
(
'border-color'
,
'var(--primary)'
)
currentItem
.
style
.
setProperty
(
'border-style'
,
'solid'
)
currentItem
.
style
.
setProperty
(
'border-style'
,
'solid'
)
currentItem
.
setAttribute
(
'selected'
,
'selected'
)
currentItem
.
setAttribute
(
'selected'
,
'selected'
)
codeView
.
scrollTop
=
currentItem
.
offsetTop
-
parseInt
(
codeView
.
offsetTop
)
codeView
.
scrollTop
=
currentItem
.
offsetTop
-
parseInt
(
codeView
.
offsetTop
)
}
setSelectedItem
(
index
)
setSelectedItem
(
index
)
setAbsoluteSelectedIndex
(
assemblyItems
.
opCodes
.
index
)
}
const
nextIndexChanged
=
(
index
:
number
)
=>
{
if
(
index
<
0
)
return
const
codeView
=
asmItemsRef
.
current
const
currentItem
=
codeView
.
children
[
index
]
if
(
currentItem
)
{
currentItem
.
style
.
setProperty
(
'border-color'
,
'var(--secondary)'
)
currentItem
.
style
.
setProperty
(
'border-style'
,
'dotted'
)
currentItem
.
setAttribute
(
'selected'
,
'selected'
)
}
}
setNextSelectedItem
(
index
)
}
}
return
(
return
(
...
...
libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts
View file @
cd997ee6
...
@@ -13,6 +13,7 @@ export const initialState = {
...
@@ -13,6 +13,7 @@ export const initialState = {
},
},
display
:
[],
display
:
[],
index
:
0
,
index
:
0
,
nextIndex
:
-
1
,
top
:
0
,
top
:
0
,
bottom
:
0
,
bottom
:
0
,
isRequesting
:
false
,
isRequesting
:
false
,
...
@@ -21,11 +22,15 @@ export const initialState = {
...
@@ -21,11 +22,15 @@ export const initialState = {
}
}
const
reducedOpcode
=
(
opCodes
)
=>
{
const
reducedOpcode
=
(
opCodes
)
=>
{
const
length
=
5
0
const
length
=
10
0
let
bottom
=
opCodes
.
index
-
10
let
bottom
=
opCodes
.
index
-
10
bottom
=
bottom
<
0
?
0
:
bottom
bottom
=
bottom
<
0
?
0
:
bottom
const
top
=
bottom
+
length
const
top
=
bottom
+
length
return
{
top
,
bottom
,
display
:
opCodes
.
code
.
slice
(
bottom
,
top
)
}
return
{
index
:
opCodes
.
index
-
bottom
,
nextIndex
:
opCodes
.
nextIndex
-
bottom
,
display
:
opCodes
.
code
.
slice
(
bottom
,
top
)
}
}
}
export
const
reducer
=
(
state
=
initialState
,
action
:
Action
)
=>
{
export
const
reducer
=
(
state
=
initialState
,
action
:
Action
)
=>
{
...
@@ -40,14 +45,15 @@ export const reducer = (state = initialState, action: Action) => {
...
@@ -40,14 +45,15 @@ export const reducer = (state = initialState, action: Action) => {
}
}
case
'FETCH_OPCODES_SUCCESS'
:
{
case
'FETCH_OPCODES_SUCCESS'
:
{
const
opCodes
=
action
.
payload
.
address
===
state
.
opCodes
.
address
?
{
const
opCodes
=
action
.
payload
.
address
===
state
.
opCodes
.
address
?
{
...
state
.
opCodes
,
index
:
action
.
payload
.
index
...
state
.
opCodes
,
index
:
action
.
payload
.
index
,
nextIndex
:
action
.
payload
.
nextIndex
}
:
deepEqual
(
action
.
payload
.
code
,
state
.
opCodes
.
code
)
?
state
.
opCodes
:
action
.
payload
}
:
deepEqual
(
action
.
payload
.
code
,
state
.
opCodes
.
code
)
?
state
.
opCodes
:
action
.
payload
const
reduced
=
reducedOpcode
(
opCodes
)
const
reduced
=
reducedOpcode
(
opCodes
)
return
{
return
{
opCodes
,
opCodes
,
display
:
reduced
.
display
,
display
:
reduced
.
display
,
index
:
reduced
.
display
.
findIndex
(
code
=>
code
===
opCodes
.
code
[
opCodes
.
index
]),
index
:
reduced
.
index
,
nextIndex
:
reduced
.
nextIndex
,
isRequesting
:
false
,
isRequesting
:
false
,
isSuccessful
:
true
,
isSuccessful
:
true
,
hasError
:
null
hasError
:
null
...
...
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