void java_mangle_decl (tree decl) { /* A copy of the check from the beginning of lhd_set_decl_assembler_name. */ /* set_decl_assembler_name may be called on TYPE_DECL to record ODR name for C++ types. By default types have no ODR names. */ if (TREE_CODE (decl) == TYPE_DECL) return; /* The language-independent code should never use the DECL_ASSEMBLER_NAME for lots of DECLs. Only FUNCTION_DECLs and VAR_DECLs for variables with static storage duration need a real DECL_ASSEMBLER_NAME. */ gcc_assert (TREE_CODE (decl) == FUNCTION_DECL || (TREE_CODE (decl) == VAR_DECL && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))); /* Mangling only applies to class members. */ if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))) { init_mangling (); switch (TREE_CODE (decl)) { case VAR_DECL: if (DECL_LANG_SPECIFIC (decl)) { if (DECL_CLASS_FIELD_P (decl)) { mangle_class_field (decl); break; } else if (DECL_VTABLE_P (decl)) { mangle_vtable (DECL_CONTEXT (decl)); break; } } mangle_field_decl (decl); break; case FUNCTION_DECL: if (DECL_LANG_SPECIFIC (decl) && DECL_LOCAL_CNI_METHOD_P (decl)) mangle_local_cni_method_decl (decl); else mangle_method_decl (decl); break; default: gcc_unreachable (); } SET_DECL_ASSEMBLER_NAME (decl, finish_mangling ()); } else lhd_set_decl_assembler_name (decl); }
void java_mangle_decl (tree decl) { /* A copy of the check from the beginning of lhd_set_decl_assembler_name. Only FUNCTION_DECLs and VAR_DECLs for variables with static storage duration need a real DECL_ASSEMBLER_NAME. */ gcc_assert (TREE_CODE (decl) == FUNCTION_DECL || (TREE_CODE (decl) == VAR_DECL && (TREE_STATIC (decl) || DECL_EXTERNAL (decl) || TREE_PUBLIC (decl)))); /* Mangling only applies to class members. */ if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))) { init_mangling (); switch (TREE_CODE (decl)) { case VAR_DECL: if (DECL_LANG_SPECIFIC (decl)) { if (DECL_CLASS_FIELD_P (decl)) { mangle_class_field (decl); break; } else if (DECL_VTABLE_P (decl)) { mangle_vtable (DECL_CONTEXT (decl)); break; } } mangle_field_decl (decl); break; case FUNCTION_DECL: if (DECL_LANG_SPECIFIC (decl) && DECL_LOCAL_CNI_METHOD_P (decl)) mangle_local_cni_method_decl (decl); else mangle_method_decl (decl); break; default: gcc_unreachable (); } SET_DECL_ASSEMBLER_NAME (decl, finish_mangling ()); } else lhd_set_decl_assembler_name (decl); }
tree java_mangle_resource_name (const char *name) { int len = strlen (name); char *buf = (char *) alloca (2 * len + 1); char *pos; const unsigned char *w1 = (const unsigned char *) name; const unsigned char *w2; const unsigned char *limit = w1 + len; pos = buf; init_mangling (); MANGLE_RAW_STRING ("Gr"); *pos++ = '_'; while (w1 < limit) { int ch; w2 = w1; ch = UTF8_GET (w1, limit); gcc_assert (ch > 0); switch (ch) { case '$': *pos++ = '$'; *pos++ = '$'; break; case '.': *pos++ = '$'; *pos++ = '_'; break; case '/': *pos++ = '$'; *pos++ = 'S'; break; default: memcpy (pos, w2, w1 - w2); pos += w1 - w2; break; } } append_gpp_mangled_name (buf, pos - buf); return finish_mangling (); }