mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 05:40:20 +02:00
* Faster keyword scanning.
* Import library and smartlink library in one file.
This commit is contained in:
parent
b4fce59bbc
commit
e7013f1efd
@ -259,8 +259,9 @@ const ar_magic:array[1..8] of char='!<arch>'#10;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
seq_no:=1;
|
seq_no:=1;
|
||||||
current_module^.linksharedlibs.insert(s);
|
if not (cs_smartlink in aktmoduleswitches) then
|
||||||
assign(out_file,s+'.ao2');
|
current_module^.linkstaticlibs.insert(s);
|
||||||
|
assign(out_file,current_module^.path^+s+'.ao2');
|
||||||
rewrite(out_file,1);
|
rewrite(out_file,1);
|
||||||
blockwrite(out_file,ar_magic,sizeof(ar_magic));
|
blockwrite(out_file,ar_magic,sizeof(ar_magic));
|
||||||
end;
|
end;
|
||||||
@ -328,7 +329,11 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 1998-06-17 14:10:14 peter
|
Revision 1.5 1998-10-16 14:20:53 daniel
|
||||||
|
* Faster keyword scanning.
|
||||||
|
* Import library and smartlink library in one file.
|
||||||
|
|
||||||
|
Revision 1.4 1998/06/17 14:10:14 peter
|
||||||
* small os2 fixes
|
* small os2 fixes
|
||||||
* fixed interdependent units with newppu (remake3 under linux works now)
|
* fixed interdependent units with newppu (remake3 under linux works now)
|
||||||
|
|
||||||
|
@ -139,6 +139,23 @@ implementation
|
|||||||
{ use any special name that is an invalid file name to avoid problems }
|
{ use any special name that is an invalid file name to avoid problems }
|
||||||
macro_special_name = '____Macro____';
|
macro_special_name = '____Macro____';
|
||||||
|
|
||||||
|
{$ifdef new__is_keyword}
|
||||||
|
function encode(const s:string):longint;
|
||||||
|
|
||||||
|
var i,result:longint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
result:=0;
|
||||||
|
for i:=1 to 6 do
|
||||||
|
begin
|
||||||
|
if length(s)<i then
|
||||||
|
break;
|
||||||
|
result:=result*32+byte(s[i])-65;
|
||||||
|
end;
|
||||||
|
encode:=result;
|
||||||
|
end;
|
||||||
|
{$endif new__is_keyword}
|
||||||
|
|
||||||
procedure create_tokenidx;
|
procedure create_tokenidx;
|
||||||
{ create an index with the first and last token for every possible token
|
{ create an index with the first and last token for every possible token
|
||||||
length, so a search only will be done in that small part }
|
length, so a search only will be done in that small part }
|
||||||
@ -152,11 +169,14 @@ implementation
|
|||||||
if ord(tokenidx[length(tokens[t].str)].first)=0 then
|
if ord(tokenidx[length(tokens[t].str)].first)=0 then
|
||||||
tokenidx[length(tokens[t].str)].first:=t;
|
tokenidx[length(tokens[t].str)].first:=t;
|
||||||
tokenidx[length(tokens[t].str)].last:=t;
|
tokenidx[length(tokens[t].str)].last:=t;
|
||||||
|
{$ifdef new__is_keyword}
|
||||||
|
tokens[t].encoded:=encode(tokens[t].str);
|
||||||
|
{$endif new__is_keyword}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifndef new__is_keyword}
|
||||||
function is_keyword(const s:string):boolean;
|
function is_keyword(const s:string):boolean;
|
||||||
var
|
var
|
||||||
low,high,mid : longint;
|
low,high,mid : longint;
|
||||||
@ -179,6 +199,28 @@ implementation
|
|||||||
is_keyword:=(pattern=tokens[ttoken(high)].str) and
|
is_keyword:=(pattern=tokens[ttoken(high)].str) and
|
||||||
(tokens[ttoken(high)].keyword in aktmodeswitches);
|
(tokens[ttoken(high)].keyword in aktmodeswitches);
|
||||||
end;
|
end;
|
||||||
|
{$else}
|
||||||
|
|
||||||
|
function is_keyword(const s:string):boolean;
|
||||||
|
var
|
||||||
|
encoded,low,high,mid : longint;
|
||||||
|
begin
|
||||||
|
encoded:=encode(s);
|
||||||
|
low:=ord(tokenidx[length(s)].first);
|
||||||
|
high:=ord(tokenidx[length(s)].last);
|
||||||
|
while low<high do
|
||||||
|
begin
|
||||||
|
mid:=(high+low+1) shr 1;
|
||||||
|
if encoded<tokens[ttoken(mid)].encoded then
|
||||||
|
high:=mid-1
|
||||||
|
else
|
||||||
|
low:=mid;
|
||||||
|
end;
|
||||||
|
is_keyword:=(encoded=tokens[ttoken(high)].encoded) and
|
||||||
|
((length(s)<6) or (pattern=tokens[Ttoken(high)].str)) and
|
||||||
|
(tokens[ttoken(high)].keyword in aktmodeswitches);
|
||||||
|
end;
|
||||||
|
{$endif new__is_keyword}
|
||||||
|
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
@ -875,9 +917,12 @@ implementation
|
|||||||
var
|
var
|
||||||
code : integer;
|
code : integer;
|
||||||
low,high,mid,
|
low,high,mid,
|
||||||
l : longint;
|
l : {$ifdef TP} word; {$else} longint; {$endif}
|
||||||
|
m : longint;
|
||||||
mac : pmacrosym;
|
mac : pmacrosym;
|
||||||
asciinr : string[3];
|
asciinr : string[3];
|
||||||
|
encoded : longint;
|
||||||
|
p:^byte;
|
||||||
label
|
label
|
||||||
exit_label;
|
exit_label;
|
||||||
begin
|
begin
|
||||||
@ -929,25 +974,44 @@ implementation
|
|||||||
gettokenpos;
|
gettokenpos;
|
||||||
|
|
||||||
{ Check first for a identifier/keyword, this is 20+% faster (PFV) }
|
{ Check first for a identifier/keyword, this is 20+% faster (PFV) }
|
||||||
if c in ['_','A'..'Z','a'..'z'] then
|
if c in ['A'..'Z','a'..'z','_'] then
|
||||||
begin
|
begin
|
||||||
readstring;
|
readstring;
|
||||||
token:=ID;
|
token:=ID;
|
||||||
idtoken:=ID;
|
idtoken:=ID;
|
||||||
{ keyword or any other known token ? }
|
{ keyword or any other known token ? }
|
||||||
if (length(pattern) in [2..tokenidlen]) then
|
if length(pattern) in [2..tokenidlen] then
|
||||||
begin
|
begin
|
||||||
|
{$ifdef new__is_keyword}
|
||||||
|
encoded:=0;
|
||||||
|
p:=@pattern[1];
|
||||||
|
l:=1;
|
||||||
|
while (length(pattern)>=l) and (l<7) do
|
||||||
|
begin
|
||||||
|
encoded:=encoded*32+p^-65;
|
||||||
|
inc(p);
|
||||||
|
inc(l);
|
||||||
|
end;
|
||||||
|
{$endif new__is_keyword}
|
||||||
low:=ord(tokenidx[length(pattern)].first);
|
low:=ord(tokenidx[length(pattern)].first);
|
||||||
high:=ord(tokenidx[length(pattern)].last);
|
high:=ord(tokenidx[length(pattern)].last);
|
||||||
while low<high do
|
while low<high do
|
||||||
begin
|
begin
|
||||||
mid:=(high+low+1) shr 1;
|
mid:=(high+low+1) shr 1;
|
||||||
|
{$ifndef new__is_keyword}
|
||||||
if pattern<tokens[ttoken(mid)].str then
|
if pattern<tokens[ttoken(mid)].str then
|
||||||
|
{$else}
|
||||||
|
if encoded<tokens[ttoken(mid)].encoded then
|
||||||
|
{$endif new__is_keyword}
|
||||||
high:=mid-1
|
high:=mid-1
|
||||||
else
|
else
|
||||||
low:=mid;
|
low:=mid;
|
||||||
end;
|
end;
|
||||||
|
{$ifndef new__is_token}
|
||||||
if pattern=tokens[ttoken(high)].str then
|
if pattern=tokens[ttoken(high)].str then
|
||||||
|
{$else}
|
||||||
|
if encoded=tokens[ttoken(high)].encoded then
|
||||||
|
{$endif new__is_token}
|
||||||
begin
|
begin
|
||||||
if tokens[ttoken(high)].keyword in aktmodeswitches then
|
if tokens[ttoken(high)].keyword in aktmodeswitches then
|
||||||
token:=ttoken(high);
|
token:=ttoken(high);
|
||||||
@ -1229,11 +1293,11 @@ implementation
|
|||||||
readchar;
|
readchar;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
valint(asciinr,l,code);
|
valint(asciinr,m,code);
|
||||||
if (asciinr='') or (code<>0) or
|
if (asciinr='') or (code<>0) or
|
||||||
(l<0) or (l>255) then
|
(m<0) or (m>255) then
|
||||||
Message(scan_e_illegal_char_const);
|
Message(scan_e_illegal_char_const);
|
||||||
pattern:=pattern+chr(l);
|
pattern:=pattern+chr(m);
|
||||||
end;
|
end;
|
||||||
'''' : begin
|
'''' : begin
|
||||||
repeat
|
repeat
|
||||||
@ -1451,7 +1515,11 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.62 1998-10-15 12:22:23 pierre
|
Revision 1.63 1998-10-16 14:20:57 daniel
|
||||||
|
* Faster keyword scanning.
|
||||||
|
* Import library and smartlink library in one file.
|
||||||
|
|
||||||
|
Revision 1.62 1998/10/15 12:22:23 pierre
|
||||||
* close include files immediately after end reading
|
* close include files immediately after end reading
|
||||||
instead of waiting until unit compilation ended !
|
instead of waiting until unit compilation ended !
|
||||||
|
|
||||||
|
@ -178,6 +178,7 @@ type
|
|||||||
str : string[tokenidlen];
|
str : string[tokenidlen];
|
||||||
special : boolean;
|
special : boolean;
|
||||||
keyword : tmodeswitch;
|
keyword : tmodeswitch;
|
||||||
|
encoded : longint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -333,7 +334,11 @@ const
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 1998-09-30 12:12:30 peter
|
Revision 1.3 1998-10-16 14:21:05 daniel
|
||||||
|
* Faster keyword scanning.
|
||||||
|
* Import library and smartlink library in one file.
|
||||||
|
|
||||||
|
Revision 1.2 1998/09/30 12:12:30 peter
|
||||||
* fixed far,near which are not keywords
|
* fixed far,near which are not keywords
|
||||||
|
|
||||||
Revision 1.1 1998/09/26 17:45:47 peter
|
Revision 1.1 1998/09/26 17:45:47 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user