Changeset 310
- Timestamp:
- Jun 10, 2003, 7:47:31 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/emxomf/stabshll.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r309 r310 126 126 const char *name; /* The field name */ 127 127 const char *sname; /* Static name */ 128 const char *mnglname; /* Mangled name for methods. (#456) */ 128 129 int flags; /* Member flags (visibility) */ 129 130 }; … … 184 185 struct type *ret; /* Return type */ 185 186 struct type *args; /* Argument types */ 187 struct type *domain; /* Domain type (C++ member) (#456) */ 186 188 int arg_count; /* Number of arguments */ 187 189 } func; … … 220 222 int flags; /* Member flags (visibility etc.) */ 221 223 const char *name; /* Name of the member function */ 224 const char *mnglname; /* Mangled Name of the member function. (#456) */ 222 225 } memfunc; 223 226 struct … … 664 667 && p->d.memfunc.offset == src->d.memfunc.offset 665 668 && p->d.memfunc.flags == src->d.memfunc.flags 666 && p->d.memfunc.name == src->d.memfunc.name) 669 && p->d.memfunc.name == src->d.memfunc.name 670 && p->d.memfunc.mnglname == src->d.memfunc.mnglname) 667 671 return p; 668 672 break; … … 1488 1492 1489 1493 ++parse_ptr; 1494 args_grow.count = 0; /* ASSUMES we can safely use args_grow/args_list. */ 1495 t2 = NULL; /* t2=Domain type; t1=Return type; */ 1490 1496 if (*parse_ptr == '#') 1491 1497 { … … 1501 1507 goto syntax; 1502 1508 t1 = parse_type (NULL); /* Return type */ 1509 /* Arguments */ 1503 1510 while (*parse_ptr != ';') 1504 1511 { 1505 1512 if (!parse_char (',')) 1506 1513 goto syntax; 1507 t2 = parse_type (NULL); /* Argument type */ 1514 grow_by (&args_grow, 1); 1515 args_list[args_grow.count++] = parse_type (NULL); /* Argument type */ 1508 1516 } 1509 1517 ++parse_ptr; 1510 1518 } 1511 1519 1520 t3 = NULL; 1521 #if 0 1522 if (args_grow.count) 1523 { 1524 t.tag = ty_args; 1525 t.index = -1; 1526 t.d.args.count = args_grow.count; 1527 t.d.args.list = xmalloc (args_grow.count * sizeof (*args_list)); 1528 memcpy (t.d.args.list, args_list, args_grow.count * sizeof (*args_list)); 1529 t3 = type_add (&t); 1530 free (t.d.args.list); 1531 } 1532 #endif 1533 1512 1534 /* Make a function type from the return type t1 */ 1513 1514 1535 t.tag = ty_func; 1515 1536 t.d.func.ret = t1; 1516 t.d.func.args = NULL; 1517 t.d.func.arg_count = 0; 1537 t.d.func.domain = t2; 1538 t.d.func.args = t3; 1539 t.d.func.arg_count = args_grow.count; 1540 args_grow.count = 0; 1541 t1 = type_add(&t); 1542 1518 1543 break; 1519 1544 … … 1704 1729 tf->flags = VIS_PUBLIC; 1705 1730 tf->name = strpool_addn (str_pool, parse_ptr, n); 1731 tf->mnglname = NULL; 1706 1732 parse_ptr = p1 + 1; 1707 1733 if (*parse_ptr == ':') … … 1711 1737 do 1712 1738 { 1739 const char * pszMangled; 1740 1713 1741 t1 = parse_type (NULL); 1714 1742 offset = 0; 1743 if (t1 == NULL || t1->tag != ty_func) 1744 { 1745 no_warning ("Invalid member function type"); 1746 goto syntax; 1747 } 1715 1748 1716 1749 if (*parse_ptr != ':') … … 1720 1753 } 1721 1754 ++parse_ptr; 1755 pszMangled = parse_ptr; 1722 1756 if (!parse_mangled_args ()) 1723 1757 goto syntax; 1758 tf->mnglname = strpool_addn(str_pool, pszMangled, parse_ptr - pszMangled - 1); /* ASSUMES not extra spaces! */ 1724 1759 tf->flags = parse_visibility () | MEMBER_FUNCTION; 1725 1760 switch (*parse_ptr) … … 1776 1811 ++parse_ptr; 1777 1812 } 1813 /* Contstructor / Destructor hack - 1814 * TODO: verify that this doesn't really work with overloaded constructors and fix it. 1815 */ 1816 if (!(tf->flags & MEMBER_STATIC)) 1817 { 1818 if (!strcmp(tf->name, "__comp_ctor") || !strcmp(tf->name, "__base_ctor")) 1819 tf->flags |= MEMBER_CTOR; 1820 else if (!strcmp(tf->name, "__comp_dtor") || !strcmp(tf->name, "__base_dtor")) 1821 tf->flags |= MEMBER_DTOR; 1822 } 1778 1823 tf->type = t1; 1779 1824 tf->offset = offset; … … 1874 1919 t.d.memfunc.type = t2; 1875 1920 t.d.memfunc.name = tmp_fields[i].name; 1921 t.d.memfunc.mnglname = tmp_fields[i].mnglname; 1876 1922 t.d.memfunc.flags = tmp_fields[i].flags; 1877 1923 t.d.memfunc.offset = tmp_fields[i].offset; … … 2694 2740 2695 2741 2696 /**2697 * Checks if the given name is likely to be a C++ method.2698 *2699 * @returns 1 if C++ method.2700 * @returns 0 if not method.2701 * @param pszName Pointer to the name.2702 * @remark Can also, if need, look around for symbols, types and stuff, but2703 * will no alter any parser state.2704 */2705 static int isCxxMethod(const char* pszName)2706 {2707 /* not perfect, but probably close enought */2708 return cplusplus_flag2709 && pszName[0] == '_'2710 && pszName[1] == 'Z'2711 && pszName[2] == 'N';2712 }2713 2714 2715 2742 /* Define a function. SYMBOL points to the sym_ptr entry. The 2716 2743 function arguments are taken from the args_list array. Several … … 2738 2765 proc_start_addr = symbol->n_value; 2739 2766 2740 if (args_grow.count == 0) 2741 t1 = NULL; 2742 else 2743 { 2744 t.tag = ty_args; 2745 t.index = -1; 2746 t.d.args.count = args_grow.count; 2747 t.d.args.list = xmalloc (args_grow.count * sizeof (*args_list)); 2748 memcpy (t.d.args.list, args_list, args_grow.count * sizeof (*args_list)); 2749 t1 = type_add (&t); 2750 free (t.d.args.list); 2751 } 2752 last_fun_type.d.func.args = t1; 2753 last_fun_type.d.func.arg_count = args_grow.count; 2754 t2 = type_add (&last_fun_type); 2755 make_type (t2, &ti); 2756 if (isCxxMethod(name)) 2757 { 2758 /* kso #456 2003-06-05: TODO - check for methods somehow */ 2759 sst_start (cplusplus_flag ? SST_CPPproc : SST_proc); 2767 /* now let's see if there is a memfunc for this name. */ 2768 for (t1 = type_head; t1; t1 = t1->next) 2769 if ( t1->tag == ty_memfunc 2770 && t.d.memfunc.mnglname 2771 && !strcmp (t1->d.memfunc.mnglname, name)) 2772 break; 2773 2774 if (t1) 2775 { /* C++ member function */ 2776 sst_start (SST_memfunc); 2760 2777 r.r_address = sst.size; 2761 2778 buffer_dword (&sst, symbol->n_value); /* Segment offset */ 2762 buffer_word (&sst, t i);/* Type index */2779 buffer_word (&sst, t1->index); /* Type index */ 2763 2780 proc_patch_base = sst.size; 2764 2781 buffer_dword (&sst, 0); /* Length of proc */ 2765 2782 buffer_word (&sst, 0); /* Length of prologue */ 2766 2783 buffer_dword (&sst, 0); /* Length of prologue and body */ 2767 buffer_word (&sst, 0); /* Class type (for member functions) */ 2784 t2 = t1->d.memfunc.type; 2785 ti = 0; 2786 if (t2 && t2->tag == ty_func && t2->d.func.domain) 2787 ti = t2->d.func.domain->index; 2788 else 2789 warning (" Can't figure out which class method '%s' is a member of!", name); 2790 buffer_word (&sst, ti); /* Class type (for member functions) */ 2768 2791 buffer_byte (&sst, 8); /* 32-bit near */ 2769 if (cplusplus_flag) 2770 buffer_enc (&sst, name); /* Proc name */ 2792 buffer_enc (&sst, name); /* Proc name */ 2793 sst_end (); 2794 } 2795 else 2796 { 2797 if (args_grow.count == 0) 2798 t1 = NULL; 2771 2799 else 2772 buffer_nstr (&sst, name); /* Proc name */ 2773 sst_end (); 2774 } 2775 else 2776 { 2800 { 2801 t.tag = ty_args; 2802 t.index = -1; 2803 t.d.args.count = args_grow.count; 2804 t.d.args.list = xmalloc (args_grow.count * sizeof (*args_list)); 2805 memcpy (t.d.args.list, args_list, args_grow.count * sizeof (*args_list)); 2806 t1 = type_add (&t); 2807 free (t.d.args.list); 2808 } 2809 last_fun_type.d.func.args = t1; 2810 last_fun_type.d.func.arg_count = args_grow.count; 2811 t2 = type_add (&last_fun_type); 2812 make_type (t2, &ti); 2813 2777 2814 sst_start (cplusplus_flag ? SST_CPPproc : SST_proc); 2778 2815 r.r_address = sst.size; … … 3062 3099 else 3063 3100 {/* kso #456 2003-06-05: We need a begin to catch the parameters. */ 3064 //block_begin (proc_start_addr);3101 struct relocation_info r = {0}; 3065 3102 sst_start (SST_begin); 3066 buffer_dword (&sst, proc_start_addr); /* Segment offset */ 3067 buffer_dword (&sst, 10); /* Length */ 3103 r.r_address = sst.size; 3104 buffer_dword (&sst, proc_start_addr); /* Segment offset */ 3105 buffer_dword (&sst, text_size - proc_start_addr); /* Length */ 3068 3106 sst_end (); 3107 r.r_length = 2; 3108 r.r_symbolnum = N_TEXT; 3109 buffer_mem (&sst_reloc, &r, sizeof (r)); 3110 prologue_length = 0; 3069 3111 } 3070 3112 … … 3140 3182 buffer_byte (&sst, lang); 3141 3183 buffer_nstr (&sst, " "); /* Compiler options */ 3142 buffer_nstr (&sst, "");/* Compiler date */3184 buffer_nstr (&sst, __DATE__); /* Compiler date */ 3143 3185 buffer_mem (&sst, &ts, sizeof (ts)); 3144 3186 sst_end (); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.