This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[GSoC] replacing op in c_expr
- From: Prathamesh Kulkarni <bilbotheelffriend at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>, Diego Novillo <dnovillo at google dot com>, gcc <gcc at gcc dot gnu dot org>, Maxim Kuvyrkov <maxim dot kuvyrkov at linaro dot org>
- Date: Tue, 29 Jul 2014 01:32:29 +0530
- Subject: [GSoC] replacing op in c_expr
- Authentication-results: sourceware.org; auth=none
I am having few issues replacing op in c_expr.
I thought of following possibilities:
a) create a new vec<cpp_token> vector new_code.
for each token in code
{
if token.type is not CPP_NAME
new_code.safe_push (token);
else
{
cpp_token new_token =
??? create new token of type CPP_NAME
with contents as name of operator ???
}
}
I tried to go this way, but am stuck with creating a new token type.
i started by:
cpp_token new_token = token; // get same attrs as token.
CPP_HASHNODE (new_token.val.node.node)->ident.str = name of operator.
CPP_HASHNODE (new_token.val.node.node)->ident.len = len of operator name.
name of operator is obtained from opers[i] in parse_for.
however this does not work because I guess
new_token = token, shallow copies
the token (default assignment operator, i didn't find an overloaded version).
b) create new struct c_expr_elem and use
vec<c_expr_elem> code, instead of vec<cpp_token> code;
sth like:
struct c_expr_elem
{
enum c_expr_elem_type { ID, TOKEN };
enum c_expr_elem_type type;
union {
cpp_token token;
const char *id;
};
};
while replacing op, compare token with op, and if it matches,
create a new c_expr_elem with type = ID, and id = name of operator.
This shall probably work, but shall require many changes to other parts
since we change c_expr::code.
I would like to hear any other suggestions.
Thanks,
Prathamesh.