-Subproject commit 564a6a8786d2db8fe1bdfa1f2a0ea94685cc04a5
+Subproject commit 26981201377874f666cf62ea915c167357637c30
spork->m_val = emit->code->stack_depth;
} else {
const Func f = unary->exp->d.exp_call.m_func;
- const m_uint size = f->def->stack_depth - (GET_FLAG(f, member) && !GET_FLAG(code, member) ? SZ_INT : 0);
- emit_exp_spork_finish(emit, size);
+ emit_exp_spork_finish(emit, f->def->stack_depth);
const Instr end = emit_add_instr(emit, is_spork ? SporkEnd : ForkEnd);
end->m_val2 = f->def->base->ret_type->size;
}
static OP_CHECK(opck_spork) {
const Exp_Unary* unary = (Exp_Unary*)data;
+ if(unary->op == op_fork && !unary->fork_ok)
+ ERR_O(exp_self(unary)->pos, "forks must be stored in a value:\n"
+ "fork xxx @=> Fork f")
if(unary->exp && unary->exp->exp_type == ae_exp_call)
return unary->op == op_spork ? t_shred : t_fork;
else if(unary->code) {
static m_int o_fork_thread, o_shred_cancel, o_fork_done, o_fork_ev, o_fork_retsize, o_fork_retval,
o_fork_orig;
+
#define FORK_THREAD(o) *(THREAD_TYPE*)(o->data + o_fork_thread)
#define FORK_RETSIZE(o) *(m_int*)(o->data + o_fork_retsize)
#define FORK_RETVAL(o) (o->data + o_fork_retval)
static MFUN(shred_yield) {
const VM_Shred s = ME(o);
- const Shreduler sh = shred->tick->shreduler;
- shredule(sh, s, GWION_EPSILON);
+ const Shreduler sh = s->tick->shreduler;
+ if(vector_size(shred->code->instr) - shred->pc > 1)
+ shredule(sh, s, GWION_EPSILON);
+ else
+ vm_shred_exit(shred);
}
static SFUN(vm_shred_from_id) {
if(decl->type == t_auto)
ERR_O(td_pos(decl->td), "can't infer type.");
}
+ if(!decl->type) // TODO: remove when scan passes are complete
+ ERR_O(td_pos(decl->td), "can't infer type.");
if(GET_FLAG(decl->type , template)) {
const Type t = typedef_base(decl->type);
CHECK_BO(traverse_template(env, t->def))
}
ANN static Type check_exp_binary(const Env env, const Exp_Binary* bin) { GWDEBUG_EXE
+ if(bin->lhs->exp_type == ae_exp_unary && bin->lhs->d.exp_unary.op == op_fork &&
+ bin->rhs->exp_type == ae_exp_decl)
+ bin->lhs->d.exp_unary.fork_ok = 1;
CHECK_OO(check_exp(env, bin->lhs))
if(bin->rhs->exp_type == ae_exp_decl && bin->rhs->d.exp_decl.type == t_auto)
bin->rhs->type = bin->rhs->d.exp_decl.type = bin->lhs->type;
const Value former = nspc_lookup_value0(env->curr, var->xid);
CHECK_BB(isres(env, var->xid, exp_self(decl)->pos))
if(former && !decl->td->exp &&
-/*!(decl->td->xid->xid == insert_symbol("auto") && former->type != t_auto) &&*/
-//(decl->td->xid->xid == insert_symbol("auto") && former->type != t_auto) &&
-//(!env->class_def ||
-// (!GET_FLAG(env->class_def, template) || !GET_FLAG(env->class_def, scan1))))
(!env->class_def || !(GET_FLAG(env->class_def, template) || GET_FLAG(env->class_def, scan1))))
ERR_B(var->pos, "variable %s has already been defined in the same scope...",
s_name(var->xid))
- if(var->array && decl->type != t_undefined && decl->type != t_auto) {
+ if(var->array) {
if(var->array->exp) {
if(GET_FLAG(decl->td, ref))
ERR_B(td_pos(decl->td), "ref array must not have array expression.\n"
t = array_type(env, decl->type, var->array->depth);
}
const Value v = var->value = former ? former : new_value(env->gwion->p, t, s_name(var->xid));
- nspc_add_value(nspc, var->xid, v);
- v->flag = decl->td->flag;
if(var->array && !var->array->exp)
SET_FLAG(v, ref);
+ nspc_add_value(nspc, var->xid, v);
+ v->flag = decl->td->flag;
if(!env->func && !env->scope->depth && !env->class_def)
SET_FLAG(v, global);
v->type = t;