diff options
author | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2020-07-18 11:07:49 +0200 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2020-07-18 11:07:49 +0200 |
commit | e8dc61312304363144da2c2062367360dd4671bd (patch) | |
tree | 33025ca54312250debd9de7ea6b0ffa36ce0b8d9 | |
parent | 78c929fb325927a103d239e8181abdb0524f9dca (diff) | |
download | efl-devs/bu5hm4n/compiler-plugin.tar.gz |
-rw-r--r-- | src/bin/eolian/sources.c | 20 | ||||
-rw-r--r-- | src/compiler-plugins/myplugin.cc | 28 |
2 files changed, 28 insertions, 20 deletions
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c index f4f5185476..564fd334a5 100644 --- a/src/bin/eolian/sources.c +++ b/src/bin/eolian/sources.c @@ -930,7 +930,6 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, if (internal && !eolian_function_is_static(fid) && !eolian_implement_is_pure_virtual(impl, ftype) && !is_empty) { /* T _class_name[_orig_class]_func_name_suffix */ - eina_strbuf_append(buf, "EAPI "); eina_strbuf_append(buf, rtpn); if (rtpn[strlen(rtpn) - 1] != '*') eina_strbuf_append_char(buf, ' '); @@ -1182,14 +1181,15 @@ _is_function_type_compatible(const Eolian_Function_Type t1, const Eolian_Functio * */ static void -_gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_Class *impl_klass, const Eolian_Implement *impl, const Eolian_Function_Type ftype, const Eolian_Function *fid, Eina_Strbuf *buf) +_gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_Class *current, const Eolian_Implement *impl, const Eolian_Function_Type ftype, const Eolian_Function *fid, Eina_Strbuf *buf) { const Eolian_Class *next_implemen_class = NULL; const Eolian_Class *definition_class = eolian_function_class_get(fid); char *impl_name; char *defi_name; + char *current_name; - if (eolian_class_type_get(impl_klass) == EOLIAN_CLASS_MIXIN) + if (eolian_class_type_get(current) == EOLIAN_CLASS_MIXIN) { //mixins cannot fast forward to a fixed implementation, so we cannot register there anything sane return; @@ -1213,6 +1213,7 @@ _gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_ if (!next_implemen_class) return; + eo_gen_class_names_get(current, NULL, NULL, ¤t_name); eo_gen_class_names_get(next_implemen_class, NULL, NULL, &impl_name); eo_gen_class_names_get(definition_class, NULL, NULL, &defi_name); @@ -1225,7 +1226,12 @@ _gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_ else if (ftype == EOLIAN_PROP_SET) prefix = "_set"; - eina_strbuf_append_printf(buf, "COMPILER_PLUGIN_REGISTER_NEXT(\"%s\", \"%s\", ", eolian_function_full_c_name_get(fid, ftype), class_name); + eina_strbuf_append_printf(buf, "COMPILER_PLUGIN_REGISTER_NEXT(\"%s\", ", eolian_function_full_c_name_get(fid, ftype)); + eina_strbuf_append_printf(buf, "\"%s_pd_offset\", ", current_name); + if (eolian_class_type_get(next_implemen_class) == EOLIAN_CLASS_MIXIN) + eina_strbuf_append_printf(buf, "\"%s_%s_pd_offset\", ", current_name, class_name); + else + eina_strbuf_append_printf(buf, "\"%s_pd_offset\", ", class_name); eina_strbuf_append_printf(buf, "\"_NEVA_USE_ME_internal_%s", impl_name); if (definition_class != next_implemen_class) eina_strbuf_append_printf(buf, "_%s", defi_name); @@ -1356,7 +1362,7 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf) { Eolian_Class *called = eina_array_data_get(call_chain, i); if (eolian_class_type_get(called) != EOLIAN_CLASS_MIXIN) - break; + continue; eina_strbuf_append_printf(name, "unsigned int %s_%s_pd_offset = -1;\n", eolian_class_c_name_get(cl), eolian_class_c_name_get(called)); eina_strbuf_tolower(name); eina_strbuf_append_buffer(buf, name); @@ -1417,9 +1423,9 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf) /* create macro for COMPILER_PLUGIN_REGISTER_NEXT */ eina_strbuf_append(buf, "#ifdef COMPILER_PLUGIN_REGISTER_NEXT_SUPPORT\n"); - eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d) __attribute__((register_next(a, b, c, d)))\n"); + eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d, e) __attribute__((register_next(a, b, c, d)))\n"); eina_strbuf_append(buf, "#else\n"); - eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d) /* NOP */\n"); + eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d, e) /* NOP */\n"); eina_strbuf_append(buf, "#endif\n"); diff --git a/src/compiler-plugins/myplugin.cc b/src/compiler-plugins/myplugin.cc index b183432f6e..d7b084721e 100644 --- a/src/compiler-plugins/myplugin.cc +++ b/src/compiler-plugins/myplugin.cc @@ -125,8 +125,12 @@ static Caller fetch_efl_super_class(const_gimple stmt) struct Registered_Api{ bool valid; + tree call; + tree pd_minus_field; + tree pd_plus_field; tree replacement_candidate; - tree provider_of_replacement_candidate; + + bool is_mixin; }; static Registered_Api @@ -145,12 +149,12 @@ fetch_replacement_api(tree klass_decl, const char* called_api) continue; //this here assumes a special tree_list structure tree attribute_arguments = TREE_VALUE(attribute); - tree call = TREE_VALUE(attribute_arguments); - tree providing_class = TREE_VALUE(TREE_CHAIN(attribute_arguments)); - tree implementation = TREE_VALUE(TREE_CHAIN(TREE_CHAIN(attribute_arguments))); - if (!!strncmp(TREE_STRING_POINTER(call), called_api, strlen(called_api))) continue; - result.provider_of_replacement_candidate = providing_class; - result.replacement_candidate = implementation; + result.call = TREE_VALUE(attribute_arguments); + result.pd_minus_field = TREE_VALUE(TREE_CHAIN(attribute_arguments)); + result.pd_plus_field = TREE_VALUE(TREE_CHAIN(TREE_CHAIN(attribute_arguments))); + result.replacement_candidate = TREE_VALUE(TREE_CHAIN(TREE_CHAIN(TREE_CHAIN(attribute_arguments)))); + //result.is_mixin = !!(TREE_VALUE(TREE_CHAIN(TREE_CHAIN(TREE_CHAIN(TREE_CHAIN(attribute_arguments)))))); + if (!!strncmp(TREE_STRING_POINTER(result.call), called_api, strlen(called_api))) continue; result.valid = true; break; } @@ -171,6 +175,7 @@ static unsigned int eo_execute(void) gcc_assert(single_succ_p(ENTRY_BLOCK_PTR_FOR_FN(cfun))); entry_bb = single_succ(ENTRY_BLOCK_PTR_FOR_FN(cfun)); + //FIXME this is jerky but we are checking if args are more than 2, if so we might be a eo op, and thats fine for (tree argument = DECL_ARGUMENTS(cfun->decl); argument; argument = DECL_CHAIN(argument)) { length ++; @@ -197,9 +202,6 @@ static unsigned int eo_execute(void) fprintf(stderr, "Replace! %s %s\n", c.called_api, TREE_STRING_POINTER(api.replacement_candidate)); //Create a new call to the found replacement candidate -#if 1 - //FIXME we need here: - //add another argument "pd - <my_class>_pd_offset + <providing_class>_pd_offset" (TODO check if these are mixins) /* * Create function declaration */ @@ -227,10 +229,10 @@ static unsigned int eo_execute(void) new_arguments.create(gimple_call_num_args(stmt) + 1); new_arguments.safe_push(DECL_ARGUMENTS(cfun->decl)); - tree field1 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("efl_object_pd_offset"), integer_type_node); //FIXME wrong field + tree field1 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier(TREE_STRING_POINTER(api.pd_minus_field)), integer_type_node); DECL_EXTERNAL(field1) = 1; TREE_PUBLIC(field1) = 1; - tree field2 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("efl_loop_consumer_pd_offset"), integer_type_node); //FIXME wrong field + tree field2 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier(TREE_STRING_POINTER(api.pd_plus_field)), integer_type_node); DECL_EXTERNAL(field2) = 1; TREE_PUBLIC(field2) = 1; tree tmp1 = build2(MINUS_EXPR, integer_type_node, DECL_CHAIN(DECL_ARGUMENTS(cfun->decl)), field1); @@ -253,7 +255,7 @@ static unsigned int eo_execute(void) gsi_remove(&removal, false); removal = gsi_for_stmt(c.class_get_call); gsi_remove(&removal, false); -#endif + } } return 0; |