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.
|
|
5 years ago | |
|---|---|---|
| c2logic | 5 years ago | |
| examples | 5 years ago | |
| include | 5 years ago | |
| .clang-format | 5 years ago | |
| .clang-tidy | 5 years ago | |
| .gitignore | 5 years ago | |
| .pylintrc | 5 years ago | |
| .style.yapf | 5 years ago | |
| LICENSE | 5 years ago | |
| README.md | 5 years ago | |
| mypy.ini | 5 years ago | |
| requirements.txt | 5 years ago | |
| setup.py | 5 years ago | |
README.md
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
Usage
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
Locals are rewritten as <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*: stores return address of func call
When developing your script, you can include c2logic/builtins.h located in the python include directory(location depends on system, mine is at ~/.local/include/python3.8/)
See examples for API sample usage.
Documentation
See include/builtins.h for API definitions.
Unsupported Features
- drawing
- getlink
- memory cell read/write
- actual functions
- structs
- enums
Some of these features may be worked around using asm().