about summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-17 00:30:33 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:50 -0700
commit02dade7b224043717bc8e2e15eaa743ec4554550 (patch)
tree83d043033bf699a52da06406f7138d9a039a3fa9 /tools
parentdeebb9322e8bf74c945da514849cc07ebd44aac3 (diff)
downloadmu-02dade7b224043717bc8e2e15eaa743ec4554550.tar.gz
-
Diffstat (limited to 'tools')
-rwxr-xr-xtools/expand_string17
-rwxr-xr-xtools/expand_string_handle20
2 files changed, 20 insertions, 17 deletions
diff --git a/tools/expand_string b/tools/expand_string
deleted file mode 100755
index a5a9ad30..00000000
--- a/tools/expand_string
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-# Expand syntax sugar for SubX string literals.
-# Helpful for converting them into handles to strings.
-
-INPUT=$(cat)
-echo "    # \"$INPUT\""
-
-# print length in bytes
-printf "    0x%x/imm32/size\n" $(echo -n $INPUT |wc -c)
-
-# print ascii codes for each character in hex
-echo -n "   "
-for c in $(echo "$INPUT" | sed -e 's/./& /g')
-do
-  echo -n " 0x$(printf '%x' "'$c")/$c"
-done
-echo
diff --git a/tools/expand_string_handle b/tools/expand_string_handle
new file mode 100755
index 00000000..0c739f65
--- /dev/null
+++ b/tools/expand_string_handle
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Expand syntax sugar for SubX string literals and show the corresponding handle definition.
+#
+# The handle has a fake alloc-id; we're never going to try to reclaim global
+# variables, we just sometimes need handles in them to satisfy type constraints.
+
+INPUT=$(cat)
+echo "    0x11/imm32/alloc-id:fake:payload"
+echo "    # \"$INPUT\""
+
+# print length in bytes
+printf "    0x%x/imm32/size\n" $(echo -n $INPUT |wc -c)
+
+# print ascii codes for each character in hex
+echo -n "   "
+for c in $(echo "$INPUT" |sed -e 's/./& /g')
+do
+  echo -n " 0x$(printf '%x' "'$c")/$c"
+done
+echo