Mercurial > hg > Papers > 2010 > kent-master
view paper/sources/nest-and-goto.c @ 10:3d9addf62d0b
organized repository.
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Feb 2010 14:35:36 +0900 |
parents | |
children |
line wrap: on
line source
static void cbc_finish_labeled_goto (location_t loc, tree label, tree retval) { tree tlab; tree cond; tree cstmt = c_begin_compound_stmt (true); tlab = define_label (loc, label); gcc_assert (tlab); decl_attributes (&tlab, NULL_TREE, 0); add_stmt (build_stmt (LABEL_EXPR, tlab)); tree ret = c_finish_return (retval); TREE_USED(ret) = 1; cond = integer_zero_node; tree if_body = c_end_compound_stmt (cstmt, true); TREE_SIDE_EFFECTS (cstmt) = 1; c_finish_if_stmt (loc, cond, if_body, NULL_TREE, false); } static tree cbc_finish_nested_function (location_t loc, tree label, tree retval_decl) { tree fnbody; tree _retval_decl, _envp_decl; struct c_declarator *declarator; tree ident; struct c_arg_info *args; struct c_declspecs *specs; struct c_typespec t; { push_scope (); declare_parm_level (); /*tree retval_type = TREE_TYPE(retval_decl);*/ _retval_decl = build_decl (PARM_DECL, get_identifier ("_retval"), TREE_TYPE (retval_decl)); DECL_SOURCE_LOCATION (_retval_decl) = loc; DECL_ARTIFICIAL (_retval_decl) = 1; DECL_ARG_TYPE (_retval_decl) = TREE_TYPE(retval_decl); pushdecl (_retval_decl); finish_decl (_retval_decl, NULL_TREE, NULL_TREE); _envp_decl = build_decl (PARM_DECL, get_identifier ("_envp"), ptr_type_node ); DECL_SOURCE_LOCATION (_envp_decl) = loc; DECL_ARTIFICIAL (_envp_decl) = 1; DECL_ARG_TYPE (_envp_decl) = ptr_type_node; pushdecl (_envp_decl); finish_decl (_envp_decl, NULL_TREE, NULL_TREE); args = get_parm_info(false); pop_scope(); } t.kind = ctsk_resword; t.spec = get_identifier("void"); specs = build_null_declspecs(); declspecs_add_type (specs, t); finish_declspecs (specs); /* make nested function. */ declarator = build_id_declarator ( get_identifier ("_cbc_internal_return")); declarator = build_function_declarator (args, declarator); c_push_function_context (); if (!start_function (specs, declarator, NULL_TREE)) { c_pop_function_context(); gcc_assert (0); } store_parm_decls (); /* start compound statement. */ tree cstmt = c_begin_compound_stmt (true); add_stmt (build_modify_expr (loc, retval_decl, NOP_EXPR, _retval_decl)); tree stmt = c_finish_goto_label (label); /* end compound statement. */ fnbody = c_end_compound_stmt (cstmt, true); TREE_SIDE_EFFECTS (cstmt) = 1; /* finish declaration of nested function. */ tree decl = current_function_decl; add_stmt (fnbody); finish_function (); c_pop_function_context (); add_stmt (build_stmt (DECL_EXPR, decl)); return decl; }