regpop(emit, SZ_INT);
const Instr instr = emit_add_instr(emit, Reg2Reg);
instr->m_val = -SZ_INT;
- emit_add_instr(emit, RegAddRef);
+// emit_add_instr(emit, RegAddRef);
return GW_OK;
}
instr->m_val2 = SZ_INT;
}
-ANN static m_bool emit_interp(const Emitter emit, const Exp exp) {
+ANN /*static*/ m_bool emit_interp(const Emitter emit, const Exp exp) {
regpushi(emit, 0);
Exp e = exp, next = NULL;
do {
if(isa(t, emit->gwion->type[et_function]) > 0)
CHECK_BB(emit_exp_call1(emit, t->info->func))
else {
+printf("call type %s %p\n", exp_call->func->type->name, actual_type(emit->gwion, exp_call->func->type));
+printf("call type %s %p\n", exp_call->func->type->name, exp_call->func->type);
struct Op_Import opi = { .op=insert_symbol("@ctor"), .rhs=t,
.data=(uintptr_t)exp_call, .pos=exp_self(exp_call)->pos, .op_type=op_exp };
CHECK_BB(op_emit(emit, &opi))
t->info->tuple = new_tupleform(gwi->gwion->mp, NULL);
t->info->parent = NULL;
t->info->cdef->cflag |= cflag_struct;
- set_tflag(t, tflag_tmpl);
+ set_tflag(t, tflag_tmpl | tflag_ntmpl);
}
return type_finish(gwi, t);
}
GWION_IMPORT(foreach) {
const Type t_foreach = gwi_struct_ini(gwi, "@Foreach:[A]");
- set_tflag(t_foreach, tflag_ntmpl | tflag_infer);
+ set_tflag(t_foreach, tflag_infer);
GWI_BB(gwi_item_ini(gwi, "@internal", "val"))
GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0))
GWI_BB(gwi_struct_end(gwi))
M_Object new_string(MemPool p, const VM_Shred shred, const m_str str) {
const M_Object o = new_object(p, shred, shred->info->vm->gwion->type[et_string]);
- STRING(o) = s_name(insert_symbol(shred->info->vm->gwion->st, str));
+ STRING(o) = mstrdup(p, str);
return o;
}
M_Object new_string2(const struct Gwion_ *gwion, const VM_Shred shred, const m_str str) {
const M_Object o = new_object(gwion->mp, shred, gwion->type[et_string]);
- STRING(o) = str;
+ STRING(o) = mstrdup(gwion->mp, str);
return o;
}
GWI_BB(gwi_item_ini(gwi, "@internal", "@val"))
GWI_BB(gwi_item_end(gwi, 0, num, 0))
GWI_BB(gwi_class_end(gwi))
- set_tflag(t_ptr, tflag_ntmpl);
GWI_BB(gwi_oper_ini(gwi, "Ptr", NULL, NULL))
GWI_BB(gwi_oper_add(gwi, opck_ptr_scan))
GWI_BB(gwi_oper_end(gwi, "@scan", NULL))
GWI_BB((gwi_item_end(gwi, ae_flag_const, num, 0)))
GWI_BB(gwi_class_end(gwi))
SET_FLAG(t_typed, abstract | ae_flag_final);
- set_tflag(t_typed, tflag_ntmpl);
return GW_OK;
}
const M_Object rhs = *(M_Object*)REG(0); \
*(m_int*)REG(-SZ_INT) = action; \
}
-describe_string_logical(eq, (lhs && rhs && STRING(lhs) == STRING(rhs)) || (!lhs && !rhs))
-describe_string_logical(neq, !(lhs && rhs && STRING(lhs) == STRING(rhs)) || (!lhs && !rhs))
+describe_string_logical(eq, (!strcmp(STRING(lhs), STRING(rhs))))
+describe_string_logical(neq, (strcmp(STRING(lhs), STRING(rhs))))
static CTOR(string_ctor) {
- STRING(o) = "";
+ STRING(o) = _mp_calloc(shred->info->vm->gwion->mp, 1);
+}
+
+static DTOR(string_dtor) {
+ free_mstr(shred->info->vm->gwion->mp, STRING(o));
}
ID_CHECK(check_funcpp) {
GWION_IMPORT(string) {
const Type t_string = gwi_class_ini(gwi, "string", NULL);
gwi->gwion->type[et_string] = t_string; // use func
- gwi_class_xtor(gwi, string_ctor, NULL);
+ gwi_class_xtor(gwi, string_ctor, string_dtor);
GWI_BB(gwi_gack(gwi, t_string, gack_string))
gwi_item_ini(gwi, "@internal", "@data");