parent
43f4a68565
commit
8739857dc4
@ -1,2 +1,3 @@ |
||||
*.o |
||||
secd |
||||
secd_debug |
||||
|
@ -1,3 +1,7 @@ |
||||
# SECD |
||||
|
||||
This is a (wip) implementation of a SECD machine written in C. For more information on what a SECD machine is, and what the goals of this project is, read [my blogpost on secd machines](https://depsterr.com/blog/2021/secd1.html). |
||||
|
||||
## DEPENDS |
||||
|
||||
* Bohem-Demer-Weiser garbage collector [web](https://www.hboehm.info/gc/) [git](https://github.com/ivmai/bdwgc) |
||||
|
@ -0,0 +1,49 @@ |
||||
# Goals |
||||
|
||||
* Be an efficent compilation target for typed lambda calculi |
||||
|
||||
* Be substantially easier to translate to than machine code. |
||||
|
||||
* Run cross-platform on as many operating systems and architectures as possible. (bare minimum 32-bit). |
||||
|
||||
* Allow for code completely independent of the host machine. |
||||
|
||||
* Leave memory managment out of the question for the compiler writer. |
||||
|
||||
* Provide significant IO functionality. |
||||
|
||||
* Have methods for representing algebraic data types built into the machine. |
||||
|
||||
* Provide efficient native methods for manipulating commonly used types |
||||
* Strings (don't represent as a list of characters, god) |
||||
* Characters |
||||
* Integers |
||||
* Floating point numbers |
||||
* Raw bytes |
||||
* Lists (cons linked list), efficient map and foldr builtin would be really nice |
||||
* Arrays (constant lookup continous memory) |
||||
|
||||
# Non-Goals |
||||
|
||||
* Safely error out or leave catchable exceptions when instruction is called with wrongful operands. |
||||
|
||||
* Dynamic linking, creating object files with polymorphic types. |
||||
|
||||
* Lazy evaluation. |
||||
|
||||
# Nicities (plausible) |
||||
|
||||
* Provide a compiler from a simply typed lambda calculus, coupled with a small standard library which would |
||||
confirm type safety of all used instructions. Maybe go even further? System F? |
||||
|
||||
* Maybe some vector operations? You could reasonably operate on chunks of the stack. |
||||
|
||||
# Nicities (dreaming) |
||||
|
||||
* Provide more complete IO functionality, such as networking, etc. (this is not likely to happen) |
||||
|
||||
* Provide some sort of FFI (this is not likely to happen) |
||||
|
||||
* It's possible one might be able to JIT compile some stuff? |
||||
|
||||
# Ideas |
@ -1,5 +1,23 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <stdint.h> |
||||
|
||||
#include <gc.h> |
||||
|
||||
#include "dbg.h" |
||||
#include "util.h" |
||||
|
||||
int main(int argc, char** argv) { |
||||
GC_INIT(); |
||||
|
||||
if (argc < 2) { |
||||
die("Not enough args"); |
||||
} |
||||
|
||||
size_t size; |
||||
uint8_t* buf; |
||||
|
||||
buf = readFile(argv[1], &size); |
||||
|
||||
fwrite(buf, 1, size, stdout); |
||||
} |
||||
|
Loading…
Reference in new issue