2025-09-21 21:08:30 +00:00
|
|
|
from copapy import Write, const
|
2025-08-29 20:58:50 +00:00
|
|
|
import copapy as rc
|
|
|
|
|
|
2025-09-26 21:25:51 +00:00
|
|
|
|
2025-08-29 20:58:50 +00:00
|
|
|
def test_compile():
|
|
|
|
|
c1 = const(1.11)
|
|
|
|
|
c2 = const(2.22)
|
|
|
|
|
|
|
|
|
|
i1 = c1 * 2
|
|
|
|
|
i2 = i1 + 3
|
|
|
|
|
|
|
|
|
|
r1 = i1 + i2
|
|
|
|
|
r2 = c2 + 4 + c1
|
|
|
|
|
|
|
|
|
|
out = [Write(r1), Write(r2)]
|
|
|
|
|
|
|
|
|
|
il = rc.compile_to_instruction_list(out)
|
|
|
|
|
|
2025-09-20 21:25:07 +00:00
|
|
|
print('#', il.print())
|
2025-08-29 20:58:50 +00:00
|
|
|
|
2025-09-26 21:25:51 +00:00
|
|
|
il.to_file('test.copapy')
|
|
|
|
|
|
2025-08-29 20:58:50 +00:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
test_compile()
|