+ va_list for printf support

This commit is contained in:
peter 1998-11-09 11:44:33 +00:00
parent 0d5d65e6bb
commit 20188aa991
5 changed files with 141 additions and 97 deletions

View File

@ -173,7 +173,8 @@ implementation
end
else
begin
if not(p^.left^.location.loc in [LOC_MEM,LOC_REFERENCE]) then
if (defcoll^.paratyp<>vs_va_list) and
not(p^.left^.location.loc in [LOC_MEM,LOC_REFERENCE]) then
CGMessage(type_e_mismatch)
else
begin
@ -639,7 +640,12 @@ implementation
falselabel:=oflabel;
{ push from right to left }
if not push_from_left_to_right and assigned(p^.right) then
secondcallparan(p^.right,defcoll^.next,push_from_left_to_right,inlined,para_offset);
begin
if defcoll^.paratyp=vs_va_list then
secondcallparan(p^.right,defcoll,push_from_left_to_right,inlined,para_offset)
else
secondcallparan(p^.right,defcoll^.next,push_from_left_to_right,inlined,para_offset);
end;
end;
@ -1515,7 +1521,10 @@ implementation
end.
{
$Log$
Revision 1.38 1998-10-21 15:12:49 pierre
Revision 1.39 1998-11-09 11:44:33 peter
+ va_list for printf support
Revision 1.38 1998/10/21 15:12:49 pierre
* bug fix for IOCHECK inside a procedure with iocheck modifier
* removed the GPF for unexistant overloading
(firstcall was called with procedinition=nil !)

View File

@ -97,6 +97,7 @@ begin
p^.insert(new(ptypesym,init('word',u16bitdef)));
p^.insert(new(ptypesym,init('boolean',booldef)));
p^.insert(new(ptypesym,init('void_pointer',voidpointerdef)));
p^.insert(new(ptypesym,init('char_pointer',charpointerdef)));
p^.insert(new(ptypesym,init('file',cfiledef)));
{$ifdef i386}
p^.insert(new(ptypesym,init('REAL',new(pfloatdef,init(s64real)))));
@ -189,6 +190,7 @@ begin
u16bitdef:=porddef(globaldef('word'));
booldef:=porddef(globaldef('boolean'));
voidpointerdef:=ppointerdef(globaldef('void_pointer'));
charpointerdef:=ppointerdef(globaldef('char_pointer'));
cfiledef:=pfiledef(globaldef('file'));
end;
@ -229,6 +231,7 @@ begin
s32fixeddef:=new(pfloatdef,init(f32bit));
{ some other definitions }
voidpointerdef:=new(ppointerdef,init(voiddef));
charpointerdef:=new(ppointerdef,init(cchardef));
cfiledef:=new(pfiledef,init(ft_untyped,nil));
registerdef:=oldregisterdef;
end;
@ -237,7 +240,10 @@ end;
end.
{
$Log$
Revision 1.9 1998-11-05 12:02:54 peter
Revision 1.10 1998-11-09 11:44:36 peter
+ va_list for printf support
Revision 1.9 1998/11/05 12:02:54 peter
* released useansistring
* removed -Sv, its now available in fpc modes

View File

@ -94,7 +94,7 @@
targconvtyp = (act_convertable,act_equal,act_exact);
tvarspez = (vs_value,vs_const,vs_var);
tvarspez = (vs_value,vs_const,vs_var,vs_va_list);
pdefcoll = ^tdefcoll;
tdefcoll = record
@ -483,7 +483,10 @@
{
$Log$
Revision 1.7 1998-11-05 12:02:59 peter
Revision 1.8 1998-11-09 11:44:37 peter
+ va_list for printf support
Revision 1.7 1998/11/05 12:02:59 peter
* released useansistring
* removed -Sv, its now available in fpc modes

View File

@ -66,7 +66,12 @@ implementation
if defcoll=nil then
firstcallparan(p^.right,nil)
else
firstcallparan(p^.right,defcoll^.next);
begin
if defcoll^.paratyp=vs_va_list then
firstcallparan(p^.right,defcoll)
else
firstcallparan(p^.right,defcoll^.next);
end;
p^.registers32:=p^.right^.registers32;
p^.registersfpu:=p^.right^.registersfpu;
{$ifdef SUPPORT_MMX}
@ -97,7 +102,7 @@ implementation
store_valid:=must_be_valid;
if (defcoll^.paratyp=vs_var) then
test_protected(p^.left);
if (defcoll^.paratyp<>vs_var) then
if not(defcoll^.paratyp in [vs_var,vs_va_list]) then
must_be_valid:=true
else
must_be_valid:=false;
@ -180,6 +185,13 @@ implementation
(defcoll^.paratyp=vs_var) and
not(is_equal(p^.left^.resulttype,defcoll^.data)) then
CGMessage(type_e_strict_var_string_violation);
{ va_list always uses pchars }
if (defcoll^.paratyp=vs_va_list) and
is_shortstring(p^.left^.resulttype) then
begin
p^.left:=gentypeconvnode(p^.left,charpointerdef);
firstpass(p^.left);
end;
{ Variablen, die call by reference <20>bergeben werden, }
{ k”nnen nicht in ein Register kopiert werden }
{ is this usefull here ? }
@ -190,7 +202,8 @@ implementation
make_not_regable(p^.left);
end;
p^.resulttype:=defcoll^.data;
if defcoll^.paratyp<>vs_va_list then
p^.resulttype:=defcoll^.data;
end;
if p^.left^.registers32>p^.registers32 then
p^.registers32:=p^.left^.registers32;
@ -434,7 +447,7 @@ implementation
pdc:=pdc^.next;
end;
{ only when the # of parameter are equal }
if l=paralength then
if (l=paralength) or ((l=1) and (pd^.para1^.paratyp=vs_va_list)) then
begin
new(hp);
hp^.data:=pd;
@ -459,92 +472,97 @@ implementation
end;
{ now we can compare parameter after parameter }
pt:=p^.left;
while assigned(pt) do
begin
{ matches a parameter of one procedure exact ? }
exactmatch:=false;
hp:=procs;
while assigned(hp) do
begin
if is_equal(hp^.nextpara^.data,pt^.resulttype) then
begin
if hp^.nextpara^.data=pt^.resulttype then
begin
pt^.exact_match_found:=true;
hp^.nextpara^.argconvtyp:=act_exact;
end
else
hp^.nextpara^.argconvtyp:=act_equal;
exactmatch:=true;
end
else
hp^.nextpara^.argconvtyp:=act_convertable;
hp:=hp^.next;
end;
if assigned(procs) and
(not assigned(procs^.nextpara) or
(procs^.nextpara^.paratyp<>vs_va_list)) then
begin
pt:=p^.left;
while assigned(pt) do
begin
{ matches a parameter of one procedure exact ? }
exactmatch:=false;
hp:=procs;
while assigned(hp) do
begin
if is_equal(hp^.nextpara^.data,pt^.resulttype) then
begin
if hp^.nextpara^.data=pt^.resulttype then
begin
pt^.exact_match_found:=true;
hp^.nextpara^.argconvtyp:=act_exact;
end
else
hp^.nextpara^.argconvtyp:=act_equal;
exactmatch:=true;
end
else
hp^.nextpara^.argconvtyp:=act_convertable;
hp:=hp^.next;
end;
{ .... if yes, del all the other procedures }
if exactmatch then
begin
{ the first .... }
while (assigned(procs)) and not(is_equal(procs^.nextpara^.data,pt^.resulttype)) do
begin
hp:=procs^.next;
dispose(procs);
procs:=hp;
end;
{ and the others }
hp:=procs;
while (assigned(hp)) and assigned(hp^.next) do
begin
if not(is_equal(hp^.next^.nextpara^.data,pt^.resulttype)) then
begin
hp2:=hp^.next^.next;
dispose(hp^.next);
hp^.next:=hp2;
end
else
hp:=hp^.next;
end;
end
{ when a parameter matches exact, remove all procs
which need typeconvs }
else
begin
{ the first... }
while (assigned(procs)) and
not(isconvertable(pt^.resulttype,procs^.nextpara^.data,
hcvt,pt^.left^.treetype,false)) do
begin
hp:=procs^.next;
dispose(procs);
procs:=hp;
end;
{ and the others }
hp:=procs;
while (assigned(hp)) and assigned(hp^.next) do
begin
if not(isconvertable(pt^.resulttype,hp^.next^.nextpara^.data,
hcvt,pt^.left^.treetype,false)) then
begin
hp2:=hp^.next^.next;
dispose(hp^.next);
hp^.next:=hp2;
end
else
hp:=hp^.next;
end;
end;
{ update nextpara for all procedures }
hp:=procs;
while assigned(hp) do
begin
hp^.nextpara:=hp^.nextpara^.next;
hp:=hp^.next;
end;
{ load next parameter }
pt:=pt^.right;
end;
{ .... if yes, del all the other procedures }
if exactmatch then
begin
{ the first .... }
while (assigned(procs)) and not(is_equal(procs^.nextpara^.data,pt^.resulttype)) do
begin
hp:=procs^.next;
dispose(procs);
procs:=hp;
end;
{ and the others }
hp:=procs;
while (assigned(hp)) and assigned(hp^.next) do
begin
if not(is_equal(hp^.next^.nextpara^.data,pt^.resulttype)) then
begin
hp2:=hp^.next^.next;
dispose(hp^.next);
hp^.next:=hp2;
end
else
hp:=hp^.next;
end;
end
{ when a parameter matches exact, remove all procs
which need typeconvs }
else
begin
{ the first... }
while (assigned(procs)) and
not(isconvertable(pt^.resulttype,procs^.nextpara^.data,
hcvt,pt^.left^.treetype,false)) do
begin
hp:=procs^.next;
dispose(procs);
procs:=hp;
end;
{ and the others }
hp:=procs;
while (assigned(hp)) and assigned(hp^.next) do
begin
if not(isconvertable(pt^.resulttype,hp^.next^.nextpara^.data,
hcvt,pt^.left^.treetype,false)) then
begin
hp2:=hp^.next^.next;
dispose(hp^.next);
hp^.next:=hp2;
end
else
hp:=hp^.next;
end;
end;
{ update nextpara for all procedures }
hp:=procs;
while assigned(hp) do
begin
hp^.nextpara:=hp^.nextpara^.next;
hp:=hp^.next;
end;
{ load next parameter }
pt:=pt^.right;
end;
end;
if not assigned(procs) then
begin
@ -924,7 +942,10 @@ implementation
end.
{
$Log$
Revision 1.9 1998-10-28 18:26:22 pierre
Revision 1.10 1998-11-09 11:44:41 peter
+ va_list for printf support
Revision 1.9 1998/10/28 18:26:22 pierre
* removed some erros after other errors (introduced by useexcept)
* stabs works again correctly (for how long !)

View File

@ -149,6 +149,7 @@ type
_LIBRARY,
_PRIVATE,
_PROGRAM,
_VA_LIST,
_VIRTUAL,
_ABSOLUTE,
_ABSTRACT,
@ -307,6 +308,7 @@ const
(str:'LIBRARY' ;special:false;keyword:m_all),
(str:'PRIVATE' ;special:false;keyword:m_none),
(str:'PROGRAM' ;special:false;keyword:m_all),
(str:'VA_LIST' ;special:false;keyword:m_fpc),
(str:'VIRTUAL' ;special:false;keyword:m_none),
(str:'ABSOLUTE' ;special:false;keyword:m_none),
(str:'ABSTRACT' ;special:false;keyword:m_none),
@ -334,7 +336,10 @@ const
{
$Log$
Revision 1.3 1998-10-16 14:21:05 daniel
Revision 1.4 1998-11-09 11:44:42 peter
+ va_list for printf support
Revision 1.3 1998/10/16 14:21:05 daniel
* Faster keyword scanning.
* Import library and smartlink library in one file.