+ 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 }
cs_mmx,cs_mmx_saturation,
{ 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;
@ -293,7 +295,10 @@ implementation
end.
{
$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
Revision 1.57 2004/06/16 20:07:07 florian

View File

@ -1254,7 +1254,12 @@ begin
consume(_NAME);
import_name:=get_stringconst;
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;
@ -1908,6 +1913,12 @@ const
var
res : boolean;
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
begin
if try_to_consume(_LECKKLAMMER) then
@ -2247,7 +2258,10 @@ const
end.
{
$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
Revision 1.181 2004/06/16 20:07:09 florian

View File

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

View File

@ -45,8 +45,10 @@ type
typesw : TSwitchType;
setsw : byte;
end;
SwitchRecTable = array['A'..'Z'] of SwitchRec;
const
SwitchTable:array['A'..'Z'] of SwitchRec=(
turboSwitchTable: 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)),
@ -75,7 +77,41 @@ const
{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);
var
switchTablePtr: ^SwitchRecTable;
begin
switch:=upcase(switch);
{ Is the Switch in the letters ? }
@ -84,8 +120,15 @@ begin
Message(scan_w_illegal_switch);
exit;
end;
{ Select switch table }
if m_mac in aktmodeswitches then
switchTablePtr:= @macSwitchTable
else
switchTablePtr:= @turboSwitchTable;
{ Handle the switch }
with SwitchTable[switch] do
with switchTablePtr^[switch] do
begin
case typesw of
ignoredsw : Message1(scan_n_ignored_switch,'$'+switch);
@ -134,8 +177,11 @@ end;
function CheckSwitch(switch,state:char):boolean;
var
found : boolean;
switchTablePtr: ^SwitchRecTable;
begin
switch:=upcase(switch);
{ Is the Switch in the letters ? }
@ -145,8 +191,15 @@ begin
CheckSwitch:=false;
exit;
end;
{ Select switch table }
if m_mac in aktmodeswitches then
switchTablePtr:= @macSwitchTable
else
switchTablePtr:= @turboSwitchTable;
{ Check the switch }
with SwitchTable[switch] do
with switchTablePtr^[switch] do
begin
case typesw of
localsw : found:=(tlocalswitch(setsw) in aktlocalswitches);
@ -165,7 +218,10 @@ end;
end.
{
$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
}