17 byval symtb
as FBSYMBOLTB
ptr, _
18 byval dims
as integer, _
19 byval id
as zstring ptr, _
20 byval dtype
as integer, _
21 byval subtype
as FBSYMBOL
ptr, _
22 byval attrib
as integer _
26 listInit( @symb.dimlist, FB_INITDIMNODES,
len( FBVARDIM ), LIST_FLAGS_NOCLEAR )
43 static as FBARRAYDIM dTB(0)
44 dim as FBSYMBOL
ptr fld =
any
51 FB_DATATYPE_INTEGER,
NULL, 0, 0 )
55 FB_DATATYPE_INTEGER,
NULL, 0, 0 )
59 FB_DATATYPE_INTEGER,
NULL, 0, 0 )
75 symb.fbarray_data = symbGetOfs( fld )
81 symb.fbarray_dimtb = symbGetOfs( fld )
86 symb.fbarraydim_lbound = symbGetOfs( fld )
88 symb.fbarraydim_ubound = symbGetOfs( fld )
93 byval symtb
as FBSYMBOLTB
ptr, _
94 byval dims
as integer, _
95 byval id
as zstring ptr, _
96 byval dtype
as integer, _
97 byval subtype
as FBSYMBOL
ptr, _
98 byval attrib
as integer _
101 static as FBARRAYDIM dTB(0)
102 dim as FBSYMBOL
ptr sym =
any
108 typeAddrOf( dtype ), subtype, 0, 0 )
112 typeAddrOf( dtype ), subtype, 0, 0 )
116 FB_DATATYPE_INTEGER,
NULL, 0, 0 )
120 FB_DATATYPE_INTEGER,
NULL, 0, 0 )
124 FB_DATATYPE_INTEGER,
NULL, 0, 0 )
128 dims = FB_MAXARRAYDIMS
133 dTB(0).upper = dims-1
135 symbAddField( sym,
"dimTB", 1, dTB(), FB_DATATYPE_STRUCT, _
136 symb.fbarraydim, 0, 0 )
146 byval array
as FBSYMBOL
ptr, _
147 byval dimensions
as integer _
150 dim as zstring ptr id =
any, id_alias =
any
151 dim as FBSYMBOL
ptr desc =
any, desctype =
any
152 dim as FB_SYMBATTRIB attrib =
any
153 dim as FBSYMBOLTB
ptr symtb =
any
154 dim as integer isdynamic =
any, ispubext =
any, stats =
any
159 if( (env.clopt.backend = FB_BACKEND_GAS)
and symbGetIsJumpTb( array ) )
then
167 if( symbIsField( array ) )
then
172 if( array->mangling <> FB_MANGLING_BASIC )
then
176 attrib = FB_SYMBATTRIB_LOCAL
177 stats = FB_SYMBSTATS_IMPLICIT
184 isdynamic = symbIsDynamic( array )
185 ispubext = (array->attrib
and (FB_SYMBATTRIB_PUBLIC
or FB_SYMBATTRIB_EXTERN)) <> 0
190 if( symbIsCommon( array )
or isdynamic )
then
192 id_alias = array->id.
alias
194 stats = array->stats
and FB_SYMBSTATS_HASALIAS
204 if( array->mangling <> FB_MANGLING_BASIC )
then
207 stats = FB_SYMBSTATS_IMPLICIT
210 attrib = array->attrib
and (FB_SYMBATTRIB_SHARED
or _
211 FB_SYMBATTRIB_COMMON
or _
212 FB_SYMBATTRIB_STATIC
or _
213 FB_SYMBATTRIB_EXTERN
or _
214 FB_SYMBATTRIB_PUBLIC
or _
218 if( isdynamic = FALSE )
then
222 if( symbIsExtern( array ) )
then
223 attrib
and=
not FB_SYMBATTRIB_EXTERN
227 attrib
and=
not FB_SYMBATTRIB_PUBLIC
231 attrib
or= FB_SYMBATTRIB_DESCRIPTOR
234 if( symbIsField( array ) )
then
236 if( parser.
scope = FB_MAINSCOPE )
then
237 symtb = @symbGetProcSymbTb( parser.currproc )
253 symbGetType( array ), symbGetSubType( array ), _
254 attrib
and FB_SYMBATTRIB_LOCAL )
257 FB_SYMBCLASS_VAR, id, id_alias, _
258 FB_DATATYPE_STRUCT, desctype, attrib )
259 if( desc =
NULL )
then
263 desc->lgt = symbGetLen( desctype )
266 desc->stats = stats
or (array->stats
and (FB_SYMBSTATS_VARALLOCATED
or FB_SYMBSTATS_ACCESSED))
268 desc->var_.initree =
NULL
269 desc->var_.array.dims = 0
270 desc->var_.array.dimhead =
NULL
271 desc->var_.array.dimtail =
NULL
272 desc->var_.array.dif = 0
273 desc->var_.array.elms = 1
274 desc->var_.array.desc =
NULL
275 desc->var_.array.has_ellipsis = FALSE
276 desc->var_.desc.array = array
277 desc->var_.stmtnum = parser.stmt.cnt
279 desc->var_.
data.prev =
NULL
286 byval s
as FBSYMBOL
ptr, _
287 byval lower
as longint, _
288 byval upper
as longint _
291 dim as FBVARDIM
ptr d =
any, n =
any
298 n = s->var_.array.dimtail
302 s->var_.array.dimhead = d
306 s->var_.array.dimtail = d
313 byval s
as FBSYMBOL
ptr, _
314 byval dimensions
as integer, _
315 dTB()
as FBARRAYDIM _
318 dim as integer i =
any
319 dim as FBVARDIM
ptr d =
any
320 dim as integer do_build = TRUE
322 if( dimensions > 0 )
then
325 if( (s->var_.array.dimhead =
NULL)
or _
326 (symbGetArrayDimensions( s ) <> dimensions) )
then
330 for i = 0
to dimensions-1
335 if( dTB(i).upper = FB_ARRAYDIM_UNKNOWN )
then do_build = FALSE
338 d = s->var_.array.dimhead
339 for i = 0
to dimensions-1
340 d->lower = dTB(i).lower
341 d->upper = dTB(i).upper
344 if( d->upper = FB_ARRAYDIM_UNKNOWN )
then do_build = FALSE
351 s->var_.array.dif = 0
352 s->var_.array.elms = 1
355 s->var_.array.dims = dimensions
358 if( dimensions <> 0 )
then
360 if( s->var_.array.desc =
NULL )
then
362 s->var_.array.desc->var_.initree = _
367 s->var_.array.desc =
NULL
374 byval id
as const zstring ptr, _
375 byval id_alias
as const zstring ptr, _
376 byval dtype
as integer, _
377 byval subtype
as FBSYMBOL
ptr, _
378 byval lgt
as longint, _
379 byval dimensions
as integer, _
380 dTB()
as FBARRAYDIM, _
381 byval attrib
as integer, _
382 byval options
as FB_SYMBOPT _
385 dim as FBSYMBOL
ptr s =
any
386 dim as FBSYMBOLTB
ptr symtb =
any
387 dim as FBHASHTB
ptr hashtb =
any
388 dim as integer isglobal =
any, stats =
any
393 isglobal = (attrib
and (FB_SYMBATTRIB_PUBLIC
or _
394 FB_SYMBATTRIB_EXTERN
or _
395 FB_SYMBATTRIB_SHARED
or _
396 FB_SYMBATTRIB_COMMON)) <> 0
404 if( id_alias =
NULL )
then
406 if( parser.mangling <> FB_MANGLING_BASIC )
then
412 stats = FB_SYMBSTATS_HASALIAS
416 if( isglobal = FALSE )
then
417 attrib
or= FB_SYMBATTRIB_LOCAL
420 if( (options
and FB_SYMBOPT_UNSCOPE) = 0 )
then
423 symtb = @symbGetProcSymbTb( parser.currproc )
434 symtb = @symbGetGlobalTb( )
435 hashtb = @symbGetGlobalHashTb( )
438 if( symbIsGlobalNamespc( ) = FALSE )
then
440 if( (options
and FB_SYMBOPT_MOVETOGLOB) = 0 )
then
441 symtb = @symbGetCompSymbTb( symbGetCurrentNamespc( ) )
442 hashtb = @symbGetCompHashTb( symbGetCurrentNamespc( ) )
448 FB_SYMBCLASS_VAR, id, id_alias, dtype, subtype, attrib )
457 s->var_.array.dimhead =
NULL
458 s->var_.array.dimtail =
NULL
459 s->var_.array.desc =
NULL
460 if( dimensions <> 0 )
then
463 s->var_.array.dims = 0
464 s->var_.array.dif = 0
465 s->var_.array.elms = 1
467 s->var_.array.has_ellipsis = FALSE
468 s->var_.desc.array =
NULL
469 s->var_.initree =
NULL
471 s->var_.stmtnum = parser.stmt.cnt
472 s->var_.
data.prev =
NULL
475 if( (options
and FB_SYMBOPT_UNSCOPE) <> 0 )
then
476 s->var_.stmtnum = parser.currproc->proc.ext->stmtnum + 1
479 elseif( (options
and FB_SYMBOPT_MOVETOGLOB) <> 0 )
then
480 s->
scope = FB_MAINSCOPE
499 byval dtype
as integer, _
500 byval subtype
as FBSYMBOL
ptr _
503 static as FBARRAYDIM dTB(0)
504 dim as FB_SYMBOPT options = FB_SYMBOPT_NONE
507 assert( typeGetDtAndPtrOnly( dtype ) <> FB_DATATYPE_CHAR )
508 assert( typeGetDtAndPtrOnly( dtype ) <> FB_DATATYPE_WCHAR )
510 if( fbLangOptIsSet( FB_LANG_OPT_SCOPE ) = FALSE )
then
511 options
or= FB_SYMBOPT_UNSCOPE
515 dTB(), FB_SYMBATTRIB_TEMP, options )
516 symbSetIsImplicit( sym )
529 byval dtype
as integer, _
530 byval subtype
as FBSYMBOL
ptr, _
531 byval options
as integer _
534 static as FBARRAYDIM dTB(0)
537 assert( typeGetDtAndPtrOnly( dtype ) <> FB_DATATYPE_CHAR )
538 assert( typeGetDtAndPtrOnly( dtype ) <> FB_DATATYPE_WCHAR )
542 symbSetIsImplicit( sym )
548 dim as FBSYMBOL
ptr s =
any
552 assert( env.clopt.backend = FB_BACKEND_GAS )
554 irProcAllocLocal( parser.currproc, s )
566 byval dimensions
as integer, _
567 dTB()
as FBARRAYDIM, _
568 byval lgt
as longint _
571 dim as integer d =
any
572 dim as longint diff =
any, elms =
any
574 if( dimensions <= 0 )
then
579 for d = 0
to (dimensions-1)-1
580 elms = (dTB(d+1).upper - dTB(d+1).lower) + 1
581 diff = (diff+dTB(d).lower) * elms
584 diff += dTB(dimensions-1).lower
593 byval s
as FBSYMBOL
ptr, _
594 byval n
as FBVARDIM
ptr =
NULL _
597 dim as longint e =
any, d =
any
600 n = s->var_.array.dimhead
604 do while( n <>
NULL )
605 d = (n->upper - n->lower) + 1
615 byval dimensions
as integer, _
616 dTB()
as FBARRAYDIM _
619 dim as longint e =
any, d =
any
622 for i
as integer = 0
to dimensions-1
623 d = (dTB(i).upper - dTB(i).lower) + 1
632 byval dimensions
as integer, _
633 dTB()
as FBARRAYDIM, _
634 byval lgt
as longint, _
635 byval is_on_stack
as integer, _
636 byval allow_ellipsis
as integer _
639 dim as ulongint allelements =
any
640 dim as ulongint elements =
any
641 dim as integer found_too_big =
any
643 found_too_big = FALSE
646 for i
as integer = 0
to dimensions-1
648 if( allow_ellipsis
and (dTB(i).upper = FB_ARRAYDIM_UNKNOWN) )
then
655 elements = (dTB(i).upper - dTB(i).lower) + 1
659 if( elements > &h7FFFFFFFu )
then
664 allelements *= elements
667 if( allelements > &h7FFFFFFFull )
then
673 if( found_too_big = FALSE )
then
676 if( allelements > &h7FFFFFFFull )
then
681 if( found_too_big )
then
684 if( is_on_stack
and (allelements >
culngint( env.clopt.stacksize )) )
then
694 if( (s->attrib
and (FB_SYMBATTRIB_SHARED
or _
695 FB_SYMBATTRIB_STATIC
or _
696 FB_SYMBATTRIB_COMMON
or _
697 FB_SYMBATTRIB_PARAMBYDESC
or _
698 FB_SYMBATTRIB_PARAMBYVAL
or _
699 FB_SYMBATTRIB_PARAMBYREF
or _
700 FB_SYMBATTRIB_TEMP
or _
701 FB_SYMBATTRIB_FUNCRESULT)) <> 0 )
then
705 select case( symbGetType( s ) )
707 case FB_DATATYPE_STRING
711 case typeAddrOf( FB_DATATYPE_WCHAR )
712 if( symbGetIsWstring( s ) )
then
719 if( symbGetArrayDimensions( s ) <> 0 )
then
732 if( (s->attrib
and (FB_SYMBATTRIB_SHARED
or _
733 FB_SYMBATTRIB_STATIC
or _
734 FB_SYMBATTRIB_COMMON
or _
735 FB_SYMBATTRIB_PARAMBYDESC
or _
736 FB_SYMBATTRIB_PARAMBYVAL
or _
737 FB_SYMBATTRIB_PARAMBYREF
or _
738 FB_SYMBATTRIB_TEMP
or _
739 FB_SYMBATTRIB_FUNCRESULT)) <> 0 )
then
743 select case( symbGetType( s ) )
745 case FB_DATATYPE_STRING
749 case typeAddrOf( FB_DATATYPE_WCHAR )
750 if( symbGetIsWstring(s) )
then
757 if( symbGetArrayDimensions( s ) <> 0 )
then
759 if( symbIsDynamic( s ) )
then
769 static as FBARRAYDIM dTB(0
to FB_MAXARRAYDIMS-1)
770 dim as FBVARDIM
ptr d =
any
771 dim as integer dimensions =
any
774 if( symbIsDescriptor( sym ) )
then
776 symbGetArrayDimensions( sym->var_.desc.array ) )
779 elseif( symbIsTemp( sym ) )
then
780 function =
symbAddTempVar( symbGetType( sym ), symbGetSubType( sym ) )
783 dimensions = symbGetArrayDimensions( sym )
784 d = symbGetArrayFirstDim( sym )
785 for i
as integer = 0
to dimensions-1
786 dTB(i).lower = d->lower
787 dTB(i).upper = d->upper
792 symbGetType( sym ), symbGetSubType( sym ), 0, _
793 dimensions, dTB(), symbGetAttrib( sym ), 0 )
799 if( fbIsModLevel( ) = FALSE )
then
801 if( symbIsLocal( sym ) )
then
803 if( symbGetScope( sym ) = FB_MAINSCOPE )
then
807 elseif( symbIsShared( sym ) = FALSE )
then
820 dim as FBVARDIM
ptr n =
any, nxt =
any
822 n = s->var_.array.dimhead
823 do while( n <>
NULL )
831 s->var_.array.dimhead =
NULL
832 s->var_.array.dimtail =
NULL
833 s->var_.array.dims = 0
836 sub symbDelVar(
byval s
as FBSYMBOL
ptr,
byval is_tbdel
as integer )
837 if( symbGetArrayDimensions( s ) > 0 )
then
839 if( is_tbdel = FALSE )
then
841 if( s->var_.array.desc )
then
847 if( symbGetIsLiteral( s ) )
then
848 s->attrib
and=
not FB_SYMBATTRIB_LITERAL
851 if( s->typ <> FB_DATATYPE_WCHAR )
then
852 if( s->var_.littext <>
NULL )
then
853 ZstrFree( s->var_.littext )
856 if( s->var_.littextw <>
NULL )
then
857 WstrFree( s->var_.littextw )
862 elseif( symbGetIsInitialized( s ) )
then
863 s->stats
and=
not FB_SYMBSTATS_INITIALIZED