simon816 / Command-Block-Assembly

Compile high-level code into Minecraft commands
https://www.simon816.com/minecraft/assembler
MIT License
272 stars 29 forks source link

Add STD Library #2

Closed chorman0773 closed 6 years ago

chorman0773 commented 6 years ago

Adds 3 parts of the standard library. Compiler should change to use the folder std, on the inclusion path, as well as reflect the requirements of stdarg.h (specifically, variadic functions should store parameters in a specialzied table, to allow for va_start_impl to work correctly). If anything is not possible, or needs further explaination, please comment.

chorman0773 commented 6 years ago

BTW, stdarg NEEDS to use char, otherwise it can't opperate correctly. I can't find any real way to implement it other than via a char (or by means of a struct, which I wish to avoid, to decrease complexity of the impl functions).

chorman0773 commented 6 years ago

Also to clarify, variadic arguments need NOT be stored in a specialized table, but rather MUST be stored adjacent to other function arguments. The reason I recommend using a specialized table is to prevent conflicts with other "auto's".

simon816 commented 6 years ago

Nice work! Surprised anyone would take on the task of implementing the standard library.

Variadic functions are not something I bothered with in the compiler because it's more a 'nice to have', so some internal work will need to be done to support this.

I have merged this into a new branch stdlib where I'll work on plumbing the compiler to support the headers. If you're wanting to add more of the standard library make sure any PRs targets this branch.