mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 10:45:08 +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
|
||||
seq_no:=1;
|
||||
current_module^.linksharedlibs.insert(s);
|
||||
assign(out_file,s+'.ao2');
|
||||
if not (cs_smartlink in aktmoduleswitches) then
|
||||
current_module^.linkstaticlibs.insert(s);
|
||||
assign(out_file,current_module^.path^+s+'.ao2');
|
||||
rewrite(out_file,1);
|
||||
blockwrite(out_file,ar_magic,sizeof(ar_magic));
|
||||
end;
|
||||
@ -328,7 +329,11 @@ end.
|
||||
|
||||
{
|
||||
$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
|
||||
* 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 }
|
||||
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;
|
||||
{ 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 }
|
||||
@ -152,11 +169,14 @@ implementation
|
||||
if ord(tokenidx[length(tokens[t].str)].first)=0 then
|
||||
tokenidx[length(tokens[t].str)].first:=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;
|
||||
|
||||
|
||||
{$ifndef new__is_keyword}
|
||||
function is_keyword(const s:string):boolean;
|
||||
var
|
||||
low,high,mid : longint;
|
||||
@ -179,6 +199,28 @@ implementation
|
||||
is_keyword:=(pattern=tokens[ttoken(high)].str) and
|
||||
(tokens[ttoken(high)].keyword in aktmodeswitches);
|
||||
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
|
||||
code : integer;
|
||||
low,high,mid,
|
||||
l : longint;
|
||||
l : {$ifdef TP} word; {$else} longint; {$endif}
|
||||
m : longint;
|
||||
mac : pmacrosym;
|
||||
asciinr : string[3];
|
||||
encoded : longint;
|
||||
p:^byte;
|
||||
label
|
||||
exit_label;
|
||||
begin
|
||||
@ -929,25 +974,44 @@ implementation
|
||||
gettokenpos;
|
||||
|
||||
{ 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
|
||||
readstring;
|
||||
token:=ID;
|
||||
idtoken:=ID;
|
||||
{ keyword or any other known token ? }
|
||||
if (length(pattern) in [2..tokenidlen]) then
|
||||
if length(pattern) in [2..tokenidlen] then
|
||||
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);
|
||||
high:=ord(tokenidx[length(pattern)].last);
|
||||
while low<high do
|
||||
begin
|
||||
mid:=(high+low+1) shr 1;
|
||||
{$ifndef new__is_keyword}
|
||||
if pattern<tokens[ttoken(mid)].str then
|
||||
{$else}
|
||||
if encoded<tokens[ttoken(mid)].encoded then
|
||||
{$endif new__is_keyword}
|
||||
high:=mid-1
|
||||
else
|
||||
low:=mid;
|
||||
end;
|
||||
{$ifndef new__is_token}
|
||||
if pattern=tokens[ttoken(high)].str then
|
||||
{$else}
|
||||
if encoded=tokens[ttoken(high)].encoded then
|
||||
{$endif new__is_token}
|
||||
begin
|
||||
if tokens[ttoken(high)].keyword in aktmodeswitches then
|
||||
token:=ttoken(high);
|
||||
@ -1229,11 +1293,11 @@ implementation
|
||||
readchar;
|
||||
end;
|
||||
end;
|
||||
valint(asciinr,l,code);
|
||||
valint(asciinr,m,code);
|
||||
if (asciinr='') or (code<>0) or
|
||||
(l<0) or (l>255) then
|
||||
(m<0) or (m>255) then
|
||||
Message(scan_e_illegal_char_const);
|
||||
pattern:=pattern+chr(l);
|
||||
pattern:=pattern+chr(m);
|
||||
end;
|
||||
'''' : begin
|
||||
repeat
|
||||
@ -1451,7 +1515,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$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
|
||||
instead of waiting until unit compilation ended !
|
||||
|
||||
|
@ -178,6 +178,7 @@ type
|
||||
str : string[tokenidlen];
|
||||
special : boolean;
|
||||
keyword : tmodeswitch;
|
||||
encoded : longint;
|
||||
end;
|
||||
|
||||
const
|
||||
@ -333,7 +334,11 @@ const
|
||||
|
||||
{
|
||||
$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
|
||||
|
||||
Revision 1.1 1998/09/26 17:45:47 peter
|
||||
|
Loading…
Reference in New Issue
Block a user