20 byval symtb
as FBSYMBOLTB
ptr, _
21 byval parent as FBSYMBOL
ptr, _
22 byval id
as const zstring ptr, _
23 byval id_alias
as const zstring ptr, _
24 byval isunion
as integer, _
25 byval align
as integer, _
26 byval base_
as FBSYMBOL
ptr, _
27 byval attrib
as integer _
30 dim as FBSYMBOL
ptr s =
any
35 if( id_alias = NULL )
then
37 if( parser.mangling <> FB_MANGLING_BASIC )
then
43 FB_SYMBCLASS_STRUCT, id, id_alias, _
44 FB_DATATYPE_STRUCT, NULL, attrib )
51 symbSetUDTIsUnion( s )
54 symbSymbTbInit( s->udt.ns.symtb, s )
58 symbHashTbInit( s->udt.ns.hashtb, s, FB_INITFIELDNODES )
72 if( fbLangIsSet( FB_LANG_QB ) )
then
83 s->udt.dbg.typenum = INVALID
88 if( base_ <> NULL )
then
89 static as FBARRAYDIM dTB(0
to 0)
91 s->udt.
base =
symbAddField( s,
"$base", 0, dTB(), FB_DATATYPE_STRUCT, base_, 0, 0 )
97 if( symbGetHasRTTI( base_ ) )
then
101 assert( base_->udt.ext->vtableelements >= 2 )
103 s->udt.ext->vtableelements = base_->udt.ext->vtableelements
104 s->udt.ext->abstractcount = base_->udt.ext->abstractcount
115 byval dtype
as integer, _
116 byval subtype
as FBSYMBOL
ptr _
119 dim as integer align =
any
121 select case as const( typeGet( dtype ) )
123 case FB_DATATYPE_STRUCT
124 align = subtype->udt.natalign
127 case FB_DATATYPE_STRING
128 align = env.pointersize
133 align = typeGetSize( dtype )
136 if( fbCpuTypeIs64bit( ) = FALSE )
then
140 if( env.clopt.target <> FB_COMPTARGET_WIN32 )
then
146 assert( (align >= 1)
and (align <= 8) )
153 byval ofs
as longint, _
154 byval align
as integer, _
155 byval dtype
as integer, _
156 byval subtype
as FBSYMBOL
ptr _
159 dim as integer natalign =
any
165 assert( fbLangIsSet( FB_LANG_QB ) = FALSE )
172 if( align > natalign )
then
179 function = (align - (ofs
and (align - 1)))
and (align - 1)
184 byval udtlen
as ulongint, _
185 byval fieldlen
as ulongint, _
186 byval fieldpad
as uinteger _
189 dim as ulongint n =
any
195 if( n > &h7FFFFFFFull )
then
206 byval udt
as FBSYMBOL
ptr, _
207 byval dtype
as integer, _
208 byval lgt
as longint, _
209 byval bits
as integer _
213 if( (bits <= 0)
or (bits > lgt*8) )
then
218 select case as const typeGet( dtype )
219 case FB_DATATYPE_BYTE, FB_DATATYPE_UBYTE, FB_DATATYPE_SHORT, FB_DATATYPE_USHORT, _
220 FB_DATATYPE_INTEGER, FB_DATATYPE_UINT, FB_DATATYPE_LONG, FB_DATATYPE_ULONG
232 byval bitpos
as integer, _
233 byval bits
as integer, _
234 byval dtype
as integer, _
235 byval lgt
as longint _
238 dim as FBSYMBOL
ptr sym =
any
245 FB_SYMBCLASS_BITFIELD, NULL, NULL, dtype, NULL )
246 if( sym = NULL )
then
250 sym->bitfld.bitpos = bitpos
251 sym->bitfld.bits = bits
260 byval parent as FBSYMBOL
ptr, _
261 byval id
as zstring ptr, _
262 byval dimensions
as integer, _
263 dTB()
as FBARRAYDIM, _
264 byval dtype
as integer, _
265 byval subtype
as FBSYMBOL
ptr, _
266 byval lgt
as longint, _
267 byval bits
as integer _
268 )
as FBSYMBOL
ptr static
270 dim as FBSYMBOL
ptr sym =
any, tail =
any, base_parent =
any, prevbitfield =
any
271 dim as integer pad =
any, updateudt =
any, elen =
any
272 dim as FBHASHTB
ptr hashtb
285 if(
parent->udt.bitpos > 0 )
then
287 tail =
parent->udt.ns.symtb.tail
288 while( symbIsField( tail ) = FALSE )
292 assert( symbGetType( tail ) = FB_DATATYPE_BITFIELD )
293 prevbitfield = tail->subtype
294 assert( symbIsBitfield( prevbitfield ) )
297 if(
parent->udt.bitpos + bits > prevbitfield->lgt*8 )
then
312 if( lgt <> prevbitfield->lgt )
then
313 dtype = symbGetType( prevbitfield )
314 lgt = prevbitfield->lgt
320 if(
parent->udt.bitpos <> 0 )
then
337 if( env.clopt.msbitfields = FALSE )
then
339 if( bits <= pad * 8 )
then
346 if( typeIsSigned( dtype ) )
then
347 dtype = FB_DATATYPE_BYTE
349 dtype = FB_DATATYPE_UBYTE
352 if( typeIsSigned( dtype ) )
then
353 dtype = FB_DATATYPE_SHORT
355 dtype = FB_DATATYPE_USHORT
379 if( elen >
parent->udt.natalign )
then
380 parent->udt.natalign = elen
387 dtype = FB_DATATYPE_BITFIELD
392 do while( symbGetUDTIsAnon( base_parent ) )
393 base_parent = symbGetUDTAnonParent( base_parent )
396 hashtb = @symbGetUDTHashTb( base_parent )
401 @symbGetUDTSymbTb(
parent ), hashtb, _
402 FB_SYMBCLASS_FIELD, _
405 iif( symbIsLocal(
parent ), _
406 FB_SYMBATTRIB_LOCAL, _
407 FB_SYMBATTRIB_NONE ) )
408 if( sym = NULL )
then
414 if( updateudt
or symbGetUDTIsUnion(
parent ) )
then
417 sym->ofs =
parent->ofs - lgt
421 sym->var_.initree = NULL
424 sym->var_.array.desc = NULL
426 sym->var_.array.dimhead = NULL
427 sym->var_.array.dimtail = NULL
428 sym->var_.array.has_ellipsis = FALSE
430 symbSetArrayDimensions( sym, dimensions )
431 if( dimensions > 0 )
then
432 for i
as integer = 0
to dimensions-1
440 lgt *= sym->var_.array.elms
442 select case as const typeGet( dtype )
444 case FB_DATATYPE_STRING
446 if( symbGetUDTIsUnionOrAnon(
parent ) )
then
447 errReport( FB_ERRMSG_VARLENSTRINGINUNION )
449 symbSetUDTHasCtorField(
parent )
450 symbSetUDTHasDtorField(
parent )
451 symbSetUDTHasPtrField(
parent )
455 case FB_DATATYPE_STRUCT
458 if( symbGetUDTHasPtrField( subtype ) )
then
459 symbSetUDTHasPtrField( base_parent )
464 if( symbGetUDTIsUnionOrAnon(
parent ) )
then
467 symbSetUDTHasCtorField(
parent )
473 if( symbGetUDTIsUnionOrAnon(
parent ) )
then
476 symbSetUDTHasDtorField(
parent )
483 if( typeIsPtr( dtype ) )
then
484 symbSetUDTHasPtrField( base_parent )
488 if( symbGetUDTIsUnion(
parent ) = FALSE )
then
496 parent->udt.bitpos += bits
497 parent->udt.bitpos
and= (typeGetBits( dtype ) - 1)
502 symbSetIsUnionField( sym )
506 if( lgt >
parent->lgt )
then
521 byval parent as FBSYMBOL
ptr, _
522 byval inner
as FBSYMBOL
ptr _
525 dim as FBSYMBOL
ptr fld =
any
526 dim as FBSYMBOLTB
ptr symtb =
any
527 dim as integer pad =
any
529 if( symbGetUDTIsUnion(
parent ) = FALSE )
then
538 fld = inner->udt.ns.symtb.head
541 if( fld = NULL )
then
545 fld->prev =
parent->udt.ns.symtb.tail
546 if(
parent->udt.ns.symtb.tail = NULL )
then
547 parent->udt.ns.symtb.head = fld
549 parent->udt.ns.symtb.tail->
next = fld
552 symtb = @
parent->udt.ns.symtb
554 if( symbGetUDTIsUnion(
parent ) )
then
556 do while( fld <> NULL )
558 symbSetIsUnionField( fld )
564 do while( fld <> NULL )
573 parent->udt.ns.symtb.tail = inner->udt.ns.symtb.tail
576 if( symbGetUDTIsUnion(
parent ) = FALSE )
then
582 if( inner->lgt >
parent->lgt )
then
588 if( inner->udt.natalign >
parent->udt.natalign )
then
589 parent->udt.natalign = inner->udt.natalign
596 inner->udt.ns.symtb.head = NULL
597 inner->udt.ns.symtb.tail = NULL
604 dim as FBSYMBOL
ptr fld =
any
605 dim as integer res =
any, unpadlen =
any
606 dim as longint unpadlen64 =
any
611 return typeAddrOf( FB_DATATYPE_STRUCT )
615 if( (env.target.options
and FB_TARGETOPT_RETURNINREGS) = 0 )
then
616 return typeAddrOf( FB_DATATYPE_STRUCT )
623 if( env.clopt.backend = FB_BACKEND_GCC )
then
624 return FB_DATATYPE_STRUCT
627 res = FB_DATATYPE_VOID
633 unpadlen64 = symbGetUDTUnpadLen( sym )
637 unpadlen = unpadlen64
638 if( unpadlen <> unpadlen64 )
then
640 return FB_DATATYPE_STRUCT
643 select case as const( unpadlen )
645 res = FB_DATATYPE_BYTE
648 res = FB_DATATYPE_SHORT
653 if( fld->lgt = 2 )
then
655 if( sym->lgt >= 4 )
then
656 res = FB_DATATYPE_INTEGER
670 if( typeGetDtAndPtrOnly( fld->typ ) = FB_DATATYPE_SINGLE )
then
671 res = FB_DATATYPE_SINGLE
674 if( typeGetDtAndPtrOnly( fld->typ ) <> FB_DATATYPE_STRUCT )
then
681 if( res = FB_DATATYPE_VOID )
then
682 res = FB_DATATYPE_INTEGER
688 if( fld->lgt = 4 )
then
690 if( sym->lgt >= 8 )
then
691 res = FB_DATATYPE_LONGINT
705 if( typeGetDtAndPtrOnly( fld->typ ) = FB_DATATYPE_DOUBLE )
then
706 res = FB_DATATYPE_DOUBLE
709 if( typeGetDtAndPtrOnly( fld->typ ) <> FB_DATATYPE_STRUCT )
then
716 if( res = FB_DATATYPE_VOID )
then
717 res = FB_DATATYPE_LONGINT
723 if( res = FB_DATATYPE_VOID )
then
725 res = typeAddrOf( FB_DATATYPE_STRUCT )
733 byval sym
as FBSYMBOL
ptr, _
734 byval isnested
as integer _
737 dim as integer pad =
any
745 sym->udt.unpadlgt = sym->lgt
749 pad =
hCalcPadding( sym->lgt, sym->udt.align, FB_DATATYPE_STRUCT, sym )
761 if( symb.fwdrefcnt > 0 )
then
768 static as FBARRAYDIM dTB(0)
769 dim as FBSYMBOL
ptr clone =
any, fld =
any
775 symbGetUDTIsUnion( sym ), _
776 sym->udt.align, NULL, 0 )
778 fld = sym->udt.ns.symtb.head
781 symbGetType( fld ), symbGetSubType( fld ), fld->lgt, 0 )
795 if( symbGetArrayDimensions( s ) > 0 )
then
805 if( s->udt.ext )
then
806 deallocate( s->udt.ext )
821 if( symbIsField( sym ) )
then
840 byval a
as FBSYMBOL
ptr, _
841 byval b
as FBSYMBOL
ptr _
844 dim as FBSYMBOL
ptr originalb =
any
865 dim as FBSYMBOL
ptr original =
any,
parent =
any
906 if( sym = NULL )
then
917 if( symbGetUDTIsUnion(
parent ) = FALSE )
then
928 byval s
as FBSYMBOL
ptr, _
929 byval baseSym
as FBSYMBOL
ptr _
932 if( s = NULL
or baseSym = NULL )
then
936 assert( symbIsStruct( s ) )
937 assert( symbIsStruct( baseSym ) )
940 do until( s->udt.
base = NULL )
941 if( s->udt.
base->subtype = baseSym )
then
945 s = s->udt.
base->subtype