📄 decl.c
字号:
DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name); make_decl_rtl (decl, NULL_PTR, 1); pushdecl (decl); if (function_code != NOT_BUILT_IN) { DECL_BUILT_IN (decl) = 1; DECL_FUNCTION_CODE (decl) = function_code; } return decl;}voidinit_decl_processing (){ register tree endlink; tree field = NULL_TREE; tree t; current_function_decl = NULL; current_binding_level = NULL_BINDING_LEVEL; free_binding_level = NULL_BINDING_LEVEL; pushlevel (0); /* make the binding_level structure for global names */ global_binding_level = current_binding_level; error_mark_node = make_node (ERROR_MARK); TREE_TYPE (error_mark_node) = error_mark_node; /* Create sizetype first - needed for other types. */ sizetype = make_unsigned_type (POINTER_SIZE); size_zero_node = build_int_2 (0, 0); TREE_TYPE (size_zero_node) = sizetype; size_one_node = build_int_2 (1, 0); TREE_TYPE (size_one_node) = sizetype; byte_type_node = make_signed_type (8); pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node)); short_type_node = make_signed_type (16); pushdecl (build_decl (TYPE_DECL, get_identifier ("short"), short_type_node)); int_type_node = make_signed_type (32); pushdecl (build_decl (TYPE_DECL, get_identifier ("int"), int_type_node)); long_type_node = make_signed_type (64); pushdecl (build_decl (TYPE_DECL, get_identifier ("long"), long_type_node)); unsigned_byte_type_node = make_unsigned_type (8); pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"), unsigned_byte_type_node)); unsigned_short_type_node = make_unsigned_type (16); pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short"), unsigned_short_type_node)); unsigned_int_type_node = make_unsigned_type (32); pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"), unsigned_int_type_node)); unsigned_long_type_node = make_unsigned_type (64); pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"), unsigned_long_type_node)); integer_type_node = type_for_size (INT_TYPE_SIZE, 0); integer_zero_node = build_int_2 (0, 0); integer_one_node = build_int_2 (1, 0); integer_two_node = build_int_2 (2, 0); integer_four_node = build_int_2 (4, 0); integer_negative_one_node = build_int_2 (-1, 0); long_zero_node = build_int_2 (0, 0); TREE_TYPE (long_zero_node) = long_type_node; void_type_node = make_node (VOID_TYPE); pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node)); layout_type (void_type_node); /* Uses size_zero_node */ ptr_type_node = build_pointer_type (void_type_node); t = make_node (VOID_TYPE); layout_type (t); /* Uses size_zero_node */ return_address_type_node = build_pointer_type (t); null_pointer_node = build_int_2 (0, 0); TREE_TYPE (null_pointer_node) = ptr_type_node; /* Used by the parser to represent empty statements and blocks. */ empty_stmt_node = build1 (NOP_EXPR, void_type_node, size_zero_node); CAN_COMPLETE_NORMALLY (empty_stmt_node) = 1;#if 0 /* Make a type to be the domain of a few array types whose domains don't really matter. 200 is small enough that it always fits in size_t and large enough that it can hold most function names for the initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */ short_array_type_node = build_prim_array_type (short_type_node, 200);#endif char_type_node = make_node (CHAR_TYPE); TYPE_PRECISION (char_type_node) = 16; fixup_unsigned_type (char_type_node); pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), char_type_node)); boolean_type_node = make_node (BOOLEAN_TYPE); TYPE_PRECISION (boolean_type_node) = 1; fixup_unsigned_type (boolean_type_node); pushdecl (build_decl (TYPE_DECL, get_identifier ("boolean"), boolean_type_node)); boolean_false_node = TYPE_MIN_VALUE (boolean_type_node); boolean_true_node = TYPE_MAX_VALUE (boolean_type_node); promoted_byte_type_node = push_promoted_type ("promoted_byte", byte_type_node); promoted_short_type_node = push_promoted_type ("promoted_short", short_type_node); promoted_char_type_node = push_promoted_type ("promoted_char", char_type_node); promoted_boolean_type_node = push_promoted_type ("promoted_boolean", boolean_type_node); float_type_node = make_node (REAL_TYPE); TYPE_PRECISION (float_type_node) = 32; pushdecl (build_decl (TYPE_DECL, get_identifier ("float"), float_type_node)); layout_type (float_type_node); double_type_node = make_node (REAL_TYPE); TYPE_PRECISION (double_type_node) = 64; pushdecl (build_decl (TYPE_DECL, get_identifier ("double"), double_type_node)); layout_type (double_type_node); float_zero_node = build_real (float_type_node, dconst0); double_zero_node = build_real (double_type_node, dconst0); /* As your adding items here, please update the code right after this section, so that the filename containing the source code of the pre-defined class gets registered correctly. */ unqualified_object_id_node = get_identifier ("Object"); object_type_node = lookup_class (get_identifier ("java.lang.Object")); object_ptr_type_node = promote_type (object_type_node); string_type_node = lookup_class (get_identifier ("java.lang.String")); string_ptr_type_node = promote_type (string_type_node); class_type_node = lookup_class (get_identifier ("java.lang.Class")); throwable_type_node = lookup_class (get_identifier ("java.lang.Throwable")); runtime_exception_type_node = lookup_class (get_identifier ("java.lang.RuntimeException")); error_exception_type_node = lookup_class (get_identifier ("java.lang.Error")); /* This section has to be updated as items are added to the previous section. */ predef_filenames_size = 6; predef_filenames = (tree *)xmalloc (predef_filenames_size * sizeof (tree)); predef_filenames [0] = get_identifier ("java/lang/Class.java"); predef_filenames [1] = get_identifier ("java/lang/Error.java"); predef_filenames [2] = get_identifier ("java/lang/Object.java"); predef_filenames [3] = get_identifier ("java/lang/RuntimeException.java"); predef_filenames [4] = get_identifier ("java/lang/String.java"); predef_filenames [5] = get_identifier ("java/lang/Throwable.java"); methodtable_type = make_node (RECORD_TYPE); layout_type (methodtable_type); build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type); methodtable_ptr_type = build_pointer_type (methodtable_type); TYPE_identifier_node = get_identifier ("TYPE"); init_identifier_node = get_identifier ("<init>"); clinit_identifier_node = get_identifier ("<clinit>"); finit_identifier_node = get_identifier ("$finit$"); void_signature_node = get_identifier ("()V"); length_identifier_node = get_identifier ("length"); this_identifier_node = get_identifier ("this"); super_identifier_node = get_identifier ("super"); continue_identifier_node = get_identifier ("continue"); /* for lack of a better place to put this stub call */ init_expr_processing(); utf8const_type = make_node (RECORD_TYPE); PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node); PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node); FINISH_RECORD (utf8const_type); utf8const_ptr_type = build_pointer_type (utf8const_type); constants_type_node = make_node (RECORD_TYPE); PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node); PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node); PUSH_FIELD (constants_type_node, field, "data", ptr_type_node); FINISH_RECORD (constants_type_node); build_decl (TYPE_DECL, get_identifier ("constants"), constants_type_node); access_flags_type_node = unsigned_short_type_node; dtable_type = make_node (RECORD_TYPE); dtable_ptr_type = build_pointer_type (dtable_type); PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type); PUSH_FIELD (object_type_node, field, "sync_info", ptr_type_node); for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t)) FIELD_PRIVATE (t) = 1; FINISH_RECORD (object_type_node); class_dtable_decl = build_dtable_decl (class_type_node); TREE_STATIC (class_dtable_decl) = 1; DECL_ARTIFICIAL (class_dtable_decl) = 1; DECL_IGNORED_P (class_dtable_decl) = 1; rest_of_decl_compilation (class_dtable_decl, (char*) 0, 1, 0); field_type_node = make_node (RECORD_TYPE); field_ptr_type_node = build_pointer_type (field_type_node); method_type_node = make_node (RECORD_TYPE); method_ptr_type_node = build_pointer_type (method_type_node); set_super_info (0, class_type_node, object_type_node, 0); set_super_info (0, string_type_node, object_type_node, 0); class_ptr_type = build_pointer_type (class_type_node); PUSH_FIELD (class_type_node, field, "next", class_ptr_type); PUSH_FIELD (class_type_node, field, "name", utf8const_ptr_type); PUSH_FIELD (class_type_node, field, "accflags", access_flags_type_node); PUSH_FIELD (class_type_node, field, "superclass", class_ptr_type); PUSH_FIELD (class_type_node, field, "constants", constants_type_node); PUSH_FIELD (class_type_node, field, "methods", method_ptr_type_node); PUSH_FIELD (class_type_node, field, "method_count", short_type_node); PUSH_FIELD (class_type_node, field, "vtable_method_count", short_type_node); PUSH_FIELD (class_type_node, field, "fields", field_ptr_type_node); PUSH_FIELD (class_type_node, field, "size_in_bytes", int_type_node); PUSH_FIELD (class_type_node, field, "field_count", short_type_node); PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node); PUSH_FIELD (class_type_node, field, "vtable", dtable_ptr_type); PUSH_FIELD (class_type_node, field, "interfaces", build_pointer_type (class_ptr_type)); PUSH_FIELD (class_type_node, field, "loader", ptr_type_node); PUSH_FIELD (class_type_node, field, "interface_count", short_type_node); PUSH_FIELD (class_type_node, field, "state", byte_type_node); PUSH_FIELD (class_type_node, field, "thread", ptr_type_node); for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t)) FIELD_PRIVATE (t) = 1; push_super_field (class_type_node, object_type_node); FINISH_RECORD (class_type_node); build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node); field_info_union_node = make_node (UNION_TYPE); PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node); PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node);#if 0 PUSH_FIELD (field_info_union_node, field, "idx", unsigned_short_type_node);#endif layout_type (field_info_union_node); PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type); PUSH_FIELD (field_type_node, field, "type", class_ptr_type); PUSH_FIELD (field_type_node, field, "accflags", access_flags_type_node); PUSH_FIELD (field_type_node, field, "bsize", unsigned_short_type_node); PUSH_FIELD (field_type_node, field, "info", field_info_union_node); FINISH_RECORD (field_type_node); CLASS_LOADED_P (field_type_node) = 1; build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node); one_elt_array_domain_type = build_index_type (integer_one_node); nativecode_ptr_array_type_node = build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type); PUSH_FIELD (dtable_type, field, "class", class_ptr_type); PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node); FINISH_RECORD (dtable_type); build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);#define jint_type int_type_node#define jint_ptr_type ptr_type_node jexception_type = make_node (RECORD_TYPE); PUSH_FIELD (jexception_type, field, "start_pc", ptr_type_node); PUSH_FIELD (jexception_type, field, "end_pc", ptr_type_node); PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node); PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type); FINISH_RECORD (jexception_type); build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node); jexception_ptr_type = build_pointer_type (jexception_type); lineNumberEntry_type = make_node (RECORD_TYPE); PUSH_FIELD (lineNumberEntry_type, field, "line_nr", unsigned_short_type_node); PUSH_FIELD (lineNumberEntry_type, field, "start_pc", ptr_type_node); FINISH_RECORD (lineNumberEntry_type); lineNumbers_type = make_node (RECORD_TYPE); PUSH_FIELD (lineNumbers_type, field, "length", unsigned_int_type_node); FINISH_RECORD (lineNumbers_type);#define instn_ptr_type_node ptr_type_node /* XXX JH */#define lineNumbers_ptr_type_node build_pointer_type(lineNumbers_type) PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type); PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type); PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node); PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node); FINISH_RECORD (method_type_node); CLASS_LOADED_P (method_type_node) = 1; build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node); endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE); t = tree_cons (NULL_TREE, class_ptr_type, tree_cons (NULL_TREE, int_type_node, endlink)); alloc_object_node = builtin_function ("_Jv_AllocObject", build_function_type (ptr_type_node, t), NOT_BUILT_IN, NULL_PTR); soft_initclass_node = builtin_function ("_Jv_InitClass", build_function_type (void_type_node, t), NOT_BUILT_IN, NULL_PTR); t = tree_cons (NULL_TREE, ptr_type_node, endlink); throw_node = builtin_function ("_Jv_Throw", build_function_type (ptr_type_node, t), NOT_BUILT_IN, NULL_PTR); t = build_function_type (int_type_node, endlink); soft_monitorenter_node = builtin_function ("_Jv_MonitorEnter", t, NOT_BUILT_IN, NULL_PTR); soft_monitorexit_node = builtin_function ("_Jv_MonitorExit", t, NOT_BUILT_IN, NULL_PTR); t = tree_cons (NULL_TREE, int_type_node, tree_cons (NULL_TREE, int_type_node, endlink)); soft_newarray_node = builtin_function ("_Jv_NewArray", build_function_type(ptr_type_node, t), NOT_BUILT_IN, NULL_PTR ); t = tree_cons (NULL_TREE, int_type_node, tree_cons (NULL_TREE, class_ptr_type, tree_cons (NULL_TREE, object_ptr_type_node, endlink))); soft_anewarray_node = builtin_function ("_Jv_NewObjectArray", build_function_type (ptr_type_node, t), NOT_BUILT_IN, NULL_PTR ); t = tree_cons (NULL_TREE, ptr_type_node, tree_cons (NULL_TREE, int_type_node, endlink)); soft_multianewarray_node = builtin_function ("_Jv_NewMultiArray", build_function_type (ptr_type_node, t), NOT_BUILT_IN, NULL_PTR ); t = build_function_type (void_type_node, tree_cons (NULL_TREE, int_type_node, endlink)); soft_badarrayindex_node = builtin_function ("_Jv_ThrowBadArrayIndex", t, NOT_BUILT_IN, NULL_PTR); TREE_THIS_VOLATILE (soft_badarrayindex_node) = 1; TREE_SIDE_EFFECTS (soft_badarrayindex_node) = 1; t = tree_cons (NULL_TREE, class_ptr_type, tree_cons (NULL_TREE, object_ptr_type_node, endlink)); soft_checkcast_node = builtin_function ("_Jv_CheckCast", build_function_type (ptr_type_node, t), NOT_BUILT_IN, NULL_PTR); t = tree_cons (NULL_TREE, object_ptr_type_node, tree_cons (NULL_TREE, class_ptr_type, endlink)); soft_instanceof_node = builtin_function ("_Jv_IsInstanceOf", build_function_type (promoted_boolean_type_node, t), NOT_BUILT_IN, NULL_PTR); t = tree_cons (NULL_TREE, object_ptr_type_node, tree_cons (NULL_TREE, object_ptr_type_node, endlink)); soft_checkarraystore_node = builtin_function ("_Jv_CheckArrayStore", build_function_type (void_type_node, t), NOT_BUILT_IN, NULL_PTR); t = tree_cons (NULL_TREE, ptr_type_node, tree_cons (NULL_TREE, ptr_type_node, tree_cons (NULL_TREE, ptr_type_node, endlink))); soft_lookupinterfacemethod_node = builtin_function ("_Jv_LookupInterfaceMethod", build_function_type (ptr_type_node, t), NOT_BUILT_IN, NULL_PTR); t = tree_cons (NULL_TREE, double_type_node, tree_cons (NULL_TREE, double_type_node, endlink)); soft_fmod_node = builtin_function ("__builtin_fmod", build_function_type (double_type_node, t), BUILT_IN_FMOD, "fmod"); soft_exceptioninfo_call_node = build (CALL_EXPR, ptr_type_node, build_address_of (builtin_function ("_Jv_exception_info", build_function_type (ptr_type_node, endlink), NOT_BUILT_IN, NULL_PTR)), NULL_TREE, NULL_TREE); TREE_SIDE_EFFECTS (soft_exceptioninfo_call_node) = 1;#if 0 t = tree_cons (NULL_TREE, float_type_node, tree_cons (NULL_TREE, float_type_node, endlink)); soft_fmodf_node = builtin_function ("__builtin_fmodf", build_function_type (float_type_node, t), BUILT_IN_FMOD, "fmodf");#endif init_class_processing ();}/* Look up NAME in the current binding level and its superiors in the namespace of variables, functions and typedefs. Return a ..._DECL node of some kind representing its definition, or return 0 if it is undefined. */treelookup_name (name) tree name;{ register tree val; if (current_binding_level != global_binding_level && IDENTIFIER_LOCAL_VALUE (name)) val = IDENTIFIER_LOCAL_VALUE (name); else val = IDENTIFIER_GLOBAL_VALUE (name); return val;}/* Similar to `lookup_name' but look only at current binding level and the previous one if its the parameter level. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -