"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/compiler/symb-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.

symb-proc.bas  (FreeBASIC-1.08.0-source.tar.xz):symb-proc.bas  (FreeBASIC-1.08.1-source.tar.xz)
skipping to change at line 934 skipping to change at line 934
end if end if
'' Only check if this really is a derived UDT '' Only check if this really is a derived UDT
overridden = NULL overridden = NULL
if( parent->udt.base ) then if( parent->udt.base ) then
'' Destructor? '' Destructor?
if( symbIsDestructor1( proc ) ) then if( symbIsDestructor1( proc ) ) then
'' There can always only be one complete dtor, so there is no '' There can always only be one complete dtor, so there is no
'' need to do a lookup and/or overload checks. '' need to do a lookup and/or overload checks.
overridden = symbGetCompDtor1( parent->udt.base-> subtype ) overridden = symbGetCompDtor1( parent->udt.base-> subtype )
elseif( symbIsDestructor0( proc ) ) then
'' There can always only be deleting dtor, so the
re is no
'' need to do a lookup and/or overload checks.
overridden = symbGetCompDtor0( parent->udt.base->
subtype )
elseif( symbIsOperator( proc ) ) then elseif( symbIsOperator( proc ) ) then
'' Get the corresponding operator from the base '' Get the corresponding operator from the base
'' (actually a chain of overloads for that partic ular operator) '' (actually a chain of overloads for that partic ular operator)
overridden = symbGetCompOpOvlHead( parent->udt.ba se->subtype, _ overridden = symbGetCompOpOvlHead( parent->udt.ba se->subtype, _
symbGetProcOpO vl( proc ) ) symbGetProcOpO vl( proc ) )
'' Find the overload with the exact same signatur e '' Find the overload with the exact same signatur e
overridden = symbFindOpOvlProc( symbGetProcOpOvl( proc ), overridden, proc ) overridden = symbFindOpOvlProc( symbGetProcOpOvl( proc ), overridden, proc )
elseif( id ) then elseif( id ) then
'' If this method has the same id and signature a s '' If this method has the same id and signature a s
skipping to change at line 1215 skipping to change at line 1219
( _ ( _
byval base_proc as FBSYMBOL ptr _ byval base_proc as FBSYMBOL ptr _
) as FBSYMBOL ptr ) as FBSYMBOL ptr
var proc = symbPreAddProc( NULL ) var proc = symbPreAddProc( NULL )
proc->proc.returnMethod = base_proc->proc.returnMethod proc->proc.returnMethod = base_proc->proc.returnMethod
'' params '' params
var param = symbGetProcHeadParam( base_proc ) var param = symbGetProcHeadParam( base_proc )
do while( param <> NULL ) do while( param <> NULL )
var p = symbAddProcParam( proc, NULL, param->typ, param->subtype, _ var p = symbAddProcParam( proc, NULL, param->typ, param->subtype, _
param->param.bydescdimensions, param->param.mode, param->attrib, param->pattrib ) param->param.bydescdimensions, param->param.mode, param->attrib, param->pattrib )
if( symbGetDontInit( param ) ) then if( symbGetDontInit( param ) ) then
symbSetDontInit( p ) symbSetDontInit( p )
end if end if
symbMakeParamOptional( proc, p, param->param.optexpr ) symbMakeParamOptional( proc, p, param->param.optexpr )
param = param->next param = param->next
loop loop
'' attribs to copy from the proc to the procptr '' attribs to copy from the proc to the procptr
'' (anything needed for procptr call checking) '' (anything needed for procptr call checking)
var attribmask = FB_SYMBATTRIB_CONST '' THIS CONSTness, needed for symbCa lcProcMatch() type checking var attribmask = FB_SYMBATTRIB_CONST '' THIS CONSTness, needed for symbCa lcProcMatch() type checking
var pattribmask = FB_PROCATTRIB_RETURNBYREF '' return byref var pattribmask = FB_PROCATTRIB_RETURNBYREF '' return byref
pattribmask or = FB_PROCATTRIB_NOTHISCONSTNESS '' method call THIS CONSTn ess checking pattribmask or = FB_PROCATTRIB_NOTHISCONSTNESS '' method call THIS CONSTn ess checking
function = symbAddProcPtr( proc, _ function = symbAddProcPtr( proc, _
symbGetFullType( base_proc ), symbGetSubtype( base_proc ) , _ symbGetFullType( base_proc ), symbGetSubtype( base_proc ) , _
base_proc->attrib and attribmask, base_proc->pattrib and pattribmask, _ base_proc->attrib and attribmask, base_proc->pattrib and pattribmask, _
symbGetProcMode( base_proc ) ) symbGetProcMode( base_proc ) )
end function end function
function symbPreAddProc( byval symbol as zstring ptr ) as FBSYMBOL ptr function symbPreAddProc( byval symbol as zstring ptr ) as FBSYMBOL ptr
dim as FBSYMBOL ptr proc = any dim as FBSYMBOL ptr proc = any
proc = listNewNode( @symb.symlist ) proc = listNewNode( @symb.symlist )
proc->class = FB_SYMBCLASS_PROC proc->class = FB_SYMBCLASS_PROC
proc->attrib = FB_SYMBATTRIB_NONE proc->attrib = FB_SYMBATTRIB_NONE
proc->pattrib = FB_PROCATTRIB_NONE proc->pattrib = FB_PROCATTRIB_NONE
proc->stats = 0 proc->stats = 0
proc->id.name = symbol proc->id.name = symbol
proc->id.alias = NULL proc->id.alias = NULL
proc->id.mangled = NULL proc->id.mangled = NULL
skipping to change at line 1275 skipping to change at line 1279
proc->proc.mode = env.target.fbcall proc->proc.mode = env.target.fbcall
proc->proc.realdtype = FB_DATATYPE_INVALID proc->proc.realdtype = FB_DATATYPE_INVALID
proc->proc.realsubtype = NULL proc->proc.realsubtype = NULL
proc->proc.returnMethod = FB_RETURN_FPU proc->proc.returnMethod = FB_RETURN_FPU
proc->proc.rtl.callback = NULL proc->proc.rtl.callback = NULL
proc->proc.ovl.minparams = 0 proc->proc.ovl.minparams = 0
proc->proc.ovl.maxparams = 0 proc->proc.ovl.maxparams = 0
proc->proc.ovl.next = NULL proc->proc.ovl.next = NULL
proc->proc.ext = NULL proc->proc.ext = NULL
'' to allow getNamespace() and GetParent() to work '' to allow getNamespace() and GetParent() to work
proc->symtb = @symbGetCompSymbTb( symbGetCurrentNamespc( ) ) proc->symtb = @symbGetCompSymbTb( symbGetCurrentNamespc( ) )
proc->hash.tb = @symbGetCompHashTb( symbGetCurrentNamespc( ) ) proc->hash.tb = @symbGetCompHashTb( symbGetCurrentNamespc( ) )
proc->hash.item = NULL proc->hash.item = NULL
proc->hash.index = 0 proc->hash.index = 0
proc->hash.prev = NULL proc->hash.prev = NULL
proc->hash.next = NULL proc->hash.next = NULL
proc->parent = NULL proc->parent = NULL
proc->prev = NULL proc->prev = NULL
proc->next = NULL proc->next = NULL
function = proc function = proc
skipping to change at line 1333 skipping to change at line 1337
assert( param->class = FB_SYMBCLASS_PARAM ) assert( param->class = FB_SYMBCLASS_PARAM )
dtype = symbGetFullType( param ) dtype = symbGetFullType( param )
subtype = param->subtype subtype = param->subtype
symbGetRealParamDtype( param->param.mode, param->param.bydescrealsubtype, dtype, subtype ) symbGetRealParamDtype( param->param.mode, param->param.bydescrealsubtype, dtype, subtype )
end sub end sub
function symbAddVarForParam( byval param as FBSYMBOL ptr ) as FBSYMBOL ptr function symbAddVarForParam( byval param as FBSYMBOL ptr ) as FBSYMBOL ptr
dim as FBARRAYDIM dTB(0) = any dim as FBARRAYDIM dTB(0) = any
dim as FBSYMBOL ptr s = any dim as FBSYMBOL ptr s = any
dim as integer attrib = any, dtype = any, dimensions = any dim as integer attrib = any, dtype = any, dimensions = any
function = NULL function = NULL
dtype = symbGetFullType( param ) dtype = symbGetFullType( param )
select case as const param->param.mode select case as const param->param.mode
case FB_PARAMMODE_BYVAL case FB_PARAMMODE_BYVAL
attrib = FB_SYMBATTRIB_PARAMBYVAL attrib = FB_SYMBATTRIB_PARAMBYVAL
skipping to change at line 1374 skipping to change at line 1378
s = symbAddVar( symbGetName( param ), NULL, dtype, param->subtype, 0, par am->param.bydescdimensions, dTB(), attrib ) s = symbAddVar( symbGetName( param ), NULL, dtype, param->subtype, 0, par am->param.bydescdimensions, dTB(), attrib )
if( s = NULL ) then if( s = NULL ) then
exit function exit function
end if end if
assert( s->var_.array.desc = NULL ) assert( s->var_.array.desc = NULL )
assert( s->var_.array.desctype = NULL ) assert( s->var_.array.desctype = NULL )
s->var_.array.desctype = param->param.bydescrealsubtype s->var_.array.desctype = param->param.bydescrealsubtype
'' declare it or arrays passed by descriptor will be initialized when REDIM' '' declare it or arrays passed by descriptor will be initialized when RED
d IM'd
symbSetIsDeclared( s ) symbSetIsDeclared( s )
if( symbGetDontInit( param ) ) then if( symbGetDontInit( param ) ) then
symbSetDontInit( s ) symbSetDontInit( s )
end if end if
if( param->stats and FB_SYMBSTATS_ARGV ) then if( param->stats and FB_SYMBSTATS_ARGV ) then
s->stats or= FB_SYMBSTATS_ARGV s->stats or= FB_SYMBSTATS_ARGV
end if end if
function = s function = s
end function end function
function symbAddVarForProcResultParam( byval proc as FBSYMBOL ptr ) as FBSYMBOL ptr function symbAddVarForProcResultParam( byval proc as FBSYMBOL ptr ) as FBSYMBOL ptr
dim as FBARRAYDIM dTB(0) = any dim as FBARRAYDIM dTB(0) = any
dim as FBSYMBOL ptr s = any dim as FBSYMBOL ptr s = any
if( symbProcReturnsOnStack( proc ) = FALSE ) then if( symbProcReturnsOnStack( proc ) = FALSE ) then
return NULL return NULL
end if end if
s = symbAddVar( symbUniqueId( ), NULL, FB_DATATYPE_STRUCT, proc->subtype, 0, _ s = symbAddVar( symbUniqueId( ), NULL, FB_DATATYPE_STRUCT, proc->subtype, 0, _
0, dTB(), FB_SYMBATTRIB_PARAMBYREF, FB_SYMBOPT_PRESERVECA SE ) 0, dTB(), FB_SYMBATTRIB_PARAMBYREF, FB_SYMBOPT_PRESERVECA SE )
symbProcAllocExt( proc ) symbProcAllocExt( proc )
proc->proc.ext->res = s proc->proc.ext->res = s
skipping to change at line 1684 skipping to change at line 1688
byval arg_subtype as FBSYMBOL ptr, _ byval arg_subtype as FBSYMBOL ptr, _
byval arg_expr as ASTNODE ptr, _ byval arg_expr as ASTNODE ptr, _
byval mode as FB_PARAMMODE = 0 _ byval mode as FB_PARAMMODE = 0 _
) as FB_OVLPROC_MATCH_SCORE ) as FB_OVLPROC_MATCH_SCORE
dim as integer arg_dclass = any, param_dt = any, arg_dt = any dim as integer arg_dclass = any, param_dt = any, arg_dt = any
dim as integer param_dtype, arg_dtype dim as integer param_dtype, arg_dtype
function = FB_OVLPROC_NO_MATCH function = FB_OVLPROC_NO_MATCH
'' don't take the const qualifier into account '' don't take the const qualifier into account
param_dtype = typeGetDtAndPtrOnly( param_dtype_in ) param_dtype = typeGetDtAndPtrOnly( param_dtype_in )
arg_dtype = typeGetDtAndPtrOnly( arg_dtype_in ) arg_dtype = typeGetDtAndPtrOnly( arg_dtype_in )
arg_dclass = typeGetClass( arg_dtype ) arg_dclass = typeGetClass( arg_dtype )
'' check classes '' check classes
select case as const typeGetClass( param_dtype ) select case as const typeGetClass( param_dtype )
'' integer? '' integer?
case FB_DATACLASS_INTEGER case FB_DATACLASS_INTEGER
skipping to change at line 1895 skipping to change at line 1899
dim as FBSYMBOL ptr param_subtype = any, arg_subtype = any, array = any dim as FBSYMBOL ptr param_subtype = any, arg_subtype = any, array = any
'' arg not passed? '' arg not passed?
if( arg_expr = NULL ) then if( arg_expr = NULL ) then
'' is param optional? '' is param optional?
if( symbParamIsOptional( param ) ) then if( symbParamIsOptional( param ) ) then
return FB_OVLPROC_FULLMATCH return FB_OVLPROC_FULLMATCH
else else
return FB_OVLPROC_NO_MATCH return FB_OVLPROC_NO_MATCH
end if end if
end if end if
param_dtype = symbGetFullType( param ) param_dtype = symbGetFullType( param )
param_subtype = symbGetSubType( param ) param_subtype = symbGetSubType( param )
param_ptrcnt = symbGetPtrCnt( param ) param_ptrcnt = symbGetPtrCnt( param )
arg_dtype = astGetFullType( arg_expr ) arg_dtype = astGetFullType( arg_expr )
arg_subtype = astGetSubType( arg_expr ) arg_subtype = astGetSubType( arg_expr )
select case symbGetParamMode( param ) select case symbGetParamMode( param )
'' by descriptor param? '' by descriptor param?
skipping to change at line 2015 skipping to change at line 2019
'' Same/compatible type, but mismatch due to CONSTness '' Same/compatible type, but mismatch due to CONSTness
return FB_OVLPROC_NO_MATCH return FB_OVLPROC_NO_MATCH
end if end if
end if end if
'' different types.. '' different types..
select case param_dtype select case param_dtype
'' UDT? try to find a ctor '' UDT? try to find a ctor
case FB_DATATYPE_STRUCT ', FB_DATATYPE_CLASS case FB_DATATYPE_STRUCT ', FB_DATATYPE_CLASS
hCheckCtorOvl( ctor_rec_cnt, param_subtype, arg_expr, arg_mode ) hCheckCtorOvl( ctor_rec_cnt, param_subtype, arg_expr, arg_mode )
'' and at last, try implicit casting.. '' and at last, try implicit casting..
hCheckCastOvlEx( cast_rec_cnt, param_dtype, param_subtype, arg_expr ) hCheckCastOvlEx( cast_rec_cnt, param_dtype, param_subtype, arg_ex
pr )
return FB_OVLPROC_NO_MATCH return FB_OVLPROC_NO_MATCH
'' enum param? refuse any other argument type, even integers, '' enum param? refuse any other argument type, even integers,
'' or operator overloading wouldn't work (as in C++) '' or operator overloading wouldn't work (as in C++)
case FB_DATATYPE_ENUM case FB_DATATYPE_ENUM
return FB_OVLPROC_NO_MATCH return FB_OVLPROC_NO_MATCH
case else case else
select case arg_dtype select case arg_dtype
'' UDT arg? try implicit casting.. '' UDT arg? try implicit casting..
case FB_DATATYPE_STRUCT ', FB_DATATYPE_CLASS case FB_DATATYPE_STRUCT ', FB_DATATYPE_CLASS
hCheckCastOvlEx( cast_rec_cnt, symbGetFullType( param ), param_subtype, arg_expr ) hCheckCastOvlEx( cast_rec_cnt, symbGetFullType( param ), param_subtype, arg_expr )
return FB_OVLPROC_NO_MATCH return FB_OVLPROC_NO_MATCH
end select end select
end select end select
'' last resource, calc the differences '' last resource, calc the differences
function = hCalcTypesDiff( symbGetFullType( param ), _ function = hCalcTypesDiff( symbGetFullType( param ), _
param_subtype, _ param_subtype, _
param_ptrcnt, _ param_ptrcnt, _
astGetFullType( arg_ex pr ), _ astGetFullType( arg_ex pr ), _
arg_subtype, _ arg_subtype, _
arg_expr, _ arg_expr, _
symbGetParamMode( para m ) ) symbGetParamMode( para m ) )
skipping to change at line 2613 skipping to change at line 2617
end sub end sub
sub symbDelPrototype( byval s as FBSYMBOL ptr ) sub symbDelPrototype( byval s as FBSYMBOL ptr )
'' del args.. '' del args..
if( s->proc.params > 0 ) then if( s->proc.params > 0 ) then
hDelParams( s ) hDelParams( s )
end if end if
symbProcFreeExt( s ) symbProcFreeExt( s )
symbFreeSymbol( s ) symbFreeSymbol( s )
'' note: can't delete the next overloaded procs in the list here '' note: can't delete the next overloaded procs in the list here
'' because global operators can be declared inside namespaces, '' because global operators can be declared inside namespaces,
'' but they will be linked together '' but they will be linked together
end sub end sub
'':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: '':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::
'' global ctors '' global ctors
'':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: '':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::
''::::: '':::::
private function hAddToGlobCtorList _ private function hAddToGlobCtorList _
( _ ( _
byval list as FB_GLOBCTORLIST ptr, _ byval list as FB_GLOBCTORLIST ptr, _
byval proc as FBSYMBOL ptr _ byval proc as FBSYMBOL ptr _
) as FB_GLOBCTORLIST_ITEM ptr ) as FB_GLOBCTORLIST_ITEM ptr
dim as FB_GLOBCTORLIST_ITEM ptr n = any dim as FB_GLOBCTORLIST_ITEM ptr n = any
n = listNewNode( @list->list ) n = listNewNode( @list->list )
'' add to list '' add to list
if( list->tail <> NULL ) then if( list->tail <> NULL ) then
list->tail->next = n list->tail->next = n
else else
list->head = n list->head = n
end if end if
n->next = NULL n->next = NULL
list->tail = n list->tail = n
'' ''
n->sym = proc n->sym = proc
function = n function = n
end function end function
function symbAddGlobalCtor( byval proc as FBSYMBOL ptr ) as FB_GLOBCTORLIST_ITEM ptr function symbAddGlobalCtor( byval proc as FBSYMBOL ptr ) as FB_GLOBCTORLIST_ITEM ptr
symbSetIsGlobalCtor( proc ) symbSetIsGlobalCtor( proc )
function = hAddToGlobCtorList( @symb.globctorlist, proc ) function = hAddToGlobCtorList( @symb.globctorlist, proc )
end function end function
function symbAddGlobalDtor( byval proc as FBSYMBOL ptr ) as FB_GLOBCTORLIST_ITEM ptr function symbAddGlobalDtor( byval proc as FBSYMBOL ptr ) as FB_GLOBCTORLIST_ITEM ptr
symbSetIsGlobalDtor( proc ) symbSetIsGlobalDtor( proc )
skipping to change at line 3097 skipping to change at line 3101
function = s function = s
end function end function
function symbGetDefaultParamMode _ function symbGetDefaultParamMode _
( _ ( _
byval dtype as integer, _ byval dtype as integer, _
byval subtype as FBSYMBOL ptr _ byval subtype as FBSYMBOL ptr _
) as integer ) as integer
select case as const( typeGetDtAndPtrOnly( dtype ) ) select case as const( typeGetDtAndPtrOnly( dtype ) )
case FB_DATATYPE_FWDREF, _ case FB_DATATYPE_FWDREF, _
FB_DATATYPE_FIXSTR, FB_DATATYPE_STRING, _ FB_DATATYPE_FIXSTR, FB_DATATYPE_STRING, _
FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR, _ FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR, _
FB_DATATYPE_STRUCT ', FB_DATATYPE_CLASS FB_DATATYPE_STRUCT ', FB_DATATYPE_CLASS
return FB_PARAMMODE_BYREF return FB_PARAMMODE_BYREF
case else case else
return FB_PARAMMODE_BYVAL return FB_PARAMMODE_BYVAL
end select end select
end function end function
'' Check whether the procedures' calling conventions are compatible '' Check whether the procedures' calling conventions are compatible
function symbAreProcModesEqual _ function symbAreProcModesEqual _
( _ ( _
byval proca as FBSYMBOL ptr, _ byval proca as FBSYMBOL ptr, _
byval procb as FBSYMBOL ptr _ byval procb as FBSYMBOL ptr _
) as integer ) as integer
 End of changes. 26 change blocks. 
49 lines changed or deleted 56 lines changed or added

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