Changeset 324 for trunk/src


Ignore:
Timestamp:
Jun 11, 2003, 11:10:35 PM (22 years ago)
Author:
bird
Message:

#456: Changed structure handling in C++ mode to the prefered to write class on output instead struct_to_class wrapping loop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/stabshll.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r323 r324  
    11881188
    11891189
    1190 /* Turn a struct into a class-struct to make icsdebug happy.
    1191    Yeah, we could've done this on output too, but this is somewhat easier
    1192    I belive. */
    1193 
    1194 static void struct_to_classstruct (struct type *tp)
    1195 {
    1196   struct type t, *t1, **list, **types;
    1197   struct field *fields;
    1198   int i, n;
    1199 
    1200   n = tp->d.struc.count;
    1201   if (n == 0)
    1202     list = NULL;
    1203   else
    1204     {
    1205       if (tp->d.struc.fields->tag != ty_fields
    1206           || tp->d.struc.fields->d.fields.count != n)
    1207         {
    1208           warning ("Invalid struct field list");
    1209           return;
    1210         }
    1211       fields = tp->d.struc.fields->d.fields.list;
    1212       if (tp->d.struc.types->tag != ty_types
    1213           || tp->d.struc.types->d.types.count != n)
    1214         {
    1215           warning ("Invalid struct types list");
    1216           return;
    1217         }
    1218       types = tp->d.struc.types->d.types.list;
    1219       list = xmalloc (n * sizeof (*list));
    1220       for (i = 0; i < n; ++i)
    1221         {
    1222           t.tag = ty_member;
    1223           t.index = -1;
    1224           t.d.member.type = types[i];
    1225           t.d.member.offset = fields[i].offset;
    1226           t.d.member.flags = VIS_PUBLIC;
    1227           t.d.member.name = fields[i].name;
    1228           t.d.member.sname = NULL;
    1229           list[i] = type_add (&t);
    1230         }
    1231     }
    1232 
    1233   t.tag = ty_types;
    1234   t.index = -1;
    1235   t.d.types.count = n;
    1236   t.d.types.list = list;
    1237   t1 = type_add (&t);
    1238 
    1239   t = *tp;
    1240   tp->tag = ty_class;
    1241   tp->d.class.members = t1;
    1242   tp->d.class.size = t.d.struc.size;
    1243   tp->d.class.count = t.d.struc.count;
    1244   tp->d.class.name = t.d.struc.name;
    1245 }
    1246 
    1247 
    12481190/* Build and return the internal representation of the `long long'
    12491191   type.  As IPMD doesn't know about `long long' we use the following
     
    24502392
    24512393    case ty_struc:
    2452       tt_start (0x79, 0x00);    /* Structure/Union */
    2453       tt_dword (tp->d.struc.size);
    2454       tt_word (tp->d.struc.count);
    2455       patch1 = tt.size;
    2456       tt_index (0);
    2457       tt_index (0);
    2458       tt_name (tp->d.struc.name);
    2459       tt_end ();
    2460       *hll = tp->index = hll_type_index++;
    2461       if (tp->d.struc.types == NULL && tp->d.struc.fields == NULL)
    2462         {
    2463           ti_1 = 0;
    2464           ti_2 = 1;
     2394    {
     2395      struct field *fields = NULL;
     2396      struct type **types = NULL;
     2397      int           cFields = tp->d.struc.count;
     2398
     2399      if (    tp->d.struc.fields
     2400          &&  tp->d.struc.fields->tag == ty_fields
     2401          &&  tp->d.struc.fields->d.fields.count == cFields)
     2402          fields = tp->d.struc.fields->d.fields.list;
     2403      if (   tp->d.struc.types
     2404          && tp->d.struc.types->tag == ty_types
     2405          && tp->d.struc.types->d.types.count == cFields)
     2406          types = tp->d.struc.types->d.types.list;
     2407
     2408      if (cplusplus_flag && ((types && fields) || !cFields))
     2409        {
     2410          struct type   t;
     2411          struct type **list;
     2412          int           i;
     2413          *hll = tp->index = hll_type_index++;
     2414          tt_start (0x40, 0x01);      /* Class is-struct */
     2415          tt_dword (tp->d.struc.size);
     2416          tt_word (tp->d.struc.count);
     2417          patch1 = tt.size;
     2418          tt_word (0);                /* Members */
     2419          tt_enc (tp->d.struc.name);  /* Class name */
     2420          tt_end ();
     2421
     2422          list = xmalloc (cFields * sizeof (*list));
     2423          for (i = 0; i < cFields; ++i)
     2424            {
     2425              t.tag             = ty_member;
     2426              t.index           = -1;
     2427              t.d.member.type   = types[i];
     2428              t.d.member.offset = fields[i].offset;
     2429              t.d.member.flags  = VIS_PUBLIC;
     2430              t.d.member.name   = fields[i].name;
     2431              t.d.member.sname  = NULL;
     2432              list[i] = type_add (&t);
     2433            }
     2434
     2435          t.tag = ty_types;
     2436          t.index = -1;
     2437          t.d.types.count = cFields;
     2438          t.d.types.list = list;
     2439          t1 = type_add (&t);
     2440
     2441          make_type (t1, &ti_1);
     2442          buffer_patch_word (&tt, patch1, ti_1);
    24652443        }
    24662444      else
    24672445        {
    2468           make_type (tp->d.struc.types, &ti_1);
    2469           make_type (tp->d.struc.fields, &ti_2);
    2470         }
    2471       buffer_patch_word (&tt, patch1+1, ti_1);
    2472       buffer_patch_word (&tt, patch1+4, ti_2);
    2473       break;
     2446          tt_start (0x79, 0x00);    /* Structure/Union */
     2447          tt_dword (tp->d.struc.size);
     2448          tt_word (tp->d.struc.count);
     2449          patch1 = tt.size;
     2450          tt_index (0);
     2451          tt_index (0);
     2452          tt_name (tp->d.struc.name);
     2453          tt_end ();
     2454          *hll = tp->index = hll_type_index++;
     2455          if (tp->d.struc.types == NULL && tp->d.struc.fields == NULL)
     2456            {
     2457              ti_1 = 0;
     2458              ti_2 = 1;
     2459            }
     2460          else
     2461            {
     2462              make_type (tp->d.struc.types, &ti_1);
     2463              make_type (tp->d.struc.fields, &ti_2);
     2464            }
     2465          buffer_patch_word (&tt, patch1+1, ti_1);
     2466          buffer_patch_word (&tt, patch1+4, ti_2);
     2467        }
     2468      break;
     2469    }
    24742470
    24752471    case ty_class:
     
    34863482      }
    34873483
    3488   /* hack/experiment to make icsdebug fancy our stuff. */
    3489 
    3490   if (cplusplus_flag)
    3491     for (t1 = type_head; t1 != NULL; t1 = t1->next)
    3492       if (t1->tag == ty_struc)
    3493          struct_to_classstruct (t1);
    3494 
    3495 
    34963484  /* Provide information about the compiler. */
    34973485
Note: See TracChangeset for help on using the changeset viewer.