diff options
author | Christoph Mallon <christoph.mallon@gmx.de> | 2017-04-26 00:42:37 +0200 |
---|---|---|
committer | Christoph Mallon <christoph.mallon@gmx.de> | 2017-04-26 00:42:37 +0200 |
commit | 1dd56f840c9aa49432879471c7c76cf0e17f7166 (patch) | |
tree | 9edf3977bf519540614b5e15be66b77751f96738 | |
parent | d3cb44e809687afa510c1b1fdf9bf1799e774985 (diff) |
Factor out common code.
-rw-r--r-- | src/firm/ast2firm.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/firm/ast2firm.c b/src/firm/ast2firm.c index 753c9d2..e20331c 100644 --- a/src/firm/ast2firm.c +++ b/src/firm/ast2firm.c @@ -2132,6 +2132,14 @@ static ir_node *select_to_firm(const select_expression_t *expression) return deref_address(dbgi, type, addr); } +static ir_node *make_name(funcname_expression_t const *const expr, char const *const name) +{ + begin_string_construction(); + obstack_grow(&string_obst, name, strlen(name)); + string_t *const string = finish_string_construction(STRING_ENCODING_CHAR); + return string_to_firm(&expr->base.pos, string); +} + static ir_node *function_name_to_firm(const funcname_expression_t *const expr) { switch (expr->kind) { @@ -2139,24 +2147,15 @@ static ir_node *function_name_to_firm(const funcname_expression_t *const expr) case FUNCNAME_PRETTY_FUNCTION: case FUNCNAME_FUNCDNAME: if (current_function_name == NULL) { - position_t const *const src_pos = &expr->base.pos; - char const *const name - = current_function_entity->base.base.symbol->string; - begin_string_construction(); - obstack_grow(&string_obst, name, strlen(name)); - string_t *string = finish_string_construction(STRING_ENCODING_CHAR); - current_function_name = string_to_firm(src_pos, string); + char const *const name = current_function_entity->base.base.symbol->string; + current_function_name = make_name(expr, name); } return current_function_name; case FUNCNAME_FUNCSIG: if (current_funcsig == NULL) { - position_t const *const src_pos = &expr->base.pos; - ir_entity *const ent = get_irg_entity(current_ir_graph); - char const *const name = get_entity_ld_name(ent); - begin_string_construction(); - obstack_grow(&string_obst, name, strlen(name)); - string_t *string = finish_string_construction(STRING_ENCODING_CHAR); - current_funcsig = string_to_firm(src_pos, string); + ir_entity *const ent = get_irg_entity(current_ir_graph); + char const *const name = get_entity_ld_name(ent); + current_funcsig = make_name(expr, name); } return current_funcsig; } |