void compile_resource_data (const char *name, const char *buffer, int length) { tree rtype, field = NULL_TREE, data_type, rinit, data, decl; char buf[60]; data_type = build_prim_array_type (unsigned_byte_type_node, strlen (name) + length); rtype = make_node (RECORD_TYPE); PUSH_FIELD (rtype, field, "name_length", unsigned_int_type_node); PUSH_FIELD (rtype, field, "resource_length", unsigned_int_type_node); PUSH_FIELD (rtype, field, "data", data_type); FINISH_RECORD (rtype); START_RECORD_CONSTRUCTOR (rinit, rtype); PUSH_FIELD_VALUE (rinit, "name_length", build_int_cst (NULL_TREE, strlen (name))); PUSH_FIELD_VALUE (rinit, "resource_length", build_int_cst (NULL_TREE, length)); data = build_string (strlen(name) + length, buffer); TREE_TYPE (data) = data_type; PUSH_FIELD_VALUE (rinit, "data", data); FINISH_RECORD_CONSTRUCTOR (rinit); TREE_CONSTANT (rinit) = 1; TREE_INVARIANT (rinit) = 1; /* Generate a unique-enough identifier. */ sprintf (buf, "_Jr%d", ++Jr_count); decl = build_decl (VAR_DECL, get_identifier (buf), rtype); TREE_STATIC (decl) = 1; DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; TREE_READONLY (decl) = 1; TREE_THIS_VOLATILE (decl) = 0; DECL_INITIAL (decl) = rinit; layout_decl (decl, 0); pushdecl (decl); rest_of_decl_compilation (decl, global_bindings_p (), 0); make_decl_rtl (decl); assemble_variable (decl, 1, 0, 0); resources = tree_cons (NULL_TREE, decl, resources); }
void compile_resource_data (const char *name, const char *buffer, int length) { tree rtype, field = NULL_TREE, data_type, rinit, data, decl; VEC(constructor_elt,gc) *v = NULL; data_type = build_prim_array_type (unsigned_byte_type_node, strlen (name) + length); rtype = make_node (RECORD_TYPE); PUSH_FIELD (input_location, rtype, field, "name_length", unsigned_int_type_node); PUSH_FIELD (input_location, rtype, field, "resource_length", unsigned_int_type_node); PUSH_FIELD (input_location, rtype, field, "data", data_type); FINISH_RECORD (rtype); START_RECORD_CONSTRUCTOR (v, rtype); PUSH_FIELD_VALUE (v, "name_length", build_int_cst (NULL_TREE, strlen (name))); PUSH_FIELD_VALUE (v, "resource_length", build_int_cst (NULL_TREE, length)); data = build_string (strlen(name) + length, buffer); TREE_TYPE (data) = data_type; PUSH_FIELD_VALUE (v, "data", data); FINISH_RECORD_CONSTRUCTOR (rinit, v, rtype); TREE_CONSTANT (rinit) = 1; decl = build_decl (input_location, VAR_DECL, java_mangle_resource_name (name), rtype); TREE_STATIC (decl) = 1; TREE_PUBLIC (decl) = 1; java_hide_decl (decl); DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; TREE_READONLY (decl) = 1; TREE_THIS_VOLATILE (decl) = 0; DECL_INITIAL (decl) = rinit; layout_decl (decl, 0); pushdecl (decl); rest_of_decl_compilation (decl, global_bindings_p (), 0); varpool_finalize_decl (decl); VEC_safe_push (tree, gc, resources, decl); }