"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/compiler/parser-proc.bas" between
FreeBASIC-1.08.0-source.tar.xz and FreeBASIC-1.08.1-source.tar.xz

About: FreeBasic is a set of cross-platform development tools consisting of a compiler, GNU-based assembler, linker and archiver, and supporting runtime libraries, including a software-based graphics library.

parser-proc.bas  (FreeBASIC-1.08.0-source.tar.xz):parser-proc.bas  (FreeBASIC-1.08.1-source.tar.xz)
skipping to change at line 130 skipping to change at line 130
private sub hCheckPrototype _ private sub hCheckPrototype _
( _ ( _
byval proto as FBSYMBOL ptr, _ byval proto as FBSYMBOL ptr, _
byval proc as FBSYMBOL ptr, _ byval proc as FBSYMBOL ptr, _
byval palias as zstring ptr, _ byval palias as zstring ptr, _
byval proc_dtype as integer, _ byval proc_dtype as integer, _
byval proc_subtype as FBSYMBOL ptr, _ byval proc_subtype as FBSYMBOL ptr, _
byval mode as integer _ byval mode as integer _
) )
dim as FBSYMBOL ptr param = any, proto_param = any dim as FBSYMBOL ptr param = any, proto_param = any
dim as integer params = any, proto_params = any, i = any dim as integer params = any, proto_params = any, i = any
'' Check ALIAS id '' Check ALIAS id
if( (palias <> NULL) and ((proto->stats and FB_SYMBSTATS_HASALIAS) <> 0) ) then if( (palias <> NULL) and ((proto->stats and FB_SYMBSTATS_HASALIAS) <> 0) ) then
if( *palias <> *proto->id.alias ) then if( *palias <> *proto->id.alias ) then
errReportEx( FB_ERRMSG_DIFFERENTALIASTHANPROTO, """" + *p alias + """" ) errReportEx( FB_ERRMSG_DIFFERENTALIASTHANPROTO, """" + *p alias + """" )
end if end if
end if end if
'' check return type '' check return type
if( (symbGetFullType( proto ) <> proc_dtype) or _ if( (symbGetFullType( proto ) <> proc_dtype) or _
skipping to change at line 181 skipping to change at line 181
if( proto_params <> params ) then if( proto_params <> params ) then
errReport( FB_ERRMSG_ARGCNTMISMATCH, TRUE ) errReport( FB_ERRMSG_ARGCNTMISMATCH, TRUE )
end if end if
'' Check each parameter. In case they had different amounts of '' Check each parameter. In case they had different amounts of
'' parameters, we already showed an error, but still can check at least '' parameters, we already showed an error, but still can check at least
'' the common parameters, for better error recovery. '' the common parameters, for better error recovery.
i = 1 i = 1
while( (i <= proto_params) and (i <= params) ) while( (i <= proto_params) and (i <= params) )
dim as integer dtype = symbGetFullType( proto_param ) dim as integer dtype = symbGetFullType( proto_param )
'' convert any AS ANY arg to the final one '' convert any AS ANY arg to the final one
if( typeGet( dtype ) = FB_DATATYPE_VOID ) then if( typeGet( dtype ) = FB_DATATYPE_VOID ) then
proto_param->typ = param->typ proto_param->typ = param->typ
proto_param->subtype = param->subtype proto_param->subtype = param->subtype
'' check if types don't conflit '' check if types don't conflit
else else
if( param->typ <> dtype ) then if( param->typ <> dtype ) then
hParamError( proc, i ) hParamError( proc, i )
elseif( param->subtype <> symbGetSubtype( proto_param ) ) then elseif( param->subtype <> symbGetSubtype( proto_param ) )
hParamError( proc, i ) then
end if hParamError( proc, i )
end if end if
end if
'' and mode '' and mode
if( param->param.mode <> proto_param->param.mode ) then if( param->param.mode <> proto_param->param.mode ) then
hParamError( proc, i ) hParamError( proc, i )
end if end if
'' Different BYDESC dimensions? '' Different BYDESC dimensions?
'' (even if one is unknown, both should be unknown) '' (even if one is unknown, both should be unknown)
if( param->param.mode = FB_PARAMMODE_BYDESC ) then if( param->param.mode = FB_PARAMMODE_BYDESC ) then
if( param->param.bydescdimensions <> proto_param->param.b ydescdimensions ) then if( param->param.bydescdimensions <> proto_param->param.b ydescdimensions ) then
hParamError( proc, i ) hParamError( proc, i )
end if end if
end if end if
'' check names and change to the new one if needed '' check names and change to the new one if needed
if( param->param.mode <> FB_PARAMMODE_VARARG ) then if( param->param.mode <> FB_PARAMMODE_VARARG ) then
symbSetName( proto_param, symbGetName( param ) ) symbSetName( proto_param, symbGetName( param ) )
'' as both have the same type, re-set the suffix, because for exa '' as both have the same type, re-set the suffix, because
mple for example
'' "a as integer" on the prototype and "a%" or just "a" on the pr '' "a as integer" on the prototype and "a%" or just "a" o
oc n the proc
'' declaration when in a defint context is allowed in QB '' declaration when in a defint context is allowed in QB
if( symbIsSuffixed( param ) ) then if( symbIsSuffixed( param ) ) then
symbGetAttrib( proto_param ) or= FB_SYMBATTRIB_SUFFIXED symbGetAttrib( proto_param ) or= FB_SYMBATTRIB_SU
else FFIXED
symbGetAttrib( proto_param ) and = not FB_SYMBATTRIB_SUFFIXED else
end if symbGetAttrib( proto_param ) and = not FB_SYMBATT
end if RIB_SUFFIXED
end if
end if
'' Warn about mismatching param initializers? '' Warn about mismatching param initializers?
'' If both params are optional, compare the two initializers '' If both params are optional, compare the two initializers
if( symbParamIsOptional( proto_param ) and symbParamIsOptional( p aram ) ) then if( symbParamIsOptional( proto_param ) and symbParamIsOptional( p aram ) ) then
if( astIsEqualParamInit( proto_param->param.optexpr, para m->param.optexpr ) = FALSE ) then if( astIsEqualParamInit( proto_param->param.optexpr, para m->param.optexpr ) = FALSE ) then
errReportParamWarn( proc, i, NULL, FB_WARNINGMSG_ MISMATCHINGPARAMINIT ) errReportParamWarn( proc, i, NULL, FB_WARNINGMSG_ MISMATCHINGPARAMINIT )
end if end if
end if end if
proto_param = proto_param->next proto_param = proto_param->next
param = param->next param = param->next
i += 1 i += 1
wend wend
end sub end sub
private sub hCheckAttribs _ private sub hCheckAttribs _
( _ ( _
byval proto as FBSYMBOL ptr, _ byval proto as FBSYMBOL ptr, _
byval attrib as FB_SYMBATTRIB, _ byval attrib as FB_SYMBATTRIB, _
byval pattrib as FB_PROCATTRIB _ byval pattrib as FB_PROCATTRIB _
skipping to change at line 506 skipping to change at line 506
elseif( returnMethod = "FPU" ) then elseif( returnMethod = "FPU" ) then
function = FB_RETURN_FPU function = FB_RETURN_FPU
end if end if
lexSkipToken( ) lexSkipToken( )
end if end if
hMatchRPRNT( ) hMatchRPRNT( )
end if end if
end function end function
function cProcCallingConv( byval default as FB_FUNCMODE ) as FB_FUNCMODE function cProcCallingConv( byval default as FB_FUNCMODE ) as FB_FUNCMODE
'' Use the default FBCALL? '' Use the default FBCALL?
if( default = FB_FUNCMODE_FBCALL ) then if( default = FB_FUNCMODE_FBCALL ) then
default = env.target.fbcall default = env.target.fbcall
end if end if
'' (CDECL|STDCALL|PASCAL|THISCALL)? '' (CDECL|STDCALL|PASCAL|THISCALL)?
select case as const lexGetToken( ) select case as const lexGetToken( )
case FB_TK_CDECL case FB_TK_CDECL
function = FB_FUNCMODE_CDECL function = FB_FUNCMODE_CDECL
lexSkipToken( LEXCHECK_POST_SUFFIX ) lexSkipToken( LEXCHECK_POST_SUFFIX )
case FB_TK_STDCALL case FB_TK_STDCALL
'' FB_FUNCMODE_STDCALL may be remapped to FB_FUNCMODE_STDCALL_MS '' FB_FUNCMODE_STDCALL may be remapped to FB_FUNCMODE_STDCALL_MS
'' for targets that do not support the @N suffix '' for targets that do not support the @N suffix
skipping to change at line 612 skipping to change at line 612
end sub end sub
private function hCheckOpOvlParams _ private function hCheckOpOvlParams _
( _ ( _
byval parent as FBSYMBOL ptr, _ byval parent as FBSYMBOL ptr, _
byval op as integer, _ byval op as integer, _
byval proc as FBSYMBOL ptr _ byval proc as FBSYMBOL ptr _
) as integer ) as integer
dim as integer found_mismatch = any 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 ) #macro hCheckParam( proc, param, num )
'' vararg? '' vararg?
if( symbGetParamMode( param ) = FB_PARAMMODE_VARARG ) then if( symbGetParamMode( param ) = FB_PARAMMODE_VARARG ) then
hParamError( proc, num, FB_ERRMSG_VARARGPARAMNOTALLOWED ) hParamError( proc, num, FB_ERRMSG_VARARGPARAMNOTALLOWED )
exit function exit function
end if end if
'' optional? '' optional?
if( symbParamIsOptional( param ) ) then if( symbParamIsOptional( param ) ) then
skipping to change at line 1234 skipping to change at line 1234
end if end if
end select end select
proc = symbPreAddProc( NULL ) proc = symbPreAddProc( NULL )
case else case else
'' Procedure/property ID '' Procedure/property ID
head_proc = hGetId( parent, @id, @dtype, _ head_proc = hGetId( parent, @id, @dtype, _
(tk = FB_TK_SUB) or (tk = FB_TK_PROPERTY) ) (tk = FB_TK_SUB) or (tk = FB_TK_PROPERTY) )
if( fbLangOptIsSet( FB_LANG_OPT_SUFFIX ) ) then
if( dtype <> FB_DATATYPE_INVALID ) then
attrib or= FB_SYMBATTRIB_SUFFIXED
end if
end if
proc = symbPreAddProc( @id ) proc = symbPreAddProc( @id )
end select end select
'' [NAKED] '' [NAKED]
cNakedAttribute( pattrib ) cNakedAttribute( pattrib )
'' CallConvention? '' CallConvention?
select case( tk ) select case( tk )
case FB_TK_CONSTRUCTOR, FB_TK_DESTRUCTOR case FB_TK_CONSTRUCTOR, FB_TK_DESTRUCTOR
'' ctors/dtors default to CDECL, so they can be passed to '' ctors/dtors default to CDECL, so they can be passed to
skipping to change at line 1484 skipping to change at line 1490
'' destructor? maybe implicitly declare the deleting destructor t oo '' destructor? maybe implicitly declare the deleting destructor t oo
if( tk = FB_TK_DESTRUCTOR ) then if( tk = FB_TK_DESTRUCTOR ) then
'' fbc won't generate any code that calls the deleting de structor '' fbc won't generate any code that calls the deleting de structor
'' so don't create the deleting destructor unless we're b inding to c++ '' so don't create the deleting destructor unless we're b inding to c++
if( symbGetMangling( parent ) = FB_MANGLING_CPP ) then if( symbGetMangling( parent ) = FB_MANGLING_CPP ) then
'' - inherit all the attribs from the declared de structor '' - inherit all the attribs from the declared de structor
'' except for the destructor type '' except for the destructor type
dim dtor0 as FBSYMBOL ptr = symbPreAddProc( NULL ) dim dtor0 as FBSYMBOL ptr = symbPreAddProc( NULL )
symbAddProcInstanceParam( parent, dtor0 ) symbAddProcInstanceParam( parent, dtor0 )
pattrib and= not FB_PROCATTRIB_DESTRUCTOR1 dtor0 = symbAddCtor( dtor0, NULL, attrib, ((pattr
pattrib or= FB_PROCATTRIB_DESTRUCTOR0 ib and not FB_PROCATTRIB_DESTRUCTOR1) or FB_PROCATTRIB_DESTRUCTOR0), mode )
dtor0 = symbAddCtor( dtor0, NULL, attrib, pattrib
, mode )
end if end if
end if end if
if( tk = FB_TK_PROPERTY ) then if( tk = FB_TK_PROPERTY ) then
hSetUdtPropertyFlags( parent, is_indexed, is_get ) hSetUdtPropertyFlags( parent, is_indexed, is_get )
end if end if
return proc return proc
end if end if
skipping to change at line 1755 skipping to change at line 1759
errReport( iif( tk = FB_TK_CONSTRUCTOR, _ errReport( iif( tk = FB_TK_CONSTRUCTOR, _
FB_ERRMSG_CONSTCTOR, FB_ERRMSG_CONSTDTOR ) ) FB_ERRMSG_CONSTCTOR, FB_ERRMSG_CONSTDTOR ) )
attrib and= not FB_SYMBATTRIB_CONST attrib and= not FB_SYMBATTRIB_CONST
end if end if
end sub end sub
'' ProcStmtBegin = (PRIVATE|PUBLIC)? (STATIC? | CONST? VIRTUAL?) '' ProcStmtBegin = (PRIVATE|PUBLIC)? (STATIC? | CONST? VIRTUAL?)
'' (SUB|FUNCTION|CONSTRUCTOR|DESTRUCTOR|OPERATOR) ProcHeader . '' (SUB|FUNCTION|CONSTRUCTOR|DESTRUCTOR|OPERATOR) ProcHeader .
sub cProcStmtBegin( byval attrib as FB_SYMBATTRIB, byval pattrib as FB_PROCATTRI B ) sub cProcStmtBegin( byval attrib as FB_SYMBATTRIB, byval pattrib as FB_PROCATTRI B )
dim as integer tkn = any, is_nested = any dim as integer tkn = any, is_nested = any
dim as FBSYMBOL ptr proc = any dim as FBSYMBOL ptr proc = any
dim as FB_CMPSTMTSTK ptr stk = any dim as FB_CMPSTMTSTK ptr stk = any
if( (attrib and (FB_SYMBATTRIB_PUBLIC or FB_SYMBATTRIB_PRIVATE)) = 0 ) th en if( (attrib and (FB_SYMBATTRIB_PUBLIC or FB_SYMBATTRIB_PRIVATE)) = 0 ) th en
if( env.opt.procpublic ) then if( env.opt.procpublic ) then
attrib or= FB_SYMBATTRIB_PUBLIC attrib or= FB_SYMBATTRIB_PUBLIC
else else
attrib or= FB_SYMBATTRIB_PRIVATE attrib or= FB_SYMBATTRIB_PRIVATE
end if end if
end if end if
cMethodAttributes( NULL, attrib, pattrib ) cMethodAttributes( NULL, attrib, pattrib )
skipping to change at line 1850 skipping to change at line 1854
'' emit proc setup '' emit proc setup
astProcBegin( proc, FALSE ) astProcBegin( proc, FALSE )
'' push to stmt stack '' push to stmt stack
stk = cCompStmtPush( FB_TK_FUNCTION, FB_CMPSTMT_MASK_DEFAULT or FB_CMPSTM T_MASK_DATA ) stk = cCompStmtPush( FB_TK_FUNCTION, FB_CMPSTMT_MASK_DEFAULT or FB_CMPSTM T_MASK_DATA )
stk->proc.tkn = tkn stk->proc.tkn = tkn
stk->proc.is_nested = is_nested stk->proc.is_nested = is_nested
stk->proc.endlabel = astGetProcExitlabel( ast.proc.curr ) stk->proc.endlabel = astGetProcExitlabel( ast.proc.curr )
end sub end sub
'' ProcStmtEnd = END (SUB | FUNCTION) . '' ProcStmtEnd = END (SUB | FUNCTION | OPERATOR | CONSTRUCTOR | DESTRUCTOR | P ROPERTY) .
sub cProcStmtEnd( ) sub cProcStmtEnd( )
dim as FB_CMPSTMTSTK ptr stk = any dim as FB_CMPSTMTSTK ptr stk = any
dim as FBSYMBOL ptr proc_res = any dim as FBSYMBOL ptr proc_res = any
stk = cCompStmtGetTOS( FB_TK_FUNCTION ) stk = cCompStmtGetTOS( FB_TK_FUNCTION )
if( stk = NULL ) then if( stk = NULL ) then
hSkipStmt( ) hSkipStmt( )
exit sub exit sub
end if end if
skipping to change at line 1896 skipping to change at line 1900
if( symbIsNaked( parser.currproc ) = FALSE ) then if( symbIsNaked( parser.currproc ) = FALSE ) then
if( symbIsReturnByRef( parser.currproc ) ) then if( symbIsReturnByRef( parser.currproc ) ) then
errReport( FB_ERRMSG_NOBYREFFUNCTIONRESUL T ) errReport( FB_ERRMSG_NOBYREFFUNCTIONRESUL T )
else else
errReportWarn( FB_WARNINGMSG_NOFUNCTIONRE SULT ) errReportWarn( FB_WARNINGMSG_NOFUNCTIONRE SULT )
end if end if
end if end if
end if end if
end if end if
'' always finish '' always finish
astProcEnd( FALSE ) astProcEnd( FALSE )
'' Close namespace again if cProcHeader() opened it '' Close namespace again if cProcHeader() opened it
if( stk->proc.is_nested ) then if( stk->proc.is_nested ) then
symbNestEnd( TRUE ) symbNestEnd( TRUE )
end if end if
'' pop from stmt stack '' pop from stmt stack
cCompStmtPop( stk ) cCompStmtPop( stk )
end sub end sub
 End of changes. 12 change blocks. 
46 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)