ANN static Type void_type(const Env env, const Type_Decl* td) {
DECL_OO(const Type, type, = known_type(env, td))
-{
const Type t = get_type(type);
if(isa(t, env->gwion->type[et_object]) > 0)
CHECK_BO(type_recursive(env, td, t))
-}
if(type->size)
return type;
ERR_O(td_pos(td), _("cannot declare variables of size '0' (i.e. 'void')..."))
op == insert_symbol("@conditionnal") ||
op == insert_symbol("@unconditionnal"))
return scan_internal_int(env, base);
- return GW_ERROR;
+ return GW_OK;
}
ANN m_bool scan1_fdef(const Env env, const Func_Def fdef) {
DECL_SECTION_FUNC(scan1)
+ANN static Type scan1_get_parent(const Env env, const Type_Def tdef) {
+ DECL_OO(const Type , parent, = tdef->type->e->parent = known_type(env, tdef->ext))
+ Type t = parent;
+ do if(tdef->type == t)
+ ERR_O(td_pos(tdef->ext), _("recursive (%s <= %s) class declaration."), tdef->type->name, t->name)
+ while((t = t->e->parent));
+ return parent;
+}
+
ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) {
const loc_t pos = td_pos(cdef->base.ext);
if(cdef->base.ext->array)
CHECK_BB(scan1_exp(env, cdef->base.ext->array->exp))
- DECL_OB(const Type , parent, = cdef->base.type->e->parent = known_type(env, cdef->base.ext))
- Type t = parent;
- do {
- if(cdef->base.type == t)
- ERR_B(pos, _("recursive (%s <= %s) class declaration."), cdef->base.type->name, t->name);
- } while((t = t->e->parent));
+ DECL_OB(const Type , parent, = scan1_get_parent(env, &cdef->base))
if(isa(parent, env->gwion->type[et_object]) < 0)
ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name)
if(parent->e->def && !GET_FLAG(parent, scan1))
#include "func.h"
#include "template.h"
#include "traverse.h"
-#include "optim.h"
#include "parse.h"
#include "nspc.h"
#include "operator.h"
#include "object.h"
-
#include "instr.h"
#include "import.h"
#include "tuple.h"
}
ANN static inline m_bool scan2_exp_primary(const Env env, const Exp_Primary* prim) {
- if(prim->primary_type == ae_primary_hack) {
+ if(prim->primary_type == ae_primary_hack)
CHECK_BB(scan2_exp(env, prim->d.exp))
- Exp e = prim->d.exp;
- do {
- if(e->exp_type == ae_exp_decl) {
- Var_Decl_List l = e->d.exp_decl.list;
- do {
- const Value v = l->self->value;
- SET_FLAG(v, used);
- }while ((l = l->next));
- }
- } while((e = e->next));
- } else if(prim->primary_type == ae_primary_id) {
+ else if(prim->primary_type == ae_primary_id) {
const Value v = prim_value(env, prim->d.var);
if(v)
SET_FLAG(v, used);
return scan2_exp(env, array->array->exp);
}
-
ANN static m_bool multi_decl(const Env env, const Exp e, const Symbol op) {
if(e->exp_type == ae_exp_decl) {
if(e->d.exp_decl.list->next)
f->base->ret_type : NULL;
struct Op_Import opi = { .op=f->base->xid, .lhs=l, .rhs=r, .ret=f->base->ret_type,
.pos=f->pos, .data=(uintptr_t)f->base->func };
- if(!strcmp(str, "@implicit")) {
+ if(!strcmp(str, "@implicit"))
opi.ck = opck_usr_implicit;
- }
CHECK_BB(add_op(env->gwion, &opi))
operator_set_func(&opi);
return GW_OK;
vector_init(&v);
do {
const Type t = nspc_lookup_type0(env->curr, id->xid);
- if(!t)continue;
+ if(!t)
+ continue;
vector_add(&v, (vtype)t);
tlen += strlen(t->name);
} while((id = id->next) && ++tlen);
return v;
}
-
-ANN static m_str template_helper(const Env env, const Func_Def f) {
- const m_str name = f->base->func ? f->base->func->name : func_tmpl_name(env, f);
- if(!name)
- return(m_str)GW_ERROR;
- const Func func = nspc_lookup_func0(env->curr, insert_symbol(name));
- if(func) {
- f->base->ret_type = known_type(env, f->base->td);
- return (m_str)(m_uint)((f->base->args && f->base->args->type) ? scan2_args(env, f) : GW_OK);
- }
- return name;
-}
-
ANN2(1,2) static m_str func_name(const Env env, const Func_Def f, const Value v) {
if(!f->base->tmpl) {
- const Symbol sym = func_symbol(env, env->curr->name, s_name(f->base->xid), NULL, v ? ++v->from->offset : 0);
+ const Symbol sym = func_symbol(env, env->curr->name,
+ s_name(f->base->xid), NULL, v ? ++v->from->offset : 0);
return s_name(sym);
}
- return template_helper(env, f);
+ const m_str name = f->base->func ? f->base->func->name : func_tmpl_name(env, f);
+ return name ?: (m_str)GW_ERROR;
}
ANN2(1,2) m_bool scan2_fdef_std(const Env env, const Func_Def f, const Value overload) {