about summary refs log tree commit diff stats
path: root/apps/tile/data.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-23 22:24:51 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-23 22:24:51 -0700
commit22a7849a5efb5d5fa76a6f5633f802b8be9b21c3 (patch)
tree2a24d1e7a12d330e22a056544a09b2d486d0879a /apps/tile/data.mu
parent890df1de516743ba06d5dfe4a63688bc7c12d4ad (diff)
downloadmu-22a7849a5efb5d5fa76a6f5633f802b8be9b21c3.tar.gz
6844 - tile: initial data model
I actually deleted a test here! Hard-core prototype mode.
Diffstat (limited to 'apps/tile/data.mu')
-rw-r--r--apps/tile/data.mu73
1 files changed, 73 insertions, 0 deletions
diff --git a/apps/tile/data.mu b/apps/tile/data.mu
new file mode 100644
index 00000000..c9988ed3
--- /dev/null
+++ b/apps/tile/data.mu
@@ -0,0 +1,73 @@
+type program {
+  defs: (handle function)
+  sandboxes: (handle sandbox)
+}
+
+type sandbox {
+  setup: (handle line)
+  data: (handle line)
+  next: (handle sandbox)
+  prev: (handle sandbox)
+}
+
+type function {
+  args: (handle word)
+  body: (handle line)
+  # some sort of indication of spatial location
+  next: (handle function)
+}
+
+type line {
+  name: (handle array byte)
+  data: (handle word)
+  result: (handle result)  # might be cached
+  next: (handle line)
+  prev: (handle line)
+}
+
+#? type word {
+#?   # at most one of these will be non-null
+#?   scalar-data: (handle gap-buffer)
+#?   box-data: (handle line)  # recurse
+#?   left: (handle word)
+#?   right: (handle word)
+#? }
+
+type result {
+  data: (handle word-stack)
+  error: (handle array byte)  # single error message for now
+}
+
+# if 'out' is non-null, save the first word of the program there
+fn initialize-program _program: (addr program), out: (addr handle word) {
+  var program/esi: (addr program) <- copy _program
+  var sandbox-ah/eax: (addr handle sandbox) <- get program, sandboxes
+  allocate sandbox-ah
+  var sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
+  initialize-sandbox sandbox, out
+}
+
+# if 'out' is non-null, save the first word of the sandbox there
+fn initialize-sandbox _sandbox: (addr sandbox), out: (addr handle word) {
+  var sandbox/esi: (addr sandbox) <- copy _sandbox
+  var line-ah/eax: (addr handle line) <- get sandbox, data
+  allocate line-ah
+  var line/eax: (addr line) <- lookup *line-ah
+  initialize-line line, out
+}
+
+# initialize line with a single empty word
+# if 'out' is non-null, save the word there as well
+fn initialize-line _line: (addr line), out: (addr handle word) {
+  var line/esi: (addr line) <- copy _line
+  var word-ah/eax: (addr handle word) <- get line, data
+  allocate word-ah
+  {
+    compare out, 0
+    break-if-=
+    var dest/edi: (addr handle word) <- copy out
+    copy-object word-ah, dest
+  }
+  var word/eax: (addr word) <- lookup *word-ah
+  initialize-word word
+}