diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-01-01 17:04:37 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-01-01 17:04:37 -0800 |
commit | 2a4088119cf41175457414dfa59bd4064b8f0562 (patch) | |
tree | 64fe184e399f9870ebd481a90eec34d51e5dff68 /archive/3.transect/compiler5 | |
parent | 23fd294d85959c6b476bcdc35ed6ad508cc99b8f (diff) | |
download | mu-2a4088119cf41175457414dfa59bd4064b8f0562.tar.gz |
5852
Diffstat (limited to 'archive/3.transect/compiler5')
-rw-r--r-- | archive/3.transect/compiler5 | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/archive/3.transect/compiler5 b/archive/3.transect/compiler5 deleted file mode 100644 index aeb857f4..00000000 --- a/archive/3.transect/compiler5 +++ /dev/null @@ -1,32 +0,0 @@ -== Goal - -A memory-safe language with a simple translator to x86 that can be feasibly written in x86. - -== Definitions of terms - -Memory-safe: it should be impossible to: - a) create a pointer out of arbitrary data, or - b) to access heap memory after it's been freed. - -Simple: do all the work in a 2-pass translator: - Pass 1: check each instruction's types in isolation. - Pass 2: emit code for each instruction in isolation. - -== types - -int -char -(address _ t), t ∋ {stack, heap, global} -(array _ t), t ∋ {stack, heap, global} - -stack addresses can't be copied to heap or global -heap addresses can't be copied [1] -global addresses you're free to use anywhere - -[1] (address _ heap) can't be copied or stored, can't be part of a type or -choice. Only thing you can do with it is access it from the register you wrote -it to. And even that not past a call instruction. Important detail: `free()` -is a call. So an address to something on the heap can never be invalid if the -program type-checks. - -<reg x> : (address T m) <- advance <reg/mem> : (array T m), <reg offset> : (index T) |