From 012469559e3f366612751477a0d5065b283b9dd2 Mon Sep 17 00:00:00 2001
From: rina
Date: Mon, 1 Jul 2024 11:10:25 +1000
Subject: [PATCH] remove web folder (moved to separate repository)
---
web/aslp.js | 88 -----------------------------------------------
web/dune | 12 -------
web/index.html | 93 --------------------------------------------------
web/js.ml | 47 -------------------------
web/reset.css | 27 ---------------
web/worker.js | 12 -------
6 files changed, 279 deletions(-)
delete mode 100644 web/aslp.js
delete mode 100644 web/dune
delete mode 100644 web/index.html
delete mode 100644 web/js.ml
delete mode 100644 web/reset.css
delete mode 100644 web/worker.js
diff --git a/web/aslp.js b/web/aslp.js
deleted file mode 100644
index 473018dd..00000000
--- a/web/aslp.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Supporting code to enable ASLp-in-JS. Handles input/output.
- */
-
-const get = query => {
- const result = document.querySelector(query);
- console.assert(result, "query returned null: " + query);
- return result;
-};
-
-// XXX: cannot use worker due to worker stack size being too small
-// const worker = new Worker('worker.js');
-
-const input = get('#op');
-const output = get('#output');
-const loading = get('#loading');
-
-
-const OPCODE = 'opcode';
-const BYTES = 'bytes';
-let mode = OPCODE;
-
-const flipEndian = s => {
- const chunked = s.match(/.{1,2}/g); // chunks of 2
- chunked.reverse();
- return chunked.join('');
-};
-
-// always returns BIG-endian string
-const getOpcode = () => {
- const val = input.value.trim().replace(/^0x/, '').replace(/\s/g, '').padStart(8, '0');
-
- if (val.length > 8) throw Error('opcode too long: ' + val.length);
- if (mode == OPCODE) return val;
- return flipEndian(val);
-}
-
-const setOpcodeMode = newMode => {
- if (mode != newMode) {
- const op = getOpcode();
- mode = newMode;
-
- if (mode == OPCODE) {
- input.value = '0x' + op.toLowerCase();
- } else {
- input.value = flipEndian(op).toUpperCase().match(/.{1,2}/g).join(' ');
- }
- }
-};
-
-const onChangeDebug = el => {
- libASL_web.setDebugLevel(parseInt(el.value, 10));
-};
-
-const clearOutput = () => {
- output.innerHTML = '';
-};
-
-const submit = () => {
- clearOutput();
- loading.classList.remove('invisible');
- // defer computation so loading indicator shows.
- setTimeout(() => {
- try {
- libASL_web.dis('0x' + getOpcode());
- } finally {
- loading.classList.add('invisible');
- }
- }, 30);
-};
-
-
-const write = (isError) => s => {
- const span = document.createElement('span');
- const data = new Uint8Array(s.length);
- for (let i = 0; i < s.length; i++) {
- data[i] = s.charCodeAt(i);
- }
- span.textContent = new TextDecoder('utf-8').decode(data);
- if (isError)
- span.classList.add('stderr');
- output.appendChild(span);
- return 0;
-};
-
-libASL_web.init(write(false), write(true));
-libASL_web.setDebugLevel(0);
-
diff --git a/web/dune b/web/dune
deleted file mode 100644
index 87f4d3c7..00000000
--- a/web/dune
+++ /dev/null
@@ -1,12 +0,0 @@
-(executable
- (name js)
- (modes js)
- (modules js)
- (libraries libASL libASL_web js_of_ocaml)
- (js_of_ocaml (flags --sourcemap :standard \ --source-map-inline))
- (preprocess (pps js_of_ocaml-ppx))
- )
-
-(alias
- (name default)
- (deps js.bc.js index.html reset.css aslp.js worker.js))
diff --git a/web/index.html b/web/index.html
deleted file mode 100644
index aa33d859..00000000
--- a/web/index.html
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
- ASLp Web
-
-
-
-
-
-
-
-
- ASLp Web
-
-
-
-
-
-
-
diff --git a/web/js.ml b/web/js.ml
deleted file mode 100644
index e16fd656..00000000
--- a/web/js.ml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-let init input out err =
- Js_of_ocaml.Sys_js.set_channel_flusher stdout out;
- Js_of_ocaml.Sys_js.set_channel_flusher stderr err;
- Js_of_ocaml.Sys_js.set_channel_filler stdin input;
- ()
-
-let cachedenv : LibASL.Eval.Env.t option ref = ref None
-let uncachedenv = lazy (Option.get @@ LibASL.Arm_env.aarch64_evaluation_environment ())
-
-let env () =
- match !cachedenv with
- | Some x -> x
- | None -> Lazy.force uncachedenv
-
-let denv = lazy (LibASL.Dis.build_env @@ env ())
-
-let print_pp = ref true
-
-let pp_stmt () =
- if !print_pp then Asl_utils.pp_stmt else fun x -> Utils.to_string (Asl_parser_pp.pp_raw_stmt x)
-
-let dis (x: string) =
- let stmts = LibASL.Dis.retrieveDisassembly (env ()) Lazy.(force denv) x in
- List.iter
- (fun s -> print_endline @@ pp_stmt () s)
- stmts;
- flush stdout
-
-
-let () =
- print_endline "libASL_web ocaml-side...";
-
- let open Js_of_ocaml in
- let () = Js.export "libASL_web"
- (object%js
- (* TODO: support stdin from javascript for repl, possibly converting asli repl to lwt *)
- method init (out : string -> unit) (err : string -> unit) = init (fun () -> "") out err
-
- method force = let env' = env () and _ = Lazy.force denv in fun () -> Js.bytestring @@ Marshal.to_string env' []
- method cache (a: Js.js_string Js.t) = (cachedenv := Some (Marshal.from_string (Js.to_bytestring a) 0))
- method uncache = (cachedenv := None)
- method dis (x: string) = dis x
- method setDebugLevel i = (LibASL.Dis.debug_level := i)
- method setPrettyPrint (x : bool) = (print_pp := x)
- end) in
- ()
diff --git a/web/reset.css b/web/reset.css
deleted file mode 100644
index bafd2ab0..00000000
--- a/web/reset.css
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Josh's Custom CSS Reset
- https://www.joshwcomeau.com/css/custom-css-reset/
-*/
-*, *::before, *::after {
- box-sizing: border-box;
-}
-* {
- margin: 0;
-}
-body {
- line-height: 1.5;
- -webkit-font-smoothing: antialiased;
-}
-img, picture, video, canvas, svg {
- display: block;
- max-width: 100%;
-}
-input, button, textarea, select {
- font: inherit;
-}
-p, h1, h2, h3, h4, h5, h6 {
- overflow-wrap: break-word;
-}
-#root, #__next {
- isolation: isolate;
-}
diff --git a/web/worker.js b/web/worker.js
deleted file mode 100644
index 42063258..00000000
--- a/web/worker.js
+++ /dev/null
@@ -1,12 +0,0 @@
-importScripts('js.bc.js');
-
-console.log('libASL_web js-side:', libASL_web);
-
-libASL_web.go();
-console.log('libASL_web worker ready');
-
-onmessage = function(e) {
- const fn = libASL_web[e.data[0]];
- console.assert(fn, "libASL_web function not found: " + e.data);
- fn(...e.data[1]);
-};