about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--apps/mu.subx47
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index b64ac6c2..bb6cd195 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -4,6 +4,7 @@
 # To run:
 #   $ ./ntranslate init.linux 0*.subx apps/mu.subx
 
+# A sketch of planned data structures. Still highly speculative.
 == data
 
 # A program is currently a linked list of functions
@@ -21,6 +22,52 @@ Function-next:
 Function-size:
   0x14/imm32/20
 
+# A block is a list of statements:
+#     statements: (address statement)
+
+# A statement can be either a regular statement consisting of:
+#     name: (address string)
+#     inputs: (address var)
+#     outputs: (address var-r)
+# or a variable declaration on the stack:
+#     name: (address string)
+#     type: (address type-sexpr)
+# or a regular statement writing to a single new variable in a register:
+#     name: (address string)
+#     inputs: (address var)
+#     output: var-r
+# or a block of statements:
+#     statements: (address statement)
+
+# Kinds of local variable declarations:
+#   var f : (array foo 10)
+#   var f/ecx : int <- copy 0
+# Variables live in either the stack or a register.
+# Variables in the stack are auto-initialized.
+#   (This is non-trivial for arrays, and arrays inside structs... We'll see.)
+# Variables in register need a real instruction.
+
+# var is a variable declaration. e.g. `foo: (array int 3)`
+#   name: (address string)
+#   type: (address type-sexpr)
+
+# var-r is a variable declaration in a register. e.g. `foo/eax: (array int 3)`
+#   name: (address string)
+#   type: (address type-sexpr)
+#   reg: int [0..7]
+
+# type-sexpr is a tree of type identifiers. e.g. (array (address int) 3)
+# either
+#   id: type-identifier
+# or
+#   car: (address type-sexpr)
+#   cdr: (address type-sexpr)
+
+# Still todo:
+#   heap allocations (planned name: 'handle')
+#   user-defined types: 'type' for structs, 'choice' for unions
+#   short-lived 'address' type for efficiently writing inside nested structs
+
 == code
 
 Entry: