-Subproject commit db1106db2e29341dff616e070530d0881a925c8f
+Subproject commit 15c110793cba16dc12855082ebf14794c5f16ea0
eGcIni,
eGcAdd,
eGcEnd,
- eGack,
eGackEnd,
+ eGack,
eNoOp,
eDotTmplVal,
eOP_MAX,
#define GcIni (f_instr)eGcIni
#define GcAdd (f_instr)eGcAdd
#define GcEnd (f_instr)eGcEnd
-#define Gack (f_instr)eGack
#define GackEnd (f_instr)eGackEnd
+#define Gack (f_instr)eGack
#define NoOp (f_instr)eNoOp
#define DotTmplVal (f_instr)eDotTmplVal
#define OP_MAX (f_instr)eOP_MAX
return GW_OK;
}
-ANN static m_bool emit_prim_hack(const Emitter emit, const Exp *exp) {
+ANN static m_bool emit_prim_unpack(const Emitter emit NUSED, const Tuple *tuple) {
+ if(prim_exp(tuple)->meta == ae_meta_var)
+ return GW_OK;
+ ERR_B(prim_pos(tuple), _("unused Tuple unpack"))
+}
+
+#define emit_prim_complex emit_prim_vec
+#define emit_prim_polar emit_prim_vec
+#define emit_prim_nil (void*)dummy_func
+
+ANN static m_bool emit_interp(const Emitter emit, const Exp exp) {
regpushi(emit, 0);
- Exp e = *exp, next = NULL;
+ Exp e = exp, next = NULL;
do {
next = e->next;
e->next = NULL;
instr->m_val = (m_uint)e->type;
instr->m_val2 = emit_code_offset(emit);
} while((e = e->next = next));
- if(!(emit->env->func && emit->env->func->def->base->xid == insert_symbol("@gack")))
- emit_add_instr(emit, GackEnd);
return GW_OK;
}
-ANN static m_bool emit_prim_unpack(const Emitter emit NUSED, const Tuple *tuple) {
- if(prim_exp(tuple)->meta == ae_meta_var)
- return GW_OK;
- ERR_B(prim_pos(tuple), _("unused Tuple unpack"))
+ANN static m_bool emit_prim_hack(const Emitter emit, const Exp *exp) {
+ CHECK_BB(emit_interp(emit, *exp))
+ if(!(emit->env->func && emit->env->func->def->base->xid == insert_symbol("@gack")))
+ emit_add_instr(emit, GackEnd);
+ return GW_OK;
}
-#define emit_prim_complex emit_prim_vec
-#define emit_prim_polar emit_prim_vec
-#define emit_prim_nil (void*)dummy_func
-
DECL_PRIM_FUNC(emit, m_bool , Emitter);
ANN static m_bool emit_prim(const Emitter emit, Exp_Primary *const prim) {
return emit_prim_func[prim->prim_type](emit, &prim->d);
return GW_OK;
}
+ANN static m_bool emit_exp_interp(const Emitter emit, const Exp_Interp *exp) {
+ CHECK_BB(emit_interp(emit, exp->exp))
+ const Instr instr = emit_add_instr(emit, GackEnd);
+ instr->m_val = 1;
+ return GW_OK;
+}
+
DECL_EXP_FUNC(emit, m_bool, Emitter)
ANN2(1) static m_bool emit_exp(const Emitter emit, Exp exp, const m_bool ref) {
return v->type;
}
+ANN static Type check_exp_interp(const Env env, const Exp_Interp* exp) {
+ CHECK_OO(check_exp(env, exp->exp))
+ return env->gwion->type[et_string];
+}
+
DECL_EXP_FUNC(check, Type, Env)
ANN Type check_exp(const Env env, const Exp exp) {
return scan1_exp(env, exp->exp);
}
+ANN static inline m_bool scan1_exp_interp(const restrict Env env, const Exp_Interp *exp) {
+ return scan1_exp(env, exp->exp);
+}
+
#define scan1_exp_lambda dummy_func
HANDLE_EXP_FUNC(scan1, m_bool, Env)
return scan2_exp(env, exp->exp);
}
+ANN static inline m_bool scan2_exp_interp(const restrict Env env, const Exp_Interp *exp) {
+ return scan2_exp(env, exp->exp);
+}
+
ANN static inline m_bool _scan2_stmt_match_case(const restrict Env env, const Stmt_Match stmt) {
CHECK_BB(scan2_exp(env, stmt->cond))
if(stmt->when)
&&staticint, &&staticfloat, &&staticother,
&&dotfunc, &&dotstaticfunc, &&pushstaticcode,
&&gcini, &&gcadd, &&gcend,
- &&gack, &&gackend, &&noop, &®pushimm, &&other, &&eoc
+ &&gackend, &&gack, &&noop, &®pushimm, &&other, &&eoc
};
const Shreduler s = vm->shreduler;
register VM_Shred shred;
while((a.obj = (M_Object)vector_pop(&shred->gc)))
_release(a.obj, shred);
DISPATCH()
-gack:
- VM_OUT
- gack(shred, (Instr)VAL);
- goto in;
gackend:
{
m_str str = *(m_str*)(reg - SZ_INT);
- gw_out("%s\n", str);
+ if(!VAL)
+ gw_out("%s\n", str);
+ else
+ *(M_Object*)(reg - SZ_INT)= new_string(vm->gwion->mp, shred, str);
mp_free2(vm->gwion->mp, strlen(str), str);
+ DISPATCH();
}
+gack:
+ VM_OUT
+ gack(shred, (Instr)VAL);
+ goto in;
noop:
DISPATCH();
other: