}
}
const Instr instr = emit_kind(emit, v->type->size, emit_addr, exec);
- instr->m_val = v->from->offset;
- instr->m_val2 = v->type->size;
+ if(emit_addr || !GET_FLAG(v, member))
+ instr->m_val = v->from->offset;
if(is_obj && (is_array || !is_ref)) {
emit_add_instr(emit, Assign);
const size_t missing_depth = type->array_depth - (array ? array->depth : 0);
static OP_EMIT(opem_array_slice) {
const Exp exp = (Exp)data;
Exp_Slice *range = &exp->d.exp_slice;
+ if(!GET_FLAG(exp->type, nonnull))
+ emit_add_instr(emit, GWOP_EXCEPT);
emit_add_instr(emit, ArraySlice);
const Instr instr = emit_add_instr(emit, ArrayInit);
instr->m_val = (m_uint)range->base->type;
polar_def2_r(Div, /, -)
static GACK(gack_complex) {
- printf("#(%.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT));
+ gw_out("#(%.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT));
}
static GACK(gack_polar) {
- printf("%%(%.4f, %.4f*pi)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT) / M_PI);
+ gw_out("%%(%.4f, %.4f*pi)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT) / M_PI);
}
EQUALITY_OPER(complex, SZ_COMPLEX)
#include "specialid.h"
static GACK(gack_class) {
- printf("class(%s)", actual_type(shred->info->vm->gwion, t)->name);
+ gw_out("class(%s)", actual_type(shred->info->vm->gwion, t)->name);
}
static GACK(gack_function) {
- printf("%s", t->name);
+ gw_out("%s", t->name);
}
static GACK(gack_fptr) {
const VM_Code code = *(VM_Code*)VALUE;
if(code)
- printf("%s", code->name);
+ gw_out("%s", code->name);
else
- printf("%s", t->name);
+ gw_out("%s", t->name);
}
static GACK(gack_void) {
- printf("(void)");
+ gw_out("(void)");
}
static GACK(gack_int) {
- printf("%"INT_F, *(m_uint*)VALUE);
+ gw_out("%"INT_F, *(m_uint*)VALUE);
}
static GACK(gack_char) {
- printf("%c", *(char*)VALUE);
+ gw_out("%c", *(char*)VALUE);
}
static GACK(gack_float) {
- printf("%.4f", *(m_float*)VALUE);
+ gw_out("%.4f", *(m_float*)VALUE);
}
#define mk_class_instr(op, arg0, arg1, ...) \
ERR_B(exp_self(l)->pos, _("argument number does not match for lambda"))
l->def->flag = def->flag;
l->def->base->td = cpy_type_decl(env->gwion->mp, def->base->td);
-// l->def = new_func_def(env->gwion->mp,
-// new_func_base(env->gwion->mp, def->base->td, l->name, l->args),
-// l->code, def->flag, loc_cpy(env->gwion->mp, def->pos));
CHECK_BB(traverse_func_def(env, l->def))
arg = l->def->base->args;
while(arg) {
}
static GACK(gack_object) {
- printf("%p", *(M_Object*)VALUE);
+ gw_out("%p", *(M_Object*)VALUE);
}
GWION_IMPORT(object) {
static INSTR(IntRange) {
shred->reg -= SZ_INT *2;
- const m_int start = *(m_uint*)REG(0);
- const m_int end = *(m_uint*)REG(SZ_INT);
+ const m_int start = *(m_int*)REG(0);
+ const m_int end = *(m_int*)REG(SZ_INT);
const m_int op = start < end ? 1 : -1;
const m_uint sz = op > 0 ? end - start : start - end;
+ if((sz - (shred->reg - (m_bit*)(shred + sizeof(struct VM_Shred_)))) > SIZEOF_REG)
+ Except(shred, _("Range too big"))
for(m_int i = start, j = 0; i != end; i += op, ++j)
*(m_uint*)REG(j * SZ_INT) = i;
*(m_uint*)REG(sz * SZ_INT) = sz;
return GW_OK;
}
static GACK(gack_bool) {
- printf("%s", *(m_uint*)VALUE ? "true" : "false");
+ gw_out("%s", *(m_uint*)VALUE ? "true" : "false");
}
static GWION_IMPORT(int_values) {
static GACK(gack_string) {
const M_Object obj = *(M_Object*)VALUE;
- printf("%s", obj ? STRING(obj) : "(null string)");
+ gw_out("%s", obj ? STRING(obj) : "(null string)");
}
static inline m_bool bounds(const m_str str, const m_int i) {
}
static GACK(gack_vec3) {
- printf("%%(%.4f, %.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT), *(m_float*)(VALUE + SZ_FLOAT*2));
+ gw_out("%%(%.4f, %.4f, %.4f)", *(m_float*)VALUE, *(m_float*)(VALUE + SZ_FLOAT), *(m_float*)(VALUE + SZ_FLOAT*2));
}
EQUALITY_OPER(vec3, SZ_VEC3);
}
static GACK(gack_vec4) {
- printf("%%(%.4f, %.4f, %.4f, %.4f)",
+ gw_out("%%(%.4f, %.4f, %.4f, %.4f)",
*(m_float*)VALUE,
*(m_float*)(VALUE + SZ_FLOAT),
*(m_float*)(VALUE + SZ_FLOAT*2),
const Var_Decl decl = arg_list->var_decl;
const Value v = decl->value;
if(arg_list->td && !arg_list->td->xid)
- arg_list->type = v->type = check_td(env, arg_list->td);
+ CHECK_OB((arg_list->type = v->type = check_td(env, arg_list->td)))
if(isa(v->type, env->gwion->type[et_object]) > 0 || isa(v->type, env->gwion->type[et_function]) > 0)
UNSET_FLAG(env->func, pure);
CHECK_BB(already_defined(env, decl->xid, decl->pos))
if(tmpl_base(fdef->base->tmpl))
return GW_OK;
if(fdef->base->td && !fdef->base->td->xid) { // tmpl ?
- fdef->base->ret_type = check_td(env, fdef->base->td);
+ CHECK_OB((fdef->base->ret_type = check_td(env, fdef->base->td)))
return traverse_func_def(env, fdef);
}
CHECK_BB(check_func_def_override(env, fdef))
nspc_pop_value(env->gwion->mp, env->curr);
--env->scope->depth;
env->func = former;
- SET_FLAG(fdef, checked);
+ if(ret > 0)
+ SET_FLAG(fdef, checked);
if(GET_FLAG(fdef, global))
env_pop(env,scope);
return ret;