ANN Type find_type(const Env, Type_Decl*);
ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos);
ANN m_bool traverse_func_template(const Env, const Func_Def);
-ANN2(1,3) void env_err(const Env, const loc_t pos, const m_str fmt, ...);
+ANN void env_err(const Env, const loc_t pos, const m_str fmt, ...);
+ANN void env_warn(const Env, const loc_t pos, const m_str fmt, ...);
ANN Value global_string(const Env env, const m_str str);
ANN void release_ctx(struct Env_Scope_ *a, struct Gwion_* gwion);
#endif
set_vflag(v, vflag_direct);// mpalloc
instr->m_val = (m_uint)v->d.ptr;
instr->m_val2 = v->type->size;
- if(is_obj && (is_array || !is_ref)) {
+ if(is_obj && (is_array || !is_ref || emit_addr)) {
const Instr assign = emit_add_instr(emit, Assign);
assign->m_val = emit_var;
/*
const uint ref = GET_FLAG(decl->td, late) || type_ref(decl->type);
Var_Decl_List list = decl->list;
do {
+ const Value v = list->self->value;
+ const uint r = ref || GET_FLAG(v, late);
if(GET_FLAG(decl->td, static))
- CHECK_BB(emit_exp_decl_static(emit, decl, list->self, ref, var))
+ CHECK_BB(emit_exp_decl_static(emit, decl, list->self, r, var))
else if(!global)
- CHECK_BB(emit_exp_decl_non_static(emit, decl, list->self, ref, var))
+ CHECK_BB(emit_exp_decl_non_static(emit, decl, list->self, r, var))
else
- CHECK_BB(emit_exp_decl_global(emit, decl, list->self, ref, var))
+ CHECK_BB(emit_exp_decl_global(emit, decl, list->self, r, var))
+ if(GET_FLAG(v->type, abstract) && !GET_FLAG(decl->td, late) && GET_FLAG(v, late)) {
+ env_warn(emit->env, decl->td->pos, _("Type '%s' is abstract, use late"), v->type->name);
+ }
} while((list = list->next));
return GW_OK;
}
const m_bool global = GET_FLAG(decl->td, global);
const m_uint scope = !global ? emit->env->scope->depth : emit_push_global(emit);
const m_bool ret = emit_decl(emit, decl);
+
if(global)
emit_pop(emit, scope);
return ret;
gw_err(_("in function: '%s'\n"), env->func->name);
}
+ANN static void env_xxx(const Env env, const loc_t pos, const m_str fmt, va_list arg) {
+#ifndef __FUZZING__
+ env_header(env);
+ loc_header(pos, env->name);
+ vfprintf(stderr, fmt, arg);
+ fprintf(stderr, "\n");
+ loc_err(pos, env->name);
+#endif
+}
+
+ANN void env_warn(const Env env, const loc_t pos, const m_str fmt, ...) {
+#ifndef __FUZZING__
+ va_list arg;
+ va_start(arg, fmt);
+ env_xxx(env, pos, fmt, arg);
+ va_end(arg);
+#endif
+}
+
ANN void env_err(const Env env, const loc_t pos, const m_str fmt, ...) {
if(env->context && env->context->error)
return;
#ifndef __FUZZING__
- env_header(env);
- loc_header(pos, env->name);
va_list arg;
va_start(arg, fmt);
- vfprintf(stderr, fmt, arg);
+ env_xxx(env, pos, fmt, arg);
va_end(arg);
- fprintf(stderr, "\n");
- loc_err(pos, env->name);
#endif
if(env->context)
env->context->error = 1;
if(opck_rassign(env, data) == env->gwion->type[et_error])
return env->gwion->type[et_error];
if(bin->rhs->exp_type == ae_exp_decl)
- SET_FLAG(bin->rhs->d.exp_decl.td, late); // ???
+ SET_FLAG(bin->rhs->d.exp_decl.list->self->value, late);
exp_setvar(bin->rhs, 1);
CHECK_BN(isa(bin->lhs->type , bin->rhs->type))
return bin->rhs->type;
}
ANN static void set_late(const Gwion gwion, const Exp_Decl *decl, const Value v) {
- if(!exp_getvar(exp_self(decl)) &&
- (GET_FLAG(decl->td, late) || is_fptr(gwion, v->type))) {
- SET_FLAG(decl->td, late);
+ if(!exp_getvar(exp_self(decl)) && (GET_FLAG(v->type, abstract) ||
+ GET_FLAG(decl->td, late) || is_fptr(gwion, v->type))) {
SET_FLAG(v, late);
} else
UNSET_FLAG(v, late);
if(var->array->exp)
CHECK_BB(scan1_exp(env, var->array->exp))
t = array_type(env, decl->type, var->array->depth);
- } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, late)) {
- // ERR_B(var->pos, "Type '%s' is abstract, use late", t->name)
- SET_FLAG(decl->td, late);
}
const Value v = var->value = var->value ?: new_value(env->gwion->mp, t, s_name(var->xid));
// rewrite logic
env->class_def->size += t->size;
}
nspc_add_value(env->curr, var->xid, v);
- v->flag |= decl->td->flag;
+ if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, late))
+ SET_FLAG(v, late);
v->type = t;
if(array_ref(var->array))
SET_FLAG(decl->td, late);
+ v->flag |= decl->td->flag;
if(env->class_def) {
if(env->class_def->info->tuple)
tuple_contains(env, v);
CHECK_BB(env_storage(env, decl->td->flag, exp_self(decl)->pos))
((Exp_Decl*)decl)->type = scan1_exp_decl_type(env, (Exp_Decl*)decl);
if(array_ref(decl->td->array))
- SET_FLAG(decl->td, late);
+ SET_FLAG(decl->td, late);
CHECK_OB(decl->type)
const m_bool global = GET_FLAG(decl->td, global);
if(global) {