about summary refs log tree commit diff stats
path: root/mu_summary
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-02-21 10:05:04 -0800
committerKartik Agaram <vc@akkartik.com>2020-02-21 10:09:59 -0800
commitfee1bbd8b4681acca7daba1b3b70ce6d26e52fb4 (patch)
treeceae46b4b130d02eac6de7cc2379ebcd61bf9564 /mu_summary
parent1837f6117632c80214f45ed94a0d3406810e431f (diff)
downloadmu-fee1bbd8b4681acca7daba1b3b70ce6d26e52fb4.tar.gz
6041 - array indexing starting to work
And we're using it now in factorial.mu!

In the process I had to fix a couple of bugs in pointer dereferencing.

There are still some limitations:
a) Indexing by a literal doesn't work yet.
b) Only arrays of ints supported so far.

Looking ahead, I'm not sure how I can support indexing arrays by non-literals
(variables in registers) unless the element size is a power of 2.
Diffstat (limited to 'mu_summary')
-rw-r--r--mu_summary6
1 files changed, 6 insertions, 0 deletions
diff --git a/mu_summary b/mu_summary
index 8eafc4e3..3a93d109 100644
--- a/mu_summary
+++ b/mu_summary
@@ -194,3 +194,9 @@ Similarly, conditional loops:
   loop-if-addr<= label
   loop-if-addr>=
   loop-if-addr>= label
+
+## Array operations
+
+  var/reg: int <- length var: (addr array T)
+  var/reg: (addr T) <- index var: (addr array T), idx: int
+  var/reg: (addr T) <- index var: (addr array T), n