- ptype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (ptype, sizeof (struct type));
- TYPE_TARGET_TYPE (ptype) = type;
- TYPE_POINTER_TYPE (type) = ptype;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM;
- /* We assume the machine has only one representation for pointers! */
- /* FIXME: This confuses host<->target data representations, and is a
- poor assumption besides. */
- TYPE_LENGTH (ptype) = sizeof (char *);
- TYPE_CODE (ptype) = TYPE_CODE_PTR;
- return ptype;
-}
-
-struct type *
-lookup_reference_type (type)
- struct type *type;
-{
- register struct type *rtype = TYPE_REFERENCE_TYPE (type);
- if (rtype) return rtype;
-
- /* This is the first time anyone wanted a pointer to a TYPE. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- rtype = (struct type *) xmalloc (sizeof (struct type));
- else
- rtype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
-
- bzero (rtype, sizeof (struct type));
- TYPE_TARGET_TYPE (rtype) = type;
- TYPE_REFERENCE_TYPE (type) = rtype;
- /* New type is permanent if type pointed to is permanent. */
- if (TYPE_FLAGS (type) & TYPE_FLAG_PERM)
- TYPE_FLAGS (rtype) |= TYPE_FLAG_PERM;
- /* We assume the machine has only one representation for pointers! */
- TYPE_LENGTH (rtype) = sizeof (char *);
- TYPE_CODE (rtype) = TYPE_CODE_REF;
- return rtype;
-}
-
-
-/* Implement direct support for MEMBER_TYPE in GNU C++.
- May need to construct such a type if this is the first use.
- The TYPE is the type of the member. The DOMAIN is the type
- of the aggregate that the member belongs to. */
-
-struct type *
-lookup_member_type (type, domain)
- struct type *type, *domain;
-{
- register struct type *mtype;
-
- mtype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
- smash_to_member_type (mtype, domain, type);
- return mtype;
-}
-
-/* Allocate a stub method whose return type is TYPE.
- This apparently happens for speed of symbol reading, since parsing
- out the arguments to the method is cpu-intensive, the way we are doing
- it. So, we will fill in arguments later.
- This always returns a fresh type. */
-
-struct type *
-allocate_stub_method (type)
- struct type *type;
-{
- struct type *mtype = (struct type *) obstack_alloc (symbol_obstack,
- sizeof (struct type));
- bzero (mtype, sizeof (struct type));
- TYPE_TARGET_TYPE (mtype) = type;
- /* _DOMAIN_TYPE (mtype) = unknown yet */
- /* _ARG_TYPES (mtype) = unknown yet */
- TYPE_FLAGS (mtype) = TYPE_FLAG_STUB;
- TYPE_CODE (mtype) = TYPE_CODE_METHOD;
- TYPE_LENGTH (mtype) = 1;
- return mtype;
-}
-
-/* Ugly hack to convert method stubs into method types.
-
- He ain't kiddin'. This demangles the name of the method into a string
- including argument types, parses out each argument type, generates
- a string casting a zero to that type, evaluates the string, and stuffs
- the resulting type into an argtype vector!!! Then it knows the type
- of the whole function (including argument types for overloading),
- which info used to be in the stab's but was removed to hack back
- the space required for them. */
-void
-check_stub_method (type, i, j)
- struct type *type;
- int i, j;
-{
- extern char *gdb_mangle_name (), *strchr ();
- struct fn_field *f;
- char *mangled_name = gdb_mangle_name (type, i, j);
- char *demangled_name = cplus_demangle (mangled_name, 0);
- char *argtypetext, *p;
- int depth = 0, argcount = 1;
- struct type **argtypes;
- struct type *mtype;
-
- /* Now, read in the parameters that define this type. */
- argtypetext = strchr (demangled_name, '(') + 1;
- p = argtypetext;
- while (*p)
- {
- if (*p == '(')
- depth += 1;
- else if (*p == ')')
- depth -= 1;
- else if (*p == ',' && depth == 0)
- argcount += 1;
-
- p += 1;
- }
- /* We need one more slot for the void [...] or NULL [end of arglist] */
- argtypes = (struct type **) obstack_alloc (symbol_obstack,
- (argcount+1) * sizeof (struct type *));
- p = argtypetext;
- argtypes[0] = lookup_pointer_type (type);
- argcount = 1;
-
- if (*p != ')') /* () means no args, skip while */
- {
- depth = 0;
- while (*p)