"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.07.1-source/src/compiler/ast.bi" (27 Sep 2019, 39763 Bytes) of package /linux/privat/FreeBASIC-1.07.1-source.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "ast.bi": 1.07.0_vs_1.07.1.

    1 #ifndef __AST_BI__
    2 #define __AST_BI__
    3 
    4 #include once "list.bi"
    5 #include once "ast-op.bi"
    6 #include once "ir.bi"
    7 
    8 const AST_INITNODES             = 8192
    9 const AST_INITPROCNODES         = 128
   10 
   11 '' when changing, update ast.bas:ast_loadcallbacks() and ast-node-misc.bas:dbg_astNodeClassNames()
   12 enum AST_NODECLASS
   13     AST_NODECLASS_NOP
   14 
   15     AST_NODECLASS_LOAD
   16     AST_NODECLASS_ASSIGN
   17     AST_NODECLASS_BOP
   18     AST_NODECLASS_UOP
   19     AST_NODECLASS_CONV
   20     AST_NODECLASS_ADDROF
   21     AST_NODECLASS_BRANCH
   22     AST_NODECLASS_JMPTB
   23     AST_NODECLASS_CALL
   24     AST_NODECLASS_CALLCTOR
   25     AST_NODECLASS_STACK
   26     AST_NODECLASS_MEM
   27 
   28     '' LOOP nodes, used to wrap loop code (e.g. new[]'s defctor calling)
   29     '' that needs to be LINKed into expression trees, because it isn't
   30     '' immediately astAdd()'ed, thus may be cloned. The LOOP wrapper node
   31     '' allows astCloneTree() to duplicate the loop's LABEL and also update
   32     '' the corresponding BRANCH.
   33     AST_NODECLASS_LOOP
   34 
   35     '' Only used to classify comparison operators, there are no COMP nodes.
   36     AST_NODECLASS_COMP
   37 
   38     AST_NODECLASS_LINK
   39     AST_NODECLASS_CONST
   40     AST_NODECLASS_VAR
   41     AST_NODECLASS_IDX
   42     AST_NODECLASS_FIELD
   43     AST_NODECLASS_DEREF
   44     AST_NODECLASS_LABEL
   45     AST_NODECLASS_ARG
   46     AST_NODECLASS_OFFSET
   47     AST_NODECLASS_DECL
   48 
   49     AST_NODECLASS_NIDXARRAY
   50 
   51     AST_NODECLASS_IIF
   52     AST_NODECLASS_LIT
   53     AST_NODECLASS_ASM
   54     AST_NODECLASS_DATASTMT
   55     AST_NODECLASS_DBG
   56 
   57     AST_NODECLASS_BOUNDCHK
   58     AST_NODECLASS_PTRCHK
   59 
   60     AST_NODECLASS_SCOPEBEGIN
   61     AST_NODECLASS_SCOPEEND
   62     AST_NODECLASS_SCOPE_BREAK
   63 
   64     AST_NODECLASS_TYPEINI
   65     AST_NODECLASS_TYPEINI_PAD
   66     AST_NODECLASS_TYPEINI_ASSIGN
   67     AST_NODECLASS_TYPEINI_CTORCALL
   68     AST_NODECLASS_TYPEINI_CTORLIST
   69     AST_NODECLASS_TYPEINI_SCOPEINI
   70     AST_NODECLASS_TYPEINI_SCOPEEND
   71 
   72     AST_NODECLASS_PROC
   73     AST_NODECLASS_MACRO
   74 
   75     AST_CLASSES
   76 end enum
   77 
   78 enum AST_OPOPT
   79     AST_OPOPT_NONE          = &h00000000
   80 
   81     AST_OPOPT_ALLOCRES      = &h00000001
   82     AST_OPOPT_LPTRARITH     = &h00000002
   83     AST_OPOPT_RPTRARITH     = &h00000004
   84     AST_OPOPT_NOCOERCION    = &h00000008
   85     AST_OPOPT_DONTCHKPTR    = &h00000010
   86     AST_OPOPT_DONTCHKOPOVL  = &h00000020
   87     AST_OPOPT_ISINI         = &h00000040
   88 
   89     AST_OPOPT_DOPTRARITH    = AST_OPOPT_LPTRARITH or AST_OPOPT_RPTRARITH
   90 
   91     AST_OPOPT_DEFAULT       = AST_OPOPT_ALLOCRES
   92 end enum
   93 
   94 #ifndef ASTNODE_
   95 type ASTNODE_ as ASTNODE
   96 #endif
   97 
   98 '' update astCloneCALL( ), astDelCALL() if the next structs are changed
   99 type AST_TMPSTRLIST_ITEM
  100     sym             as FBSYMBOL ptr
  101     srctree         as ASTNODE_ ptr
  102     prev            as AST_TMPSTRLIST_ITEM ptr
  103 end type
  104 
  105 type AST_NODE_CALL
  106     isrtl           as integer
  107     args            as integer
  108     currarg         as FBSYMBOL ptr
  109     argtail         as ASTNODE_ ptr
  110     strtail         as AST_TMPSTRLIST_ITEM ptr  '' fixed-length string argument copy-back list
  111     tmpres          as FBSYMBOL ptr                 '' temp result structure, if needed
  112 end type
  113 
  114 type AST_NODE_ARG
  115     mode            as integer                      '' to pass NULL's to byref args, etc
  116     lgt             as longint                      '' length, used to push UDT's by value
  117 end type
  118 
  119 type AST_NODE_VAR
  120     ofs             as longint                      '' offset
  121 end type
  122 
  123 type AST_NODE_IDX
  124     ofs             as longint                      '' offset
  125     mult            as integer                      '' multipler
  126     '' Note: the multiplier field is used in combination with x86 ASM-backend specific
  127     '' optimizations only, see hOptConstIdxMult().
  128 end type
  129 
  130 type AST_NODE_PTR
  131     ofs             as longint                      '' offset
  132 end type
  133 
  134 type AST_NODE_IIF
  135     falselabel      as FBSYMBOL ptr
  136 end type
  137 
  138 type AST_NODE_LOAD
  139     isres           as integer
  140 end type
  141 
  142 type AST_NODE_LABEL
  143     flush           as integer
  144 end type
  145 
  146 type AST_NODE_LIT
  147     text            as zstring ptr
  148 end type
  149 
  150 type AST_NODE_ASM
  151     tokhead as ASTASMTOK ptr
  152 end type
  153 
  154 type AST_NODE_OP  '' used by: bop, uop, addr
  155     op              as integer
  156     options         as AST_OPOPT
  157     ex              as FBSYMBOL ptr                 '' (extra: label, etc)
  158 end type
  159 
  160 type AST_NODE_OFFS
  161     ofs             as longint
  162 end type
  163 
  164 type AST_NODE_JMPTB
  165     '' Dynamically allocated buffer holding the jmptb's value/label pairs
  166     values              as ulongint ptr
  167     labels              as FBSYMBOL ptr ptr
  168     labelcount          as integer
  169 
  170     deflabel            as FBSYMBOL ptr
  171     bias                as ulongint
  172     span                as ulongint
  173 end type
  174 
  175 type AST_NODE_DBG
  176     ex              as integer
  177     filename        as zstring ptr
  178     op              as integer
  179 end type
  180 
  181 type AST_NODE_MEM
  182     bytes               as longint
  183     op              as integer
  184 end type
  185 
  186 type AST_NODE_STACK
  187     op              as integer
  188 end type
  189 
  190 type AST_NODE_TYPEINI
  191     ofs             as longint
  192     union
  193         bytes       as longint
  194         elements    as longint
  195     end union
  196     scp             as FBSYMBOL ptr
  197     lastscp         as FBSYMBOL ptr
  198 end type
  199 
  200 type AST_NODE_TYPEINISCOPE
  201     '' Whether the typeini scope corresponds to an array initializer or a
  202     '' UDT initializer.
  203     '' This matters to the LLVM backend when emitting varinis, because
  204     '' global array/struct initiializers have different syntax there.
  205     '' It doesn't matter to the C backend (all initializers use "{...}"
  206     '' braces) or the ASM backend (varini scopes aren't used at all).
  207     is_array as integer
  208 end type
  209 
  210 type AST_NODE_BREAK
  211     parent          as ASTNODE_ ptr
  212     scope           as integer
  213     linenum         as integer
  214     stmtnum         as integer                      '' can't use colnum as it's unreliable
  215 end type
  216 
  217 type AST_BREAKLIST
  218     head            as ASTNODE_ ptr
  219     tail            as ASTNODE_ ptr
  220 end type
  221 
  222 type AST_NODE_PROC
  223     ismain          as integer
  224     decl_last       as ASTNODE_ ptr                 '' to support implicit variables decl
  225 end type
  226 
  227 type AST_NODE_BLOCK
  228     parent          as ASTNODE_ ptr
  229     inistmt         as integer
  230     endstmt         as integer
  231     initlabel       as FBSYMBOL ptr
  232     exitlabel       as FBSYMBOL ptr
  233     breaklist       as AST_BREAKLIST
  234     proc            as AST_NODE_PROC
  235 end type
  236 
  237 type AST_NODE_DATASTMT
  238     union
  239         id          as integer
  240         elmts       as integer
  241     end union
  242 end type
  243 
  244 type AST_NODE_LINK
  245     ret_left        as integer
  246 end type
  247 
  248 type AST_NODE_CAST
  249     doconv          as integer  '' do conversion (TRUE or FALSE)
  250     do_convfd2fs    as integer  '' whether or not to ensure truncation in double2single conversions
  251     convconst       as integer  '' const qualifier bits discarded/changed in the conversion (TRUE or FALSE)
  252 end type
  253 
  254 ''
  255 type ASTNODE
  256     class           as AST_NODECLASS
  257 
  258     dtype           as integer
  259     subtype         as FBSYMBOL ptr
  260 
  261     sym             as FBSYMBOL ptr                 '' attached symbol
  262 
  263     vector          as integer                  '' 0, 2, 3, or 4 (> 2 for single only)
  264 
  265     union
  266         val         as FBVALUE    '' CONST nodes
  267         var_        as AST_NODE_VAR
  268         idx         as AST_NODE_IDX
  269         ptr         as AST_NODE_PTR
  270         call        as AST_NODE_CALL
  271         arg         as AST_NODE_ARG
  272         iif         as AST_NODE_IIF
  273         op          as AST_NODE_OP
  274         lod         as AST_NODE_LOAD
  275         lbl         as AST_NODE_LABEL
  276         ofs         as AST_NODE_OFFS
  277         lit         as AST_NODE_LIT
  278         asm         as AST_NODE_ASM
  279         jmptb       as AST_NODE_JMPTB
  280         dbg         as AST_NODE_DBG
  281         mem         as AST_NODE_MEM
  282         stack       as AST_NODE_STACK
  283         typeini     as AST_NODE_TYPEINI
  284         typeiniscope    as AST_NODE_TYPEINISCOPE
  285         block       as AST_NODE_BLOCK               '' shared by PROC and SCOPE nodes
  286         break       as AST_NODE_BREAK
  287         data        as AST_NODE_DATASTMT
  288         link        as AST_NODE_LINK
  289         cast        as AST_NODE_CAST
  290     end union
  291 
  292     l               as ASTNODE ptr                  '' left node
  293     r               as ASTNODE ptr                  '' right /
  294 
  295     prev            as ASTNODE ptr                  '' used by astAdd()
  296     next            as ASTNODE ptr                  '' /
  297 end type
  298 
  299 type AST_PROC_CTX
  300     head            as ASTNODE ptr                  '' procs list
  301     tail            as ASTNODE ptr                  '' /     /
  302     curr            as ASTNODE ptr                  '' current proc
  303 end type
  304 
  305 type AST_CALL_CTX
  306     tmpstrlist      as TLIST                        '' list of temp strings
  307 end type
  308 
  309 type AST_GLOBINST_CTX
  310     list            as TLIST                        '' global symbols with ctors/dtors
  311     ctorcnt         as integer                      '' number of ctors in the list above
  312     dtorcnt         as integer                      ''      /    dtors       /
  313 end type
  314 
  315 type AST_DATASTMT_CTX
  316     desc            as FBSYMBOL ptr
  317     lastsym         as FBSYMBOL ptr
  318     firstsym        as FBSYMBOL ptr
  319     lastlbl         as FBSYMBOL ptr
  320 end type
  321 
  322 type AST_DTORLIST_ITEM
  323     sym             as FBSYMBOL ptr
  324 
  325     '' Some integer used to identify temp vars from expressions nested
  326     '' inside the true/false expressions of iif()'s, which may have to be
  327     '' destroyed conditionally, depending on which code path was executed.
  328     cookie          as integer
  329 
  330     refcount        as integer
  331 end type
  332 
  333 type AST_DTORLIST_SCOPESTACK
  334     '' Grow array; the stack of cookies of the current live dtorlist scopes
  335     cookies as integer ptr
  336     count   as integer
  337     room    as integer
  338 end type
  339 
  340 type ASTCTX
  341     astTB           as TLIST
  342 
  343     proc            as AST_PROC_CTX
  344     call            as AST_CALL_CTX
  345     globinst        as AST_GLOBINST_CTX             '' global instances
  346     data            as AST_DATASTMT_CTX             '' DATA stmt garbage
  347 
  348     currblock       as ASTNODE ptr                  '' current scope block (PROC or SCOPE)
  349 
  350     doemit          as integer
  351 
  352     '' Count of TYPEINI nodes in expressions that are about to be astAdd()ed
  353     '' (so astAdd() only bothers running astTypeIniUpdate() if it's really
  354     '' necessary -- another pass besides astOptimizeTree() walking the
  355     '' whole expression tree during every astAdd() would just be
  356     '' unnecessarily slow)
  357     typeinicount        as integer
  358 
  359     '' Same for FIELD with bitfield type (for astUpdateBitfields())
  360     bitfieldcount       as integer
  361 
  362     '' The counters must always be >= the amount of corresponding nodes that
  363     '' will be given to astAdd() so that the updating functions don't miss
  364     '' anything. That's why it's important to update the counters during
  365     '' astCloneTree() for example. On the other hand, nodes in field or
  366     '' parameter initializers don't need to be counted, since these
  367     '' expressions will always be cloned instead of being astAdd()ed
  368     '' themselves. Unfortunately
  369 
  370     dtorlist        as TLIST                        '' temp dtors list
  371     dtorlistscopes      as AST_DTORLIST_SCOPESTACK  '' scope stack for astDtorListScope*()
  372     dtorlistcookies     as integer          '' Cookie counter used to allocate new cookie numbers
  373     flushdtorlist   as integer
  374 
  375     asmtoklist      as TLIST  '' inline ASM token nodes
  376 
  377     '' Whether warnings related to CONST nodes (e.g. "const overflow"
  378     '' warnings from astCheckConst()) should be hidden. Sometimes we do
  379     '' internal astNew*() operations that cause such warnings, but since
  380     '' they're part of internal optimizations, they shouldn't be shown to
  381     '' the user.
  382     '' This works like a nesting level counter so that the
  383     '' astBeginHideWarnings()/astEndHideWarnings() functions work like a
  384     '' push/pop stack.
  385     ''   0 => show warnings
  386     '' > 0 => hide warnings
  387     hidewarningslevel   as integer
  388 end type
  389 
  390 enum AST_OPFLAGS
  391     AST_OPFLAGS_NONE        = &h00000000
  392     AST_OPFLAGS_SELF        = &h00000001            '' op=
  393     AST_OPFLAGS_COMM        = &h00000002            '' commutative
  394     AST_OPFLAGS_NORES       = &h00000004            '' no result (it's a SUB)
  395     AST_OPFLAGS_RELATIONAL      = &h00000008  '' whether it's one of the relational BOPs
  396 end enum
  397 
  398 type AST_OPINFO
  399     class           as AST_NODECLASS
  400     flags           as AST_OPFLAGS
  401     id              as const zstring ptr
  402     selfop          as AST_OP                       '' self version
  403 end type
  404 
  405 declare sub astInit( )
  406 declare sub astEnd( )
  407 declare sub astProcListInit( )
  408 declare sub astProcListEnd( )
  409 declare sub astCallInit( )
  410 declare sub astCallEnd( )
  411 declare sub astMiscInit( )
  412 declare sub astMiscEnd( )
  413 declare sub astDataStmtInit( )
  414 
  415 declare sub astDelNode _
  416     ( _
  417         byval n as ASTNODE ptr _
  418     )
  419 
  420 declare function astCloneTree( byval n as ASTNODE ptr ) as ASTNODE ptr
  421 
  422 declare sub astDelTree _
  423     ( _
  424         byval n as ASTNODE ptr _
  425     )
  426 
  427 declare function astIsTreeEqual _
  428     ( _
  429         byval l as ASTNODE ptr, _
  430         byval r as ASTNODE ptr _
  431     ) as integer
  432 
  433 declare function astIsEqualParamInit _
  434     ( _
  435         byval l as ASTNODE ptr, _
  436         byval r as ASTNODE ptr _
  437     ) as integer
  438 
  439 declare function astIsConstant( byval expr as ASTNODE ptr ) as integer
  440 
  441 declare sub astProcBegin( byval proc as FBSYMBOL ptr, byval ismain as integer )
  442 declare function astProcEnd( byval callrtexit as integer ) as integer
  443 
  444 declare sub astProcVectorize _
  445     ( _
  446         byval p as ASTNODE ptr _
  447     )
  448 
  449 declare function astProcAddStaticInstance _
  450     ( _
  451         byval sym as FBSYMBOL ptr _
  452     ) as FBSYMBOL ptr
  453 
  454 declare sub astProcAddGlobalInstance _
  455     ( _
  456         byval sym as FBSYMBOL ptr, _
  457         byval initree as ASTNODE ptr, _
  458         byval call_dtor as integer _
  459     )
  460 
  461 declare function astScopeBegin( ) as ASTNODE ptr
  462 declare sub astScopeBreak( byval tolabel as FBSYMBOL ptr )
  463 declare sub astScopeEnd( byval s as ASTNODE ptr )
  464 declare function astScopeUpdBreakList( byval proc as ASTNODE ptr ) as integer
  465 declare sub astScopeDestroyVars( byval symtbtail as FBSYMBOL ptr )
  466 declare sub astScopeAllocLocals( byval symtbhead as FBSYMBOL ptr )
  467 declare function astTempScopeBegin _
  468     ( _
  469         byref lastscp as FBSYMBOL ptr, _
  470         byval backnode as ASTNODE ptr _
  471     ) as FBSYMBOL ptr
  472 declare sub astTempScopeEnd _
  473     ( _
  474         byval scp as FBSYMBOL ptr, _
  475         byval lastscp as FBSYMBOL ptr _
  476     )
  477 declare sub astTempScopeClone _
  478     ( _
  479         byval scp as FBSYMBOL ptr, _
  480         byval clonetree as ASTNODE ptr _
  481     )
  482 declare sub astTempScopeDelete( byval scp as FBSYMBOL ptr )
  483 
  484 declare function astAdd _
  485     ( _
  486         byval n as ASTNODE ptr _
  487     ) as ASTNODE ptr
  488 
  489 declare function astAddAfter _
  490     ( _
  491         byval n as ASTNODE ptr, _
  492         byval ref as ASTNODE ptr _
  493     ) as ASTNODE ptr
  494 
  495 declare sub astAddUnscoped _
  496     ( _
  497         byval n as ASTNODE ptr _
  498     )
  499 
  500 declare function astFindFirstCode( byval proc as ASTNODE ptr ) as ASTNODE ptr
  501 
  502 declare function astBuildBranch _
  503     ( _
  504         byval expr as ASTNODE ptr, _
  505         byval label as FBSYMBOL ptr, _
  506         byval is_inverse as integer, _
  507         byval is_iif as integer = FALSE _
  508     ) as ASTNODE ptr
  509 
  510 declare function astPtrCheck _
  511     ( _
  512         byval pdtype as integer, _
  513         byval psubtype as FBSYMBOL ptr, _
  514         byval pparammode as integer, _
  515         byval expr as ASTNODE ptr _
  516     ) as integer
  517 
  518 declare function astNewNOP _
  519     ( _
  520         _
  521     ) as ASTNODE ptr
  522 
  523 declare function astNewASSIGN _
  524     ( _
  525         byval l as ASTNODE ptr, _
  526         byval r as ASTNODE ptr, _
  527         byval options as AST_OPOPT = AST_OPOPT_NONE _
  528     ) as ASTNODE ptr
  529 
  530 enum AST_CONVOPT
  531     AST_CONVOPT_SIGNCONV = &h1
  532     AST_CONVOPT_CHECKSTR = &h2
  533     AST_CONVOPT_PTRONLY  = &h4
  534     AST_CONVOPT_DONTCHKPTR = &h8
  535     AST_CONVOPT_DONTWARNCONST = &h10
  536     AST_CONVOPT_DONTWARNFUNCPTR = &h20
  537 end enum
  538 
  539 declare function astTryOvlStringCONV( byref expr as ASTNODE ptr ) as integer
  540 
  541 declare function astNewCONV _
  542     ( _
  543         byval to_dtype as integer, _
  544         byval to_subtype as FBSYMBOL ptr, _
  545         byval l as ASTNODE ptr, _
  546         byval options as AST_CONVOPT = 0, _
  547         byval perrmsg as integer ptr = NULL _
  548     ) as ASTNODE ptr
  549 
  550 declare function astNewOvlCONV _
  551     ( _
  552         byval to_dtype as integer, _
  553         byval to_subtype as FBSYMBOL ptr, _
  554         byval l as ASTNODE ptr _
  555     ) as ASTNODE ptr
  556 
  557 declare sub astUpdateCONVFD2FS _
  558     ( _
  559         byval n as ASTNODE ptr, _
  560         byval dtype as integer, _
  561         byval is_expr as integer _
  562     )
  563 
  564 declare function astSkipConstCASTs( byval n as ASTNODE ptr ) as ASTNODE ptr
  565 declare function astSkipNoConvCAST( byval n as ASTNODE ptr ) as ASTNODE ptr
  566 declare function astRemoveNoConvCAST( byval n as ASTNODE ptr ) as ASTNODE ptr
  567 declare function astSkipCASTs( byval n as ASTNODE ptr ) as ASTNODE ptr
  568 declare function astRemoveCASTs( byval n as ASTNODE ptr ) as ASTNODE ptr
  569 
  570 declare function astNewBOP _
  571     ( _
  572         byval op as integer, _
  573         byval l as ASTNODE ptr, _
  574         byval r as ASTNODE ptr, _
  575         byval ex as FBSYMBOL ptr = NULL, _
  576         byval options as AST_OPOPT = AST_OPOPT_DEFAULT _
  577     ) as ASTNODE ptr
  578 
  579 declare function astNewSelfBOP _
  580     ( _
  581         byval op as integer, _
  582         byval l as ASTNODE ptr, _
  583         byval r as ASTNODE ptr, _
  584         byval ex as FBSYMBOL ptr = NULL, _
  585         byval options as AST_OPOPT = AST_OPOPT_DEFAULT _
  586     ) as ASTNODE ptr
  587 
  588 declare function astNewUOP _
  589     ( _
  590         byval op as integer, _
  591         byval o as ASTNODE ptr _
  592     ) as ASTNODE ptr
  593 
  594 declare function astConstEqZero( byval n as ASTNODE ptr ) as integer
  595 declare function astConstGeZero( byval n as ASTNODE ptr ) as integer
  596 declare function astIsConst0OrMinus1( byval n as ASTNODE ptr ) as integer
  597 
  598 declare function astNewCONST _
  599     ( _
  600         byval v as FBVALUE ptr, _
  601         byval dtype as integer, _
  602         byval subtype as FBSYMBOL ptr = NULL _
  603     ) as ASTNODE ptr
  604 
  605 declare function astNewCONSTstr _
  606     ( _
  607         byval v as zstring ptr _
  608     ) as ASTNODE ptr
  609 
  610 declare function astNewCONSTwstr _
  611     ( _
  612         byval v as wstring ptr _
  613     ) as ASTNODE ptr
  614 
  615 declare function astNewCONSTi _
  616     ( _
  617         byval value as longint, _
  618         byval dtype as integer = FB_DATATYPE_INTEGER, _
  619         byval subtype as FBSYMBOL ptr = NULL _
  620     ) as ASTNODE ptr
  621 
  622 declare function astNewCONSTf _
  623     ( _
  624         byval value as double, _
  625         byval dtype as integer = FB_DATATYPE_DOUBLE _
  626     ) as ASTNODE ptr
  627 
  628 declare function astNewCONSTz _
  629     ( _
  630         byval dtype as integer = FB_DATATYPE_CHAR, _
  631         byval subtype as FBSYMBOL ptr = NULL _
  632     ) as ASTNODE ptr
  633 
  634 declare function astConstFlushToInt _
  635     ( _
  636         byval n as ASTNODE ptr, _
  637         byval dtype as integer = FB_DATATYPE_INTEGER _
  638     ) as longint
  639 
  640 declare function astConstFlushToStr( byval n as ASTNODE ptr ) as string
  641 declare function astConstFlushToWstr( byval n as ASTNODE ptr ) as wstring ptr
  642 declare function astConstGetAsInt64( byval n as ASTNODE ptr ) as longint
  643 declare function astConstGetAsDouble( byval n as ASTNODE ptr ) as double
  644 declare function astBuildConst( byval sym as FBSYMBOL ptr ) as ASTNODE ptr
  645 declare function astConvertRawCONSTi _
  646     ( _
  647         byval dtype as integer, _
  648         byval subtype as FBSYMBOL ptr, _
  649         byval l as ASTNODE ptr _
  650     ) as ASTNODE ptr
  651 
  652 declare function astNewVAR _
  653     ( _
  654         byval sym as FBSYMBOL ptr, _
  655         byval ofs as longint = 0, _
  656         byval dtype as integer = FB_DATATYPE_INVALID, _
  657         byval subtype as FBSYMBOL ptr = NULL _
  658     ) as ASTNODE ptr
  659 
  660 declare function astNewIDX( byval var_ as ASTNODE ptr, byval idx as ASTNODE ptr ) as ASTNODE ptr
  661 
  662 declare function astNewFIELD _
  663     ( _
  664         byval l as ASTNODE ptr, _
  665         byval sym as FBSYMBOL ptr _
  666     ) as ASTNODE ptr
  667 declare sub astForgetBitfields( byval n as ASTNODE ptr )
  668 declare function astUpdateBitfields( byval n as ASTNODE ptr ) as ASTNODE ptr
  669 
  670 declare function astNewDEREF _
  671     ( _
  672         byval l as ASTNODE ptr, _
  673         byval dtype as integer = FB_DATATYPE_INVALID, _
  674         byval subtype as FBSYMBOL ptr = NULL, _
  675         byval ofs as longint = 0 _
  676     ) as ASTNODE ptr
  677 
  678 declare function astNewCALL _
  679     ( _
  680         byval sym as FBSYMBOL ptr, _
  681         byval ptrexpr as ASTNODE ptr = NULL _
  682     ) as ASTNODE ptr
  683 
  684 declare function astNewCALLCTOR _
  685     ( _
  686         byval procexpr as ASTNODE ptr, _
  687         byval instptr as ASTNODE ptr _
  688     ) as ASTNODE ptr
  689 
  690 declare sub astCloneCALL _
  691     ( _
  692         byval n as ASTNODE ptr, _
  693         byval c as ASTNODE ptr _
  694     )
  695 
  696 declare sub astDelCALL _
  697     ( _
  698         byval n as ASTNODE ptr _
  699     )
  700 
  701 declare function astNewARG _
  702     ( _
  703         byval f as ASTNODE ptr, _
  704         byval p as ASTNODE ptr, _
  705         byval dtype as integer = FB_DATATYPE_INVALID, _
  706         byval mode as integer = INVALID _
  707     ) as ASTNODE ptr
  708 
  709 declare sub astReplaceInstanceArg _
  710     ( _
  711         byval parent as ASTNODE ptr, _
  712         byval expr as ASTNODE ptr, _
  713         byval mode as integer = INVALID _
  714     )
  715 
  716 declare function astNewADDROF _
  717     ( _
  718         byval l as ASTNODE ptr _
  719     ) as ASTNODE ptr
  720 
  721 declare function astNewLOAD _
  722     ( _
  723         byval l as ASTNODE ptr, _
  724         byval dtype as integer, _
  725         byval isresult as integer = FALSE _
  726     ) as ASTNODE ptr
  727 
  728 declare function astNewBRANCH _
  729     ( _
  730         byval op as integer, _
  731         byval label as FBSYMBOL ptr, _
  732         byval l as ASTNODE ptr = NULL _
  733     ) as ASTNODE ptr
  734 
  735 declare function astBuildJMPTB _
  736     ( _
  737         byval tempvar as FBSYMBOL ptr, _
  738         byval values1 as ulongint ptr, _
  739         byval labels1 as FBSYMBOL ptr ptr, _
  740         byval labelcount as integer, _
  741         byval deflabel as FBSYMBOL ptr, _
  742         byval bias as ulongint, _
  743         byval span as ulongint _
  744     ) as ASTNODE ptr
  745 
  746 declare function astNewLOOP _
  747     ( _
  748         byval label as FBSYMBOL ptr, _
  749         byval tree as ASTNODE ptr _
  750     ) as ASTNODE ptr
  751 
  752 declare function astNewIIF _
  753     ( _
  754         byval condexpr as ASTNODE ptr, _
  755         byval truexpr as ASTNODE ptr, _
  756         byval truecookie as integer, _
  757         byval falsexpr as ASTNODE ptr, _
  758         byval falsecookie as integer _
  759     ) as ASTNODE ptr
  760 
  761 declare function astNewLINK _
  762     ( _
  763         byval l as ASTNODE ptr, _
  764         byval r as ASTNODE ptr, _
  765         byval ret_left as integer = TRUE _
  766     ) as ASTNODE ptr
  767 
  768 declare function astNewSTACK _
  769     ( _
  770         byval op as integer, _
  771         byval l as ASTNODE ptr _
  772     ) as ASTNODE ptr
  773 
  774 declare function astNewLABEL _
  775     ( _
  776         byval sym as FBSYMBOL ptr, _
  777         byval doflush as integer = TRUE _
  778     ) as ASTNODE ptr
  779 
  780 declare function astNewLIT _
  781     ( _
  782         byval text as zstring ptr _
  783     ) as ASTNODE ptr
  784 
  785 declare function astAsmAppendText _
  786     ( _
  787         byval tail as ASTASMTOK ptr, _
  788         byval text as zstring ptr _
  789     ) as ASTASMTOK ptr
  790 
  791 declare function astAsmAppendSymb _
  792     ( _
  793         byval tail as ASTASMTOK ptr, _
  794         byval sym as FBSYMBOL ptr _
  795     ) as ASTASMTOK ptr
  796 
  797 declare function astNewASM( byval asmtokhead as ASTASMTOK ptr ) as ASTNODE ptr
  798 
  799 declare function astNewDBG _
  800     ( _
  801         byval op as integer, _
  802         byval ex as integer = 0, _
  803         byval filename as zstring ptr = 0 _
  804     ) as ASTNODE ptr
  805 
  806 declare function astNewMEM _
  807     ( _
  808         byval op as integer, _
  809         byval l as ASTNODE ptr, _
  810         byval r as ASTNODE ptr, _
  811         byval bytes as longint = 0 _
  812     ) as ASTNODE ptr
  813 
  814 declare function astNewMACRO _
  815     ( _
  816         byval op as AST_OP, _
  817         byval arg1 as ASTNODE ptr, _
  818         byval arg2 as ASTNODE ptr, _
  819         byval dtype as integer, _
  820         byval subtype as FBSYMBOL ptr _
  821     ) as ASTNODE ptr
  822 
  823 declare function astBuildNewOp _
  824     ( _
  825         byval op as AST_OP, _
  826         byval tmp as FBSYMBOL ptr, _
  827         byval elementsexpr as ASTNODE ptr, _
  828         byval initexpr as ASTNODE ptr, _
  829         byval dtype as integer, _
  830         byval subtype as FBSYMBOL ptr, _
  831         byval do_clear as integer, _
  832         byval newexpr as ASTNODE ptr _
  833     ) as ASTNODE ptr
  834 
  835 declare function astBuildDeleteOp _
  836     ( _
  837         byval op as AST_OP, _
  838         byval ptrexpr as ASTNODE ptr _
  839     ) as ASTNODE ptr
  840 
  841 declare function astNewBOUNDCHK _
  842     ( _
  843         byval l as ASTNODE ptr, _
  844         byval lb as ASTNODE ptr, _
  845         byval ub as ASTNODE ptr, _
  846         byval linenum as integer, _
  847         byval filename as zstring ptr _
  848     ) as ASTNODE ptr
  849 
  850 declare function astBuildBOUNDCHK _
  851     ( _
  852         byval expr as ASTNODE ptr, _
  853         byval lb as ASTNODE ptr, _
  854         byval ub as ASTNODE ptr _
  855     ) as ASTNODE ptr
  856 
  857 declare function astNewPTRCHK _
  858     ( _
  859         byval l as ASTNODE ptr, _
  860         byval linenum as integer, _
  861         byval filename as zstring ptr _
  862     ) as ASTNODE ptr
  863 
  864 declare function astBuildPTRCHK( byval expr as ASTNODE ptr ) as ASTNODE ptr
  865 
  866 declare function astNewDECL _
  867     ( _
  868         byval sym as FBSYMBOL ptr, _
  869         byval do_defaultinit as integer _
  870     ) as ASTNODE ptr
  871 
  872 declare function astNewNIDXARRAY _
  873     ( _
  874         byval expr as ASTNODE ptr _
  875     ) as ASTNODE ptr
  876 
  877 declare function astRemoveNIDXARRAY( byval n as ASTNODE ptr ) as ASTNODE ptr
  878 
  879 declare function astNewNode _
  880     ( _
  881         byval class_ as integer, _
  882         byval dtype as integer, _
  883         byval subtype as FBSYMBOL ptr = NULL _
  884     ) as ASTNODE ptr
  885 
  886 declare function astLoad _
  887     ( _
  888         byval n as ASTNODE ptr _
  889     ) as IRVREG ptr
  890 
  891 declare function astIncOffset( byval n as ASTNODE ptr, byval ofs as longint ) as integer
  892 
  893 declare function astOptimizeTree _
  894     ( _
  895         byval n as ASTNODE ptr _
  896     ) as ASTNODE ptr
  897 
  898 declare function astOptAssignment _
  899     ( _
  900         byval n as ASTNODE ptr _
  901     ) as ASTNODE ptr
  902 
  903 declare sub astCheckConst _
  904     ( _
  905         byval dtype as integer, _
  906         byval n as ASTNODE ptr _
  907     )
  908 
  909 declare function astCheckASSIGN _
  910     ( _
  911         byval l as ASTNODE ptr, _
  912         byval r as ASTNODE ptr _
  913     ) as integer
  914 
  915 declare function astCheckASSIGNToType _
  916     ( _
  917         byval ldtype as integer, _
  918         byval lsubtype as FBSYMBOL ptr, _
  919         byval r as ASTNODE ptr _
  920     ) as integer
  921 
  922 declare function astCheckByrefAssign _
  923     ( _
  924         byval ldtype as integer, _
  925         byval lsubtype as FBSYMBOL ptr, _
  926         byval r as ASTNODE ptr _
  927     ) as integer
  928 
  929 declare function astCheckConvNonPtrToPtr _
  930     ( _
  931         byval to_dtype as integer, _
  932         byval expr_dtype as integer, _
  933         byval expr as ASTNODE ptr, _
  934         byval options as AST_CONVOPT _
  935     ) as integer
  936 
  937 declare function astCheckCONV _
  938     ( _
  939         byval to_dtype as integer, _
  940         byval to_subtype as FBSYMBOL ptr, _
  941         byval l as ASTNODE ptr _
  942     ) as integer
  943 
  944 declare function astUpdStrConcat( byval n as ASTNODE ptr ) as ASTNODE ptr
  945 
  946 declare function astHasSideFx( byval n as ASTNODE ptr ) as integer
  947 
  948 declare function astIsSymbolOnTree _
  949     ( _
  950         byval sym as FBSYMBOL ptr, _
  951         byval n as ASTNODE ptr _
  952     ) as integer
  953 
  954 declare function astGetStrLitSymbol _
  955     ( _
  956         byval n as ASTNODE ptr _
  957     ) as FBSYMBOL ptr
  958 
  959 declare function astTypeIniBegin _
  960     ( _
  961         byval dtype as integer, _
  962         byval subtype as FBSYMBOL ptr, _
  963         byval is_local as integer, _
  964         byval ofs as longint = 0 _
  965     ) as ASTNODE ptr
  966 
  967 declare sub astTypeIniEnd _
  968     ( _
  969         byval tree as ASTNODE ptr, _
  970         byval is_initializer as integer _
  971     )
  972 
  973 declare sub astTypeIniRemoveLastNode( byval tree as ASTNODE ptr )
  974 
  975 declare function astTypeIniAddPad _
  976     ( _
  977         byval tree as ASTNODE ptr, _
  978         byval bytes as longint _
  979     ) as ASTNODE ptr
  980 
  981 declare function astTypeIniAddAssign _
  982     ( _
  983         byval tree as ASTNODE ptr, _
  984         byval expr as ASTNODE ptr, _
  985         byval sym as FBSYMBOL ptr, _
  986         byval dtype as integer = FB_DATATYPE_INVALID, _
  987         byval subtype as FBSYMBOL ptr = NULL _
  988     ) as ASTNODE ptr
  989 
  990 declare function astTypeIniAddCtorCall _
  991     ( _
  992         byval tree as ASTNODE ptr, _
  993         byval sym as FBSYMBOL ptr, _
  994         byval procexpr as ASTNODE ptr, _
  995         byval dtype as integer = FB_DATATYPE_INVALID, _
  996         byval subtype as FBSYMBOL ptr = NULL _
  997     ) as ASTNODE ptr
  998 
  999 declare function astTypeIniAddCtorList _
 1000     ( _
 1001         byval tree as ASTNODE ptr, _
 1002         byval sym as FBSYMBOL ptr, _
 1003         byval elements as longint, _
 1004         byval dtype as integer = FB_DATATYPE_INVALID, _
 1005         byval subtype as FBSYMBOL ptr = NULL _
 1006     ) as ASTNODE ptr
 1007 
 1008 declare function astTypeIniScopeBegin _
 1009     ( _
 1010         byval tree as ASTNODE ptr, _
 1011         byval sym as FBSYMBOL ptr, _
 1012         byval is_array as integer _
 1013     ) as ASTNODE ptr
 1014 
 1015 declare function astTypeIniScopeEnd _
 1016     ( _
 1017         byval tree as ASTNODE ptr, _
 1018         byval sym as FBSYMBOL ptr _
 1019     ) as ASTNODE ptr
 1020 
 1021 declare sub astTypeIniCopyElements _
 1022     ( _
 1023         byval tree as ASTNODE ptr, _
 1024         byval source as ASTNODE ptr, _
 1025         byval beginindex as integer _
 1026     )
 1027 
 1028 declare sub astTypeIniReplaceElement _
 1029     ( _
 1030         byval tree as ASTNODE ptr, _
 1031         byval element as integer, _
 1032         byval expr as ASTNODE ptr _
 1033     )
 1034 
 1035 declare sub astLoadStaticInitializer _
 1036     ( _
 1037         byval tree as ASTNODE ptr, _
 1038         byval basesym as FBSYMBOL ptr _
 1039     )
 1040 
 1041 declare function astTypeIniFlush overload _
 1042     ( _
 1043         byval target as ASTNODE ptr, _
 1044         byval initree as ASTNODE ptr, _
 1045         byval update_typeinicount as integer, _
 1046         byval assignoptions as integer _
 1047     ) as ASTNODE ptr
 1048 
 1049 declare function astTypeIniFlush overload _
 1050     ( _
 1051         byval target as FBSYMBOL ptr, _
 1052         byval initree as ASTNODE ptr, _
 1053         byval update_typeinicount as integer, _
 1054         byval assignoptions as integer _
 1055     ) as ASTNODE ptr
 1056 
 1057 declare function astTypeIniIsConst _
 1058     ( _
 1059         byval tree as ASTNODE ptr _
 1060     ) as integer
 1061 
 1062 declare function astTypeIniUsesLocals _
 1063     ( _
 1064         byval n as ASTNODE ptr, _
 1065         byval ignoreattrib as integer _
 1066     ) as integer
 1067 
 1068 declare function astTypeIniUpdate _
 1069     ( _
 1070         byval tree as ASTNODE ptr _
 1071     ) as ASTNODE ptr
 1072 
 1073 declare function astTypeIniClone( byval tree as ASTNODE ptr ) as ASTNODE ptr
 1074 declare function astTypeIniTryRemove( byval tree as ASTNODE ptr ) as ASTNODE ptr
 1075 declare sub astTypeIniDelete( byval tree as ASTNODE ptr )
 1076 
 1077 declare function astDataStmtBegin( ) as ASTNODE ptr
 1078 
 1079 declare function astDataStmtStore _
 1080     ( _
 1081         byval tree as ASTNODE ptr, _
 1082         byval expr as ASTNODE ptr _
 1083     ) as ASTNODE ptr
 1084 
 1085 declare sub astDataStmtEnd( byval tree as ASTNODE ptr )
 1086 
 1087 declare function astDataStmtAdd _
 1088     ( _
 1089         byval label as FBSYMBOL ptr, _
 1090         byval elements as integer _
 1091     ) as FBSYMBOL ptr
 1092 
 1093 declare function astGetInverseLogOp _
 1094     ( _
 1095         byval op as integer _
 1096     ) as integer
 1097 
 1098 declare function astGetEffectiveNode( byval n as ASTNODE ptr ) as ASTNODE ptr
 1099 declare function astGetEffectiveClass( byval n as ASTNODE ptr ) as integer
 1100 declare function astRebuildWithoutEffectivePart( byval n as ASTNODE ptr ) as ASTNODE ptr
 1101 declare function astCanTakeAddrOf( byval n as ASTNODE ptr ) as integer
 1102 declare function astMakeRef( byref expr as ASTNODE ptr ) as ASTNODE ptr
 1103 declare function astRemSideFx( byref n as ASTNODE ptr ) as ASTNODE ptr
 1104 
 1105 declare function astBuildVarDeref( byval sym as FBSYMBOL ptr ) as ASTNODE ptr
 1106 declare function astBuildVarAddrof( byval sym as FBSYMBOL ptr ) as ASTNODE ptr
 1107 
 1108 declare function astBuildVarInc _
 1109     ( _
 1110         byval lhs as FBSYMBOL ptr, _
 1111         byval rhs as integer _
 1112     ) as ASTNODE ptr
 1113 
 1114 declare function astBuildVarAssign overload _
 1115     ( _
 1116         byval lhs as FBSYMBOL ptr, _
 1117         byval rhs as integer, _
 1118         byval options as integer = 0 _
 1119     ) as ASTNODE ptr
 1120 
 1121 declare function astBuildVarAssign _
 1122     ( _
 1123         byval lhs as FBSYMBOL ptr, _
 1124         byval rhs as ASTNODE ptr, _
 1125         byval options as integer = 0 _
 1126     ) as ASTNODE ptr
 1127 
 1128 declare function astBuildFakeWstringAccess( byval sym as FBSYMBOL ptr ) as ASTNODE ptr
 1129 declare function astBuildFakeWstringAssign _
 1130     ( _
 1131         byval sym as FBSYMBOL ptr, _
 1132         byval expr as ASTNODE ptr, _
 1133         byval options as integer = 0 _
 1134     ) as ASTNODE ptr
 1135 
 1136 declare function astBuildDerefAddrOf overload _
 1137     ( _
 1138         byval n as ASTNODE ptr, _
 1139         byval offsetexpr as ASTNODE ptr, _
 1140         byval dtype as integer, _
 1141         byval subtype as FBSYMBOL ptr, _
 1142         byval maybeafield as FBSYMBOL ptr = NULL _
 1143     ) as ASTNODE ptr
 1144 
 1145 declare function astBuildDerefAddrOf overload _
 1146     ( _
 1147         byval n as ASTNODE ptr, _
 1148         byval offset as longint, _
 1149         byval dtype as integer, _
 1150         byval subtype as FBSYMBOL ptr, _
 1151         byval maybeafield as FBSYMBOL ptr = NULL _
 1152     ) as ASTNODE ptr
 1153 
 1154 declare function astBuildVarField _
 1155     ( _
 1156         byval sym as FBSYMBOL ptr, _
 1157         byval fld as FBSYMBOL ptr = NULL, _
 1158         byval offset as longint = 0 _
 1159     ) as ASTNODE ptr
 1160 
 1161 declare function astBuildTempVarClear( byval sym as FBSYMBOL ptr ) as ASTNODE ptr
 1162 
 1163 declare function astBuildCall _
 1164     ( _
 1165         byval proc as FBSYMBOL ptr, _
 1166         byval arg1 as ASTNODE ptr = NULL, _
 1167         byval arg2 as ASTNODE ptr = NULL, _
 1168         byval arg3 as ASTNODE ptr = NULL _
 1169     ) as ASTNODE ptr
 1170 
 1171 declare function astBuildVtableLookup _
 1172     ( _
 1173         byval proc as FBSYMBOL ptr, _
 1174         byval thisexpr as ASTNODE ptr _
 1175     ) as ASTNODE ptr
 1176 
 1177 declare function astBuildCtorCall _
 1178     ( _
 1179         byval sym as FBSYMBOL ptr, _
 1180         byval thisexpr as ASTNODE ptr _
 1181     ) as ASTNODE ptr
 1182 
 1183 declare function astBuildDtorCall _
 1184     ( _
 1185         byval sym as FBSYMBOL ptr, _
 1186         byval thisexpr as ASTNODE ptr, _
 1187         byval ignore_virtual as integer = FALSE _
 1188     ) as ASTNODE ptr
 1189 
 1190 declare function astBuildWhileCounterBegin _
 1191     ( _
 1192         byval tree as ASTNODE ptr, _
 1193         byval cnt as FBSYMBOL ptr, _
 1194         byval label as FBSYMBOL ptr, _
 1195         byval exitlabel as FBSYMBOL ptr, _
 1196         byval initexpr as ASTNODE ptr, _
 1197         byval flush_label as integer = TRUE _
 1198     ) as ASTNODE ptr
 1199 
 1200 declare function astBuildWhileCounterEnd _
 1201     ( _
 1202         byval tree as ASTNODE ptr, _
 1203         byval cnt as FBSYMBOL ptr, _
 1204         byval label as FBSYMBOL ptr, _
 1205         byval exitlabel as FBSYMBOL ptr, _
 1206         byval flush_label as integer = TRUE _
 1207     ) as ASTNODE ptr
 1208 
 1209 declare function astBuildForBegin _
 1210     ( _
 1211         byval tree as ASTNODE ptr, _
 1212         byval cnt as FBSYMBOL ptr, _
 1213         byval label as FBSYMBOL ptr, _
 1214         byval inivalue as integer, _
 1215         byval flush_label as integer = TRUE _
 1216     ) as ASTNODE ptr
 1217 
 1218 declare function astBuildForEnd _
 1219     ( _
 1220         byval tree as ASTNODE ptr, _
 1221         byval cnt as FBSYMBOL ptr, _
 1222         byval label as FBSYMBOL ptr, _
 1223         byval endvalue as ASTNODE ptr _
 1224     ) as ASTNODE ptr
 1225 
 1226 declare function astBuildVarDtorCall overload _
 1227     ( _
 1228         byval varexpr as ASTNODE ptr _
 1229     ) as ASTNODE ptr
 1230 
 1231 declare function astBuildVarDtorCall overload _
 1232     ( _
 1233         byval s as FBSYMBOL ptr, _
 1234         byval check_access as integer = FALSE _
 1235     ) as ASTNODE ptr
 1236 
 1237 declare function astBuildTypeIniCtorList _
 1238     ( _
 1239         byval sym as FBSYMBOL ptr _
 1240     ) as ASTNODE ptr
 1241 
 1242 declare function astBuildProcAddrof( byval proc as FBSYMBOL ptr ) as ASTNODE ptr
 1243 
 1244 declare function astBuildProcResultVar _
 1245     ( _
 1246         byval proc as FBSYMBOL ptr, _
 1247         byval sym as FBSYMBOL ptr _
 1248     ) as ASTNODE ptr
 1249 
 1250 declare function astPatchCtorCall _
 1251     ( _
 1252         byval procexpr as ASTNODE ptr, _
 1253         byval thisexpr as ASTNODE ptr _
 1254     ) as ASTNODE ptr
 1255 
 1256 declare function astCALLCTORToCALL _
 1257     ( _
 1258         byval n as ASTNODE ptr _
 1259     ) as ASTNODE ptr
 1260 
 1261 declare function astBuildImplicitCtorCall _
 1262     ( _
 1263         byval subtype as FBSYMBOL ptr, _
 1264         byval expr as ASTNODE ptr, _
 1265         byval arg_mode as FB_PARAMMODE, _
 1266         byref is_ctorcall as integer _
 1267     ) as ASTNODE ptr
 1268 
 1269 declare function astBuildImplicitCtorCallEx _
 1270     ( _
 1271         byval sym as FBSYMBOL ptr, _
 1272         byval expr as ASTNODE ptr, _
 1273         byval arg_mode as FB_PARAMMODE, _
 1274         byref is_ctorcall as integer _
 1275     ) as ASTNODE ptr
 1276 
 1277 declare function astBuildArrayDescIniTree _
 1278     ( _
 1279         byval desc as FBSYMBOL ptr, _
 1280         byval array as FBSYMBOL ptr, _
 1281         byval array_expr as ASTNODE ptr _
 1282     ) as ASTNODE ptr
 1283 
 1284 declare function astBuildArrayBound _
 1285     ( _
 1286         byval arrayexpr as ASTNODE ptr, _
 1287         byval dimexpr as ASTNODE ptr, _
 1288         byval tk as integer _
 1289     ) as ASTNODE ptr
 1290 
 1291 declare function astBuildStrPtr( byval lhs as ASTNODE ptr ) as ASTNODE ptr
 1292 
 1293 declare function astBuildMultiDeref _
 1294     ( _
 1295         byval cnt as integer, _
 1296         byval expr as ASTNODE ptr, _
 1297         byval dtype as integer, _
 1298         byval subtype as FBSYMBOL ptr _
 1299     ) as ASTNODE ptr
 1300 
 1301 declare sub astReplaceSymbolOnTree _
 1302     ( _
 1303         byval n as ASTNODE ptr, _
 1304         byval old_sym as FBSYMBOL ptr, _
 1305         byval new_sym as FBSYMBOL ptr _
 1306     )
 1307 
 1308 declare sub astReplaceFwdref _
 1309     ( _
 1310         byval n as ASTNODE ptr, _
 1311         byval oldsubtype as FBSYMBOL ptr, _
 1312         byval newdtype as integer, _
 1313         byval newsubtype as FBSYMBOL ptr _
 1314     )
 1315 
 1316 #if __FB_DEBUG__
 1317 declare sub astDtorListDump( )
 1318 #endif
 1319 declare sub astDtorListAdd( byval sym as FBSYMBOL ptr )
 1320 declare sub astDtorListAddRef( byval sym as FBSYMBOL ptr )
 1321 declare sub astDtorListRemoveRef( byval sym as FBSYMBOL ptr )
 1322 declare function astDtorListFlush( byval cookie as integer = 0 ) as ASTNODE ptr
 1323 declare sub astDtorListDel( byval sym as FBSYMBOL ptr )
 1324 declare sub astDtorListScopeBegin( byval cookie as integer = 0 )
 1325 declare function astDtorListScopeEnd( ) as integer
 1326 declare sub astDtorListUnscope( byval cookie as integer )
 1327 
 1328 declare sub astSetType _
 1329     ( _
 1330         byval n as ASTNODE ptr, _
 1331         byval dtype as integer, _
 1332         byval subtype as FBSYMBOL ptr _
 1333     )
 1334 
 1335 declare function astSizeOf( byval n as ASTNODE ptr, byref is_fixlenstr as integer = FALSE ) as longint
 1336 declare function astIsAccessToLocal( byval expr as ASTNODE ptr ) as integer
 1337 declare function astIsRelationalBop( byval n as ASTNODE ptr ) as integer
 1338 
 1339 declare function astGetOFFSETChildOfs( byval l as ASTNODE ptr ) as longint
 1340 
 1341 declare function astBuildCallResultVar( byval expr as ASTNODE ptr ) as ASTNODE ptr
 1342 declare function astBuildCallResultUdt( byval expr as ASTNODE ptr ) as ASTNODE ptr
 1343 declare function astBuildByrefResultDeref( byval expr as ASTNODE ptr ) as ASTNODE ptr
 1344 declare function astIsByrefResultDeref( byval expr as ASTNODE ptr ) as integer
 1345 declare function astRemoveByrefResultDeref( byval expr as ASTNODE ptr ) as ASTNODE ptr
 1346 declare function astIgnoreCallResult( byval n as ASTNODE ptr ) as ASTNODE ptr
 1347 declare function astBuildFakeCall( byval proc as FBSYMBOL ptr ) as ASTNODE ptr
 1348 
 1349 declare sub astGosubAddInit( byval proc as FBSYMBOL ptr )
 1350 
 1351 declare sub astGosubAddJmp _
 1352     ( _
 1353         byval proc as FBSYMBOL ptr, _
 1354         byval l as FBSYMBOL ptr _
 1355     )
 1356 
 1357 declare sub astGosubAddJumpPtr _
 1358     ( _
 1359         byval proc as FBSYMBOL ptr, _
 1360         byval expr as ASTNODE ptr, _
 1361         byval exitlabel as FBSYMBOL ptr _
 1362     )
 1363 
 1364 declare function astGosubAddReturn _
 1365     ( _
 1366         byval proc as FBSYMBOL ptr, _
 1367         byval l as FBSYMBOL ptr _
 1368     ) as integer
 1369 
 1370 declare sub astGosubAddExit(byval proc as FBSYMBOL ptr)
 1371 
 1372 declare function astLoadNOP( byval n as ASTNODE ptr ) as IRVREG ptr
 1373 declare function astLoadASSIGN( byval n as ASTNODE ptr ) as IRVREG ptr
 1374 declare function astLoadCONV( byval n as ASTNODE ptr ) as IRVREG ptr
 1375 declare function astLoadBOP( byval n as ASTNODE ptr ) as IRVREG ptr
 1376 declare function astLoadUOP( byval n as ASTNODE ptr ) as IRVREG ptr
 1377 declare function astLoadCONST( byval n as ASTNODE ptr ) as IRVREG ptr
 1378 declare function astLoadVAR( byval n as ASTNODE ptr ) as IRVREG ptr
 1379 declare function astLoadIDX( byval n as ASTNODE ptr ) as IRVREG ptr
 1380 declare function astLoadDEREF( byval n as ASTNODE ptr ) as IRVREG ptr
 1381 declare function astLoadCALL( byval n as ASTNODE ptr ) as IRVREG ptr
 1382 declare function astLoadCALLCTOR( byval n as ASTNODE ptr ) as IRVREG ptr
 1383 declare function astLoadADDROF( byval n as ASTNODE ptr ) as IRVREG ptr
 1384 declare function astLoadLOAD( byval n as ASTNODE ptr ) as IRVREG ptr
 1385 declare function astLoadBRANCH( byval n as ASTNODE ptr ) as IRVREG ptr
 1386 declare function astLoadIIF( byval n as ASTNODE ptr ) as IRVREG ptr
 1387 declare function astLoadOFFSET( byval n as ASTNODE ptr ) as IRVREG ptr
 1388 declare function astLoadLINK( byval n as ASTNODE ptr ) as IRVREG ptr
 1389 declare function astLoadFIELD( byval n as ASTNODE ptr ) as IRVREG ptr
 1390 declare function astLoadSTACK( byval n as ASTNODE ptr ) as IRVREG ptr
 1391 declare function astLoadLABEL( byval n as ASTNODE ptr ) as IRVREG ptr
 1392 declare function astLoadLIT( byval n as ASTNODE ptr ) as IRVREG ptr
 1393 declare function astLoadASM( byval n as ASTNODE ptr ) as IRVREG ptr
 1394 declare function astLoadJMPTB( byval n as ASTNODE ptr ) as IRVREG ptr
 1395 declare function astLoadLOOP( byval n as ASTNODE ptr ) as IRVREG ptr
 1396 declare function astLoadDBG( byval n as ASTNODE ptr ) as IRVREG ptr
 1397 declare function astLoadMEM( byval n as ASTNODE ptr ) as IRVREG ptr
 1398 declare function astLoadBOUNDCHK( byval n as ASTNODE ptr ) as IRVREG ptr
 1399 declare function astLoadPTRCHK( byval n as ASTNODE ptr ) as IRVREG ptr
 1400 declare function astLoadSCOPEBEGIN( byval n as ASTNODE ptr ) as IRVREG ptr
 1401 declare function astLoadSCOPEEND( byval n as ASTNODE ptr ) as IRVREG ptr
 1402 declare function astLoadDECL( byval n as ASTNODE ptr ) as IRVREG ptr
 1403 declare function astLoadNIDXARRAY( byval n as ASTNODE ptr ) as IRVREG ptr
 1404 declare function astLoadMACRO( byval n as ASTNODE ptr ) as IRVREG ptr
 1405 
 1406 ''
 1407 '' macros
 1408 ''
 1409 
 1410 #define astBeginHideWarnings( ) ast.hidewarningslevel += 1
 1411 #define astEndHideWarnings( )   ast.hidewarningslevel -= 1
 1412 #define astShouldShowWarnings( ) (ast.hidewarningslevel = 0)
 1413 
 1414 #macro astInitNode( n, class_, dtype_, subtype_ )
 1415     (n)->class = class_
 1416     (n)->dtype = dtype_
 1417     (n)->subtype = subtype_
 1418     (n)->l = NULL
 1419     (n)->r = NULL
 1420     (n)->sym = NULL
 1421     (n)->vector = 0
 1422 #endmacro
 1423 
 1424 #define astCopy(dst, src) *dst = *src
 1425 
 1426 #define astGetClass(n) n->class
 1427 
 1428 #define astGetLeft( n ) n->l
 1429 
 1430 #define astGetRight( n ) n->r
 1431 
 1432 #define astGetPrev( n ) n->prev
 1433 
 1434 #define astGetNext( n ) n->next
 1435 
 1436 #define astIsCONST(n) (n->class = AST_NODECLASS_CONST)
 1437 
 1438 #define astIsVAR(n) (n->class = AST_NODECLASS_VAR)
 1439 
 1440 #define astIsIDX(n) (n->class = AST_NODECLASS_IDX)
 1441 
 1442 #define astIsCALL(n) (n->class = AST_NODECLASS_CALL)
 1443 
 1444 #define astIsCALLCTOR(n) (n->class = AST_NODECLASS_CALLCTOR)
 1445 
 1446 #define astIsDEREF(n) (n->class = AST_NODECLASS_DEREF)
 1447 
 1448 #define astIsOFFSET(n) (n->class = AST_NODECLASS_OFFSET)
 1449 
 1450 #define astIsFIELD(n) (n->class = AST_NODECLASS_FIELD)
 1451 
 1452 #define astIsBITFIELD(n) iif( astIsFIELD( n ), symbFieldIsBitfield( (n)->sym ), FALSE )
 1453 
 1454 #define astIsNIDXARRAY(n) (n->class = AST_NODECLASS_NIDXARRAY)
 1455 
 1456 #define astIsTYPEINI(n) (n->class = AST_NODECLASS_TYPEINI)
 1457 
 1458 #define astIsCAST(n) (n->class = AST_NODECLASS_CONV)
 1459 
 1460 #define astConstGetVal( n ) (@(n)->val)
 1461 #define astConstGetFloat( n ) ((n)->val.f)
 1462 #define astConstGetInt( n ) ((n)->val.i)
 1463 #define astConstGetUint( n ) cunsg( (n)->val.i )
 1464 
 1465 #define astGetFullType(n) n->dtype
 1466 #define astGetDataType(n) typeGetDtAndPtrOnly( astGetFullType( n ) )
 1467 
 1468 #define astGetSubtype(n) n->subtype
 1469 
 1470 #define astGetDataClass(n) typeGetClass( astGetDataType( n ) )
 1471 
 1472 #define astGetSymbol(n) n->sym
 1473 
 1474 #define astGetProcExitlabel(n) n->block.exitlabel
 1475 
 1476 #define astGetProc() ast.proc.curr
 1477 
 1478 #define astGetProcTailNode() ast.proc.curr->r
 1479 
 1480 #define astTypeIniGetOfs( n ) n->typeini.ofs
 1481 
 1482 #define astGetOpClass( op ) ast_opTB(op).class
 1483 #define astGetOpIsCommutative( op ) ((ast_opTB(op).flags and AST_OPFLAGS_COMM) <> 0)
 1484 #define astGetOpIsSelf( op ) ((ast_opTB(op).flags and AST_OPFLAGS_SELF) <> 0)
 1485 #define astGetOpNoResult( op ) ((ast_opTB(op).flags and AST_OPFLAGS_NORES) <> 0)
 1486 #define astOpIsRelational( op ) ((ast_opTB(op).flags and AST_OPFLAGS_RELATIONAL) <> 0)
 1487 #define astGetOpSelfVer( op ) ast_opTB(op).selfop
 1488 
 1489 #define astGetOpId( op ) ast_opTB(op).id
 1490 
 1491 #define astGetFirstDataStmtSymbol( ) ast.data.firstsym
 1492 
 1493 #define astGetLastDataStmtSymbol( ) ast.data.lastsym
 1494 
 1495 #define astDTorListIsEmpty( ) (listGetHead( @ast.dtorlist ) = NULL)
 1496 
 1497 #define astIsUOP( n, uop ) ( ((n)->class = AST_NODECLASS_UOP) andalso ((n)->op.op = (uop)) )
 1498 
 1499 #define astIsBOP( n, bop ) ( ((n)->class = AST_NODECLASS_BOP) andalso ((n)->op.op = (bop)) )
 1500 
 1501 ''
 1502 '' inter-module globals
 1503 ''
 1504 extern ast as ASTCTX
 1505 
 1506 extern ast_opTB( 0 to AST_OPCODES-1 ) as AST_OPINFO
 1507 
 1508 declare function astDumpOpToStr( byval op as AST_OP ) as string
 1509 
 1510 declare sub astDumpTree _
 1511     ( _
 1512         byval n as ASTNODE ptr, _
 1513         byval col as integer = 0 _
 1514     )
 1515 
 1516 declare sub astDumpList _
 1517     ( _
 1518         byval n as ASTNODE ptr, _
 1519         byval col as integer = 0 _
 1520     )
 1521 
 1522 #if __FB_DEBUG__
 1523 declare function astDumpInline( byval n as ASTNODE ptr ) as string
 1524 declare sub astDumpSmall( byval n as ASTNODE ptr, byref prefix as string = "" )
 1525 #endif
 1526 
 1527 #endif '' __AST_BI__