about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-10-29 22:34:01 -0700
committerKartik Agaram <vc@akkartik.com>2019-10-29 22:34:01 -0700
commit6c9450b5d14abd8471462130850c764097858c1f (patch)
tree6fa8d1625ff9c10cf0f17773e3a6f39fd06aec2a
parent4e631258c834651d7974d0ab71a5637f66e33322 (diff)
downloadmu-6c9450b5d14abd8471462130850c764097858c1f.tar.gz
5722
Already http://akkartik.name/post/mu-2019-2 is out of date.
-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: