about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-15 21:11:43 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-15 21:22:33 -0800
commit49424b1933051b6cf1ce3371ada9cd7fa2d31df0 (patch)
tree3a30ae973fca31024aec4a48a29b75d5f66400fa /baremetal
parent8ed27ce4319eb843ee021ca0b1cb46d275c2f89d (diff)
downloadmu-49424b1933051b6cf1ce3371ada9cd7fa2d31df0.tar.gz
7523
There's a dependency cycle here:

- draw-grapheme (Mu) uses read-grapheme (Mu) to be unicode-aware.
- read-grapheme uses read-byte (SubX). Streams are a fundamental data
  structure in Mu. For the Mu compiler to be able to reason about the
  safety of stream operations, they need to be an opaque type. All
  stream primitives are written in SubX. To manipulate a stream's
  internals we force people to reach for SubX. That way if there's no
  SubX code there's confidence that things are safe.
- read-byte and other stream operations have unit tests, like they
  should. The unit tests need to print data to screen when say a test
  fails. To do this they use various check- functions (SubX) that take a
  string argument.
- Printing a string to screen uses draw-grapheme (Mu).

Perhaps I should maintain variants of drawing primitives that operate
only on ASCII.
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/106stream.subx3
-rw-r--r--baremetal/108write.subx6
-rw-r--r--baremetal/109stream-equal.subx3
-rw-r--r--baremetal/112read-byte.subx5
-rw-r--r--baremetal/115write-byte.subx5
5 files changed, 18 insertions, 4 deletions
diff --git a/baremetal/106stream.subx b/baremetal/106stream.subx
index 84d0580b..9949ee7d 100644
--- a/baremetal/106stream.subx
+++ b/baremetal/106stream.subx
@@ -8,6 +8,9 @@
 # some primitives for operating on streams:
 #   - clear-stream (clears everything but the data size)
 #   - rewind-stream (resets read pointer)
+#
+# We need to do this in machine code because streams need to be opaque types,
+# and we don't yet support opaque types in Mu.
 
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
diff --git a/baremetal/108write.subx b/baremetal/108write.subx
index 4f3b0b7f..43e9bf9b 100644
--- a/baremetal/108write.subx
+++ b/baremetal/108write.subx
@@ -1,9 +1,7 @@
 # write: write to in-memory streams
 #
-# A stream looks like this:
-#   read: int  # index at which to read next
-#   write: int  # index at which writes go
-#   data: (array byte)  # prefixed by size as usual
+# We need to do this in machine code because streams need to be opaque types,
+# and we don't yet support opaque types in Mu.
 
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
diff --git a/baremetal/109stream-equal.subx b/baremetal/109stream-equal.subx
index 8f6cf1bf..ad0dcb7c 100644
--- a/baremetal/109stream-equal.subx
+++ b/baremetal/109stream-equal.subx
@@ -1,4 +1,7 @@
 # some primitives for checking stream contents
+#
+# We need to do this in machine code because streams need to be opaque types,
+# and we don't yet support opaque types in Mu.
 
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
diff --git a/baremetal/112read-byte.subx b/baremetal/112read-byte.subx
index f86498bb..c6dd3ddf 100644
--- a/baremetal/112read-byte.subx
+++ b/baremetal/112read-byte.subx
@@ -1,3 +1,8 @@
+# Read a single byte from a stream.
+#
+# We need to do this in machine code because streams need to be opaque types,
+# and we don't yet support opaque types in Mu.
+
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
 # . op          subop               mod             rm32          base        index         scale       r32
diff --git a/baremetal/115write-byte.subx b/baremetal/115write-byte.subx
index af32f610..3ac587f0 100644
--- a/baremetal/115write-byte.subx
+++ b/baremetal/115write-byte.subx
@@ -1,3 +1,8 @@
+# Write a single byte to a stream.
+#
+# We need to do this in machine code because streams need to be opaque types,
+# and we don't yet support opaque types in Mu.
+
 == code
 #   instruction                     effective address                                                   register    displacement    immediate
 # . op          subop               mod             rm32          base        index         scale       r32