diff options
Diffstat (limited to 'apps/tile/data.mu')
-rw-r--r-- | apps/tile/data.mu | 73 |
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 +} |