17 byval sym
as FBSYMBOL
ptr, _
18 byval doflush
as integer _
21 dim as ASTNODE
ptr n =
any
23 n =
astNewNode( AST_NODECLASS_LABEL, FB_DATATYPE_INVALID )
26 n->lbl.flush = doflush
28 if( symbIsLabel( sym ) )
then
29 if( symbGetLabelIsDeclared( sym ) = FALSE )
then
30 symbSetLabelIsDeclared( sym )
31 symbGetLabelStmt( sym ) = parser.stmt.cnt
32 symbGetLabelParent( sym ) = parser.currblock
41 if( n->lbl.flush )
then
44 irEmitLABELNF( n->sym )
52 function astNewLIT(
byval text
as zstring ptr )
as ASTNODE
ptr
53 dim as ASTNODE
ptr n =
any
55 n =
astNewNode( AST_NODECLASS_LIT, FB_DATATYPE_INVALID )
57 n->lit.text = ZstrAllocate(
len( *text ) )
63 function astLoadLIT(
byval n
as ASTNODE
ptr )
as IRVREG
ptr
65 irEmitCOMMENT( n->lit.text )
68 ZstrFree( n->lit.text )
75 byval tail
as ASTASMTOK
ptr, _
76 byval typ
as integer _
79 dim as ASTASMTOK
ptr asmtok =
any
94 byval tail
as ASTASMTOK
ptr, _
95 byval text
as zstring ptr _
100 tail->text = ZstrAllocate(
len( *text ) )
108 byval tail
as ASTASMTOK
ptr, _
109 byval sym
as FBSYMBOL
ptr _
120 function astNewASM(
byval asmtokhead
as ASTASMTOK
ptr )
as ASTNODE
ptr
121 dim as ASTNODE
ptr n =
any
123 n =
astNewNode( AST_NODECLASS_ASM, FB_DATATYPE_INVALID )
125 n->
asm.tokhead = asmtokhead
131 dim as ASTASMTOK
ptr node =
any, nxt =
any
133 if( ast.doemit )
then
137 node = n->
asm.tokhead
141 select case( node->
type )
143 if( ast.doemit )
then
144 irEmitAsmText( node->text )
146 ZstrFree( node->text )
148 if( ast.doemit )
then
149 irEmitAsmSymb( node->sym )
157 if( ast.doemit )
then
167 byval op as integer, _
168 byval ex
as integer _
171 dim as ASTNODE
ptr n =
any
173 if( env.clopt.debug = FALSE )
then
177 n =
astNewNode( AST_NODECLASS_DBG, FB_DATATYPE_INVALID )
186 if( ast.doemit )
then
187 irEmitDBG( n->dbg.
op, astGetProc( )->sym, n->dbg.ex )
195 dim as ASTNODE
ptr n =
any
197 n =
astNewNode( AST_NODECLASS_NOP, FB_DATATYPE_INVALID )
209 dim as ASTNODE
ptr n =
any
211 n =
astNewNode( AST_NODECLASS_NIDXARRAY, FB_DATATYPE_INVALID )
226 byval l as ASTNODE
ptr, _
227 byval r
as ASTNODE
ptr, _
228 byval ret_left
as integer _
231 dim as ASTNODE
ptr n =
any
242 n =
astNewNode( AST_NODECLASS_LINK, astGetFullType(
l ),
l->subtype )
244 n =
astNewNode( AST_NODECLASS_LINK, astGetFullType( r ), r->subtype )
247 n->link.ret_left = ret_left
255 dim as IRVREG
ptr vrl =
any, vrr =
any
263 if( n->link.ret_left )
then
273 byval l as ASTNODE
ptr, _
274 byval dtype
as integer, _
275 byval isresult
as integer _
279 dim as ASTNODE
ptr n =
astNewNode( AST_NODECLASS_LOAD, dtype )
282 n->lod.isres = isresult
288 dim as ASTNODE
ptr l =
any
289 dim as IRVREG
ptr v1 =
any, vr =
any
298 if( ast.doemit )
then
299 if( n->lod.isres )
then
300 vr = irAllocVREG( irGetVRDataType( v1 ), irGetVRSubType( v1 ) )
301 irEmitLOADRES( v1, vr )
318 byval l as ASTNODE
ptr, _
319 byval sym
as FBSYMBOL
ptr _
322 dim as ASTNODE
ptr n =
any
323 dim as integer dtype =
any
324 dim as FBSYMBOL
ptr subtype =
any
329 if( typeGetDtAndPtrOnly( dtype ) = FB_DATATYPE_BITFIELD )
then
331 dtype = typeJoin( dtype, FB_DATATYPE_UINT )
334 ast.bitfieldcount += 1
341 n =
astNewNode( AST_NODECLASS_FIELD, dtype, subtype )
352 if( (n = NULL)
or (ast.bitfieldcount <= 0) )
then
356 if( astIsBITFIELD( n ) )
then
357 ast.bitfieldcount -= 1
366 byval l as ASTNODE
ptr, _
367 byval r
as ASTNODE
ptr _
370 dim as FBSYMBOL
ptr s =
any
379 assert( symbIsBitfield( s ) )
383 astGetFullType(
l ) = symbGetFullType( s )
384 l->subtype = s->subtype
403 if( s->bitfld.bitpos > 0 )
then
412 dim as FBSYMBOL
ptr s =
any
419 assert( symbIsBitfield( s ) )
424 l->dtype = typeJoin(
l->dtype, s->typ )
425 l->subtype = s->subtype
428 if( s->bitfld.bitpos > 0 )
then
439 dim as integer count =
any
444 if( astIsBITFIELD( n ) )
then
460 dim as ASTNODE
ptr l =
any
465 if( ast.bitfieldcount <= 0 )
then
473 select case( n->
class )
474 case AST_NODECLASS_ASSIGN
476 if( n->
l->
class = AST_NODECLASS_FIELD )
then
477 if( astGetDataType( n->
l->
l ) = FB_DATATYPE_BITFIELD )
then
479 ast.bitfieldcount -= 1
489 case AST_NODECLASS_FIELD
491 if( astGetDataType(
l ) = FB_DATATYPE_BITFIELD )
then
495 ast.bitfieldcount -= 1
511 dim as IRVREG
ptr vr =
any
516 if( ast.doemit )
then
517 vr->vector = n->vector
527 byval op as integer, _
528 byval l as ASTNODE
ptr _
531 dim as ASTNODE
ptr n =
any
537 n =
astNewNode( AST_NODECLASS_STACK, astGetFullType(
l ), NULL )
546 dim as ASTNODE
ptr l =
any
547 dim as IRVREG
ptr vr =
any
556 if( ast.doemit )
then
557 irEmitSTACK( n->stack.
op, vr )
584 byval col
as integer, _
585 byval just
as integer, _
586 byval depth
as integer = -1 _
589 dim pad
as integer =
any
601 print space(pad-1); s
603 print str(depth);
space(pad-1 -
len(
str(depth)) ); s
649 @
"TYPEINI_ASSIGN" ), _
650 @
"TYPEINI_CTORCALL" ), _
651 @
"TYPEINI_CTORLIST" ), _
652 @
"TYPEINI_SCOPEINI" ), _
653 @
"TYPEINI_SCOPEEND" ), _
778 if((
op > AST_OPCODES - 1 )
or (
op < 0 ))
then
779 return "OP:" +
str(
op)
787 byval c
as AST_NODECLASS _
790 if(( c > AST_CLASSES - 1 )
or ( c < 0 ))
then
791 return "CLASS:" +
str(c)
801 byval s
as FBSYMBOL
ptr _
804 if( s = NULL )
then return ""
806 if( s->id.
name )
then
808 elseif( s->id.
alias )
then
809 return *(s->id.
alias)
816 byval n
as ASTNODE
ptr _
819 select case as const n->
class
820 case AST_NODECLASS_BOP
823 case AST_NODECLASS_UOP
826 case AST_NODECLASS_CONST
827 if( typeGetClass( n->dtype ) = FB_DATACLASS_FPOINT )
then
828 return str( astConstGetFloat( n ) )
830 return str( astConstGetInt( n ) )
832 case AST_NODECLASS_VAR
833 return "VAR( " & *symbGetName( n->sym ) &
" )"
835 case AST_NODECLASS_DECL
837 return "DECL( " & *symbGetName( n->sym ) &
" )"
841 case AST_NODECLASS_CALL
842 return "CALL( " & *symbGetName( n->sym ) &
" )"
844 case AST_NODECLASS_LABEL
847 case AST_NODECLASS_BRANCH
850 case AST_NODECLASS_SCOPEBEGIN
862 byval n
as ASTNODE
ptr, _
863 byval col
as integer, _
864 byval just
as integer, _
865 byval depth
as integer _
868 if( col <= 4
or col >= 76 )
then
885 if( n->
l <> NULL )
then
886 if( n->r <> NULL )
then
891 elseif( n->r <> NULL )
then
897 if( n->
l <> NULL )
then
900 if( n->r <> NULL )
then
909 byval n
as ASTNODE
ptr, _
910 byval col
as integer _
920 byval n
as ASTNODE
ptr, _
921 byval col
as integer _
924 do while( n <> NULL )
933 static reclevel
as integer
944 var have_data = (n->sym <> NULL)
or (n->
l <> NULL)
or (n->r <> NULL)
945 select case as const( n->
class )
946 case AST_NODECLASS_BOP, AST_NODECLASS_UOP, AST_NODECLASS_CONST
954 select case as const( n->
class )
955 case AST_NODECLASS_BOP, AST_NODECLASS_UOP
957 case AST_NODECLASS_CONST
958 if( typeGetClass( n->dtype ) = FB_DATACLASS_FPOINT )
then
959 s +=
str( astConstGetFloat( n ) ) +
", "
961 s +=
str( astConstGetInt( n ) ) +
", "
966 s += *symbGetName( n->sym ) +
", "
976 if(
right( s, 2 ) =
", " )
then
977 s =
left( s,
len( s ) - 2 )