You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.6 KiB
1.6 KiB
c2logic
Compiles C code to Mindustry logic. Still in beta, so compiled output may not be fully optimized.
Installation
pip install git+https://github.com/SuperStormer/c2logic
Documentation
Run the command line tool using:
c2logic filename -O optimization_level
where filename is a string and optimization_level is an optional integer.
Optimization Level:
- completely unoptimized.
- the default
- modify variables without using a temporary
- turns on some potentially unsafe optimizations
- augmented assignment and pre/postincrement/decrement don't modify
__rax - returning from main becomes equivalent to
end
- augmented assignment and pre/postincrement/decrement don't modify
Locals are rewritten as _<varname>_<func_name>. Globals are unchanged.
Special Variables:
__rax: similar to x86 rax__rbx: stores left hand side of binary ops to avoid clobbering by the right side__retaddr__<func_name>: stores return address of func call
When writing your code, you must include c2logic/builtins.h, which is located in the python include directory (location depends on system, mine is at ~/.local/include/python3.8/).
See include/builtins.h for API definitions and examples for API sample usage.
Supported Features
- all Mindustry instructions as of BE
- all control flow structures except goto
- functions
- local/global variables
Unsupported Features
- structs - split it into multiple variables
- enums - use an int plus macros
- block scoped variables - just use locals
- typedefs - use macros
- pointers - don't use them
- goto - don't use it