void declare_function_name () { tree decl, init; char *name, *printable_name; if (current_function_decl == NULL) { name = ""; printable_name = "top level"; } else { char *kind = "function"; if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) kind = "method"; /* Allow functions to be nameless (such as artificial ones). */ if (DECL_NAME (current_function_decl)) name = IDENTIFIER_POINTER (DECL_NAME (current_function_decl)); else name = ""; printable_name = (*decl_printable_name) (current_function_decl, &kind); } push_obstacks_nochange (); decl = build_decl (VAR_DECL, get_identifier ("__FUNCTION__"), char_array_type_node); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_SOURCE_LINE (decl) = 0; DECL_IN_SYSTEM_HEADER (decl) = 1; DECL_IGNORED_P (decl) = 1; init = build_string (strlen (name) + 1, name); TREE_TYPE (init) = char_array_type_node; DECL_INITIAL (decl) = init; finish_decl (pushdecl (decl), init, NULL_TREE); push_obstacks_nochange (); decl = build_decl (VAR_DECL, get_identifier ("__PRETTY_FUNCTION__"), char_array_type_node); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_SOURCE_LINE (decl) = 0; DECL_IN_SYSTEM_HEADER (decl) = 1; DECL_IGNORED_P (decl) = 1; init = build_string (strlen (printable_name) + 1, printable_name); TREE_TYPE (init) = char_array_type_node; DECL_INITIAL (decl) = init; finish_decl (pushdecl (decl), init, NULL_TREE); }
void declare_function_name () { tree decl, type, init; char *name, *printable_name; int len; if (current_function_decl == NULL) { name = ""; printable_name = "top level"; } else { char *kind = "function"; if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) kind = "method"; /* Allow functions to be nameless (such as artificial ones). */ if (DECL_NAME (current_function_decl)) name = IDENTIFIER_POINTER (DECL_NAME (current_function_decl)); else name = ""; printable_name = (*decl_printable_name) (current_function_decl, &kind); } /* If the default size of char arrays isn't big enough for the name, make a bigger one. */ len = strlen (name) + 1; type = char_array_type_node; if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TREE_TYPE (char_array_type_node))) < len) type = build_array_type (char_type_node, build_index_type (build_int_2 (len, 0))); push_obstacks_nochange (); decl = build_decl (VAR_DECL, get_identifier ("__FUNCTION__"), type); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_SOURCE_LINE (decl) = 0; DECL_IN_SYSTEM_HEADER (decl) = 1; DECL_IGNORED_P (decl) = 1; init = build_string (len, name); TREE_TYPE (init) = type; DECL_INITIAL (decl) = init; finish_decl (pushdecl (decl), init, NULL_TREE); len = strlen (printable_name) + 1; type = char_array_type_node; if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TREE_TYPE (char_array_type_node))) < len) type = build_array_type (char_type_node, build_index_type (build_int_2 (len, 0))); push_obstacks_nochange (); decl = build_decl (VAR_DECL, get_identifier ("__PRETTY_FUNCTION__"), type); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_SOURCE_LINE (decl) = 0; DECL_IN_SYSTEM_HEADER (decl) = 1; DECL_IGNORED_P (decl) = 1; init = build_string (len, printable_name); TREE_TYPE (init) = type; DECL_INITIAL (decl) = init; finish_decl (pushdecl (decl), init, NULL_TREE); }
void finish_var_decl (tree var, tree initializer) { finish_decl (var, input_location, initializer, NULL_TREE, NULL_TREE); }
static void finish_handler_array () { tree decl = current_handler->handler_array_decl; tree t; tree handler_array_init = NULL_TREE; int handlers_count = 1; int nelts; /* Build the table mapping exceptions to handler(-number)s. This is done in reverse order. */ /* First push the end of the list. This is either the ELSE handler (current_handler->else_handler>0) or NULL handler to indicate the end of the list (if current_handler->else-handler == 0). The following works either way. */ handler_array_init = build_tree_list (NULL_TREE, chill_expand_tuple (handler_element_type, build_nt (CONSTRUCTOR, NULL_TREE, tree_cons (NULL_TREE, null_pointer_node, build_tree_list (NULL_TREE, build_int_2 (current_handler->else_handler, 0)))))); for (t = current_handler->on_alt_list; t != NULL_TREE; t = TREE_CHAIN (t)) { tree handler_number = TREE_PURPOSE(t); tree elist = TREE_VALUE (t); for ( ; elist != NULL_TREE; elist = TREE_CHAIN (elist)) { tree ex_decl = build_chill_exception_decl (IDENTIFIER_POINTER(TREE_VALUE(elist))); tree ex_addr = build1 (ADDR_EXPR, char_pointer_type_for_handler, ex_decl); tree el = build_nt (CONSTRUCTOR, NULL_TREE, tree_cons (NULL_TREE, ex_addr, build_tree_list (NULL_TREE, handler_number))); mark_addressable (ex_decl); TREE_CONSTANT (ex_addr) = 1; handler_array_init = tree_cons (NULL_TREE, chill_expand_tuple (handler_element_type, el), handler_array_init); handlers_count++; } } #if 1 nelts = list_length (handler_array_init); TYPE_DOMAIN (TREE_TYPE (decl)) = build_index_type (build_int_2 (nelts - 1, - (nelts == 0))); layout_type (TREE_TYPE (decl)); DECL_INITIAL (decl) = convert (TREE_TYPE (decl), build_nt (CONSTRUCTOR, NULL_TREE, handler_array_init)); /* Pop back to the obstack that is current for this binding level. This is because MAXINDEX, rtl, etc. to be made below must go in the permanent obstack. But don't discard the temporary data yet. */ pop_obstacks (); layout_decl (decl, 0); /* To prevent make_decl_rtl (called indiectly by rest_of_decl_compilation) throwing the existing RTL (which has already been used). */ PUT_MODE (DECL_RTL (decl), DECL_MODE (decl)); rest_of_decl_compilation (decl, (char*)0, 0, 0); expand_decl_init (decl); #else /* To prevent make_decl_rtl (called indirectly by finish_decl) altering the existing RTL. */ GET_MODE (DECL_RTL (current_handler->handler_array_decl)) = DECL_MODE (current_handler->handler_array_decl); finish_decl (current_handler->handler_array_decl, build_nt (CONSTRUCTOR, NULL_TREE, handler_array_init), NULL_TREE); #endif }