#ifndef __MEMOIZE
#define __MEMOIZE
+
+#ifndef NOMEMOIZE
+#define MEMOIZE_CALL if(GET_FLAG(f, pure)) emit_add_instr(emit, MemoizeCall);
+#define MEMOIZE_STORE if(GET_FLAG(emit->env->func, pure)) emit_add_instr(emit, MemoizeStore);
+#define MEMOIZE_INI if(GET_FLAG(func, pure)) func->code->memoize = memoize_ini(func, kindof(func->def->ret_type->size, !func->def->ret_type->size));
typedef struct Memoize_ * Memoize;
-//m_bool memoize_get(VM_Shred shred);
Memoize memoize_ini(const Func f, const enum Kind);
void memoize_end(Memoize m);
INSTR(MemoizeCall);
INSTR(MemoizeStore);
+#else
+#define MEMOIZE_CALL
+#define MEMOIZE_STORE
+#define MEMOIZE_INI
+#endif
#endif
}
ANN static Instr emit_call(const Emitter emit, const Func f) {
- if(GET_FLAG(f, pure))
- emit_add_instr(emit, MemoizeCall);
+ MEMOIZE_CALL
const Type t = actual_type(f->value_ref->type);
const f_instr exec = isa(t, t_fptr) < 0 ? GET_FLAG(f->def, builtin) ?
GET_FLAG(f, member) ? FuncMember : FuncStatic : FuncUsr : FuncPtr;
}
vector_clear(&emit->code->stack_return);
emit_pop_scope(emit);
- if(GET_FLAG(emit->env->func, pure))
- emit_add_instr(emit, MemoizeStore);
+ MEMOIZE_STORE
emit_add_instr(emit, FuncReturn);
}
emit_func_def_code(emit, func);
emit->env->func = former;
emit_pop_code(emit);
- if(GET_FLAG(func, pure))
- func->code->memoize = memoize_ini(func, kindof(func->def->ret_type->size, !func->def->ret_type->size));
+ MEMOIZE_INI
return GW_OK;
}
PUSH_REG(shred, size); \
}
-describe_regpushimmxxx(Imm, m_int, SZ_INT)
describe_regpushimmxxx(Imm2, m_float, SZ_FLOAT)
INSTR(RegPushImm3) { GWDEBUG_EXE
memcpy(REG(0), instr->ptr, instr->m_val2);