skopy/lib/include/compiler.h

75 lines
2.2 KiB
C
Raw Normal View History

2024-03-31 21:10:56 +00:00
#ifndef SK_COMPILER_H
#define SK_COMPILER_H
#include "commons.h"
#include "prog.h"
2024-04-02 15:33:31 +00:00
#include "sym.h"
2024-03-31 21:10:56 +00:00
2024-04-06 18:44:58 +00:00
struct state;
2024-04-07 18:43:13 +00:00
struct mod
{
char* name;
struct module* module;
};
2024-03-31 21:10:56 +00:00
struct compiler
{
struct vec var_names;
2024-04-07 18:43:13 +00:00
struct vec modules;
struct vec funs;
2024-03-31 21:10:56 +00:00
};
2024-04-07 18:43:13 +00:00
void mod_free(struct mod* self);
2024-03-31 21:10:56 +00:00
void compiler_init(struct compiler* self);
void compiler_free(struct compiler* self);
void compiler_compile(struct compiler* self,
struct node* node,
2024-04-02 15:33:31 +00:00
struct prog* prog,
2024-04-06 18:44:58 +00:00
struct sym* sym,
struct state* state);
2024-03-31 21:10:56 +00:00
2024-03-31 23:32:47 +00:00
void compiler_compile_children(struct compiler* self,
struct node* node,
2024-04-02 15:33:31 +00:00
struct prog* prog,
2024-04-06 18:44:58 +00:00
struct sym* sym,
struct state* state);
2024-04-01 12:00:06 +00:00
void compiler_compile_value(struct compiler* self,
struct node* node,
struct prog* prog,
TypeKind type,
union val val);
void compiler_compile_and(struct compiler* self,
struct node* node,
2024-04-02 15:33:31 +00:00
struct prog* prog,
2024-04-06 18:44:58 +00:00
struct sym* sym,
struct state* state);
2024-04-01 12:00:06 +00:00
void compiler_compile_or(struct compiler* self,
2024-04-02 15:33:31 +00:00
struct node* node,
struct prog* prog,
2024-04-06 18:44:58 +00:00
struct sym* sym,
struct state* state);
2024-04-02 17:16:22 +00:00
void compiler_compile_if(struct compiler* self,
struct node* node,
struct prog* prog,
struct sym* sym,
2024-04-06 18:44:58 +00:00
struct state* state,
2024-04-02 17:16:22 +00:00
struct vec* to_end);
struct symbol* compiler_find(struct compiler* self,
char* name,
struct sym* sym,
struct node* node);
void compiler_compile_fun(struct compiler* self,
struct node* node,
struct prog* prog,
struct sym* sym,
struct state* state);
2024-03-31 21:10:56 +00:00
#endif