Merged revision(s) 28691, 31914 from branches/svenbarth/packages:

Convert export options from constants to a set and accordingly adjust all usage locations

git-svn-id: trunk@32945 -
This commit is contained in:
svenbarth 2016-01-15 16:06:06 +00:00
parent af4f75de75
commit 3b71841a84
11 changed files with 54 additions and 52 deletions

View File

@ -31,18 +31,20 @@ uses
symtype,symdef,symsym, symtype,symdef,symsym,
aasmbase,aasmdata; aasmbase,aasmdata;
const
{ export options }
eo_resident = $1;
eo_index = $2;
eo_name = $4;
type type
{ export options }
texportoption=(eo_none,
eo_resident,
eo_index,
eo_name
);
texportoptions=set of texportoption;
texported_item = class(TLinkedListItem) texported_item = class(TLinkedListItem)
sym : tsym; sym : tsym;
index : longint; index : longint;
name : pshortstring; name : pshortstring;
options : word; options : texportoptions;
is_var : boolean; is_var : boolean;
constructor create; constructor create;
destructor destroy;override; destructor destroy;override;
@ -71,14 +73,14 @@ type
TExportLibClass=class of TExportLib; TExportLibClass=class of TExportLib;
procedure exportprocsym(sym: tsym; const s : string; index: longint; options: word); procedure exportprocsym(sym: tsym; const s : string; index: longint; options: texportoptions);
procedure exportvarsym(sym: tsym; const s : string; index: longint; options: word); procedure exportvarsym(sym: tsym; const s : string; index: longint; options: texportoptions);
{ to export symbols not directly related to a tsym (e.g., the Objective-C { to export symbols not directly related to a tsym (e.g., the Objective-C
rtti) } rtti) }
procedure exportname(const s : string; options: word); procedure exportname(const s : string; options: texportoptions);
procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: word); procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: texportoptions);
procedure exportallprocsymnames(ps: tprocsym; options: word); procedure exportallprocsymnames(ps: tprocsym; options: texportoptions);
var var
@ -98,20 +100,20 @@ uses
TExported_procedure TExported_procedure
****************************************************************************} ****************************************************************************}
procedure exportprocsym(sym: tsym; const s : string; index: longint; options: word); procedure exportprocsym(sym: tsym; const s : string; index: longint; options: texportoptions);
var var
hp : texported_item; hp : texported_item;
begin begin
hp:=texported_item.create; hp:=texported_item.create;
hp.name:=stringdup(s); hp.name:=stringdup(s);
hp.sym:=sym; hp.sym:=sym;
hp.options:=options or eo_name; hp.options:=options+[eo_name];
hp.index:=index; hp.index:=index;
exportlib.exportprocedure(hp); exportlib.exportprocedure(hp);
end; end;
procedure exportvarsym(sym: tsym; const s : string; index: longint; options: word); procedure exportvarsym(sym: tsym; const s : string; index: longint; options: texportoptions);
var var
hp : texported_item; hp : texported_item;
begin begin
@ -119,19 +121,19 @@ procedure exportvarsym(sym: tsym; const s : string; index: longint; options: wor
hp.name:=stringdup(s); hp.name:=stringdup(s);
hp.sym:=sym; hp.sym:=sym;
hp.is_var:=true; hp.is_var:=true;
hp.options:=options or eo_name; hp.options:=options+[eo_name];
hp.index:=index; hp.index:=index;
exportlib.exportvar(hp); exportlib.exportvar(hp);
end; end;
procedure exportname(const s : string; options: word); procedure exportname(const s : string; options: texportoptions);
begin begin
exportvarsym(nil,s,0,options); exportvarsym(nil,s,0,options);
end; end;
procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: word); procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: texportoptions);
var var
item: TCmdStrListItem; item: TCmdStrListItem;
begin begin
@ -148,7 +150,7 @@ procedure exportname(const s : string; options: word);
end; end;
procedure exportallprocsymnames(ps: tprocsym; options: word); procedure exportallprocsymnames(ps: tprocsym; options: texportoptions);
var var
i: longint; i: longint;
begin begin
@ -167,7 +169,7 @@ begin
sym:=nil; sym:=nil;
index:=-1; index:=-1;
name:=nil; name:=nil;
options:=0; options:=[];
is_var:=false; is_var:=false;
end; end;

View File

@ -88,7 +88,7 @@ var
hp2 : texported_item; hp2 : texported_item;
begin begin
{ first test the index value } { first test the index value }
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
begin begin
Message1(parser_e_no_export_with_index_for_target,target_info.shortname); Message1(parser_e_no_export_with_index_for_target,target_info.shortname);
exit; exit;

View File

@ -287,7 +287,7 @@ end;
{ TODO: package visibility (private_extern) -- must not be exported { TODO: package visibility (private_extern) -- must not be exported
either} either}
if not(vf.visibility in [vis_private,vis_strictprivate]) then if not(vf.visibility in [vis_private,vis_strictprivate]) then
exportname(prefix+vf.RealName,0); exportname(prefix+vf.RealName,[]);
end; end;
end; end;
@ -297,15 +297,15 @@ end;
if (target_info.system in systems_objc_nfabi) then if (target_info.system in systems_objc_nfabi) then
begin begin
{ export class and metaclass symbols } { export class and metaclass symbols }
exportname(def.rtti_mangledname(objcclassrtti),0); exportname(def.rtti_mangledname(objcclassrtti),[]);
exportname(def.rtti_mangledname(objcmetartti),0); exportname(def.rtti_mangledname(objcmetartti),[]);
{ export public/protected instance variable offset symbols } { export public/protected instance variable offset symbols }
exportobjcclassfields(def); exportobjcclassfields(def);
end end
else else
begin begin
{ export the class symbol } { export the class symbol }
exportname('.objc_class_name_'+def.objextname^,0); exportname('.objc_class_name_'+def.objextname^,[]);
end; end;
end; end;

View File

@ -63,14 +63,14 @@ implementation
srsymtable : TSymtable; srsymtable : TSymtable;
hpname : shortstring; hpname : shortstring;
index : longint; index : longint;
options : word; options : texportoptions;
function IsGreater(hp1,hp2:texported_item):boolean; function IsGreater(hp1,hp2:texported_item):boolean;
var var
i2 : boolean; i2 : boolean;
begin begin
i2:=(hp2.options and eo_index)<>0; i2:=eo_index in hp2.options;
if (hp1.options and eo_index)<>0 then if eo_index in hp1.options then
begin begin
if i2 then if i2 then
IsGreater:=hp1.index>hp2.index IsGreater:=hp1.index>hp2.index
@ -88,7 +88,7 @@ implementation
consume(_EXPORTS); consume(_EXPORTS);
repeat repeat
hpname:=''; hpname:='';
options:=0; options:=[];
index:=0; index:=0;
if token=_ID then if token=_ID then
begin begin
@ -151,7 +151,7 @@ implementation
index:=0; index:=0;
consume(_INTCONST); consume(_INTCONST);
end; end;
options:=options or eo_index; include(options,eo_index);
pt.free; pt.free;
if target_info.system in [system_i386_win32,system_i386_wdosx,system_arm_wince,system_i386_wince] then if target_info.system in [system_i386_win32,system_i386_wdosx,system_arm_wince,system_i386_wince] then
DefString:=srsym.realname+'='+InternalProcName+' @ '+tostr(index) DefString:=srsym.realname+'='+InternalProcName+' @ '+tostr(index)
@ -167,13 +167,13 @@ implementation
hpname:=chr(tordconstnode(pt).value.svalue and $ff) hpname:=chr(tordconstnode(pt).value.svalue and $ff)
else else
consume(_CSTRING); consume(_CSTRING);
options:=options or eo_name; include(options,eo_name);
pt.free; pt.free;
DefString:=hpname+'='+InternalProcName; DefString:=hpname+'='+InternalProcName;
end; end;
if try_to_consume(_RESIDENT) then if try_to_consume(_RESIDENT) then
begin begin
options:=options or eo_resident; include(options,eo_resident);
DefString:=srsym.realname+'='+InternalProcName;{Resident ignored!} DefString:=srsym.realname+'='+InternalProcName;{Resident ignored!}
end; end;
if (DefString<>'') and UseDeffileForExports then if (DefString<>'') and UseDeffileForExports then
@ -188,7 +188,7 @@ implementation
{ export section (it doesn't make sense to export } { export section (it doesn't make sense to export }
{ the generic mangled name, because the name of } { the generic mangled name, because the name of }
{ the parent unit is used in that) } { the parent unit is used in that) }
if ((options and (eo_name or eo_index))=0) and if (options*[eo_name,eo_index]=[]) and
(tprocdef(tprocsym(srsym).procdeflist[0]).aliasnames.count>1) then (tprocdef(tprocsym(srsym).procdeflist[0]).aliasnames.count>1) then
exportallprocsymnames(tprocsym(srsym),options) exportallprocsymnames(tprocsym(srsym),options)
else else
@ -198,7 +198,7 @@ implementation
{ same index? And/or should we also export the aliases } { same index? And/or should we also export the aliases }
{ if a name is specified? (JM) } { if a name is specified? (JM) }
if ((options and eo_name)=0) then if not (eo_name in options) then
{ Export names are not mangled on Windows and OS/2 } { Export names are not mangled on Windows and OS/2 }
if (target_info.system in (systems_all_windows+[system_i386_emx, system_i386_os2])) then if (target_info.system in (systems_all_windows+[system_i386_emx, system_i386_os2])) then
hpname:=orgs hpname:=orgs
@ -216,7 +216,7 @@ implementation
end; end;
staticvarsym: staticvarsym:
begin begin
if ((options and eo_name)=0) then if not (eo_name in options) then
{ for "cvar" } { for "cvar" }
if (vo_has_mangledname in tstaticvarsym(srsym).varoptions) then if (vo_has_mangledname in tstaticvarsym(srsym).varoptions) then
hpname:=srsym.mangledname hpname:=srsym.mangledname

View File

@ -1372,7 +1372,7 @@ type
begin begin
hp:=texported_item.create; hp:=texported_item.create;
hp.name:=stringdup(s); hp.name:=stringdup(s);
hp.options:=hp.options or eo_name; include(hp.options,eo_name);
exportlib.exportprocedure(hp); exportlib.exportprocedure(hp);
end; end;
@ -1383,7 +1383,7 @@ type
begin begin
hp:=texported_item.create; hp:=texported_item.create;
hp.name:=stringdup(s); hp.name:=stringdup(s);
hp.options:=hp.options or eo_name; include(hp.options,eo_name);
exportlib.exportvar(hp); exportlib.exportvar(hp);
end; end;

View File

@ -93,7 +93,7 @@ var
hp2 : texported_item; hp2 : texported_item;
begin begin
{ first test the index value } { first test the index value }
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
begin begin
Message1(parser_e_no_export_with_index_for_target,'beos'); Message1(parser_e_no_export_with_index_for_target,'beos');
exit; exit;

View File

@ -94,7 +94,7 @@ var
hp2 : texported_item; hp2 : texported_item;
begin begin
{ first test the index value } { first test the index value }
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
begin begin
Message1(parser_e_no_export_with_index_for_target,'haiku'); Message1(parser_e_no_export_with_index_for_target,'haiku');
exit; exit;

View File

@ -165,16 +165,16 @@ var
hp2 : texported_item; hp2 : texported_item;
begin begin
{ first test the index value } { first test the index value }
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
begin begin
Comment(V_Error,'can''t export with index under netware'); Comment(V_Error,'can''t export with index under netware');
exit; exit;
end; end;
{ use pascal name is none specified } { use pascal name is none specified }
if (hp.options and eo_name)=0 then if not (eo_name in hp.options) then
begin begin
hp.name:=stringdup(hp.sym.name); hp.name:=stringdup(hp.sym.name);
hp.options:=hp.options or eo_name; include(hp.options,eo_name);
end; end;
{ now place in correct order } { now place in correct order }
hp2:=texported_item(current_module._exports.first); hp2:=texported_item(current_module._exports.first);

View File

@ -167,16 +167,16 @@ var
hp2 : texported_item; hp2 : texported_item;
begin begin
{ first test the index value } { first test the index value }
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
begin begin
Comment(V_Error,'can''t export with index under netware'); Comment(V_Error,'can''t export with index under netware');
exit; exit;
end; end;
{ use pascal name is none specified } { use pascal name is none specified }
if (hp.options and eo_name)=0 then if eo_name in hp.options then
begin begin
hp.name:=stringdup(hp.sym.name); hp.name:=stringdup(hp.sym.name);
hp.options:=hp.options or eo_name; include(hp.options,eo_name);
end; end;
{ now place in correct order } { now place in correct order }
hp2:=texported_item(current_module._exports.first); hp2:=texported_item(current_module._exports.first);

View File

@ -651,12 +651,12 @@ implementation
procedure TExportLibWin.exportprocedure(hp : texported_item); procedure TExportLibWin.exportprocedure(hp : texported_item);
begin begin
if ((hp.options and eo_index)<>0) and ((hp.index<=0) or (hp.index>$ffff)) then if (eo_index in hp.options) and ((hp.index<=0) or (hp.index>$ffff)) then
begin begin
message1(parser_e_export_invalid_index,tostr(hp.index)); message1(parser_e_export_invalid_index,tostr(hp.index));
exit; exit;
end; end;
if hp.options and eo_index=eo_index then if eo_index in hp.options then
EList_indexed.Add(hp) EList_indexed.Add(hp)
else else
EList_nonindexed.Add(hp); EList_nonindexed.Add(hp);
@ -830,7 +830,7 @@ implementation
hp:=texported_item(current_module._exports.first); hp:=texported_item(current_module._exports.first);
while assigned(hp) do while assigned(hp) do
begin begin
if (hp.options and eo_name)<>0 then if eo_name in hp.options then
begin begin
current_asmdata.getjumplabel(name_label); current_asmdata.getjumplabel(name_label);
name_table_pointers.concat(Tai_const.Create_rva_sym(name_label)); name_table_pointers.concat(Tai_const.Create_rva_sym(name_label));

View File

@ -127,7 +127,7 @@ end;
procedure TExportLibWin16.exportprocedure(hp: texported_item); procedure TExportLibWin16.exportprocedure(hp: texported_item);
begin begin
if ((hp.options and eo_index)<>0) and ((hp.index<=0) or (hp.index>$ffff)) then if (eo_index in hp.options) and ((hp.index<=0) or (hp.index>$ffff)) then
begin begin
message1(parser_e_export_invalid_index,tostr(hp.index)); message1(parser_e_export_invalid_index,tostr(hp.index));
exit; exit;
@ -172,9 +172,9 @@ begin
DllExport_COMENT:=TOmfRecord_COMENT.Create; DllExport_COMENT:=TOmfRecord_COMENT.Create;
DllExport_COMENT.CommentClass:=CC_OmfExtension; DllExport_COMENT.CommentClass:=CC_OmfExtension;
expflag:=0; expflag:=0;
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
expflag:=expflag or $80; expflag:=expflag or $80;
if (hp.options and eo_resident)<>0 then if eo_resident in hp.options then
expflag:=expflag or $40; expflag:=expflag or $40;
if assigned(hp.sym) then if assigned(hp.sym) then
case hp.sym.typ of case hp.sym.typ of
@ -188,7 +188,7 @@ begin
else else
internal_name:=hp.name^; internal_name:=hp.name^;
DllExport_COMENT.CommentString:=#2+Chr(expflag)+Chr(Length(hp.name^))+hp.name^+Chr(Length(internal_name))+internal_name; DllExport_COMENT.CommentString:=#2+Chr(expflag)+Chr(Length(hp.name^))+hp.name^+Chr(Length(internal_name))+internal_name;
if (hp.options and eo_index)<>0 then if eo_index in hp.options then
DllExport_COMENT.CommentString:=DllExport_COMENT.CommentString+Chr(Byte(hp.index))+Chr(Byte(hp.index shr 8)); DllExport_COMENT.CommentString:=DllExport_COMENT.CommentString+Chr(Byte(hp.index))+Chr(Byte(hp.index shr 8));
DllExport_COMENT.EncodeTo(RawRecord); DllExport_COMENT.EncodeTo(RawRecord);
RawRecord.WriteTo(ObjWriter); RawRecord.WriteTo(ObjWriter);