1 /* Perform non-arithmetic operations on values, for GDB.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
22 #include "initialize.h"
29 /* Cast value ARG2 to type TYPE and return as a value.
30 More general than a C cast: accepts any two types of the same length,
31 and if ARG2 is an lvalue it can be cast into anything at all. */
34 value_cast (type, arg2)
38 register enum type_code code1;
39 register enum type_code code2;
42 /* Coerce arrays but not enums. Enums will work as-is
43 and coercing them would cause an infinite recursion. */
44 if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_ENUM)
47 code1 = TYPE_CODE (type);
48 code2 = TYPE_CODE (VALUE_TYPE (arg2));
49 scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT
50 || code2 == TYPE_CODE_ENUM);
52 if (code1 == TYPE_CODE_FLT && scalar)
53 return value_from_double (type, value_as_double (arg2));
54 else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM)
55 && (scalar || code2 == TYPE_CODE_PTR))
56 return value_from_long (type, value_as_long (arg2));
57 else if (TYPE_LENGTH (type) == TYPE_LENGTH (VALUE_TYPE (arg2)))
59 if ((code1 == TYPE_CODE_MPTR) ^ (code2 == TYPE_CODE_MPTR))
60 printf ("warning: assignment between pointer-to-member and non pointer-to-member types\n");
62 VALUE_TYPE (arg2) = type;
65 else if (VALUE_LVAL (arg2) == lval_memory)
67 if ((code1 == TYPE_CODE_MPTR) ^ (code2 == TYPE_CODE_MPTR))
68 printf ("warning: assignment between pointer-to-member and non pointer-to-member types\n");
70 return value_at (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2));
73 error ("Invalid cast.");
76 /* Return the value with a specified type located at specified address. */
83 register value val = allocate_value (type);
85 read_memory (addr, VALUE_CONTENTS (val), TYPE_LENGTH (type));
86 VALUE_LVAL (val) = lval_memory;
87 VALUE_ADDRESS (val) = addr;
92 /* Store the contents of FROMVAL into the location of TOVAL.
93 Return a new value with the location of TOVAL and contents of FROMVAL. */
96 value_assign (toval, fromval)
97 register value toval, fromval;
99 register struct type *type = VALUE_TYPE (toval);
101 char raw_buffer[MAX_REGISTER_RAW_SIZE];
102 char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
105 COERCE_ARRAY (fromval);
107 if (VALUE_LVAL (toval) != lval_internalvar)
108 fromval = value_cast (type, fromval);
110 /* If TOVAL is a special machine register requiring conversion
111 of program values to a special raw format,
112 convert FROMVAL's contents now, with result in `raw_buffer',
113 and set USE_BUFFER to the number of bytes to write. */
115 if (VALUE_REGNO (toval) >= 0
116 && REGISTER_CONVERTIBLE (VALUE_REGNO (toval)))
118 int regno = VALUE_REGNO (toval);
119 if (VALUE_TYPE (fromval) != REGISTER_VIRTUAL_TYPE (regno))
120 fromval = value_cast (REGISTER_VIRTUAL_TYPE (regno), fromval);
121 bcopy (VALUE_CONTENTS (fromval), virtual_buffer,
122 REGISTER_VIRTUAL_SIZE (regno));
123 REGISTER_CONVERT_TO_RAW (regno, virtual_buffer, raw_buffer);
124 use_buffer = REGISTER_RAW_SIZE (regno);
127 switch (VALUE_LVAL (toval))
129 case lval_internalvar:
130 set_internalvar (VALUE_INTERNALVAR (toval), fromval);
133 case lval_internalvar_component:
134 set_internalvar_component (VALUE_INTERNALVAR (toval),
135 VALUE_OFFSET (toval),
136 VALUE_BITPOS (toval),
137 VALUE_BITSIZE (toval),
142 if (VALUE_BITSIZE (toval))
145 read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
147 modify_field (&val, value_as_long (fromval),
148 VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
149 write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
153 write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
154 raw_buffer, use_buffer);
156 write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
157 VALUE_CONTENTS (fromval), TYPE_LENGTH (type));
161 if (VALUE_BITSIZE (toval))
165 read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
167 modify_field (&val, value_as_long (fromval),
168 VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
169 write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
173 write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
174 raw_buffer, use_buffer);
176 write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
177 VALUE_CONTENTS (fromval), TYPE_LENGTH (type));
181 error ("Left side of = operation is not an lvalue.");
184 /* Return a value just like TOVAL except with the contents of FROMVAL. */
186 val = allocate_value (type);
187 bcopy (toval, val, VALUE_CONTENTS (val) - (char *) val);
188 bcopy (VALUE_CONTENTS (fromval), VALUE_CONTENTS (val), TYPE_LENGTH (type));
193 /* Extend a value VAL to COUNT repetitions of its type. */
196 value_repeat (arg1, count)
202 if (VALUE_LVAL (arg1) != lval_memory)
203 error ("Only values in memory can be extended with '@'.");
205 error ("Invalid number %d of repetitions.", count);
207 val = allocate_repeat_value (VALUE_TYPE (arg1), count);
209 read_memory (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1),
210 VALUE_CONTENTS (val),
211 TYPE_LENGTH (VALUE_TYPE (val)) * count);
212 VALUE_LVAL (val) = lval_memory;
213 VALUE_ADDRESS (val) = VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1);
219 value_of_variable (var)
222 return read_var_value (var, (CORE_ADDR) 0);
225 /* Given a value which is an array, return a value which is
226 a pointer to its first element. */
229 value_coerce_array (arg1)
232 register struct type *type;
235 if (VALUE_LVAL (arg1) != lval_memory)
236 error ("Attempt to take address of value not located in memory.");
238 /* Get type of elements. */
239 if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY)
240 type = TYPE_TARGET_TYPE (VALUE_TYPE (arg1));
242 /* A phony array made by value_repeat.
243 Its type is the type of the elements, not an array type. */
244 type = VALUE_TYPE (arg1);
246 /* Get the type of the result. */
247 type = lookup_pointer_type (type);
248 val = value_from_long (builtin_type_long,
249 VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1));
250 VALUE_TYPE (val) = type;
254 /* Return a pointer value for the object for which ARG1 is the contents. */
260 register struct type *type;
261 register value val, arg1_coerced;
263 /* Taking the address of an array is really a no-op
264 once the array is coerced to a pointer to its first element. */
266 COERCE_ARRAY (arg1_coerced);
267 if (arg1 != arg1_coerced)
270 if (VALUE_LVAL (arg1) != lval_memory)
271 error ("Attempt to take address of value not located in memory.");
273 /* Get the type of the result. */
274 type = lookup_pointer_type (VALUE_TYPE (arg1));
275 val = value_from_long (builtin_type_long,
276 VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1));
277 VALUE_TYPE (val) = type;
281 /* Given a value of a pointer type, apply the C unary * operator to it. */
289 if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_MPTR)
290 error ("not implemented: member pointers in value_ind");
292 /* Allow * on an integer so we can cast it to whatever we want. */
293 if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT)
294 return value_at (builtin_type_long,
295 (CORE_ADDR) value_as_long (arg1));
296 else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR)
297 return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
298 (CORE_ADDR) value_as_long (arg1));
299 else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF)
300 return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
301 (CORE_ADDR) value_as_long (arg1));
302 error ("Attempt to take contents of a non-pointer value.");
305 /* Pushing small parts of stack frames. */
307 /* Push one word (the size of object that a register holds). */
310 push_word (sp, buffer)
312 REGISTER_TYPE buffer;
314 register int len = sizeof (REGISTER_TYPE);
318 write_memory (sp, &buffer, len);
319 #else /* stack grows upward */
320 write_memory (sp, &buffer, len);
322 #endif /* stack grows upward */
327 /* Push LEN bytes with data at BUFFER. */
330 push_bytes (sp, buffer, len)
337 write_memory (sp, buffer, len);
338 #else /* stack grows upward */
339 write_memory (sp, buffer, len);
341 #endif /* stack grows upward */
346 /* Push onto the stack the specified value VALUE. */
350 register CORE_ADDR sp;
353 register int len = TYPE_LENGTH (VALUE_TYPE (arg));
357 write_memory (sp, VALUE_CONTENTS (arg), len);
358 #else /* stack grows upward */
359 write_memory (sp, VALUE_CONTENTS (arg), len);
361 #endif /* stack grows upward */
366 /* Perform the standard coercions that are specified
367 for arguments to be passed to C functions. */
370 value_arg_coerce (arg)
373 register struct type *type;
377 type = VALUE_TYPE (arg);
379 if (TYPE_CODE (type) == TYPE_CODE_INT
380 && TYPE_LENGTH (type) < sizeof (int))
381 return value_cast (builtin_type_int, arg);
383 if (type == builtin_type_float)
384 return value_cast (builtin_type_double, arg);
389 /* Push the value ARG, first coercing it as an argument
393 value_arg_push (sp, arg)
394 register CORE_ADDR sp;
397 return value_push (sp, value_arg_coerce (arg));
400 /* Perform a function call in the inferior.
401 ARGS is a vector of values of arguments (NARGS of them).
402 FUNCTION is a value, the function to be called.
403 Returns a value representing what the function returned.
404 May fail to return, if a breakpoint or signal is hit
405 during the execution of the function. */
408 call_function (function, nargs, args)
413 register CORE_ADDR sp;
416 static REGISTER_TYPE dummy[] = CALL_DUMMY;
417 REGISTER_TYPE dummy1[sizeof dummy / sizeof (REGISTER_TYPE)];
419 struct type *value_type;
424 register CORE_ADDR funaddr;
425 register struct type *ftype = VALUE_TYPE (function);
426 register enum type_code code = TYPE_CODE (ftype);
428 if (code == TYPE_CODE_MPTR)
429 error ("not implemented: member pointer to call_function");
431 /* Determine address to call. */
432 if (code == TYPE_CODE_FUNC)
434 funaddr = VALUE_ADDRESS (function);
435 value_type = TYPE_TARGET_TYPE (ftype);
437 else if (code == TYPE_CODE_PTR)
439 funaddr = value_as_long (function);
440 if (TYPE_CODE (TYPE_TARGET_TYPE (ftype))
442 value_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype));
444 value_type = builtin_type_int;
446 else if (code == TYPE_CODE_INT)
448 /* Handle the case of functions lacking debugging info.
449 Their values are characters since their addresses are char */
450 if (TYPE_LENGTH (ftype) == 1)
451 funaddr = value_as_long (value_addr (function));
453 /* Handle integer used as address of a function. */
454 funaddr = value_as_long (function);
456 value_type = builtin_type_int;
459 error ("Invalid data type for function to be called.");
461 /* Create a call sequence customized for this function
462 and the number of arguments for it. */
463 bcopy (dummy, dummy1, sizeof dummy);
464 FIX_CALL_DUMMY (dummy1, funaddr, nargs);
467 old_sp = sp = read_register (SP_REGNUM);
469 #if 1 INNER_THAN 2 /* Stack grows down */
471 write_memory (sp, dummy1, sizeof dummy);
473 for (i = nargs - 1; i >= 0; i--)
474 sp = value_arg_push (sp, args[i]);
475 #else /* Stack grows up */
477 write_memory (sp, dummy1, sizeof dummy);
479 for (i = 0; i < nargs; i++)
480 sp = value_arg_push (sp, args[i]);
481 #endif /* Stack grows up */
483 write_register (SP_REGNUM, sp);
485 /* Figure out the value returned by the function. */
487 char retbuf[REGISTER_BYTES];
489 /* Execute the stack dummy routine, calling FUNCTION.
490 When it is done, discard the empty frame
491 after storing the contents of all regs into retbuf. */
492 run_stack_dummy (start_sp + CALL_DUMMY_START_OFFSET, retbuf);
494 return value_being_returned (value_type, retbuf);
498 /* Create a value for a string constant:
499 Call the function malloc in the inferior to get space for it,
500 then copy the data into that space
501 and then return the address with type char *.
502 PTR points to the string constant data; LEN is number of characters. */
505 value_string (ptr, len)
510 register struct symbol *sym;
512 register char *copy = (char *) alloca (len + 1);
514 register char *o = copy, *ibeg = ptr;
517 /* Copy the string into COPY, processing escapes.
518 We could not conveniently process them in expread
519 because the string there wants to be a substring of the input. */
521 while (i - ibeg < len)
526 c = parse_escape (&i);
534 /* Get the length of the string after escapes are processed. */
538 /* Find the address of malloc in the inferior. */
540 sym = lookup_symbol ("malloc", 0, VAR_NAMESPACE);
543 if (SYMBOL_CLASS (sym) != LOC_BLOCK)
544 error ("\"malloc\" exists in this program but is not a function.");
545 val = value_of_variable (sym);
550 for (i = 0; i < misc_function_count; i++)
551 if (!strcmp (misc_function_vector[i].name, "malloc"))
553 if (i < misc_function_count)
554 val = value_from_long (builtin_type_long,
555 misc_function_vector[i].address);
557 error ("String constants require the program to have a function \"malloc\".");
560 blocklen = value_from_long (builtin_type_int, len + 1);
561 val = call_function (val, 1, &blocklen);
562 if (value_zerop (val))
563 error ("No memory available for string constant.");
564 write_memory (value_as_long (val), copy, len + 1);
565 VALUE_TYPE (val) = lookup_pointer_type (builtin_type_char);
569 /* Given ARG1, a value of type (pointer to a)* structure/union,
570 extract the component named NAME from the ultimate target structure/union
571 and return it as a value with its appropriate type.
572 ERR is used in the error message if ARG1's type is wrong.
574 C++: ARGS is a list of argument types to aid in the selection of
575 an appropriate method. Also, handle derived types.
577 ERR is an error message to be printed in case the field is not found. */
580 value_struct_elt (arg1, args, name, err)
581 register value arg1, *args;
585 register struct type *t;
589 struct type *baseclass;
593 t = VALUE_TYPE (arg1);
595 /* Follow pointers until we get to a non-pointer. */
597 while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
599 arg1 = value_ind (arg1);
601 t = VALUE_TYPE (arg1);
604 if (TYPE_CODE (t) == TYPE_CODE_MPTR)
605 error ("not implemented: member pointers in value_struct_elt");
607 if (TYPE_CODE (t) != TYPE_CODE_STRUCT
608 && TYPE_CODE (t) != TYPE_CODE_UNION)
609 error ("Attempt to extract a component of a value that is not a %s.", err);
615 /* if there are no arguments ...do this... */
617 /* Try as a variable first, because if we succeed, there
618 is less work to be done. */
621 for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
623 if (!strcmp (TYPE_FIELD_NAME (t, i), name))
631 return TYPE_FIELD_STATIC (t, i)
632 ? value_static_field (t, name, i) : value_field (arg1, i);
634 t = TYPE_BASECLASS (t);
635 VALUE_TYPE (arg1) = t; /* side effect! */
638 /* C++: If it was not found as a data field, then try to
639 return it as a pointer to a method. */
641 VALUE_TYPE (arg1) = t; /* side effect! */
643 if (destructor_name_p (name, t))
644 error ("use `info method' command to print out value of destructor");
648 for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
650 if (! strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
652 error ("use `info method' command to print value of method \"%s\"", name);
655 t = TYPE_BASECLASS (t);
659 error("there is no field named %s", name);
663 if (destructor_name_p (name, t))
667 /* destructors are a special case. */
668 return (value)value_fn_field (arg1, 0, TYPE_FN_FIELDLIST_LENGTH (t, 0));
672 error ("destructor should not have any argument");
676 /* This following loop is for methods with arguments. */
679 /* Look up as method first, because that is where we
680 expect to find it first. */
681 for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; i--)
683 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
685 if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
688 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
691 for (j = TYPE_FN_FIELDLIST_LENGTH (t, i) - 1; j >= 0; --j)
693 if (!typecmp (TYPE_FN_FIELD_ARGS (f, j), args))
695 if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
697 /* First, get the virtual function table pointer.
698 That comes with a strange type, so cast
699 it to type `pointer to long' (which
700 should serve just fine as a function type).
701 Then, index into the table, and convert
702 final value to appropriate function type. */
704 value vi = value_from_long (builtin_type_int,
705 TYPE_FN_FIELD_VOFFSET (f, j));
706 VALUE_TYPE (arg1) = TYPE_VPTR_BASETYPE (t);
708 if (TYPE_VPTR_FIELDNO (t) < 0)
709 TYPE_VPTR_FIELDNO (t)
710 = fill_in_vptr_fieldno (t);
712 vtbl = value_field (arg1, TYPE_VPTR_FIELDNO (t));
713 vfn = value_subscript (vtbl, vi);
714 VALUE_TYPE (vfn) = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j));
718 return (value)value_fn_field (arg1, i, j);
723 t = TYPE_BASECLASS (t);
724 VALUE_TYPE (arg1) = t; /* side effect! */
729 error ("Structure method %s not defined for arglist.", name);
734 /* See if user tried to invoke data as function */
738 for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
740 if (!strcmp (TYPE_FIELD_NAME (t, i), name))
748 return TYPE_FIELD_STATIC (t, i)
749 ? value_static_field (t, name, i) : value_field (arg1, i);
751 t = TYPE_BASECLASS (t);
752 VALUE_TYPE (arg1) = t; /* side effect! */
754 error ("Structure has no component named %s.", name);
758 /* C++: return 1 is NAME is a legitimate name for the destructor
759 of type TYPE. If TYPE does not have a destructor, or
760 if NAME is inappropriate for TYPE, an error is signaled. */
762 destructor_name_p (name, type)
766 /* destructors are a special case. */
767 char *dname = TYPE_NAME (type);
771 if (! TYPE_HAS_DESTRUCTOR (type))
772 error ("type `%s' does not have destructor defined",
774 /* Skip past the "struct " at the front. */
775 while (*dname++ != ' ') ;
776 if (strcmp (dname, name+1))
777 error ("destructor specification error");
784 /* C++: Given ARG1, a value of type (pointer to a)* structure/union,
785 return 1 if the component named NAME from the ultimate
786 target structure/union is defined, otherwise, return 0. */
789 check_field (arg1, name)
793 register struct type *t;
797 struct type *baseclass;
801 t = VALUE_TYPE (arg1);
803 /* Follow pointers until we get to a non-pointer. */
805 while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
807 arg1 = value_ind (arg1);
809 t = VALUE_TYPE (arg1);
812 if (TYPE_CODE (t) == TYPE_CODE_MPTR)
813 error ("not implemented: member pointers in check_field");
815 if (TYPE_CODE (t) != TYPE_CODE_STRUCT
816 && TYPE_CODE (t) != TYPE_CODE_UNION)
817 error ("Internal error: `this' is not an aggregate");
823 for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
825 if (!strcmp (TYPE_FIELD_NAME (t, i), name))
830 t = TYPE_BASECLASS (t);
831 VALUE_TYPE (arg1) = t; /* side effect! */
834 /* C++: If it was not found as a data field, then try to
835 return it as a pointer to a method. */
837 VALUE_TYPE (arg1) = t; /* side effect! */
839 /* Destructors are a special case. */
840 if (destructor_name_p (name, t))
845 for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
847 if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
850 t = TYPE_BASECLASS (t);
855 /* C++: Given an aggregate type DOMAIN, and a member name NAME,
856 return the address of this member as a pointer to member
857 type. If INTYPE is non-null, then it will be the type
858 of the member we are looking for. This will help us resolve
859 pointers to member functions. */
862 value_struct_elt_for_address (domain, intype, name)
863 struct type *domain, *intype;
866 register struct type *t = domain;
871 struct type *baseclass;
873 if (TYPE_CODE (t) != TYPE_CODE_STRUCT
874 && TYPE_CODE (t) != TYPE_CODE_UNION)
875 error ("Internal error: non-aggregate type to value_struct_elt_for_address");
881 for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
883 if (!strcmp (TYPE_FIELD_NAME (t, i), name))
885 if (TYPE_FIELD_PACKED (t, i))
886 error ("pointers to bitfield members not allowed");
888 v = value_from_long (builtin_type_int, TYPE_FIELD_BITPOS (t, i) >> 3);
889 VALUE_TYPE (v) = lookup_member_pointer_type (TYPE_FIELD_TYPE (t, i), baseclass);
893 t = TYPE_BASECLASS (t);
896 /* C++: If it was not found as a data field, then try to
897 return it as a pointer to a method. */
900 /* Destructors are a special case. */
901 if (destructor_name_p (name, t))
903 error ("pointers to destructors not implemented yet");
908 for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
910 if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name))
912 int j = TYPE_FN_FIELDLIST_LENGTH (t, i);
913 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
915 if (intype == 0 && j > 1)
916 error ("non-unique member `%s' requires type instantiation", name);
920 if (TYPE_FN_FIELD_TYPE (f, j) == intype)
923 error ("no member function matches that type instantiation");
928 if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
930 v = value_from_long (builtin_type_long,
931 TYPE_FN_FIELD_VOFFSET (f, j));
935 struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
937 v = locate_var_value (s, 0);
939 VALUE_TYPE (v) = lookup_member_pointer_type (TYPE_FN_FIELD_TYPE (f, j), baseclass);
943 t = TYPE_BASECLASS (t);
948 /* Compare two argument lists and return the position in which they differ,
949 or zero if equal. Note that we ignore the first argument, which is
950 the type of the instance variable. This is because we want to handle
951 derived classes. This is not entirely correct: we should actually
952 check to make sure that a requested operation is type secure,
960 if (t1[0]->code == TYPE_CODE_VOID) return 0;
962 for (i = 1; t1[i]->code != TYPE_CODE_VOID; i++)
965 || t1[i]->code != t2[i]->type->code
966 || t1[i]->target_type != t2[i]->type->target_type)
971 return t2[i] ? i+1 : 0;
978 /* C++: return the value of the class instance variable, if one exists.
979 Flag COMPLAIN signals an error if the request is made in an
980 inappropriate context. */
982 value_of_this (complain)
985 extern FRAME selected_frame;
986 struct symbol *func, *sym;
991 if (selected_frame == 0)
993 error ("no frame selected");
996 func = get_frame_function (selected_frame);
998 funname = SYMBOL_NAME (func);
1001 error ("no `this' in nameless context");
1004 b = SYMBOL_BLOCK_VALUE (func);
1005 i = BLOCK_NSYMS (b);
1008 error ("no args, no `this'");
1011 sym = BLOCK_SYM (b, 0);
1012 if (strncmp ("$this", SYMBOL_NAME (sym), 5))
1014 error ("current stack frame not in method");
1017 return read_var_value (sym, selected_frame);