-Subproject commit 56d8b92b822a2d2891e4d4cea954936538698a28
+Subproject commit aa633ad736df71d78d94346d79f0ed61bf5ef0d3
vector_add(v, (vtype)emit_add_instr(emit, Goto));
else if (stmt->idx) {
if (emit_jump_index(emit, v, stmt->idx) < 0)
- ERR_B(stmt_self(stmt)->pos, _("too many jumps required."))
+ ERR_B(stmt_self(stmt)->loc, _("too many jumps required."))
}
return GW_OK;
}
mp_vector_set(slist, struct Stmt_, 0, ((struct Stmt_) {
.stmt_type = ae_stmt_exp,
.d = { .stmt_exp = { .val = gwi->ck->exp } },
- .pos = gwi->loc
+ .loc = gwi->loc
}));
Section section = (Section) {
.section_type = ae_section_stmt,
mp_vector_set(code, struct Stmt_, 0,
((struct Stmt_) {
.stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = bin }},
- .pos = impl->e->pos
+ .loc = impl->e->pos
}));
const Func_Def def = new_func_def(env->gwion->mp, base, code);
def->base->tag.sym = impl->e->d.prim.d.var;
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, .pos = func->pos };
+ struct Stmt_ one = { .d = { .stmt_exp = { .val = func }}, .stmt_type = ae_stmt_exp, .loc = func->pos };
Exp samp = new_prim_id(mp, insert_symbol(env->gwion->st, "samp"), func->pos);
Exp _now = new_prim_id(mp, insert_symbol(env->gwion->st, "now"), func->pos);
Exp time = new_exp_binary(mp, samp, chuck, _now, func->pos);
CHECK_BN(traverse_exp(env, time));
- struct Stmt_ two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .pos = func->pos };
+ struct Stmt_ two = { .d = { .stmt_exp = { .val = time }}, .stmt_type = ae_stmt_exp, .loc = func->pos };
free_exp(mp, bin->lhs);
free_exp(mp, bin->rhs);
.body = stmt
}
},
- .pos = func->pos
+ .loc = func->pos
}));
exp->exp_type = ae_exp_unary;
exp->d.exp_unary.unary_type = unary_code;
mp_vector_set(code, struct Stmt_, 0,
((struct Stmt_) {
.stmt_type = ae_stmt_exp, .d = { .stmt_exp = { .val = when }},
- .pos = when->pos
+ .loc = when->pos
}));
mp_vector_set(code, struct Stmt_, 1,
((struct Stmt_) {
.stmt_type = ae_stmt_exp,
- .pos = when->pos
+ .loc = when->pos
}));
const Func_Def fdef = new_func_def(env->gwion->mp, fb, code);
tdef->when_def = fdef;
ret_id->d.prim.value = new_value(env, tdef->type, "self", tdef->tag.loc);
struct Stmt_ ret = {
.stmt_type = ae_stmt_return, .d = { .stmt_exp = { .val = ret_id }},
- .pos = when->pos
+ .loc = when->pos
};
mp_vector_set(fdef->d.code, struct Stmt_, 1, ret);
ret_id->type = tdef->type;
ANN static inline m_bool for_empty(const Env env, const Stmt_For stmt) {
if (!stmt->c2 || !stmt->c2->d.stmt_exp.val)
- ERR_B(stmt_self(stmt)->pos,
+ ERR_B(stmt_self(stmt)->loc,
_("empty for loop condition..."
"...(note: explicitly use 'true' if it's the intent)"
"...(e.g., 'for(; true;){{ /*...*/ }')"))
ANN static m_bool check_stmt_return(const Env env, const Stmt_Exp stmt) {
if (is_new(env->func->def)) {
if(stmt->val)
- ERR_B(stmt_self(stmt)->pos,
+ ERR_B(stmt_self(stmt)->loc,
_("'return' statement inside constructor function should have no expression"))
return GW_OK;
}
Arg *arg = mp_vector_at(env->func->def->base->args, Arg, 0);
if (env->func->def->base->tag.sym == insert_symbol("@implicit") &&
ret_type == arg->type)
- ERR_B(stmt_self(stmt)->pos,
+ ERR_B(stmt_self(stmt)->loc,
_("can't use implicit casting while defining it"))
if (check_implicit(env, stmt->val, env->func->def->base->ret_type) > 0)
return GW_OK;
- ERR_B(stmt_self(stmt)->pos,
+ ERR_B(stmt_self(stmt)->loc,
_("invalid return type: got '%s', expected '%s'"), ret_type->name,
env->func->def->base->ret_type->name)
}
if (isa(env->func->def->base->ret_type, env->gwion->type[et_void]) > 0)
return GW_OK;
- ERR_B(stmt_self(stmt)->pos, _("missing value for return statement"))
+ ERR_B(stmt_self(stmt)->loc, _("missing value for return statement"))
}
#define describe_check_stmt_stack(stack, name) \
ANN static m_bool check_stmt_##name(const Env env, const Stmt stmt) { \
if (!vector_size(&env->scope->stack)) \
- ERR_B(stmt->pos, _("'" #name "' found outside of for/while/until...")) \
+ ERR_B(stmt->loc, _("'" #name "' found outside of for/while/until...")) \
return GW_OK; \
}
describe_check_stmt_stack(conts, continue);
!strncmp(stmt->data, "memoize", strlen("memoize")))
env->func->memoize = strtol(stmt->data + 7, NULL, 10);
else if(stmt->pp_type == ae_pp_locale) {
- const loc_t loc = stmt_self(stmt)->pos;
+ const loc_t loc = stmt_self(stmt)->loc;
const Exp id = new_prim_id(env->gwion->mp, stmt->xid, loc);
const Exp arg = new_prim_id(env->gwion->mp, insert_symbol("_"), loc);
arg->next = stmt->exp;
mp_vector_set(code, struct Stmt_, 0,
((struct Stmt_) {
.stmt_type = type, .d = { .stmt_exp = { .val = call }},
- .pos = func->pos
+ .loc = func->pos
}));
return code;
}
if (stmt->d.stmt_pp.pp_type == ae_pp_include)
env->name = stmt->d.stmt_pp.data;
else if (stmt->d.stmt_pp.pp_type == ae_pp_import)
- CHECK_BB(plugin_ini(env->gwion, stmt->d.stmt_pp.data, stmt->pos));
+ CHECK_BB(plugin_ini(env->gwion, stmt->d.stmt_pp.data, stmt->loc));
} else if (stmt->stmt_type == ae_stmt_spread) {
if(!spreadable(env))
- ERR_B(stmt->pos, "spread statement outside of variadic environment");
+ ERR_B(stmt->loc, "spread statement outside of variadic environment");
if(!env->context->extend)
env->context->extend = new_mp_vector(env->gwion->mp, Section, 0);
CHECK_BB(spread_tmpl(env, &stmt->d.stmt_spread));
for(uint32_t i = 0; i < list->len; i++) {
Stmt stmt = mp_vector_at(list, struct Stmt_, i);
if(stmt->d.stmt_exp.val->exp_type != ae_exp_decl)
- ERR_B(stmt->pos, "trait can only contains variable requests and functions");
+ ERR_B(stmt->loc, "trait can only contains variable requests and functions");
}
} else
ERR_B(pdef->tag.loc, "invalid section for trait definition");
ANN static inline m_bool stmt_each_defined(const restrict Env env,
const Stmt_Each stmt) {
if (nspc_lookup_value1(env->curr, stmt->tag.sym))
- ERR_B(stmt_self(stmt)->pos, _("foreach value '%s' is already defined"),
+ ERR_B(stmt_self(stmt)->loc, _("foreach value '%s' is already defined"),
s_name(stmt->tag.sym))
if (stmt->idx && nspc_lookup_value1(env->curr, stmt->idx->var.tag.sym))
ERR_B(stmt->idx->var.tag.loc, _("foreach index '%s' is already defined"),
ANN static m_bool scan1_stmt_return(const Env env, const Stmt_Exp stmt) {
if (!env->func)
- ERR_B(stmt_self(stmt)->pos,
+ ERR_B(stmt_self(stmt)->loc,
_("'return' statement found outside function definition"))
if (env->scope->depth == 1) env->func->memoize = 1;
if(stmt->val) CHECK_BB(scan1_exp(env, stmt->val));
if (stmt->pp_type == ae_pp_include) env->name = stmt->data;
if (stmt->pp_type == ae_pp_pragma && !strcmp(stmt->data, "packed")) {
if(env->class_def && !tflag(env->class_def, tflag_union)) set_tflag(env->class_def, tflag_packed);
- else ERR_B(stmt_self(stmt)->pos, "`packed` pragma outside of {G+}class{0} or {G+}struct{0} declaration");
+ else ERR_B(stmt_self(stmt)->loc, "`packed` pragma outside of {G+}class{0} or {G+}struct{0} declaration");
}
return GW_OK;
}
}
ANN static m_bool scan1_stmt_spread(const Env env, const Spread_Def spread) {
- ERR_B(stmt_self(spread)->pos, "spread statement outside of variadic environment");
+ ERR_B(stmt_self(spread)->loc, "spread statement outside of variadic environment");
}
DECL_STMT_FUNC(scan1, m_bool, Env)
if(section.section_type == ae_section_stmt && !section.d.stmt_list)
break;
if(section.section_type != ae_section_stmt)
- ERR_O(stmt.pos, "invalid section in variadic func");
+ 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);