const Value v = prim->value;
if(v->owner_class)
return emit_symbol_owned(emit, prim);
+ if(isa(v->type, t_class) > 0) {
+ regpushi(emit, (m_uint)actual_type(v->type));
+ return GW_OK;
+ }
if(GET_FLAG(v, builtin) || GET_FLAG(v, union) || GET_FLAG(v, enum))
return emit_symbol_builtin(emit, prim);
const m_uint size = v->type->size;
}
ANN static m_bool emit_exp_typeof(const Emitter emit, const Exp_Typeof *exp) {
- regpushi(emit, (m_uint)exp->exp->type);
+ regpushi(emit, (m_uint)actual_type(exp->exp->type));
return GW_OK;
}
free_vector(((Gwion)gwion)->mp, (Vector)instr->m_val2);
}
+
+#define mk_class_instr(op, arg0, arg1, ...) \
+static INSTR(instr_class_##op) { \
+ POP_REG(shred, SZ_INT); \
+ const Type l = *(Type*)(shred->reg - SZ_INT); \
+ const Type r = *(Type*)(shred->reg); \
+ *(m_uint*)(shred->reg - SZ_INT) = isa(arg0, arg1) > 0 __VA_ARGS__; \
+}
+mk_class_instr(ge, l, r)
+mk_class_instr(gt, l, r, && l != r)
+mk_class_instr(le, r, l)
+mk_class_instr(lt, r, l, && l != r)
+
ANN static m_bool import_core_libs(const Gwi gwi) {
GWI_OB((t_class = gwi_mk_type(gwi, "Class", SZ_INT, NULL)))
GWI_BB(gwi_add_type(gwi, t_class))
GWI_BB(import_string(gwi))
GWI_BB(import_shred(gwi))
GWI_BB(import_modules(gwi))
+
+ GWI_BB(gwi_oper_ini(gwi, "Class", "Class", "int"))
+ GWI_BB(gwi_oper_end(gwi, "==", int_eq))
+ GWI_BB(gwi_oper_end(gwi, ">=", instr_class_ge))
+ GWI_BB(gwi_oper_end(gwi, ">", instr_class_gt))
+ GWI_BB(gwi_oper_end(gwi, "<=", instr_class_le))
+ GWI_BB(gwi_oper_end(gwi, "<", instr_class_lt))
+
register_freearg(gwi, SwitchIni, freearg_switchini);
register_freearg(gwi, SwitchBranch, freearg_switchbranch);
register_freearg(gwi, Gack, freearg_gack);
return t;
}
+ANN static Type no_xid(const Env env, const Exp_Decl* decl) {
+ DECL_OO(const Type, t, = check_td(env, decl->td))
+ ((Exp_Decl*)decl)->type = NULL;
+ Var_Decl_List list = decl->list;
+ do nspc_add_value(env->curr, list->self->xid, NULL);
+ while((list = list->next));
+ CHECK_BO(traverse_decl(env, decl))
+ return decl->type;
+}
+
ANN Type check_exp_decl(const Env env, const Exp_Decl* decl) {
Var_Decl_List list = decl->list;
CHECK_BO(switch_decl(env, exp_self(decl)->pos))
- if(!decl->td->xid) {
- DECL_OO(const Type, t, = check_td(env, decl->td))
- ((Exp_Decl*)decl)->type = NULL;
- CHECK_BO(scan1_exp(env, exp_self(decl)))
- CHECK_BO(scan2_exp(env, exp_self(decl)))
- }
+ if(!decl->td->xid)
+ return no_xid(env, decl);
if(decl->td->xid->xid == insert_symbol("auto")) { // should be better
CHECK_BO(scan1_exp(env, exp_self(decl)))
CHECK_BO(scan2_exp(env, exp_self(decl)))
CHECK_BO(check_exp_decl_parent(env, var))
if(var->array && var->array->exp)
CHECK_BO(check_exp_array_subscripts(env, var->array->exp))
- if(GET_FLAG(decl->td, member) && env->class_def) {
- decl_member(env, v);
- if(isa(env->class_def, t_object) > 0)
- tuple_info(env, decl->td, var);
+ if(env->class_def) {
+ if(GET_FLAG(decl->td, member)) {
+ decl_member(env, v);
+ if(isa(env->class_def, t_object) > 0)
+ tuple_info(env, decl->td, var);
+ } else if(GET_FLAG(decl->td, static))
+ decl_static(env, v);
}
- else if(GET_FLAG(decl->td, static))
- decl_static(env, v);
else if(global || (env->func && GET_FLAG(env->func->def, global)))
SET_FLAG(v, abstract);
if(isa(decl->type, t_fptr) > 0)