forked from enlightenment/efl
eolian: manage class/vars through new node system
This commit is contained in:
parent
aa313ccfb6
commit
80445f5160
|
@ -1111,18 +1111,8 @@ eo_lexer_node_release(Eo_Lexer *ls, Eolian_Object *obj)
|
||||||
static void
|
static void
|
||||||
_temps_free(Eo_Lexer_Temps *tmp)
|
_temps_free(Eo_Lexer_Temps *tmp)
|
||||||
{
|
{
|
||||||
Eolian_Type *tp;
|
|
||||||
Eolian_Typedecl *tpd;
|
Eolian_Typedecl *tpd;
|
||||||
|
|
||||||
if (tmp->kls)
|
|
||||||
database_class_del(tmp->kls);
|
|
||||||
|
|
||||||
if (tmp->var)
|
|
||||||
database_var_del(tmp->var);
|
|
||||||
|
|
||||||
EINA_LIST_FREE(tmp->type_defs, tp)
|
|
||||||
database_type_del(tp);
|
|
||||||
|
|
||||||
EINA_LIST_FREE(tmp->type_decls, tpd)
|
EINA_LIST_FREE(tmp->type_decls, tpd)
|
||||||
database_typedecl_del(tpd);
|
database_typedecl_del(tpd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,6 @@ typedef struct _Lexer_Ctx
|
||||||
typedef struct _Eo_Lexer_Temps
|
typedef struct _Eo_Lexer_Temps
|
||||||
{
|
{
|
||||||
Eolian_Class *kls;
|
Eolian_Class *kls;
|
||||||
Eolian_Variable *var;
|
|
||||||
Eina_List *type_defs;
|
|
||||||
Eina_List *type_decls;
|
Eina_List *type_decls;
|
||||||
Eina_List *expr_defs;
|
Eina_List *expr_defs;
|
||||||
} Eo_Lexer_Temps;
|
} Eo_Lexer_Temps;
|
||||||
|
@ -241,6 +239,42 @@ eo_lexer_type_release(Eo_Lexer *ls, Eolian_Type *tp)
|
||||||
return (Eolian_Type *)eo_lexer_node_release(ls, (Eolian_Object *)tp);
|
return (Eolian_Type *)eo_lexer_node_release(ls, (Eolian_Object *)tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Eolian_Typedecl *
|
||||||
|
eo_lexer_typedecl_new(Eo_Lexer *ls)
|
||||||
|
{
|
||||||
|
return (Eolian_Typedecl *)eo_lexer_node_new(ls, sizeof(Eolian_Typedecl));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eolian_Typedecl *
|
||||||
|
eo_lexer_typedecl_release(Eo_Lexer *ls, Eolian_Typedecl *tp)
|
||||||
|
{
|
||||||
|
return (Eolian_Typedecl *)eo_lexer_node_release(ls, (Eolian_Object *)tp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eolian_Variable *
|
||||||
|
eo_lexer_variable_new(Eo_Lexer *ls)
|
||||||
|
{
|
||||||
|
return (Eolian_Variable *)eo_lexer_node_new(ls, sizeof(Eolian_Variable));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eolian_Variable *
|
||||||
|
eo_lexer_variable_release(Eo_Lexer *ls, Eolian_Variable *var)
|
||||||
|
{
|
||||||
|
return (Eolian_Variable *)eo_lexer_node_release(ls, (Eolian_Object *)var);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eolian_Expression *
|
||||||
|
eo_lexer_expr_new(Eo_Lexer *ls)
|
||||||
|
{
|
||||||
|
return (Eolian_Expression *)eo_lexer_node_new(ls, sizeof(Eolian_Expression));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Eolian_Expression *
|
||||||
|
eo_lexer_expr_release(Eo_Lexer *ls, Eolian_Expression *expr)
|
||||||
|
{
|
||||||
|
return (Eolian_Expression *)eo_lexer_node_release(ls, (Eolian_Object *)expr);
|
||||||
|
}
|
||||||
|
|
||||||
/* "stack" management, only to protect against errors (jumps) in parsing */
|
/* "stack" management, only to protect against errors (jumps) in parsing */
|
||||||
void eo_lexer_dtor_push(Eo_Lexer *ls, Eina_Free_Cb free_cb, void *data);
|
void eo_lexer_dtor_push(Eo_Lexer *ls, Eina_Free_Cb free_cb, void *data);
|
||||||
void eo_lexer_dtor_pop(Eo_Lexer *ls);
|
void eo_lexer_dtor_pop(Eo_Lexer *ls);
|
||||||
|
|
|
@ -834,9 +834,8 @@ parse_typedef(Eo_Lexer *ls)
|
||||||
static Eolian_Variable *
|
static Eolian_Variable *
|
||||||
parse_variable(Eo_Lexer *ls, Eina_Bool global)
|
parse_variable(Eo_Lexer *ls, Eina_Bool global)
|
||||||
{
|
{
|
||||||
Eolian_Variable *def = calloc(1, sizeof(Eolian_Variable));
|
Eolian_Variable *def = eo_lexer_variable_new(ls);
|
||||||
Eina_Strbuf *buf;
|
Eina_Strbuf *buf;
|
||||||
ls->tmp.var = def;
|
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
if (ls->t.kw == KW_at_extern)
|
if (ls->t.kw == KW_at_extern)
|
||||||
{
|
{
|
||||||
|
@ -2016,7 +2015,7 @@ parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
|
||||||
int line, col;
|
int line, col;
|
||||||
Eina_Strbuf *buf = eina_strbuf_new();
|
Eina_Strbuf *buf = eina_strbuf_new();
|
||||||
eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
|
eo_lexer_dtor_push(ls, EINA_FREE_CB(eina_strbuf_free), buf);
|
||||||
ls->klass = (ls->tmp.kls = calloc(1, sizeof(Eolian_Class)));
|
ls->klass = (Eolian_Class *)eo_lexer_node_new(ls, sizeof(Eolian_Class));
|
||||||
FILL_BASE(ls->klass->base, ls, ls->line_number, ls->column, CLASS);
|
FILL_BASE(ls->klass->base, ls, ls->line_number, ls->column, CLASS);
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
ls->klass->type = type;
|
ls->klass->type = type;
|
||||||
|
@ -2128,9 +2127,9 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
|
||||||
case KW_const:
|
case KW_const:
|
||||||
case KW_var:
|
case KW_var:
|
||||||
{
|
{
|
||||||
database_var_add(ls->unit, parse_variable(ls, ls->t.kw == KW_var));
|
Eolian_Variable *var = parse_variable(ls, ls->t.kw == KW_var);
|
||||||
eolian_object_ref(&ls->tmp.var->base);
|
database_var_add(ls->unit, eo_lexer_variable_release(ls, var));
|
||||||
ls->tmp.var = NULL;
|
eolian_object_ref(&var->base);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KW_struct:
|
case KW_struct:
|
||||||
|
@ -2248,10 +2247,10 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
|
||||||
_eolian_log("eolian: no class for file '%s'", filename);
|
_eolian_log("eolian: no class for file '%s'", filename);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
ls->klass = ls->tmp.kls = NULL;
|
ls->klass = NULL;
|
||||||
|
|
||||||
EOLIAN_OBJECT_ADD(ls->unit, cl->base.name, cl, classes);
|
EOLIAN_OBJECT_ADD(ls->unit, cl->base.name, cl, classes);
|
||||||
eina_hash_set(ls->state->classes_f, cl->base.file, cl);
|
eina_hash_set(ls->state->classes_f, cl->base.file, cl);
|
||||||
|
eo_lexer_node_release(ls, &cl->base);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ret = ls->unit;
|
ret = ls->unit;
|
||||||
|
|
Loading…
Reference in New Issue