From e3018f09db408131cdb41940fb93d654d92ef561 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Feb 2022 10:26:59 +0100 Subject: [PATCH 1/6] add function type --- libs/remix-debug/src/solidity-decoder/decodeInfo.ts | 8 +++++++- .../src/solidity-decoder/types/FunctionType.ts | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 libs/remix-debug/src/solidity-decoder/types/FunctionType.ts diff --git a/libs/remix-debug/src/solidity-decoder/decodeInfo.ts b/libs/remix-debug/src/solidity-decoder/decodeInfo.ts index 44c620615a..f141a7e1f9 100644 --- a/libs/remix-debug/src/solidity-decoder/decodeInfo.ts +++ b/libs/remix-debug/src/solidity-decoder/decodeInfo.ts @@ -11,6 +11,7 @@ import { Struct as StructType } from './types/Struct' import { Int as IntType } from './types/Int' import { Uint as UintType } from './types/Uint' import { Mapping as MappingType } from './types/Mapping' +import { FunctionType } from './types/FunctionType' import { extractLocation, removeLocation } from './types/util' /** @@ -78,6 +79,10 @@ function bool (type) { return new BoolType() } +function functionType (type, stateDefinitions, contractName, location) { + return new FunctionType(type, stateDefinitions, contractName, location) +} + /** * DynamicByteArray decode the given @arg type * @@ -300,7 +305,8 @@ function parseType (type, stateDefinitions, contractName, location) { struct: struct, int: int, uint: uint, - mapping: mapping + mapping: mapping, + function: functionType } const currentType = typeClass(type) if (currentType === null) { diff --git a/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts b/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts new file mode 100644 index 0000000000..765edcf980 --- /dev/null +++ b/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts @@ -0,0 +1,12 @@ +'use strict' +import { ValueType } from './ValueType' + +export class FunctionType extends ValueType { + constructor (type, stateDefinitions, contractName, location) { + super(1, 8, 'function') + } + + decodeValue (value) { + return value + } +} From 3f986ed7455cdb1b782bd6c46e021ef322f4077e Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Feb 2022 11:25:22 +0100 Subject: [PATCH 2/6] do not trigger step changed --- libs/remix-debug/src/debugger/stepManager.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/remix-debug/src/debugger/stepManager.ts b/libs/remix-debug/src/debugger/stepManager.ts index 6fd2e5fa22..07693ca62f 100644 --- a/libs/remix-debug/src/debugger/stepManager.ts +++ b/libs/remix-debug/src/debugger/stepManager.ts @@ -121,6 +121,7 @@ export class DebuggerStepManager { if (solidityMode) { step = this.resolveToReducedTrace(step, -1) } + if (this.currentStepIndex === step) return this.currentStepIndex = step this.triggerStepChanged(step) } @@ -136,6 +137,7 @@ export class DebuggerStepManager { if (solidityMode) { step = this.resolveToReducedTrace(step, 1) } + if (this.currentStepIndex === step) return this.currentStepIndex = step this.triggerStepChanged(step) } @@ -146,12 +148,14 @@ export class DebuggerStepManager { if (solidityMode) { step = this.resolveToReducedTrace(step, 0) } + if (this.currentStepIndex === step) return this.currentStepIndex = step this.triggerStepChanged(step) } jumpTo (step) { if (!this.traceManager.inRange(step)) return + if (this.currentStepIndex === step) return this.currentStepIndex = step this.triggerStepChanged(step) } From e17e25367131f915202844dc4ebf5864ef69b295 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Feb 2022 11:25:48 +0100 Subject: [PATCH 3/6] use onMouseUp --- .../debugger-ui/src/lib/slider/slider.tsx | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx index 06fe05e949..89a09ce80e 100644 --- a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx @@ -1,35 +1,28 @@ import React, { useState, useEffect, useRef } from 'react' // eslint-disable-line export const Slider = ({ jumpTo, sliderValue, traceLength }) => { - const [state, setState] = useState({ - currentValue: 0 - }) - const onChangeId = useRef(null) + const slider = useRef(null) useEffect(() => { setValue(sliderValue) }, [sliderValue]) const setValue = (value) => { - if (value === state.currentValue) return - setState(prevState => { - return { ...prevState, currentValue: value } - }) - jumpTo && jumpTo(value) - } - - const handleChange = (e) => { + if (value === slider.current.value) return + slider.current.value = value if (onChangeId.current) { - window.clearTimeout(onChangeId.current) + clearTimeout(onChangeId.current) } ((value) => { onChangeId.current = setTimeout(() => { - console.log(value) - value = parseInt(value) - setValue(value) + jumpTo && jumpTo(value) }, 100) - })(e.target.value) + })(value) + } + + const handleChange = (e) => { + setValue(parseInt(e.target.value)) } return ( @@ -37,11 +30,11 @@ export const Slider = ({ jumpTo, sliderValue, traceLength }) => { From 0c9f56a17bf202abbdf1c89bae4c5f8bdd489cb8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Feb 2022 11:26:18 +0100 Subject: [PATCH 4/6] update label for function type --- libs/remix-debug/src/solidity-decoder/types/FunctionType.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts b/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts index 765edcf980..ffa4b9f1c6 100644 --- a/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/FunctionType.ts @@ -7,6 +7,6 @@ export class FunctionType extends ValueType { } decodeValue (value) { - return value + return 'at program counter ' + value } } From 74c127ae08e9caf01f5cf5862b8aeb0c5317e82a Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Feb 2022 12:34:18 +0100 Subject: [PATCH 5/6] fix e2e --- apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts | 5 ++++- libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts b/apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts index 56616f1ac9..5a3ae6ae82 100644 --- a/apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts +++ b/apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts @@ -12,7 +12,10 @@ class GoToVmTraceStep extends EventEmitter { function goToVMtraceStep (browser: NightwatchBrowser, step: number, incr: number, done: VoidFunction) { browser.execute(function (step) { (document.getElementById('slider') as HTMLInputElement).value = (step - 1).toString() }, [step]) .setValue('*[data-id="slider"]', new Array(1).fill(browser.Keys.RIGHT_ARROW)) - .pause(1000) + .execute((step) => { + (document.querySelector('*[data-id="slider"]') as any).internal_onmouseup({ target: { value: step }}) + }, [step]) + .pause(10000) .perform(() => { done() }) diff --git a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx index 89a09ce80e..2d4c374770 100644 --- a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx @@ -25,6 +25,8 @@ export const Slider = ({ jumpTo, sliderValue, traceLength }) => { setValue(parseInt(e.target.value)) } + if (slider.current) slider.current.internal_onmouseup = handleChange + return (
Date: Mon, 28 Feb 2022 14:49:20 +0100 Subject: [PATCH 6/6] switch file only if necessary --- apps/remix-ide/src/app/files/fileManager.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 9c11b5863d..2ad2ea4aa9 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -608,9 +608,10 @@ class FileManager extends Plugin { this.events.emit('noFileSelected') } else { file = this.normalize(file) - await this.saveCurrentFile() const resolved = this.getPathFromUrl(file) file = resolved.file + await this.saveCurrentFile() + if (this.currentFile() === file) return const provider = resolved.provider this._deps.config.set('currentFile', file) this.openedFiles[file] = file