comparison gcc/c-parser.c @ 35:3f5886e153cb

modify cbc_replace_args
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Dec 2009 20:49:36 +0900
parents c845c9fe357a
children 9117c3b65bc3
comparison
equal deleted inserted replaced
34:5f3bba7b355c 35:3f5886e153cb
1550 /* 1550 /*
1551 attrs = get_identifier("fastcall"); 1551 attrs = get_identifier("fastcall");
1552 attrs = build_tree_list(attrs, NULL_TREE); 1552 attrs = build_tree_list(attrs, NULL_TREE);
1553 declspecs_add_attrs(specs, attrs); 1553 declspecs_add_attrs(specs, attrs);
1554 */ 1554 */
1555 attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE); 1555 //attrs = build_tree_list (get_identifier("fastcall"), NULL_TREE);
1556 //attrs = build_tree_list (get_identifier("noreturn"), attrs); 1556 /*attrs = build_tree_list (get_identifier("noreturn"), attrs);*/
1557 declspecs_add_attrs(specs, attrs); 1557 //declspecs_add_attrs(specs, attrs);
1558 1558
1559 c_parser_consume_token (parser); 1559 c_parser_consume_token (parser);
1560 break; 1560 break;
1561 #endif 1561 #endif
1562 case RID_ENUM: 1562 case RID_ENUM:
3735 3735
3736 static tree 3736 static tree
3737 cbc_replace_arguments (location_t loc, tree call) 3737 cbc_replace_arguments (location_t loc, tree call)
3738 { 3738 {
3739 tree args; 3739 tree args;
3740 tree fn;
3740 tree tmp_decl; 3741 tree tmp_decl;
3741 int i=0; 3742 int i=0;
3742 3743
3744 fn = CALL_EXPR_FN (call);
3745 if ( TREE_CODE (fn)==PARM_DECL || !TREE_CONSTANT (fn) )
3746 {
3747 tmp_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE(fn));
3748 pushdecl (tmp_decl);
3749
3750 add_stmt (build_modify_expr (loc, tmp_decl, NOP_EXPR, fn));
3751 CALL_EXPR_FN (call) = tmp_decl;
3752 }
3753
3743 args = CALL_EXPR_ARGS (call); 3754 args = CALL_EXPR_ARGS (call);
3744 for ( ;args; args = TREE_CHAIN (args), i++) 3755 for ( ;args; args = TREE_CHAIN (args), i++)
3745 { 3756 {
3746 tree arg = TREE_VALUE (args); 3757 tree arg = TREE_VALUE (args);
3747 3758
3748 if (CONSTANT_CLASS_P (arg) || VAR_OR_FUNCTION_DECL_P (arg) ) 3759 //if ( !CONSTANT_CLASS_P (arg) && !VAR_OR_FUNCTION_DECL_P (arg) )
3749 continue; 3760 if ( TREE_CODE (arg)==PARM_DECL || !TREE_CONSTANT (arg) )
3750 3761 {
3751 tmp_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE(arg)); 3762 tmp_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE(arg));
3752 pushdecl (tmp_decl); 3763 pushdecl (tmp_decl);
3753 3764
3754 add_stmt (build_modify_expr (loc, tmp_decl, NOP_EXPR, arg)); 3765 add_stmt (build_modify_expr (loc, tmp_decl, NOP_EXPR, arg));
3755 CALL_EXPR_ARG (call, i) = tmp_decl; 3766 CALL_EXPR_ARG (call, i) = tmp_decl;
3767 }
3756 } 3768 }
3757 3769
3758 return call; 3770 return call;
3759 } 3771 }
3760 3772
3823 { 3835 {
3824 location_t loc = c_parser_peek_token (parser)->location; 3836 location_t loc = c_parser_peek_token (parser)->location;
3825 cbc_replace_arguments (loc, expr.value); 3837 cbc_replace_arguments (loc, expr.value);
3826 3838
3827 TREE_TYPE(expr.value) = void_type_node; 3839 TREE_TYPE(expr.value) = void_type_node;
3828 //tree env = NULL_TREE; 3840 /*tree env = NULL_TREE;**/
3829 CbC_IS_CbC_GOTO (expr.value) = 1; 3841 CbC_IS_CbC_GOTO (expr.value) = 1;
3830 CALL_EXPR_TAILCALL (expr.value) = 1; 3842 CALL_EXPR_TAILCALL (expr.value) = 1;
3831 add_stmt(expr.value); 3843 add_stmt(expr.value);
3832 stmt = c_finish_return (0); 3844 stmt = c_finish_return (0);
3833 } 3845 }
5264 struct c_declspecs *specs; 5276 struct c_declspecs *specs;
5265 struct c_typespec t; 5277 struct c_typespec t;
5266 { 5278 {
5267 push_scope (); 5279 push_scope ();
5268 declare_parm_level (); 5280 declare_parm_level ();
5269 //tree retval_type = TREE_TYPE(retval_decl); 5281 /*tree retval_type = TREE_TYPE(retval_decl);*/
5270 5282
5271 _retval_decl = build_decl (PARM_DECL, get_identifier ("_retval"), TREE_TYPE(retval_decl)); 5283 _retval_decl = build_decl (PARM_DECL, get_identifier ("_retval"), TREE_TYPE(retval_decl));
5272 DECL_SOURCE_LOCATION (_retval_decl) = loc; 5284 DECL_SOURCE_LOCATION (_retval_decl) = loc;
5273 DECL_ARTIFICIAL (_retval_decl) = 1; 5285 DECL_ARTIFICIAL (_retval_decl) = 1;
5274 DECL_ARG_TYPE (_retval_decl) = TREE_TYPE(retval_decl); 5286 DECL_ARG_TYPE (_retval_decl) = TREE_TYPE(retval_decl);
5291 specs = build_null_declspecs(); 5303 specs = build_null_declspecs();
5292 declspecs_add_type (specs, t); 5304 declspecs_add_type (specs, t);
5293 finish_declspecs (specs); 5305 finish_declspecs (specs);
5294 5306
5295 /* make nested function. */ 5307 /* make nested function. */
5296 //ident = build_decl (/*TODO:*/VAR_DECL, get_identifier ("_cbc_internal_return"), specs->type);
5297 declarator = build_id_declarator (get_identifier ("_cbc_internal_return")); 5308 declarator = build_id_declarator (get_identifier ("_cbc_internal_return"));
5298 //declarator->id_loc = ;
5299 declarator = build_function_declarator (args, declarator); 5309 declarator = build_function_declarator (args, declarator);
5300 5310
5301 c_push_function_context (); 5311 c_push_function_context ();
5302 5312
5303 if (!start_function (specs, declarator, NULL_TREE)) 5313 if (!start_function (specs, declarator, NULL_TREE))
5890 pushdecl (decl_cond); 5900 pushdecl (decl_cond);
5891 5901
5892 /* define nested function. */ 5902 /* define nested function. */
5893 decl = 5903 decl =
5894 cbc_finish_nested_function (location, label, decl_cond); 5904 cbc_finish_nested_function (location, label, decl_cond);
5895 //tree nested_func = cbc_make_nested_function (location);
5896 5905
5897 /* define if-ed goto label and return statement. */ 5906 /* define if-ed goto label and return statement. */
5898 cbc_finish_labeled_goto (location, label, decl_cond); 5907 cbc_finish_labeled_goto (location, label, decl_cond);
5899 5908
5900 /* get pointer to nested function. */ 5909 /* get pointer to nested function. */
5901 value = build_addr (decl , current_function_decl); 5910 value = build_addr (decl , current_function_decl);
5902 SET_EXPR_LOCATION (value, location); 5911 SET_EXPR_LOCATION (value, location);
5903 add_stmt (value); 5912 add_stmt (value);
5904 //value = build_external_ref (get_identifier("_cbc_internal_return"), false, location); 5913 /*value = build_external_ref (get_identifier("_cbc_internal_return"), false, location);*/
5905 //value = build_unary_op (location, ADDR_EXPR, value, 0); 5914 /*value = build_unary_op (location, ADDR_EXPR, value, 0);*/
5906 //add_stmt (value); 5915 /*add_stmt (value);*/
5907 5916
5908 TREE_SIDE_EFFECTS (stmt) = 1; 5917 TREE_SIDE_EFFECTS (stmt) = 1;
5909 expr.value = c_finish_stmt_expr (stmt); 5918 expr.value = c_finish_stmt_expr (stmt);
5910 expr.original_code = ERROR_MARK; 5919 expr.original_code = ERROR_MARK;
5911 } 5920 }