68 lines
2.1 KiB
C
68 lines
2.1 KiB
C
#include "src/comp.h"
|
|
#include "src/object.h"
|
|
#include "src/register.h"
|
|
#include "trig.c"
|
|
|
|
#include "src/lang/ast.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
int main() {
|
|
|
|
struct PawAST *ast = ast_make();
|
|
ast_insert_property(ast, "i", make_pawval_int(ast->mem, 0));
|
|
ast_append_cfunc(ast, print);
|
|
|
|
enum PawCtrl *body = make_pawctrl_seq(ast->mem);
|
|
pawseq_append(body,
|
|
make_pawctrl_asign(
|
|
ast->mem, PSV_P(ast_get_property(ast, "i")),
|
|
make_pawval_expr(ast->mem, ast_get_property(ast, "i"),
|
|
make_pawval_int(ast->mem, 1), op_add)));
|
|
|
|
enum PawCtrl *truthy = make_pawctrl_seq(ast->mem);
|
|
pawseq_append(truthy, make_pawctrl_spush(ast->mem, PSV_INT(0)));
|
|
pawseq_append(truthy, make_pawctrl_asign(ast->mem, PSV_SP(0),
|
|
ast_get_property(ast, "i")));
|
|
pawseq_append(truthy, make_pawctrl_ccall(ast->mem, 0));
|
|
pawseq_append(truthy, make_pawctrl_spop(ast->mem));
|
|
pawseq_append(body,
|
|
make_pawctrl_if(
|
|
ast->mem,
|
|
make_pawval_expr(ast->mem, ast_get_property(ast, "i"),
|
|
make_pawval_int(ast->mem, 20), op_equals),
|
|
truthy, make_pawctrl_seq(ast->mem)));
|
|
pawseq_append(
|
|
ast->prog,
|
|
make_pawctrl_while(ast->mem,
|
|
make_pawval_expr(ast->mem, ast_get_property(ast, "i"),
|
|
make_pawval_int(ast->mem, 1000000),
|
|
op_unequals),
|
|
body));
|
|
ast_exec(ast);
|
|
return 0;
|
|
|
|
struct Vk *vk;
|
|
cat_Comp *state = cat_comp_init("meooow", 500, 500, &vk);
|
|
|
|
struct Register *reg = make_register();
|
|
reg_attatch_type(reg, "trig", OBJ_MAKE make_trig, OBJ_FREE free_trig,
|
|
OBJ_TICK trig_tick);
|
|
struct Scene *scene = make_scene(vk, reg);
|
|
|
|
scene_queue_insert(scene, "trig", trig_make_args(scene));
|
|
|
|
while (!cat_comp_should_close(state)) {
|
|
scene_tick(scene);
|
|
cat_comp_draw(state);
|
|
}
|
|
|
|
free_scene(scene);
|
|
free_register(reg);
|
|
|
|
cat_comp_uninit(state);
|
|
|
|
state = NULL;
|
|
reg = NULL;
|
|
scene = NULL;
|
|
}
|