From d42acece1346dc0826a32f2bcdcc2fac481a0dac Mon Sep 17 00:00:00 2001 From: redbrain Date: Fri, 25 Mar 2011 16:37:52 +0000 Subject: [PATCH] fixed string usage --- gcc/python/py-decl.c | 14 ++++++-------- gcc/python/py-runtime.c | 36 ++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/gcc/python/py-decl.c b/gcc/python/py-decl.c index d494b67ed08..02d360f09ec 100644 --- a/gcc/python/py-decl.c +++ b/gcc/python/py-decl.c @@ -117,15 +117,13 @@ VEC(tree,gc) * gpy_process_assign (gpy_symbol_obj ** op_a, gpy_symbol_obj ** op_ VEC_safe_push (tree, gc, retval, build2 (MODIFY_EXPR, gpy_object_type_ptr, decl,rhs_tree_res_decl)); - /* VEC(tree,gc) * bc = gpy_builtin_get_incr_ref_call (decl); - GPY_VEC_stmts_append(retval,bc);*/ - /* + VEC(tree,gc) * bc = gpy_builtin_get_incr_ref_call (decl); + GPY_VEC_stmts_append(retval,bc); + bc = gpy_builtin_get_set_decl_call (decl); GPY_VEC_stmts_append(retval,bc); - */ VEC_safe_push (tree, gc, retval, decl); - } else fatal_error("Invalid accessor for assignment <0x%x>!\n", opa->type ); @@ -140,7 +138,7 @@ gpy_process_bin_expression (gpy_symbol_obj ** op_a, gpy_symbol_obj ** op_b, VEC(tree,gc) * retval = NULL; VEC(tree,gc) * t1 = NULL, * t2 = NULL; - tree op = NULL; + VEC(tree,gc) * op = NULL; gpy_symbol_obj *opa, *opb; if( op_a && op_b ) { opa= *op_a; opb= *op_b; } else { @@ -168,6 +166,7 @@ gpy_process_bin_expression (gpy_symbol_obj ** op_a, gpy_symbol_obj ** op_b, if( op ) { + gcc_assert (VEC_length(tree, op) == 1); retval = t2; int idx = 0; tree itx = NULL_TREE; @@ -179,8 +178,7 @@ gpy_process_bin_expression (gpy_symbol_obj ** op_a, gpy_symbol_obj ** op_b, tree address = build_decl (opa->loc, VAR_DECL, create_tmp_var_name("T"), gpy_object_type_ptr); VEC_safe_push (tree, gc, retval, - build2 (MODIFY_EXPR, gpy_object_type_ptr, address, op)); - + build2 (MODIFY_EXPR, gpy_object_type_ptr, address, VEC_index(tree,op,0))); VEC_safe_push (tree,gc,retval,address); } diff --git a/gcc/python/py-runtime.c b/gcc/python/py-runtime.c index e2f68507325..e13ff481983 100644 --- a/gcc/python/py-runtime.c +++ b/gcc/python/py-runtime.c @@ -352,18 +352,34 @@ VEC(tree,gc) * gpy_builtin_get_set_decl_call (tree decl) DECL_EXTERNAL (gpy_rr_decl ) = 1; TREE_PUBLIC (gpy_rr_decl ) = 1; - const char * c_ident = IDENTIFIER_POINTER(DECL_NAME(decl)); + const char * c_ident = IDENTIFIER_POINTER (DECL_NAME(decl)); debug ("c_ident = <%s>!\n", c_ident); - tree str = build_string (strlen (c_ident), c_ident); - TREE_TYPE (str) = gpy_const_char_ptr; - tree ident = build_fold_addr_expr (str); + tree type = build_array_type (char_type_node, + build_index_type (size_int ( + IDENTIFIER_LENGTH (DECL_NAME(decl)) + ))); + type = build_qualified_type (type, TYPE_QUAL_CONST); + gpy_preserve_from_gc (type); - VEC(tree,gc) * retval = VEC_alloc(tree,gc,0); - VEC_safe_push (tree,gc,retval, - build_call_expr (gpy_rr_decl, 2, ident, decl) - ); + tree str = build_string (IDENTIFIER_LENGTH (DECL_NAME(decl)), c_ident); + TREE_TYPE (str) = type; + tree ident = str; //build_fold_addr_expr (str); + + tree address = build_decl (BUILTINS_LOCATION, VAR_DECL, + create_tmp_var_name("R"), + type); + TREE_STATIC (address) = 1; + TREE_READONLY (address) = 1; + DECL_ARTIFICIAL (address) = 1; + VEC(tree,gc) * retval = VEC_alloc (tree,gc,0); + VEC_safe_push (tree, gc, retval, + build2 (MODIFY_EXPR, type, address, ident)); + + VEC_safe_push (tree, gc, retval, + build_call_expr (gpy_rr_decl, 2, + address, decl)); return retval; } @@ -448,8 +464,8 @@ VEC(tree,gc) * gpy_builtin_get_register_callable_call (tree decl, int n) VEC(tree,gc) * retval = VEC_alloc (tree,gc,0); VEC_safe_push (tree, gc, retval, - build2 (MODIFY_EXPR, type, - address, ident)); + build2 (MODIFY_EXPR, type, address, ident)); + VEC_safe_push (tree, gc, retval, build_call_expr (gpy_rr_decl, 3, build_fold_addr_expr (decl), -- 2.11.4.GIT