--- /dev/null
+#include "cerise.h"
+#include <limits.h>
+#include <assert.h>
+
+Type BoolType = {
+ .form = FORM_BOOL,
+ .size = sizeof(bool)
+};
+
+Type IntType = {
+ .form = FORM_INT,
+ .size = sizeof(long)
+};
+
+Type RealType = {
+ .form = FORM_REAL,
+ .size = sizeof(double)
+};
+
+Type StringType = {
+ .form = FORM_STRING,
+ .size = -1
+};
+
+void codegen_setint(Item* item, Type* type, long long val)
+{
+ item->mode = ITEM_CONST;
+ item->type = type;
+ item->reg = 0;
+ item->imm.i = val;
+}
+
+void codegen_setreal(Item* item, double val)
+{
+ item->mode = ITEM_CONST;
+ item->type = &RealType;
+ item->reg = 0;
+ item->imm.f = val;
+}
+
+void codegen_setstr(Item* item, char* val)
+{
+ item->mode = ITEM_CONST;
+ item->type = &StringType;
+ item->reg = 0;
+ item->imm.s = val;
+}
+
+void codegen_imports(Parser* p)
+{
+ (void)p;
+}
+
+void codegen_global(Parser* p, char* name, Type* type)
+{
+ (void)p, (void)name, (void)type;
+}
+
+void codegen_main(Parser* p)
+{
+ (void)p;
+}
+
+void codegen_startproc(Parser* p, char* name, long long localsz)
+{
+ (void)p, (void)name, (void)localsz;
+}
+
+void codegen_endproc(Parser* p)
+{
+ (void)p;
+}
+
+void codegen_unop(Parser* p, int op, Item* a)
+{
+ (void)p, (void)op, (void)a;
+}
+
+void codegen_binop(Parser* p, int op, Item* a, Item* b)
+{
+ (void)p, (void)op, (void)a, (void)b;
+}
+
+void codegen_store(Parser* p, Item* a, Item* b)
+{
+ (void)p, (void)a, (void)b;
+}
#!/bin/sh
+
+CCCMD="cc -g -Wall -Wextra --std=c99 -Iinc/"
+BACKEND=backend/x86_64
+TEST_BACKEND=backend/test
+
ctags -R &
-cc -g -D CERISE_TESTS -Wall -Wextra --std=c99 -o cerisec-test *.c \
- && cc -g -Wall -Wextra --std=c99 -o cerisec *.c \
+$CCCMD -D CERISE_TESTS -o cerisec-test src/*.c "$TEST_BACKEND"/*.c \
+ && $CCCMD -o cerisec src/*.c "$BACKEND"/*.c \
&& ./cerisec-test \
&& ./cerisec tests/Module.m | tee tests/Module.s \
&& cc -o Module tests/Module.s
--- /dev/null
+long A, B;
+
+void pos(void) { A = +A; }
+void neg(void) { A = -A; }
+
+void inc(void) { A++; }
+void dec(void) { A--; }
+
+void add(void) { A = A + B; }
+void sub(void) { A = A - B; }
+void mul(void) { A = A * B; }
+void div(void) { A = A / B; }
+void mod(void) { A = A % B; }
+
+void eq(void) { A = A == B; }
+void neq(void) { A = A != B; }
+void lt(void) { A = A < B; }
+void lte(void) { A = A <= B; }
+void gt(void) { A = A > B; }
+void gte(void) { A = A >= B; }
+
+void shr(void) { A = A >> B; }
+void shl(void) { A = A << B; }
+
+void band(void) { A = A & B; }
+void bor(void) { A = A | B; }
+void bnot(void) { A = ~A; }
+void bxor(void) { A = A ^ B; }
+