-Subproject commit 3095d6563e507c752ad0010ac384ca487573b0fe
+Subproject commit cc1bdcbd2b43cc3eb08c80de725dbdb1b94cb3ef
-Subproject commit 1884860fc01b25f295cd7c5e7ddc304a1a69e730
+Subproject commit b9bb73a25ec8c235c6c6ba9bb9711104f01bc573
ANN static void clean_case_list(Clean *a, Stmt_List b);
ANN static void clean_stmt_match(Clean *a, Stmt_Match b);
ANN static void clean_stmt_case(Clean *a, Stmt_Match b);
-ANN static void clean_stmt(Clean *a, Stmt b);
+ANN static void clean_stmt(Clean *a, Stmt* b);
ANN static void clean_arg_list(Clean *a, Arg_List b);
ANN static void clean_stmt_list(Clean *a, Stmt_List b);
ANN static void clean_func_base(Clean *a, Func_Base *b);
struct Looper {
const Exp exp;
- const Stmt stmt;
+ Stmt *const stmt;
/*const */ m_uint offset;
const m_uint n;
const f_looper roll;
RET_NSPC(exp) \
}
-ANN m_bool check_stmt(const Env env, const Stmt stmt);
+ANN m_bool check_stmt(const Env env, Stmt* stmt);
ANN m_bool check_stmt_list(const Env env, const Stmt_List);
typedef m_bool (*_exp_func)(const void *, const void *);
-Subproject commit b873e18a508dcb46d9d0e3e6335cd262e3a9d6f8
+Subproject commit efdeca6a71c1cb39ad9bfdaef4c8a5e6e0d8a029
ANN static void clean_case_list(Clean *a, Stmt_List b) {
for(m_uint i = 0; i < b->len; i++) {
- const Stmt stmt = mp_vector_at(b, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(b, struct Stmt_, i);
clean_stmt_case(a, &stmt->d.stmt_match);
}
}
#define clean_stmt_spread clean_dummy
DECL_STMT_FUNC(clean, void, Clean *)
-ANN static void clean_stmt(Clean *a, Stmt b) {
+ANN static void clean_stmt(Clean *a, Stmt* b) {
clean_stmt_func[b->stmt_type](a, &b->d);
}
ANN static void clean_stmt_list(Clean *a, Stmt_List b) {
for(m_uint i = 0; i < b->len; i++) {
- const Stmt stmt = mp_vector_at(b, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(b, struct Stmt_, i);
clean_stmt(a, stmt);
}
}
instr->m_val2 = (m_uint)type;
}
-ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt);
+ANN static m_bool emit_stmt(const Emitter emit, Stmt* stmt);
ANN static m_bool emit_defers(const Emitter emit) {
const Vector v = &emit->code->frame->defer;
if (!vector_size(v)) return GW_OK;
m_uint i;
for(i = vector_size(v) + 1; --i;) {
- const Stmt s = (Stmt)vector_at(v, i - 1);
+ Stmt* s = (Stmt*)vector_at(v, i - 1);
if(s) CHECK_BB(emit_stmt(emit, s));
}
VLEN(v) = i;
ANN static m_bool emit_defers2(const Emitter emit) {
const Vector v = &emit->code->frame->defer;
for (m_uint i = vector_size(v) + 1; --i;) {
- const Stmt s = (Stmt)vector_at(v, i - 1);
+ Stmt* s = (Stmt*)vector_at(v, i - 1);
if (!s) break;
CHECK_BB(emit_stmt(emit, s));
}
}
ANN /*static */ m_bool emit_exp(const Emitter emit, Exp exp);
-ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt);
ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List list);
ANN static m_bool emit_exp_dot(const Emitter emit, const Exp_Dot *member);
ANN static m_bool emit_prim_locale(const Emitter emit, const Symbol *id) {
if(emit->locale->def->d.code) {
- const Stmt stmt = mp_vector_at((emit->locale->def->d.code), struct Stmt_, 0);
+ const Stmt* stmt = mp_vector_at((emit->locale->def->d.code), struct Stmt_, 0);
const Func f = stmt->d.stmt_exp.val->d.exp_call.func->type->info->func;
CHECK_OB(emit_ensure_func(emit, f));
}
--emit->env->scope->depth;
}
-ANN static m_bool scoped_stmt(const Emitter emit, const Stmt stmt) {
+ANN static m_bool scoped_stmt(const Emitter emit, Stmt* stmt) {
scoped_ini(emit);
const m_bool ret = emit_stmt(emit, stmt);
scoped_end(emit);
}
ANN static inline m_bool roll(const Emitter emit, Looper*const loop) {
-const Instr instr = loop->roll(emit, loop);
+ const Instr instr = loop->roll(emit, loop);
// DECL_OB(const Instr, instr, = each_op(emit, loop)); // maybe check in check.c
CHECK_BB(scoped_stmt(emit, loop->stmt));
instr->m_val = emit_code_size(emit) + 1; // pass after goto
ANN static m_bool emit_stmt_cases(const Emitter emit, Stmt_List list) {
for(m_uint i = 0; i < list->len; i++) {
- const Stmt stmt = mp_vector_at(list, struct Stmt_, i);
+ const Stmt* stmt = mp_vector_at(list, struct Stmt_, i);
CHECK_BB(emit_stmt_match_case(emit, &stmt->d.stmt_match));
}
return GW_OK;
DECL_STMT_FUNC(emit, m_bool, Emitter);
-ANN static m_bool emit_stmt(const Emitter emit, const Stmt stmt) {
+ANN static m_bool emit_stmt(const Emitter emit, Stmt* stmt) {
CHECK_BB(emit_stmt_func[stmt->stmt_type](emit, &stmt->d));
if (stmt->stmt_type == ae_stmt_exp && stmt->d.stmt_exp.val)
pop_exp(emit, stmt->d.stmt_exp.val);
ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- const Stmt stmt = mp_vector_at(l, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(l, struct Stmt_, i);
CHECK_BB(emit_stmt(emit, stmt));
}
return GW_OK;
#include "tmp_resolve.h"
ANN static Exp uncurry(const Env env, const Exp_Binary *bin) {
- const Stmt stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, struct Stmt_, 0);
+ const Stmt* stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, struct Stmt_, 0);
const Exp ecall = stmt->d.stmt_exp.val;
const Exp_Call *call = &ecall->d.exp_call;
Exp args = call->args;
static OP_CHECK(opck_func_call) {
Exp_Binary *bin = (Exp_Binary *)data;
if(!strncmp(bin->rhs->type->name, "partial:", 8)) {
- const Stmt stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, struct Stmt_, 0);
+ const Stmt* stmt = mp_vector_at(bin->rhs->type->info->func->def->d.code, struct Stmt_, 0);
const Exp_Call *call = &stmt->d.stmt_exp.val->d.exp_call;
DECL_ON(const Exp, args, = uncurry(env, bin));
return mk_call(env, exp_self(bin), call->func, args);
static OP_CHECK(opck_sift) {
Exp_Binary *bin = (Exp_Binary*)data;
const Exp lhs = bin->lhs;
- Stmt stmt = mp_vector_at(lhs->d.exp_unary.code, struct Stmt_, 0);
- Stmt fst = mp_vector_at(stmt->d.stmt_flow.body->d.stmt_code.stmt_list, struct Stmt_, 0);
+ Stmt* stmt = mp_vector_at(lhs->d.exp_unary.code, struct Stmt_, 0);
+ Stmt* fst = mp_vector_at(stmt->d.stmt_flow.body->d.stmt_code.stmt_list, struct Stmt_, 0);
const Symbol chuck = insert_symbol(env->gwion->st, "=>");
Exp next = new_exp_binary(env->gwion->mp, fst->d.stmt_exp.val, chuck, bin->rhs, bin->rhs->loc);
CHECK_BN(traverse_exp(env, next)); // how do we free it?
Stmt_List slist = new_mp_vector(mp, struct Stmt_, 2);
mp_vector_set(slist, struct Stmt_, 0, one);
mp_vector_set(slist, struct Stmt_, 1, two);
- const Stmt stmt = new_stmt_code(mp, slist, func->loc);
+ Stmt* stmt = new_stmt_code(mp, slist, func->loc);
const Exp cond = new_prim_id(mp, insert_symbol(env->gwion->st, "true"), func->loc);
check_exp(env, cond);
return GW_OK;
}
-ANN static inline m_bool _check_breaks(const Env env, const Stmt b) {
+ANN static inline m_bool _check_breaks(const Env env, Stmt* b) {
RET_NSPC(check_stmt(env, b))}
-ANN static m_bool check_breaks(const Env env, const Stmt a, const Stmt b) {
+ANN static m_bool check_breaks(const Env env, Stmt* a, Stmt* b) {
vector_add(&env->scope->breaks, (vtype)a);
const m_bool ret = _check_breaks(env, b);
vector_pop(&env->scope->breaks);
return ret;
}
-ANN static m_bool check_conts(const Env env, const Stmt a, const Stmt b) {
+ANN static m_bool check_conts(const Env env, Stmt* a, Stmt* b) {
vector_add(&env->scope->conts, (vtype)a);
CHECK_BB(check_breaks(env, a, b));
vector_pop(&env->scope->conts);
}
#define describe_check_stmt_stack(stack, name) \
- ANN static m_bool check_stmt_##name(const Env env, const Stmt stmt) { \
+ ANN static m_bool check_stmt_##name(const Env env, const Stmt* stmt) { \
if (!vector_size(&env->scope->stack)) \
ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")) \
return GW_OK; \
ANN static m_bool case_loop(const Env env, const Stmt_Match stmt) {
for(m_uint i = 0; i < stmt->list->len; i++) {
- const Stmt s = mp_vector_at(stmt->list, struct Stmt_, i);
+ Stmt* s = mp_vector_at(stmt->list, struct Stmt_, i);
CHECK_BB(check_stmt_case(env, &s->d.stmt_match));
}
return GW_OK;
#define check_stmt_spread dummy_func
DECL_STMT_FUNC(check, m_bool, Env)
-ANN m_bool check_stmt(const Env env, const Stmt stmt) {
+ANN m_bool check_stmt(const Env env, Stmt* stmt) {
return check_stmt_func[stmt->stmt_type](env, &stmt->d);
}
ANN m_bool check_stmt_list(const Env env, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- const Stmt s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, struct Stmt_, i);
CHECK_BB(check_stmt(env, s));
}
return GW_OK;
if (section->section_type == ae_section_stmt) {
Stmt_List l = section->d.stmt_list;
for(m_uint i = 0; i < l->len; i++) {
- const Stmt stmt = mp_vector_at(l, struct Stmt_, i);
+ const Stmt* stmt = mp_vector_at(l, struct Stmt_, i);
if (stmt->stmt_type == ae_stmt_exp) {
CHECK_BB(traverse_exp(env, stmt->d.stmt_exp.val));
Var_Decl vd = stmt->d.stmt_exp.val->d.exp_decl.var.vd;
if(strcmp(s_name(f->base->tag.sym), "@ctor"))return false;
Stmt_List l = f->d.code;
for(m_uint i = 0; i < l->len; i++) {
- const Stmt stmt = mp_vector_at(l, struct Stmt_, i);
+ const Stmt* stmt = mp_vector_at(l, struct Stmt_, i);
if (stmt->stmt_type == ae_stmt_pp) continue;
if (stmt->stmt_type == ae_stmt_exp) {
const Exp exp = stmt->d.stmt_exp.val;
ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- const Stmt stmt = mp_vector_at(l, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(l, struct Stmt_, i);
if (stmt->stmt_type == ae_stmt_pp) {
if (stmt->d.stmt_pp.pp_type == ae_pp_include)
env->name = stmt->d.stmt_pp.data;
} else if (section->section_type == ae_section_stmt) {
Stmt_List list = section->d.stmt_list;
for(uint32_t i = 0; i < list->len; i++) {
- Stmt stmt = mp_vector_at(list, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(list, struct Stmt_, i);
if(stmt->d.stmt_exp.val->exp_type != ae_exp_decl)
ERR_B(stmt->loc, "trait can only contains variable requests and functions");
}
#include "import.h"
ANN static m_bool scan1_stmt_list(const Env env, Stmt_List list);
-ANN static m_bool scan1_stmt(const Env env, Stmt stmt);
+ANN static m_bool scan1_stmt(const Env env, Stmt* stmt);
ANN static inline m_bool type_cyclic(const Env env, const Type t,
const Type_Decl *td) {
if (stmt->where) CHECK_BB(scan1_stmt(env, stmt->where));
Stmt_List l = stmt->list;
for(m_uint i = 0; i < l->len; i++) {
- const Stmt s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, struct Stmt_, i);
CHECK_BB(scan1_stmt_match_case(env, &s->d.stmt_match));
}
return GW_OK;
scan1_exp(env, stmt->cond) < 0 ||
scan1_stmt(env, stmt->body) < 0) ? 1 : -1)
-ANN static inline bool if_stmt_is_return(const Stmt stmt) {
+ANN static inline bool if_stmt_is_return(Stmt* stmt) {
if (stmt->stmt_type == ae_stmt_return) return true;
if (stmt->stmt_type == ae_stmt_code) {
if (mp_vector_len(stmt->d.stmt_code.stmt_list)) {
- Stmt s = mp_vector_back(stmt->d.stmt_code.stmt_list, struct Stmt_);
+ Stmt* s = mp_vector_back(stmt->d.stmt_code.stmt_list, struct Stmt_);
if (s->stmt_type == ae_stmt_return) return true;
}
}
DECL_STMT_FUNC(scan1, m_bool, Env)
-ANN static inline m_bool scan1_stmt(const Env env, const Stmt stmt) {
+ANN static inline m_bool scan1_stmt(const Env env, Stmt* stmt) {
return scan1_stmt_func[stmt->stmt_type](env, &stmt->d);
}
-ANN static inline bool end_flow(Stmt s) {
+ANN static inline bool end_flow(Stmt* s) {
const ae_stmt_t t = s->stmt_type;
return t == ae_stmt_continue ||
t == ae_stmt_break ||
ANN static void dead_code(const Env env, Stmt_List l, uint32_t len) {
for(uint32_t i = len; i < l->len; i++) {
- const Stmt s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, struct Stmt_, i);
free_stmt(env->gwion->mp, s);
}
l->len = len;
ANN static m_bool scan1_stmt_list(const Env env, Stmt_List l) {
uint32_t i;
for(i = 0; i < l->len; i++) {
- const Stmt s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, struct Stmt_, i);
CHECK_BB(scan1_stmt(env, s));
if(end_flow(s)) break;
}
if(section.section_type == ae_section_stmt) {
Stmt_List list = section.d.stmt_list;
for(uint32_t j = 0; j < list->len; j++) {
- Stmt stmt = mp_vector_at(list, struct Stmt_, j);
+ Stmt* stmt = mp_vector_at(list, struct Stmt_, j);
mp_vector_add(mp, &ctor, struct Stmt_, *stmt);
}
} else mp_vector_add(mp, &body, Section, section);
#include "spread.h"
#include "closure.h"
-ANN static m_bool scan2_stmt(const Env, const Stmt);
+ANN static m_bool scan2_stmt(const Env, Stmt*);
ANN static m_bool scan2_stmt_list(const Env, Stmt_List);
ANN static inline m_bool ensure_scan2(const Env env, const Type t) {
if (stmt->where) CHECK_BB(scan2_stmt(env, stmt->where));
Stmt_List l = stmt->list;
for(m_uint i = 0; i < l->len; i++) {
- const Stmt s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, struct Stmt_, i);
CHECK_BB(scan2_stmt_match_case(env, &s->d.stmt_match));
}
return GW_OK;
DECL_STMT_FUNC(scan2, m_bool, Env)
-ANN static m_bool scan2_stmt(const Env env, const Stmt stmt) {
+ANN static m_bool scan2_stmt(const Env env, Stmt* stmt) {
return scan2_stmt_func[stmt->stmt_type](env, &stmt->d);
}
ANN static m_bool scan2_stmt_list(const Env env, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- const Stmt s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, struct Stmt_, i);
CHECK_BB(scan2_stmt(env, s));
}
return GW_OK;