Skip to content

Commit

Permalink
Merge branch 'fbc-1.08' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrm committed Jun 13, 2021
2 parents 829f907 + bce19e9 commit abc89c3
Show file tree
Hide file tree
Showing 13 changed files with 1,002 additions and 194 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 1.09.0

[fixed]
- github #315: set parameters when calling SCREENCONTROL (was broken in fbc 1.08.0 due to new LONG/LONGINT SCREENCONTROL API's)
- github #318: duplicate definition for deleting destructor; the deleting destructor was being emitted even though the class was declarations only on the fbc side


Version 1.08.0
Expand Down
100 changes: 50 additions & 50 deletions src/compiler/ast-node-proc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ private sub hProcFlush _
byval doemit as integer _
)

dim as ASTNODE ptr n = any, nxt = any
dim as FBSYMBOL ptr sym = any
dim as ASTNODE ptr n = any, nxt = any
dim as FBSYMBOL ptr sym = any

sym = p->sym

Expand Down Expand Up @@ -153,19 +153,19 @@ private sub hProcFlush _
n = nxt
loop

'' emit footer
if( ast.doemit ) then
irEmitPROCEND( sym, p->block.initlabel, p->block.exitlabel )
'' emit footer
if( ast.doemit ) then
irEmitPROCEND( sym, p->block.initlabel, p->block.exitlabel )

'' Emit static local variables
irProcAllocStaticVars( symbGetProcSymbTbHead( sym ) )
end if
end if

'' del symbols from hash and symbol tb's
symbDelSymbolTb( @sym->proc.symtb, FALSE )
'' del symbols from hash and symbol tb's
symbDelSymbolTb( @sym->proc.symtb, FALSE )

''
symbNestEnd( FALSE )
''
symbNestEnd( FALSE )

hDelProcNode( p )

Expand All @@ -179,9 +179,9 @@ private sub hProcFlushAll _
_
)

dim as ASTNODE ptr n = any
dim as integer doemit = any
dim as FBSYMBOL ptr sym = any
dim as ASTNODE ptr n = any
dim as integer doemit = any
dim as FBSYMBOL ptr sym = any

'' procs should be sorted by include file

Expand Down Expand Up @@ -634,9 +634,9 @@ private function hCallProfiler _
end function

function astProcEnd( byval callrtexit as integer ) as integer
static as integer rec_cnt = 0
static as integer rec_cnt = 0
dim as integer res = any, do_flush = any, enable_implicit_code = any
dim as FBSYMBOL ptr sym = any
dim as FBSYMBOL ptr sym = any
dim as ASTNODE ptr n = any

n = ast.proc.curr
Expand Down Expand Up @@ -673,14 +673,14 @@ function astProcEnd( byval callrtexit as integer ) as integer
res = (symbCheckLabels(symbGetProcSymbTbHead(parser.currproc)) = 0)

if( res ) then
'' Complete Destructor?
'' Complete Destructor? (D1)
if( symbIsDestructor1( sym ) and enable_implicit_code ) then
'' Call destructors, behind the exit label, so they'll
'' always be called, even with early returns.
hCallDtors( sym )
end if

'' Deleting Destructor?
'' Deleting Destructor? (D0)
if( symbIsDestructor0( sym ) and enable_implicit_code ) then
hCallDeleteDtor( sym )
end if
Expand Down Expand Up @@ -770,7 +770,7 @@ function astProcEnd( byval callrtexit as integer ) as integer

''
if( do_flush ) then
if( n->block.proc.ismain = FALSE ) then
if( n->block.proc.ismain = FALSE ) then
hProcFlush( n, TRUE )
else
hProcFlushAll( )
Expand All @@ -781,20 +781,20 @@ function astProcEnd( byval callrtexit as integer ) as integer
ast.proc.curr = ast.proc.head
ast.currblock = ast.proc.head

parser.scope = FB_MAINSCOPE
parser.currproc = env.main.proc
parser.currblock = env.main.proc
parser.scope = FB_MAINSCOPE
parser.currproc = env.main.proc
parser.currblock = env.main.proc

''
rec_cnt -= 1
''
rec_cnt -= 1

function = res

end function

private function hDeclVarsForProcParams( byval proc as FBSYMBOL ptr ) as integer
dim as integer i = any
dim as FBSYMBOL ptr p = any
dim as integer i = any
dim as FBSYMBOL ptr p = any

function = FALSE

Expand Down Expand Up @@ -825,8 +825,8 @@ private function hDeclVarsForProcParams( byval proc as FBSYMBOL ptr ) as integer
end function

private sub hLoadProcResult( byval proc as FBSYMBOL ptr )
dim as FBSYMBOL ptr s = any
dim as ASTNODE ptr n = any
dim as FBSYMBOL ptr s = any
dim as ASTNODE ptr n = any

s = symbGetProcResult( proc )

Expand All @@ -851,7 +851,7 @@ private sub hLoadProcResult( byval proc as FBSYMBOL ptr )
end sub

private function hModLevelIsEmpty( byval p as ASTNODE ptr ) as integer
dim as ASTNODE ptr n = any, nxt = any
dim as ASTNODE ptr n = any, nxt = any

'' an empty module-level proc will have just the
'' initial and final labels as nodes and nothing else
Expand Down Expand Up @@ -1351,7 +1351,7 @@ private sub hCallDtors( byval proc as FBSYMBOL ptr )
parent = symbGetNamespace( proc )

'' 1st) fields dtors
hCallFieldDtors( parent, proc )
hCallFieldDtors( parent, proc )

'' 2nd) base dtor
hCallBaseDtor( parent, proc )
Expand Down Expand Up @@ -1396,9 +1396,9 @@ private sub hGenStaticInstancesDtors( byval proc as FBSYMBOL ptr )
exit sub
end if

'' for each node..
wrap = listGetHead( dtorlist )
do while( wrap <> NULL )
'' for each node..
wrap = listGetHead( dtorlist )
do while( wrap <> NULL )
astProcBegin( wrap->proc, FALSE )
n = ast.proc.curr

Expand All @@ -1412,13 +1412,13 @@ private sub hGenStaticInstancesDtors( byval proc as FBSYMBOL ptr )
'' proc is flushed
hProcFlush( n, TRUE )

wrap = listGetNext( wrap )
loop
wrap = listGetNext( wrap )
loop

'' destroy list
listEnd( dtorlist )
deallocate( proc->proc.ext->statdtor )
proc->proc.ext->statdtor = NULL
'' destroy list
listEnd( dtorlist )
deallocate( proc->proc.ext->statdtor )
proc->proc.ext->statdtor = NULL
end sub

'':::::
Expand All @@ -1443,16 +1443,16 @@ function astProcAddStaticInstance _
listInit( dtorlist, 16, len( FB_DTORWRAPPER ), LIST_FLAGS_NOCLEAR )
end if

''
wrap = listNewNode( dtorlist )
''
wrap = listNewNode( dtorlist )

proc = symbAddProc( symbPreAddProc( NULL ), symbUniqueLabel( ), NULL, FB_DATATYPE_VOID, NULL, _
FB_SYMBATTRIB_PRIVATE, FB_PROCATTRIB_NONE, FB_FUNCMODE_CDECL, FB_SYMBOPT_DECLARING )

wrap->proc = proc
wrap->sym = sym
wrap->proc = proc
wrap->sym = sym

'' can't be undefined
'' can't be undefined
symbSetCantUndef( sym )

function = proc
Expand All @@ -1467,16 +1467,16 @@ sub astProcAddGlobalInstance _
byval call_dtor as integer _
)

dim as FB_GLOBINSTANCE ptr wrap = any
dim as FB_GLOBINSTANCE ptr wrap = any

''
wrap = listNewNode( @ast.globinst.list )
''
wrap = listNewNode( @ast.globinst.list )

wrap->sym = sym
wrap->initree = initree
wrap->sym = sym
wrap->initree = initree
wrap->call_dtor = call_dtor

'' can't be undefined
'' can't be undefined
symbSetCantUndef( sym )

if( initree <> NULL ) then
Expand Down Expand Up @@ -1554,5 +1554,5 @@ private sub hGenGlobalInstancesCtor( )
astProcEnd( FALSE )
end if

'' list will be deleted by astProcListEnd( )
'' list will be deleted by astProcListEnd( )
end sub
84 changes: 41 additions & 43 deletions src/compiler/parser-proc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ private sub hCheckPrototype _
byval mode as integer _
)

dim as FBSYMBOL ptr param = any, proto_param = any
dim as integer params = any, proto_params = any, i = any
dim as FBSYMBOL ptr param = any, proto_param = any
dim as integer params = any, proto_params = any, i = any

'' Check ALIAS id
if( (palias <> NULL) and ((proto->stats and FB_SYMBSTATS_HASALIAS) <> 0) ) then
Expand Down Expand Up @@ -179,21 +179,21 @@ private sub hCheckPrototype _
'' the common parameters, for better error recovery.
i = 1
while( (i <= proto_params) and (i <= params) )
dim as integer dtype = symbGetFullType( proto_param )

'' convert any AS ANY arg to the final one
if( typeGet( dtype ) = FB_DATATYPE_VOID ) then
proto_param->typ = param->typ
proto_param->subtype = param->subtype

'' check if types don't conflit
else
if( param->typ <> dtype ) then
hParamError( proc, i )
elseif( param->subtype <> symbGetSubtype( proto_param ) ) then
hParamError( proc, i )
end if
end if
dim as integer dtype = symbGetFullType( proto_param )

'' convert any AS ANY arg to the final one
if( typeGet( dtype ) = FB_DATATYPE_VOID ) then
proto_param->typ = param->typ
proto_param->subtype = param->subtype

'' check if types don't conflit
else
if( param->typ <> dtype ) then
hParamError( proc, i )
elseif( param->subtype <> symbGetSubtype( proto_param ) ) then
hParamError( proc, i )
end if
end if

'' and mode
if( param->param.mode <> proto_param->param.mode ) then
Expand All @@ -208,19 +208,19 @@ private sub hCheckPrototype _
end if
end if

'' check names and change to the new one if needed
if( param->param.mode <> FB_PARAMMODE_VARARG ) then
symbSetName( proto_param, symbGetName( param ) )
'' check names and change to the new one if needed
if( param->param.mode <> FB_PARAMMODE_VARARG ) then
symbSetName( proto_param, symbGetName( param ) )

'' as both have the same type, re-set the suffix, because for example
'' "a as integer" on the prototype and "a%" or just "a" on the proc
'' declaration when in a defint context is allowed in QB
if( symbIsSuffixed( param ) ) then
symbGetAttrib( proto_param ) or= FB_SYMBATTRIB_SUFFIXED
else
symbGetAttrib( proto_param ) and = not FB_SYMBATTRIB_SUFFIXED
end if
end if
'' as both have the same type, re-set the suffix, because for example
'' "a as integer" on the prototype and "a%" or just "a" on the proc
'' declaration when in a defint context is allowed in QB
if( symbIsSuffixed( param ) ) then
symbGetAttrib( proto_param ) or= FB_SYMBATTRIB_SUFFIXED
else
symbGetAttrib( proto_param ) and = not FB_SYMBATTRIB_SUFFIXED
end if
end if

'' Warn about mismatching param initializers?
'' If both params are optional, compare the two initializers
Expand All @@ -230,8 +230,8 @@ private sub hCheckPrototype _
end if
end if

proto_param = proto_param->next
param = param->next
proto_param = proto_param->next
param = param->next
i += 1
wend

Expand Down Expand Up @@ -504,10 +504,10 @@ function cProcReturnMethod( byval dtype as FB_DATATYPE ) as FB_PROC_RETURN_METHO
end function

function cProcCallingConv( byval default as FB_FUNCMODE ) as FB_FUNCMODE
'' Use the default FBCALL?
if( default = FB_FUNCMODE_FBCALL ) then
default = env.target.fbcall
end if
'' Use the default FBCALL?
if( default = FB_FUNCMODE_FBCALL ) then
default = env.target.fbcall
end if

'' (CDECL|STDCALL|PASCAL|THISCALL)?
select case as const lexGetToken( )
Expand Down Expand Up @@ -610,7 +610,7 @@ private function hCheckOpOvlParams _
) as integer

dim as integer found_mismatch = any
dim as integer is_method = symbIsMethod( proc )
dim as integer is_method = symbIsMethod( proc )

#macro hCheckParam( proc, param, num )
'' vararg?
Expand Down Expand Up @@ -1482,9 +1482,7 @@ function cProcHeader _
'' except for the destructor type
dim dtor0 as FBSYMBOL ptr = symbPreAddProc( NULL )
symbAddProcInstanceParam( parent, dtor0 )
pattrib and= not FB_PROCATTRIB_DESTRUCTOR1
pattrib or= FB_PROCATTRIB_DESTRUCTOR0
dtor0 = symbAddCtor( dtor0, NULL, attrib, pattrib, mode )
dtor0 = symbAddCtor( dtor0, NULL, attrib, ((pattrib and not FB_PROCATTRIB_DESTRUCTOR1) or FB_PROCATTRIB_DESTRUCTOR0), mode )
end if
end if

Expand Down Expand Up @@ -1753,8 +1751,8 @@ end sub
'' (SUB|FUNCTION|CONSTRUCTOR|DESTRUCTOR|OPERATOR) ProcHeader .
sub cProcStmtBegin( byval attrib as FB_SYMBATTRIB, byval pattrib as FB_PROCATTRIB )
dim as integer tkn = any, is_nested = any
dim as FBSYMBOL ptr proc = any
dim as FB_CMPSTMTSTK ptr stk = any
dim as FBSYMBOL ptr proc = any
dim as FB_CMPSTMTSTK ptr stk = any

if( (attrib and (FB_SYMBATTRIB_PUBLIC or FB_SYMBATTRIB_PRIVATE)) = 0 ) then
if( env.opt.procpublic ) then
Expand Down Expand Up @@ -1848,7 +1846,7 @@ sub cProcStmtBegin( byval attrib as FB_SYMBATTRIB, byval pattrib as FB_PROCATTRI
stk->proc.endlabel = astGetProcExitlabel( ast.proc.curr )
end sub

'' ProcStmtEnd = END (SUB | FUNCTION) .
'' ProcStmtEnd = END (SUB | FUNCTION | OPERATOR | CONSTRUCTOR | DESTRUCTOR | PROPERTY) .
sub cProcStmtEnd( )
dim as FB_CMPSTMTSTK ptr stk = any
dim as FBSYMBOL ptr proc_res = any
Expand Down Expand Up @@ -1894,7 +1892,7 @@ sub cProcStmtEnd( )
end if
end if

'' always finish
'' always finish
astProcEnd( FALSE )

'' Close namespace again if cProcHeader() opened it
Expand Down
Loading

0 comments on commit abc89c3

Please sign in to comment.