From f18b16c81f07a411914763a60bf8b84c9da518c9 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Fri, 23 Feb 2024 15:28:17 -0500 Subject: [PATCH] Allow multiple backends --- src/components/ExportModal.vue | 6 +- src/components/TabBarItems.vue | 2 +- src/components/console/BitmapTab.vue | 12 +- src/components/console/BreakTab.vue | 13 +- src/components/console/Console.vue | 2 +- src/components/console/RegistersTab.vue | 2 +- src/state/console-data.ts | 16 +- src/state/state.ts | 3 +- src/utils/debug.ts | 19 +- src/utils/events.ts | 8 +- src/utils/mips.ts | 464 ------------------------ src/utils/mips/mips.ts | 281 ++++++++++++++ src/utils/mips/tauri-backend.ts | 263 ++++++++++++++ src/utils/mips/wasm-backend.ts | 48 +++ src/utils/mips/wasm-worker.ts | 1 + src/utils/query/serialize-files.ts | 2 +- src/utils/settings.ts | 7 +- src/utils/storage.ts | 4 +- src/utils/tabs.ts | 6 +- 19 files changed, 647 insertions(+), 512 deletions(-) delete mode 100644 src/utils/mips.ts create mode 100644 src/utils/mips/mips.ts create mode 100644 src/utils/mips/tauri-backend.ts create mode 100644 src/utils/mips/wasm-backend.ts create mode 100644 src/utils/mips/wasm-worker.ts diff --git a/src/components/ExportModal.vue b/src/components/ExportModal.vue index 3374424..90fc8fc 100644 --- a/src/components/ExportModal.vue +++ b/src/components/ExportModal.vue @@ -99,10 +99,8 @@ import Modal from './Modal.vue' import { tab } from '../state/state' -import { consoleData, ConsoleType, DebugTab, openConsole, pushConsole } from '../state/console-data' -import { assembleRegions } from '../utils/mips' +import { backend, consoleData, ConsoleType, DebugTab, openConsole, pushConsole } from '../state/console-data' import { collectLines } from '../utils/tabs' -import { selectSaveDestination } from '../utils/query/access-manager' import { exportHexContents, exportHexRegions } from '../utils/query/serialize-files' import { postBuildMessage } from '../utils/debug' import { DocumentArrowUpIcon, XMarkIcon } from '@heroicons/vue/24/solid' @@ -157,7 +155,7 @@ async function exportRegions() { return } - const result = await assembleRegions(collectLines(current.lines), current.path, state) + const result = await backend.assembleRegions(collectLines(current.lines), current.path, state) if (result.regions) { switch (result.regions.type) { diff --git a/src/components/TabBarItems.vue b/src/components/TabBarItems.vue index 15f2215..e3ff3e6 100644 --- a/src/components/TabBarItems.vue +++ b/src/components/TabBarItems.vue @@ -81,7 +81,7 @@ import { computed } from 'vue' import { consoleData } from '../state/console-data' import { build, pause, resume, step, rewind, stop } from '../utils/debug' -import { ExecutionModeType } from '../utils/mips' +import { ExecutionModeType } from '../utils/mips/mips' import { tab } from '../state/state' import { diff --git a/src/components/console/BitmapTab.vue b/src/components/console/BitmapTab.vue index b977014..c351427 100644 --- a/src/components/console/BitmapTab.vue +++ b/src/components/console/BitmapTab.vue @@ -132,14 +132,14 @@ import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue' import { ArrowLeftIcon } from '@heroicons/vue/24/solid' -import { ExclamationCircleIcon, CheckCircleIcon } from '@heroicons/vue/24/outline' -import { consoleData } from '../../state/console-data' +import { ExclamationCircleIcon } from '@heroicons/vue/24/outline' +import { backend, consoleData } from '../../state/console-data' import { settings } from '../../state/state' import NumberField from './NumberField.vue' import { convertFileSrc } from '@tauri-apps/api/tauri' -import { ExecutionState, lastDisplay } from '../../utils/mips' import { displayConfig } from '../../utils/settings' +import { MipsExecution } from '../../utils/mips/mips' const wrapper = ref(null as HTMLElement | null) const canvas = ref(null as HTMLCanvasElement | null) @@ -288,7 +288,7 @@ watch(() => consoleData.execution, checkConnected) async function renderFrameFallback( context: CanvasRenderingContext2D, - execution: ExecutionState + execution: MipsExecution ) { const memory = await execution.memoryAt(0x10008000, 64 * 64 * 4) @@ -352,14 +352,14 @@ async function renderFrameProtocol(context: CanvasRenderingContext2D) { } async function renderLastDisplay(context: CanvasRenderingContext2D) { - const last = await lastDisplay() + const last = await backend.lastDisplay() // No data, don't render. if (!last.data) { return } - await renderOrdered( + renderOrdered( context, last.width, last.height, diff --git a/src/components/console/BreakTab.vue b/src/components/console/BreakTab.vue index dec3ea5..0766653 100644 --- a/src/components/console/BreakTab.vue +++ b/src/components/console/BreakTab.vue @@ -112,14 +112,13 @@