-Subproject commit cc1bdcbd2b43cc3eb08c80de725dbdb1b94cb3ef
+Subproject commit a83bf5dab86a2a9c682bb93fa6c85f95f779ca68
-Subproject commit b9bb73a25ec8c235c6c6ba9bb9711104f01bc573
+Subproject commit 379c80d6914e8e204739d49f97c45cfe386b749f
ANN static void clean_case_list(Clean *a, Stmt_List b) {
for(m_uint i = 0; i < b->len; i++) {
- Stmt* stmt = mp_vector_at(b, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(b, Stmt, i);
clean_stmt_case(a, &stmt->d.stmt_match);
}
}
ANN static void clean_stmt_list(Clean *a, Stmt_List b) {
for(m_uint i = 0; i < b->len; i++) {
- Stmt* stmt = mp_vector_at(b, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(b, Stmt, i);
clean_stmt(a, stmt);
}
}
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), Stmt, 0);
const Func f = stmt->d.stmt_exp.val->d.exp_call.func->type->info->func;
CHECK_OB(emit_ensure_func(emit, f));
}
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, Stmt, i);
CHECK_BB(emit_stmt_match_case(emit, &stmt->d.stmt_match));
}
return GW_OK;
ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- Stmt* stmt = mp_vector_at(l, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(l, Stmt, i);
CHECK_BB(emit_stmt(emit, stmt));
}
return GW_OK;
}
ANN static m_int gwi_item_tmpl(const Gwi gwi) {
- Stmt_List slist = new_mp_vector(gwi->gwion->mp, struct Stmt_, 1);
- mp_vector_set(slist, struct Stmt_, 0, ((struct Stmt_) {
+ Stmt_List slist = new_mp_vector(gwi->gwion->mp, Stmt, 1);
+ mp_vector_set(slist, Stmt, 0, ((Stmt) {
.stmt_type = ae_stmt_exp,
.d = { .stmt_exp = { .val = gwi->ck->exp } },
.loc = gwi->loc
#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, 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, 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);
new_prim_id(env->gwion->mp, larg1->var.vd.tag.sym, impl->e->loc);
const Exp bin = new_exp_binary(env->gwion->mp, lhs, impl->e->d.prim.d.var,
rhs, impl->e->loc);
- Stmt_List code = new_mp_vector(env->gwion->mp, struct Stmt_, 1);
- mp_vector_set(code, struct Stmt_, 0,
- ((struct Stmt_) {
+ Stmt_List code = new_mp_vector(env->gwion->mp, Stmt, 1);
+ mp_vector_set(code, Stmt, 0,
+ ((Stmt) {
.stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = bin }},
.loc = impl->e->loc
}));
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, Stmt, 0);
+ Stmt* fst = mp_vector_at(stmt->d.stmt_flow.body->d.stmt_code.stmt_list, 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?
func->d.exp_binary.lhs = call;
func->d.exp_binary.op = chuck;
CHECK_BN(traverse_exp(env, func));
- struct Stmt_ one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->loc };
+ Stmt one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->loc };
Exp samp = new_prim_id(mp, insert_symbol(env->gwion->st, "samp"), func->loc);
Exp _now = new_prim_id(mp, insert_symbol(env->gwion->st, "now"), func->loc);
Exp time = new_exp_binary(mp, samp, chuck, _now, func->loc);
CHECK_BN(traverse_exp(env, time));
- struct Stmt_ two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->loc };
+ Stmt two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->loc };
free_exp(mp, bin->lhs);
free_exp(mp, bin->rhs);
- 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);
+ Stmt_List slist = new_mp_vector(mp, Stmt, 2);
+ mp_vector_set(slist, Stmt, 0, one);
+ mp_vector_set(slist, Stmt, 1, two);
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);
- const Stmt_List code = new_mp_vector(mp, struct Stmt_, 1);
- mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) {
+ const Stmt_List code = new_mp_vector(mp, Stmt, 1);
+ mp_vector_set(code, Stmt, 0, ((Stmt) {
.stmt_type = ae_stmt_while,
.d = {
.stmt_flow = {
const Exp when = tdef->when;
tdef->when = NULL;
when->next = helper;
- Stmt_List code = new_mp_vector(env->gwion->mp, struct Stmt_, 2);
- mp_vector_set(code, struct Stmt_, 0,
- ((struct Stmt_) {
+ Stmt_List code = new_mp_vector(env->gwion->mp, Stmt, 2);
+ mp_vector_set(code, Stmt, 0,
+ ((Stmt) {
.stmt_type = ae_stmt_exp, .d = { .stmt_exp = { .val = when }},
.loc = when->loc
}));
- mp_vector_set(code, struct Stmt_, 1,
- ((struct Stmt_) {
+ mp_vector_set(code, Stmt, 1,
+ ((Stmt) {
.stmt_type = ae_stmt_exp,
.loc = when->loc
}));
// casting while defining it*
const Exp ret_id = new_prim_id(env->gwion->mp, insert_symbol("self"), when->loc);
ret_id->d.prim.value = new_value(env, tdef->type, "self", tdef->tag.loc);
- struct Stmt_ ret = {
+ Stmt ret = {
.stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = ret_id }},
.loc = when->loc
};
- mp_vector_set(fdef->d.code, struct Stmt_, 1, ret);
+ mp_vector_set(fdef->d.code, Stmt, 1, ret);
ret_id->type = tdef->type;
}
if (tflag(tdef->type, tflag_cdef))
ANN static m_bool case_loop(const Env env, const Stmt_Match stmt) {
for(m_uint i = 0; i < stmt->list->len; i++) {
- Stmt* s = mp_vector_at(stmt->list, struct Stmt_, i);
+ Stmt* s = mp_vector_at(stmt->list, Stmt, i);
CHECK_BB(check_stmt_case(env, &s->d.stmt_match));
}
return GW_OK;
ANN m_bool check_stmt_list(const Env env, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- Stmt* s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, 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, 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, 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;
const uint32_t max, const ae_stmt_t type) {
const Exp arg = mk_args(p, lst, max);
const Exp call = new_exp_call(p, func, arg, func->loc);
- Stmt_List code = new_mp_vector(p, struct Stmt_, 1);
- mp_vector_set(code, struct Stmt_, 0,
- ((struct Stmt_) {
+ Stmt_List code = new_mp_vector(p, Stmt, 1);
+ mp_vector_set(code, Stmt, 0,
+ ((Stmt) {
.stmt_type = type, .d = { .stmt_exp = { .val = call }},
.loc = func->loc
}));
ANN static Stmt_List partial_code(const Env env, Arg_List args, const Exp efun, const Exp earg) {
const Exp arg = partial_call(env, args, earg);
const Exp exp = new_exp_call(env->gwion->mp, efun, arg, efun->loc);
- Stmt_List code = new_mp_vector(env->gwion->mp, struct Stmt_, 1);
- mp_vector_set(code, struct Stmt_, 0, ((struct Stmt_) {
+ Stmt_List code = new_mp_vector(env->gwion->mp, Stmt, 1);
+ mp_vector_set(code, Stmt, 0, ((Stmt) {
.stmt_type = ae_stmt_return,
.d = { .stmt_exp = { .val = exp }}
}));
ANN static m_bool scan0_stmt_list(const Env env, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- Stmt* stmt = mp_vector_at(l, struct Stmt_, i);
+ Stmt* stmt = mp_vector_at(l, 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, 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");
}
if (stmt->where) CHECK_BB(scan1_stmt(env, stmt->where));
Stmt_List l = stmt->list;
for(m_uint i = 0; i < l->len; i++) {
- Stmt* s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, Stmt, i);
CHECK_BB(scan1_stmt_match_case(env, &s->d.stmt_match));
}
return GW_OK;
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, Stmt);
if (s->stmt_type == ae_stmt_return) return true;
}
}
ANN static void dead_code(const Env env, Stmt_List l, uint32_t len) {
for(uint32_t i = len; i < l->len; i++) {
- Stmt* s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, 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++) {
- Stmt* s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, Stmt, i);
CHECK_BB(scan1_stmt(env, s));
if(end_flow(s)) break;
}
isa(cdef->base.type, env->gwion->type[et_dict]) < 0) {
MemPool mp = env->gwion->mp;
Ast base = cdef->body;
- Stmt_List ctor = new_mp_vector(mp, struct Stmt_, 0);
+ Stmt_List ctor = new_mp_vector(mp, Stmt, 0);
Ast body = new_mp_vector(mp, Section, 1); // room for ctor
for(uint32_t i = 0; i < base->len; i++) {
Section section = *mp_vector_at(base, Section, i);
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);
- mp_vector_add(mp, &ctor, struct Stmt_, *stmt);
+ Stmt* stmt = mp_vector_at(list, Stmt, j);
+ mp_vector_add(mp, &ctor, Stmt, *stmt);
}
} else mp_vector_add(mp, &body, Section, section);
}
if (stmt->where) CHECK_BB(scan2_stmt(env, stmt->where));
Stmt_List l = stmt->list;
for(m_uint i = 0; i < l->len; i++) {
- Stmt* s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, Stmt, i);
CHECK_BB(scan2_stmt_match_case(env, &s->d.stmt_match));
}
return GW_OK;
ANN static m_bool scan2_stmt_list(const Env env, Stmt_List l) {
for(m_uint i = 0; i < l->len; i++) {
- Stmt* s = mp_vector_at(l, struct Stmt_, i);
+ Stmt* s = mp_vector_at(l, Stmt, i);
CHECK_BB(scan2_stmt(env, s));
}
return GW_OK;
Stmt_List list = section.d.stmt_list;
Stmt_List acc = NULL;
for(uint32_t j = 0; j < list->len; j++) {
- const struct Stmt_ stmt = *mp_vector_at(list, struct Stmt_, j);
+ const Stmt stmt = *mp_vector_at(list, Stmt, j);
if(stmt.stmt_type == ae_stmt_spread) {
if(acc) {
mp_vector_add(env->gwion->mp, &new_body, Section, MK_SECTION(stmt, stmt_list, acc));
}
} else {
if(!acc)
- acc = new_mp_vector(env->gwion->mp, struct Stmt_, 0);
- mp_vector_add(env->gwion->mp, &acc, struct Stmt_, stmt);
+ acc = new_mp_vector(env->gwion->mp, Stmt, 0);
+ mp_vector_add(env->gwion->mp, &acc, Stmt, stmt);
}
}
if(acc) {
ANN Stmt_List spread_func(const Env env, const Stmt_List body) {
const Ast extend = env->context->extend;
- Ast new_body = new_mp_vector(env->gwion->mp, struct Stmt_, 0);
+ Ast new_body = new_mp_vector(env->gwion->mp, Stmt, 0);
uint32_t offset = 0;
for(uint32_t i = 0; i < body->len; i++) {
- const struct Stmt_ stmt = *mp_vector_at(body, struct Stmt_, i);
+ const Stmt stmt = *mp_vector_at(body, Stmt, i);
if(stmt.stmt_type == ae_stmt_spread) {
for(; offset < extend->len; offset++) {
const Section section = *mp_vector_at(extend, Section, offset);
ERR_O(stmt.loc, "invalid section in variadic func");
const Stmt_List list = section.d.stmt_list;
for(uint32_t j = 0; j < list->len; j++) {
- const struct Stmt_ stmt = *mp_vector_at(list, struct Stmt_, j);
- mp_vector_add(env->gwion->mp, &new_body, struct Stmt_, stmt);
+ const Stmt stmt = *mp_vector_at(list, Stmt, j);
+ mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt);
}
break;
}
} else {
- mp_vector_add(env->gwion->mp, &new_body, struct Stmt_, stmt);
+ mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt);
}
}
free_mp_vector(env->gwion->mp, Stmt_List, body);