highlight the last 5 items instead of only one

pull/1385/head^2
yann300 3 years ago
parent fbf73b42ec
commit db52833967
  1. 8
      libs/remix-debug/src/code/codeManager.ts
  2. 4
      libs/remix-debug/src/debugger/VmDebugger.ts
  3. 23
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx
  4. 8
      libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts

@ -147,13 +147,17 @@ export class CodeManager {
private async retrieveIndexAndTrigger (codeMananger, address, step, code) { private async retrieveIndexAndTrigger (codeMananger, address, step, code) {
let result let result
let next const next = []
const returnInstructionIndexes = [] const returnInstructionIndexes = []
const outOfGasInstructionIndexes = [] const outOfGasInstructionIndexes = []
try { try {
result = codeMananger.getInstructionIndex(address, step) result = codeMananger.getInstructionIndex(address, step)
next = codeMananger.getInstructionIndex(address, step + 1) for (let i = 1; i < 6; i++) {
if (this.traceManager.inRange(step + i)) {
next.push(codeMananger.getInstructionIndex(address, step + i))
}
}
let values = this.traceManager.getAllStopIndexes() let values = this.traceManager.getAllStopIndexes()
if (values) { if (values) {

@ -59,8 +59,8 @@ export class VmDebuggerLogic {
} }
listenToCodeManagerEvents () { listenToCodeManagerEvents () {
this._codeManager.event.register('changed', (code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes) => { this._codeManager.event.register('changed', (code, address, index, nextIndexes, returnInstructionIndexes, outOfGasInstructionIndexes) => {
this.event.trigger('codeManagerChanged', [code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes]) this.event.trigger('codeManagerChanged', [code, address, index, nextIndexes, returnInstructionIndexes, outOfGasInstructionIndexes])
}) })
} }

@ -6,15 +6,15 @@ export const AssemblyItems = ({ registerEvent }) => {
const [assemblyItems, dispatch] = useReducer(reducer, initialState) const [assemblyItems, dispatch] = useReducer(reducer, initialState)
const [absoluteSelectedIndex, setAbsoluteSelectedIndex] = useState(0) const [absoluteSelectedIndex, setAbsoluteSelectedIndex] = useState(0)
const [selectedItem, setSelectedItem] = useState(0) const [selectedItem, setSelectedItem] = useState(0)
const [nextSelectedItem, setNextSelectedItem] = useState(1) const [nextSelectedItems, setNextSelectedItems] = useState([1])
const [returnInstructionIndexes, setReturnInstructionIndexes] = useState([]) const [returnInstructionIndexes, setReturnInstructionIndexes] = useState([])
const [outOfGasInstructionIndexes, setOutOfGasInstructionIndexes] = useState([]) const [outOfGasInstructionIndexes, setOutOfGasInstructionIndexes] = useState([])
const refs = useRef({}) const refs = useRef({})
const asmItemsRef = useRef(null) const asmItemsRef = useRef(null)
useEffect(() => { useEffect(() => {
registerEvent && registerEvent('codeManagerChanged', (code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes) => { registerEvent && registerEvent('codeManagerChanged', (code, address, index, nextIndexes, returnInstructionIndexes, outOfGasInstructionIndexes) => {
dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes } }) dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index, nextIndexes, returnInstructionIndexes, outOfGasInstructionIndexes } })
}) })
}, []) }, [])
@ -22,7 +22,7 @@ export const AssemblyItems = ({ registerEvent }) => {
if (absoluteSelectedIndex !== assemblyItems.index) { if (absoluteSelectedIndex !== assemblyItems.index) {
clearItems() clearItems()
indexChanged(assemblyItems.index) indexChanged(assemblyItems.index)
nextIndexChanged(assemblyItems.nextIndex) nextIndexesChanged(assemblyItems.nextIndexes)
returnIndexes(assemblyItems.returnInstructionIndexes) returnIndexes(assemblyItems.returnInstructionIndexes)
outOfGasIndexes(assemblyItems.outOfGasInstructionIndexes) outOfGasIndexes(assemblyItems.outOfGasInstructionIndexes)
} }
@ -40,7 +40,11 @@ export const AssemblyItems = ({ registerEvent }) => {
const clearItems = () => { const clearItems = () => {
clearItem(refs.current[selectedItem] ? refs.current[selectedItem] : null) clearItem(refs.current[selectedItem] ? refs.current[selectedItem] : null)
clearItem(refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null) if (nextSelectedItems) {
nextSelectedItems.map((index) => {
clearItem(refs.current[index] ? refs.current[index] : null)
})
}
returnInstructionIndexes.map((index) => { returnInstructionIndexes.map((index) => {
if (index < 0) return if (index < 0) return
@ -70,18 +74,19 @@ export const AssemblyItems = ({ registerEvent }) => {
setAbsoluteSelectedIndex(assemblyItems.opCodes.index) setAbsoluteSelectedIndex(assemblyItems.opCodes.index)
} }
const nextIndexChanged = (index: number) => { const nextIndexesChanged = (indexes: Array<number>) => {
indexes.map((index) => {
if (index < 0) return if (index < 0) return
const codeView = asmItemsRef.current const codeView = asmItemsRef.current
const currentItem = codeView.children[index] const currentItem = codeView.children[index]
if (currentItem) { if (currentItem) {
currentItem.style.setProperty('border-color', 'var(--secondary)') currentItem.style.setProperty('color', 'var(--primary)')
currentItem.style.setProperty('border-style', 'dotted')
currentItem.setAttribute('selected', 'selected') currentItem.setAttribute('selected', 'selected')
} }
setNextSelectedItem(index) })
setNextSelectedItems(indexes)
} }
const returnIndexes = (indexes) => { const returnIndexes = (indexes) => {

@ -13,7 +13,7 @@ export const initialState = {
}, },
display: [], display: [],
index: 0, index: 0,
nextIndex: -1, nextIndexes: [-1],
returnInstructionIndexes: [], returnInstructionIndexes: [],
outOfGasInstructionIndexes: [], outOfGasInstructionIndexes: [],
top: 0, top: 0,
@ -30,7 +30,7 @@ const reducedOpcode = (opCodes, payload) => {
const top = bottom + length const top = bottom + length
return { return {
index: opCodes.index - bottom, index: opCodes.index - bottom,
nextIndex: opCodes.nextIndex - bottom, nextIndexes: opCodes.nextIndexes.map(index => index - bottom),
display: opCodes.code.slice(bottom, top), display: opCodes.code.slice(bottom, top),
returnInstructionIndexes: payload.returnInstructionIndexes.map((index) => index.instructionIndex - bottom), returnInstructionIndexes: payload.returnInstructionIndexes.map((index) => index.instructionIndex - bottom),
outOfGasInstructionIndexes: payload.outOfGasInstructionIndexes.map((index) => index.instructionIndex - bottom) outOfGasInstructionIndexes: payload.outOfGasInstructionIndexes.map((index) => index.instructionIndex - bottom)
@ -49,7 +49,7 @@ 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, nextIndex: action.payload.nextIndex ...state.opCodes, index: action.payload.index, nextIndexes: action.payload.nextIndexes
} : 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, action.payload) const reduced = reducedOpcode(opCodes, action.payload)
@ -57,7 +57,7 @@ export const reducer = (state = initialState, action: Action) => {
opCodes, opCodes,
display: reduced.display, display: reduced.display,
index: reduced.index, index: reduced.index,
nextIndex: reduced.nextIndex, nextIndexes: reduced.nextIndexes,
isRequesting: false, isRequesting: false,
isSuccessful: true, isSuccessful: true,
hasError: null, hasError: null,

Loading…
Cancel
Save