17 byval proc as ASTNODE
ptr, _
18 byval n
as ASTNODE
ptr _
23 byval n
as ASTNODE
ptr, _
24 byval check_backward
as integer _
28 dim as ASTNODE
ptr n =
any
29 dim as FBSYMBOL
ptr s =
any
31 if( parser.
scope >= FB_MAXSCOPEDEPTH )
then
35 n =
astNewNode( AST_NODECLASS_SCOPEBEGIN, FB_DATATYPE_INVALID )
47 n->block.parent = ast.currblock
48 n->block.inistmt = parser.stmt.cnt
59 symbSetCurrentSymTb( @s->scp.symtb )
72 byval list as AST_BREAKLIST
ptr, _
73 byval node
as ASTNODE
ptr _
77 list->tail->
next = node
82 node->prev =
list->tail
89 dim as ASTNODE
ptr n =
any
91 n =
astNewNode( AST_NODECLASS_SCOPE_BREAK, FB_DATATYPE_INVALID,
NULL )
94 n->break.parent = ast.currblock
95 n->break.
scope = parser.
scope
96 n->break.linenum = lexLineNum( )
97 n->break.stmtnum = parser.stmt.cnt
110 dim as FBSYMBOL
ptr s =
any
112 assert( n->
class = AST_NODECLASS_SCOPEBEGIN )
120 n->block.endstmt = parser.stmt.cnt
130 symbSetCurrentSymTb( s->symtb )
132 ast.currblock = n->block.parent
133 parser.currblock = ast.currblock->sym
138 n =
astNewNode( AST_NODECLASS_SCOPEEND, FB_DATATYPE_INVALID )
147 dim as ASTNODE
ptr n =
any
152 n =
proc->block.breaklist.head
153 do while( n <>
NULL )
156 if( n->sym =
proc->block.exitlabel )
then
178 byval errnum
as integer, _
179 byval n
as ASTNODE
ptr, _
180 byval s
as FBSYMBOL
ptr =
NULL _
183 dim as integer showerror
186 showerror = env.clopt.showerror
187 env.clopt.showerror = FALSE
189 if( symbGetName( n->sym ) <>
NULL )
then
190 msg =
"to label: " + *symbGetName( n->sym )
198 if( symbGetType( s ) = FB_DATATYPE_STRING )
then
200 elseif( symbGetArrayDimensions( s ) <> 0 )
then
206 msg += *symbGetName( s )
211 env.clopt.showerror = showerror
217 byval errnum
as integer, _
218 byval n
as ASTNODE
ptr, _
219 byval s
as FBSYMBOL
ptr =
NULL _
222 dim as integer showerror
225 showerror = env.clopt.showerror
226 env.clopt.showerror = FALSE
228 if( symbGetName( n->sym ) <>
NULL )
then
229 msg =
"to label: " + *symbGetName( n->sym )
237 msg += *symbGetName( s )
242 env.clopt.showerror = showerror
249 byval branch_parent
as ASTNODE
ptr, _
250 byval label_parent_sym
as FBSYMBOL
ptr _
253 dim as ASTNODE
ptr label_parent = label_parent_sym->scp.backnode
255 dim as integer branch_scope = symbGetScope( branch_parent->sym )
256 dim as integer label_scope = symbGetScope( label_parent_sym )
258 if( branch_scope > label_scope )
then
260 branch_parent = branch_parent->block.parent
261 branch_scope = symbGetScope( branch_parent->sym )
262 loop until( branch_scope = label_scope )
264 elseif( branch_scope < label_scope )
then
266 label_parent = label_parent->block.parent
267 label_scope = symbGetScope( label_parent->sym )
268 loop until( label_scope = branch_scope )
271 do until( branch_parent = label_parent )
272 branch_parent = branch_parent->block.parent
273 label_parent = label_parent->block.parent
276 function = branch_parent->sym
282 byval n
as ASTNODE
ptr, _
283 byval blk
as FBSYMBOL
ptr, _
284 byval top_stmt
as integer, _
285 byval bot_stmt
as integer _
288 dim as FBSYMBOL
ptr s =
any
289 dim as integer stmt =
any
296 if( symbIsScope( blk ) )
then
297 s = symbGetScopeSymbtb( blk ).head
299 s = symbGetProcSymbtb( blk ).head
302 do while( s <>
NULL )
303 if( symbIsVar( s ) )
then
304 stmt = symbGetVarStmt( s )
305 if( stmt > top_stmt )
then
306 if( stmt < bot_stmt )
then
308 hBranchError( FB_ERRMSG_BRANCHCROSSINGDYNDATADEF, n, s )
312 if( (s->attrib
and (FB_SYMBATTRIB_STATIC
or _
313 FB_SYMBATTRIB_SHARED
or _
314 FB_SYMBATTRIB_TEMP)) = 0 )
then
316 if( symbGetDontInit( s ) = FALSE )
then
331 byval n
as ASTNODE
ptr, _
332 byval top_parent
as FBSYMBOL
ptr =
NULL _
335 dim as FBSYMBOL
ptr label =
any, blk =
any
336 dim as integer label_stmt =
any, branch_stmt =
any
338 if( top_parent =
NULL )
then
339 top_parent = n->break.parent->sym
342 branch_stmt = n->break.stmtnum
345 label_stmt = symbGetLabelStmt( label )
347 blk = symbGetLabelParent( label )
353 if( symbGetSymbtb( blk ) =
NULL )
then
357 blk = symbGetParent( blk )
360 if( blk = top_parent )
then
362 if( label_stmt > branch_stmt )
then
373 byval blk
as FBSYMBOL
ptr, _
374 byval top_stmt
as integer, _
375 byval bot_stmt
as integer, _
376 byval base_expr
as ASTNODE
ptr _
379 dim as FBSYMBOL
ptr s =
any
380 dim as ASTNODE
ptr expr =
any
381 dim as integer stmt =
any
384 if( symbIsScope( blk ) )
then
385 s = symbGetScopeSymbTb( blk ).tail
387 s = symbGetProcSymbTb( blk ).tail
390 do while( s <>
NULL )
391 if( symbIsVar( s ) )
then
392 stmt = symbGetVarStmt( s )
393 if( stmt > top_stmt )
then
394 if( stmt < bot_stmt )
then
399 if( expr <>
NULL )
then
415 byval n
as ASTNODE
ptr _
421 symbGetLabelStmt( n->sym ), _
428 #define hisInside( blk, lbl_stmt ) _
429 ( (lbl_stmt) >= (blk)->block.inistmt
andalso (lbl_stmt) < (blk)->block.endstmt)
435 byval n
as ASTNODE
ptr, _
436 byval check_backward
as integer _
439 dim as FBSYMBOL
ptr s =
any
440 dim as integer label_stmt =
any, branch_stmt =
any
441 dim as ASTNODE
ptr blk =
any
443 label_stmt = symbGetLabelStmt( n->sym )
444 branch_stmt = n->break.stmtnum
447 blk = n->break.parent
456 blk = blk->block.parent
457 if( blk =
NULL )
then
462 if( hIsInside( blk, label_stmt ) )
then
463 if( check_backward )
then
466 if( label_stmt <= branch_stmt )
then
483 byval proc as FBSYMBOL
ptr, _
484 byval label
as FBSYMBOL
ptr _
488 if( (
proc->stats
and (FB_SYMBSTATS_MAINPROC
or _
489 FB_SYMBSTATS_MODLEVELPROC)) <> 0 )
then
491 function = symbGetParent( label ) <> @symbGetGlobalNamespc( )
494 function = symbGetParent( label ) <>
proc
502 byval proc as ASTNODE
ptr, _
503 byval n
as ASTNODE
ptr _
506 dim as ASTNODE
ptr branch_parent =
any
507 dim as FBSYMBOL
ptr label =
any, label_parent =
any
508 dim as integer branch_scope =
any, label_scope =
any
509 dim as integer branch_stmt =
any, label_stmt =
any, isparent =
any
516 if( symbGetLabelIsDeclared( label ) = FALSE )
then
517 hBranchError( FB_ERRMSG_BRANCHTARGETOUTSIDECURRPROC, n )
523 hBranchError( FB_ERRMSG_BRANCHTARGETOUTSIDECURRPROC, n )
528 label_scope = symbGetScope( label )
529 label_parent = symbGetLabelParent( label )
530 label_stmt = symbGetLabelStmt( label )
532 branch_scope = n->break.
scope
533 branch_parent = n->break.parent
534 branch_stmt = n->break.stmtnum
537 if( hIsInside( branch_parent, label_stmt ) )
then
539 if( label_scope > branch_scope )
then
544 if( label_stmt <= branch_stmt )
then
551 if( label_stmt <= branch_stmt )
then
567 if( symbIsScope( label_parent ) )
then
568 isparent = (label_parent->scp.backnode->block.inistmt <= _
569 branch_parent->block.inistmt)
and _
570 (label_parent->scp.backnode->block.endstmt >= _
571 branch_parent->block.endstmt)
574 if( isparent = FALSE )
then
586 if( label_stmt > branch_stmt )
then
601 dim as FBSYMBOL
ptr s =
any
607 if( symbIsVar( s ) )
then
618 dim as FBSYMBOL
ptr s =
any
624 if( env.clopt.backend = FB_BACKEND_GCC )
then
642 if( symbIsVar( s )
and symbIsTemp( s ) )
then
643 assert( (symbIsShared( s ) = FALSE)
and (symbIsParam( s ) = FALSE) )
659 if( symbIsVar( s )
and ((symbGetAttrib( s )
and (FB_SYMBATTRIB_SHARED
or FB_SYMBATTRIB_STATIC)) = 0) )
then
661 if( symbIsParam( s ) )
then
662 irProcAllocArg( parser.currproc, s )
664 irProcAllocLocal( parser.currproc, s )
666 symbSetVarIsAllocated( s )
674 dim as FBSYMBOL
ptr s =
any
678 s->scp.emit.baseofs = symbGetProcLocalOfs( parser.currproc )
680 if( ast.doemit )
then
681 irEmitSCOPEBEGIN( s )
689 dim as FBSYMBOL
ptr s =
any
693 if( ast.doemit )
then
697 symbSetProcLocalOfs( parser.currproc, s->scp.emit.baseofs )
709 byref lastscp
as FBSYMBOL
ptr, _
710 byval backnode
as ASTNODE
ptr _
713 dim as FBSYMBOL
ptr scp =
any
717 lastscp = parser.currblock
720 parser.currblock = scp
722 symbSetCurrentSymTb( @scp->scp.symtb )
729 byval scp
as FBSYMBOL
ptr, _
730 byval lastscp
as FBSYMBOL
ptr _
733 dim as FBSYMBOL
ptr sym =
any
739 symbSetCurrentSymTb( scp->symtb )
743 parser.currblock = lastscp
748 sym = symbGetScopeSymbTbHead( scp )
750 if( symbIsVar( sym ) )
then
760 byval scp
as FBSYMBOL
ptr, _
761 byval clonetree
as ASTNODE
ptr _
764 dim as FBSYMBOL
ptr sym =
any, clonesym =
any
767 sym = symbGetScopeSymbTbHead( scp )
775 if( symbIsVar( clonesym ) )
then
785 dim as FBSYMBOL
ptr sym =
any, nxt =
any
787 sym = symbGetScopeSymbTbHead( scp )