Changeset 746
- Timestamp:
- Sep 29, 2003, 4:00:10 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.22
to1.23
r745 r746 282 282 static const char *parse_ptr; 283 283 284 /* Start of the stabs string we're parsing. Us ful when printing284 /* Start of the stabs string we're parsing. Useful when printing 285 285 messages. */ 286 286 static const char *parse_start; 287 288 /* Current stabs index. Useful when printing messages. */ 289 static int *parse_pindex; 287 290 288 291 /* The next HLL type index. When creating a complex type, this index … … 400 403 fputc ('\n', stderr); 401 404 405 402 406 if (parse_ptr && parse_start && parse_ptr >= parse_start) 403 fprintf (stderr, "emxomf info: Currently parsing '%c' at position %ld in\n%s\n", 404 *parse_ptr, parse_ptr - parse_start, parse_start); 407 { 408 if (parse_pindex && *parse_pindex >= 0 && *parse_pindex < sym_count) 409 fprintf (stderr, "emxomf info: parsing sym no.%d type=%d at char '%c' in position %ld:\n%s\n", 410 *parse_pindex, sym_ptr[*parse_pindex].n_type, 411 *parse_ptr, parse_ptr - parse_start, parse_start); 412 else 413 fprintf (stderr, "emxomf info: parsing '%c' at position %ld:\n%s\n", 414 *parse_ptr, parse_ptr - parse_start, parse_start); 415 } 405 416 } 406 417 … … 1563 1574 { 1564 1575 const char *saved_ptr, *p1; 1576 char ch; 1565 1577 struct type t, *result, *t1, *t2, *t3, **tlist; 1566 1578 int i, n, class_flag, is_void; … … 1902 1914 1903 1915 ++parse_ptr; 1904 switch (*parse_ptr) 1916 ch = *parse_ptr++; 1917 p1 = nextcolon (parse_ptr); 1918 if (p1 == NULL) 1919 { 1920 warning ("Invalid forward reference: missing colon"); 1921 goto syntax; 1922 } 1923 1924 switch (ch) 1905 1925 { 1906 1926 case 's': 1907 1927 case 'u': 1908 break;1909 case 'e':1910 warning ("Cannot convert incomplete enum type");1911 goto syntax;1912 default:1913 warning ("Unknown forward reference: %c", *parse_ptr);1914 goto syntax;1915 }1916 ++parse_ptr;1917 p1 = nextcolon (parse_ptr);1918 if (p1 == NULL)1919 {1920 warning ("Invalid forward reference: missing colon");1921 goto syntax;1922 }1923 t.tag = ty_struc;1924 t.d.struc.types = NULL;1925 t.d.struc.fields = NULL;1926 t.d.struc.size = 0;1927 t.d.struc.count = 0;1928 t.d.struc.name = strpool_addn (str_pool, parse_ptr, p1 - parse_ptr);1929 t.d.struc.flags = STRUC_FORWARD;1930 1931 /* Avoid adding an incomplete type if the complete one is1932 already defined. We're ignoring scoping (TODO). */1933 1934 for (t3 = type_head; t3 != NULL; t3 = t3->next)1935 if ((t3->tag == ty_struc && t3->d.struc.name == t.d.struc.name1936 && !(t3->d.struc.flags & STRUC_FORWARD))1937 || (t3->tag == ty_class && t3->d.class.name == t.d.struc.name))1938 1928 { 1939 result = t3; 1929 t.tag = ty_struc; 1930 t.d.struc.types = NULL; 1931 t.d.struc.fields = NULL; 1932 t.d.struc.size = 0; 1933 t.d.struc.count = 0; 1934 t.d.struc.name = strpool_addn (str_pool, parse_ptr, p1 - parse_ptr); 1935 t.d.struc.flags = STRUC_FORWARD; 1936 1937 /* Avoid adding an incomplete type if the complete one is 1938 already defined. We're ignoring scoping (TODO). */ 1939 1940 for (t3 = type_head; t3 != NULL; t3 = t3->next) 1941 if ((t3->tag == ty_struc && t3->d.struc.name == t.d.struc.name 1942 && !(t3->d.struc.flags & STRUC_FORWARD)) 1943 || (t3->tag == ty_class && t3->d.class.name == t.d.struc.name)) 1944 { 1945 result = t3; 1946 break; 1947 } 1940 1948 break; 1941 1949 } 1950 1951 case 'e': 1952 { /* just make it a primary. */ 1953 /** @todo make an enum perhaps? */ 1954 t.tag = ty_prim; 1955 t.index = 0x82; /* 32 bit signed */ 1956 break; 1957 } 1958 1959 default: 1960 warning ("Unknown forward reference: %c", ch); 1961 parse_ptr = p1 + 1; 1962 goto syntax; 1963 } 1942 1964 parse_ptr = p1 + 1; 1943 1965 break; 1944 1966 1945 case 's': /* struct, class */1946 case 'u': /* union */1967 case 's': /* struct, class */ 1968 case 'u': /* union */ 1947 1969 1948 1970 /* Structures, unions and classes: … … 2488 2510 { 2489 2511 struct type *t1; 2490 int ti_1, ti_2, i, qual;2512 int ti_1, ti_2, ti_3, i, qual; 2491 2513 int patch1; 2492 2514 2493 2515 #define RETURN(X) do {*hll = (X); return;} while (0) 2494 2516 2495 if (tp->index == -2) 2496 { 2497 warning_parse ("Cycle detected by make_type."); 2498 RETURN (0); 2499 } 2500 if (tp->index != -1) 2517 if (tp->index <= -2) 2518 { 2519 /* bird: A hack where we allow a 2nd recursion of rectain types. 2520 * The normal issue is C++ class references. */ 2521 if (tp->tag != ty_alias || tp->index <= -3) 2522 { 2523 warning_parse ("Cycle detected by make_type."); 2524 RETURN (0); 2525 } 2526 } 2527 if (tp->index > -1) 2501 2528 RETURN (tp->index); 2502 tp->index = -2;2529 tp->index--; 2503 2530 switch (tp->tag) 2504 2531 { … … 2637 2664 2638 2665 case ty_member: 2639 make_type (tp->d.member.type, &ti_1);2640 2666 qual = 0; 2641 2667 if (tp->d.member.flags & MEMBER_STATIC) … … 2643 2669 tt_start (0x46, qual); 2644 2670 tt_byte (tp->d.member.flags & MEMBER_VIS); 2645 tt_word (ti_1); 2671 patch1 = tt.size; 2672 tt_word (0); 2646 2673 tt_unsigned_span (tp->d.member.offset); 2647 2674 if (tp->d.member.flags & MEMBER_STATIC) … … 2652 2679 tt_end (); 2653 2680 *hll = tp->index = hll_type_index++; 2681 2682 make_type (tp->d.member.type, &ti_1); 2683 buffer_patch_word (&tt, patch1, ti_1); 2654 2684 break; 2655 2685 … … 2688 2718 2689 2719 case ty_func: 2720 tt_start (0x54, 0x05); /* Function */ 2721 tt_word (tp->d.func.arg_count); /* Number of parameters */ 2722 tt_word (tp->d.func.arg_count); /* Max. Number of parameters */ 2723 patch1 = tt.size; 2724 tt_index (0); /* Return value */ 2725 tt_index (0); /* Argument list */ 2726 tt_end (); 2727 *hll = tp->index = hll_type_index++; 2728 2729 if (tp->d.func.domain) 2730 make_type (tp->d.func.domain, &ti_3); 2690 2731 make_type (tp->d.func.ret, &ti_1); 2691 2732 if (tp->d.func.args == NULL) … … 2693 2734 else 2694 2735 make_type (tp->d.func.args, &ti_2); 2695 tt_start (0x54, 0x05); /* Function */ 2696 tt_word (tp->d.func.arg_count); /* Number of parameters */ 2697 tt_word (tp->d.func.arg_count); /* Max. Number of parameters */ 2698 tt_index (ti_1); /* Return value */ 2699 tt_index (ti_2); /* Argument list */ 2700 tt_end (); 2701 *hll = tp->index = hll_type_index++; 2736 buffer_patch_word (&tt, patch1+1, ti_1); 2737 buffer_patch_word (&tt, patch1+4, ti_2); 2702 2738 break; 2703 2739 … … 2902 2938 2903 2939 alloc_flag = concat_symbols (index, &str); 2940 parse_start = str; 2941 parse_pindex = index; 2904 2942 p = nextcolon (str); 2905 2943 if (p != NULL) … … 2912 2950 printf ("LSYM/LCSYM/GSYM/PSYM/RSYM/STSYM/FUN %s\n", str); 2913 2951 #endif 2914 parse_ start = parse_ptr = p + 1;2952 parse_ptr = p + 1; 2915 2953 switch (*parse_ptr) 2916 2954 { … … 3122 3160 struct type t, *t1, *t2, *t3; 3123 3161 struct relocation_info r; 3124 const char *str, *p ;3162 const char *str, *p, *p2; 3125 3163 const char *name; 3126 3164 int n, /* size of name. */ … … 3145 3183 if (t1) 3146 3184 { /* C++ member function */ 3147 ti = t1->index;3148 if (ti == -1)3149 make_type (t1, &ti);3150 3151 3185 t2 = t1->d.memfunc.type; 3152 3186 if (t2 && t2->tag == ty_func && t2->d.func.domain) 3153 ticlass = t2->d.func.domain->index;3187 make_type (t2->d.func.domain, &ticlass); 3154 3188 else 3155 { /* the hard way - search for the freaking string in suitable .stabs. */ 3189 { /* the hard way - search for the freaking string in suitable .stabs. 3190 * I think this is rather slow when done for many members.. :/ */ 3156 3191 int i; 3157 3192 for (i = 0, t3 = NULL, ticlass = -1; !t3 && i < sym_count; ++i) … … 3161 3196 { 3162 3197 str = str_ptr + sym_ptr[i].n_un.n_strx; 3163 if ((p = strstr (str, name)) != NULL 3164 /** @todo parse the string to get the name right. */ 3165 && p[-1] == ':' && p[n] == ';') 3198 p = nextcolon (str); 3199 if (p && p[1] == 'T' && p[2] == 't') 3166 3200 { 3167 p = nextcolon (str); 3168 if (p && p[1] == 'T' && p[2] == 't') 3201 /* Now, there can be several name which NAME is a 3202 * substring in. 3203 */ 3204 /** @todo: the string parsing still is a bit spooky. */ 3205 for (p2 = p; (p2 = strstr (p2, name)) != NULL; p2 += n) 3206 if (p2[-1] == ':' && p2[n] == ';') 3169 3207 { 3170 int stab = atoi (&p[3]); 3171 t3 = stype_find (stab); 3208 int stab = atoi (&p[3]); 3209 t3 = stype_find (stab); 3210 break; 3172 3211 } 3173 3212 } … … 3184 3223 } 3185 3224 3225 make_type (t1, &ti); 3186 3226 sst_start (SST_memfunc); 3187 3227 r.r_address = sst.size; … … 3280 3320 symbol = &sym_ptr[*index]; 3281 3321 alloc_flag = concat_symbols (index, &str); 3322 parse_start = str; 3323 parse_pindex = index; 3282 3324 p = nextcolon (str); 3283 3325 if (p != NULL) … … 3291 3333 #endif 3292 3334 3293 parse_ start = parse_ptr = p + 1;3335 parse_ptr = p + 1; 3294 3336 switch (*parse_ptr) 3295 3337 { -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.