+ added external facilities for macpas

This commit is contained in:
olle 2004-07-14 23:19:21 +00:00
parent e35eb9986b
commit 41bdd6178c
4 changed files with 133 additions and 21 deletions

View File

@ -71,7 +71,9 @@ interface
{ mmx } { mmx }
cs_mmx,cs_mmx_saturation, cs_mmx,cs_mmx_saturation,
{ parser } { parser }
cs_typed_addresses,cs_strict_var_strings,cs_ansistrings cs_typed_addresses,cs_strict_var_strings,cs_ansistrings,
{ macpas specific}
cs_external_var, cs_externally_visible
); );
tlocalswitches = set of tlocalswitch; tlocalswitches = set of tlocalswitch;
@ -293,7 +295,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.58 2004-06-20 08:55:29 florian Revision 1.59 2004-07-14 23:19:22 olle
+ added external facilities for macpas
Revision 1.58 2004/06/20 08:55:29 florian
* logs truncated * logs truncated
Revision 1.57 2004/06/16 20:07:07 florian Revision 1.57 2004/06/16 20:07:07 florian

View File

@ -1254,7 +1254,12 @@ begin
consume(_NAME); consume(_NAME);
import_name:=get_stringconst; import_name:=get_stringconst;
tprocdef(pd).setmangledname(import_name); tprocdef(pd).setmangledname(import_name);
end; end
else if (m_mac in aktmodeswitches) and (token=_SEMICOLON) then
begin
{In MacPas a single "external" has the same effect as "external name 'xxx'"}
tprocdef(pd).setmangledname(tprocdef(pd).procsym.realname);
end;
end; end;
end; end;
@ -1908,6 +1913,12 @@ const
var var
res : boolean; res : boolean;
begin begin
if (m_mac in aktmodeswitches) and (cs_externally_visible in aktlocalswitches) then
begin
tprocdef(pd).aliasnames.insert(tprocdef(pd).procsym.realname);
include(pd.procoptions,po_public);
end;
while token in [_ID,_LECKKLAMMER] do while token in [_ID,_LECKKLAMMER] do
begin begin
if try_to_consume(_LECKKLAMMER) then if try_to_consume(_LECKKLAMMER) then
@ -2247,7 +2258,10 @@ const
end. end.
{ {
$Log$ $Log$
Revision 1.182 2004-06-20 08:55:30 florian Revision 1.183 2004-07-14 23:19:21 olle
+ added external facilities for macpas
Revision 1.182 2004/06/20 08:55:30 florian
* logs truncated * logs truncated
Revision 1.181 2004/06/16 20:07:09 florian Revision 1.181 2004/06/16 20:07:09 florian

View File

@ -695,6 +695,7 @@ implementation
unionsym : tvarsym; unionsym : tvarsym;
uniontype : ttype; uniontype : ttype;
dummysymoptions : tsymoptions; dummysymoptions : tsymoptions;
semicolonatend: boolean;
begin begin
old_current_object_option:=current_object_option; old_current_object_option:=current_object_option;
{ all variables are public if not in a object declaration } { all variables are public if not in a object declaration }
@ -764,6 +765,7 @@ implementation
ignore_equal:=false; ignore_equal:=false;
hasdefaultvalue:=false; hasdefaultvalue:=false;
symdone:=false; symdone:=false;
if is_gpc_name then if is_gpc_name then
begin begin
vs:=tvarsym(sc.first); vs:=tvarsym(sc.first);
@ -775,6 +777,7 @@ implementation
include(vs.varoptions,vo_is_external); include(vs.varoptions,vo_is_external);
symdone:=true; symdone:=true;
end; end;
{ check for absolute } { check for absolute }
if not symdone and if not symdone and
(idtoken=_ABSOLUTE) and not(is_record or is_object or is_threadvar) then (idtoken=_ABSOLUTE) and not(is_record or is_object or is_threadvar) then
@ -943,13 +946,18 @@ implementation
end; end;
end; end;
{ Check for variable directives } { Check for EXTERNAL etc directives or, in macpas, if cs_external_var is set}
if not symdone and (token=_ID) then if not symdone and not(is_record or is_object or is_threadvar) then
begin begin
{ Check for C Variable declarations } if (
if (m_cvar_support in aktmodeswitches) and (token=_ID) and
not(is_record or is_object or is_threadvar) and (m_cvar_support in aktmodeswitches) and
(idtoken in [_EXPORT,_EXTERNAL,_PUBLIC,_CVAR]) then (idtoken in [_EXPORT,_EXTERNAL,_PUBLIC,_CVAR])
) or
(
(m_mac in aktmodeswitches) and
((cs_external_var in aktlocalswitches) or (cs_externally_visible in aktlocalswitches))
) then
begin begin
{ only allowed for one var } { only allowed for one var }
vs:=tvarsym(sc.first); vs:=tvarsym(sc.first);
@ -964,6 +972,7 @@ implementation
extern_var:=false; extern_var:=false;
export_var:=false; export_var:=false;
C_name:=sorg; C_name:=sorg;
semicolonatend:= false;
{ cdecl } { cdecl }
if idtoken=_CVAR then if idtoken=_CVAR then
begin begin
@ -977,7 +986,23 @@ implementation
begin begin
consume(_EXTERNAL); consume(_EXTERNAL);
extern_var:=true; extern_var:=true;
semicolonatend:= true;
end; end;
{ macpas specific handling due to some switches}
if (m_mac in aktmodeswitches) then
begin
if (cs_external_var in aktlocalswitches) then
begin {The effect of this is the same as if cvar; external; has been given as directives.}
is_cdecl:=true;
C_name:=target_info.Cprefix+sorg;
extern_var:=true;
end
else if (cs_externally_visible in aktlocalswitches) then
begin {The effect of this is the same as if cvar has been given as directives.}
is_cdecl:=true;
C_name:=target_info.Cprefix+sorg;
end;
end;
{ export } { export }
if idtoken in [_EXPORT,_PUBLIC] then if idtoken in [_EXPORT,_PUBLIC] then
begin begin
@ -986,7 +1011,10 @@ implementation
(symtablestack.symtabletype in [parasymtable,localsymtable]) then (symtablestack.symtabletype in [parasymtable,localsymtable]) then
Message(parser_e_not_external_and_export) Message(parser_e_not_external_and_export)
else else
export_var:=true; begin
export_var:=true;
semicolonatend:= true;
end;
end; end;
{ external and export need a name after when no cdecl is used } { external and export need a name after when no cdecl is used }
if not is_cdecl then if not is_cdecl then
@ -1001,8 +1029,9 @@ implementation
C_name:=get_stringconst; C_name:=get_stringconst;
end; end;
{ consume the ; when export or external is used } { consume the ; when export or external is used }
if extern_var or export_var then if semicolonatend then
consume(_SEMICOLON); consume(_SEMICOLON);
{ set some vars options } { set some vars options }
if is_dll then if is_dll then
include(vs.varoptions,vo_is_dll_var) include(vs.varoptions,vo_is_dll_var)
@ -1042,9 +1071,12 @@ implementation
current_module.Externals.insert(tExternalsItem.create(vs.mangledname)); current_module.Externals.insert(tExternalsItem.create(vs.mangledname));
end; end;
symdone:=true; symdone:=true;
end end;
else end;
if (is_object) and (cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
{ Check for STATIC directive }
if not symdone and (is_object) and
(cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
begin begin
include(current_object_option,sp_static); include(current_object_option,sp_static);
insert_syms(sc,tt,false,dummysymoptions); insert_syms(sc,tt,false,dummysymoptions);
@ -1053,7 +1085,7 @@ implementation
consume(_SEMICOLON); consume(_SEMICOLON);
symdone:=true; symdone:=true;
end; end;
end;
{ insert it in the symtable, if not done yet } { insert it in the symtable, if not done yet }
if not symdone then if not symdone then
begin begin
@ -1082,7 +1114,9 @@ implementation
insert_syms(sc,tt,is_threadvar,dummysymoptions); insert_syms(sc,tt,is_threadvar,dummysymoptions);
current_object_option:=old_current_object_option; current_object_option:=old_current_object_option;
end; end;
end; end;
{ Check for Case } { Check for Case }
if is_record and (token=_CASE) then if is_record and (token=_CASE) then
begin begin
@ -1194,7 +1228,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.75 2004-06-20 08:55:30 florian Revision 1.76 2004-07-14 23:19:22 olle
+ added external facilities for macpas
Revision 1.75 2004/06/20 08:55:30 florian
* logs truncated * logs truncated
Revision 1.74 2004/06/16 20:07:09 florian Revision 1.74 2004/06/16 20:07:09 florian

View File

@ -45,8 +45,10 @@ type
typesw : TSwitchType; typesw : TSwitchType;
setsw : byte; setsw : byte;
end; end;
SwitchRecTable = array['A'..'Z'] of SwitchRec;
const const
SwitchTable:array['A'..'Z'] of SwitchRec=( turboSwitchTable: SwitchRecTable =(
{A} (typesw:unsupportedsw; setsw:ord(cs_localnone)), {A} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{B} (typesw:localsw; setsw:ord(cs_full_boolean_eval)), {B} (typesw:localsw; setsw:ord(cs_full_boolean_eval)),
{C} (typesw:localsw; setsw:ord(cs_do_assertion)), {C} (typesw:localsw; setsw:ord(cs_do_assertion)),
@ -75,7 +77,41 @@ const
{Z} (typesw:illegalsw; setsw:ord(cs_localnone)) {Z} (typesw:illegalsw; setsw:ord(cs_localnone))
); );
macSwitchTable: SwitchRecTable =(
{A} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{B} (typesw:localsw; setsw:ord(cs_full_boolean_eval)),
{C} (typesw:localsw; setsw:ord(cs_do_assertion)),
{D} (typesw:modulesw; setsw:ord(cs_debuginfo)),
{E} (typesw:modulesw; setsw:ord(cs_fp_emulation)),
{F} (typesw:ignoredsw; setsw:ord(cs_localnone)),
{G} (typesw:ignoredsw; setsw:ord(cs_localnone)),
{H} (typesw:localsw; setsw:ord(cs_ansistrings)),
{I} (typesw:localsw; setsw:ord(cs_check_io)),
{J} (typesw:localsw; setsw:ord(cs_external_var)),
{K} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{L} (typesw:modulesw; setsw:ord(cs_local_browser)),
{M} (typesw:localsw; setsw:ord(cs_generate_rtti)),
{N} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{O} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{P} (typesw:modulesw; setsw:ord(cs_openstring)),
{Q} (typesw:localsw; setsw:ord(cs_check_overflow)),
{R} (typesw:localsw; setsw:ord(cs_check_range)),
{S} (typesw:localsw; setsw:ord(cs_check_stack)),
{T} (typesw:localsw; setsw:ord(cs_typed_addresses)),
{U} (typesw:illegalsw; setsw:ord(cs_localnone)),
{V} (typesw:localsw; setsw:ord(cs_strict_var_strings)),
{W} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{X} (typesw:modulesw; setsw:ord(cs_extsyntax)),
{Y} (typesw:modulesw; setsw:ord(cs_browser)),
{Z} (typesw:localsw; setsw:ord(cs_externally_visible))
);
procedure HandleSwitch(switch,state:char); procedure HandleSwitch(switch,state:char);
var
switchTablePtr: ^SwitchRecTable;
begin begin
switch:=upcase(switch); switch:=upcase(switch);
{ Is the Switch in the letters ? } { Is the Switch in the letters ? }
@ -84,8 +120,15 @@ begin
Message(scan_w_illegal_switch); Message(scan_w_illegal_switch);
exit; exit;
end; end;
{ Select switch table }
if m_mac in aktmodeswitches then
switchTablePtr:= @macSwitchTable
else
switchTablePtr:= @turboSwitchTable;
{ Handle the switch } { Handle the switch }
with SwitchTable[switch] do with switchTablePtr^[switch] do
begin begin
case typesw of case typesw of
ignoredsw : Message1(scan_n_ignored_switch,'$'+switch); ignoredsw : Message1(scan_n_ignored_switch,'$'+switch);
@ -134,8 +177,11 @@ end;
function CheckSwitch(switch,state:char):boolean; function CheckSwitch(switch,state:char):boolean;
var var
found : boolean; found : boolean;
switchTablePtr: ^SwitchRecTable;
begin begin
switch:=upcase(switch); switch:=upcase(switch);
{ Is the Switch in the letters ? } { Is the Switch in the letters ? }
@ -145,8 +191,15 @@ begin
CheckSwitch:=false; CheckSwitch:=false;
exit; exit;
end; end;
{ Select switch table }
if m_mac in aktmodeswitches then
switchTablePtr:= @macSwitchTable
else
switchTablePtr:= @turboSwitchTable;
{ Check the switch } { Check the switch }
with SwitchTable[switch] do with switchTablePtr^[switch] do
begin begin
case typesw of case typesw of
localsw : found:=(tlocalswitch(setsw) in aktlocalswitches); localsw : found:=(tlocalswitch(setsw) in aktlocalswitches);
@ -165,7 +218,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.14 2004-06-20 08:55:30 florian Revision 1.15 2004-07-14 23:19:22 olle
+ added external facilities for macpas
Revision 1.14 2004/06/20 08:55:30 florian
* logs truncated * logs truncated
} }