mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-12 06:09:22 +02:00
pastojs: added $i %file%
git-svn-id: trunk@40487 -
This commit is contained in:
parent
a82e5bab50
commit
58e50ef07e
@ -2054,10 +2054,34 @@ end;
|
||||
|
||||
function TPas2jsPasScanner.HandleInclude(const Param: String): TToken;
|
||||
|
||||
procedure SetStr(const s: string);
|
||||
procedure SetStr(s: string);
|
||||
var
|
||||
i: Integer;
|
||||
h: String;
|
||||
begin
|
||||
Result:=tkString;
|
||||
SetCurTokenString(''''+s+'''');
|
||||
if s='' then
|
||||
s:=''''''
|
||||
else
|
||||
for i:=length(s) downto 1 do
|
||||
case s[i] of
|
||||
#0..#31,#127:
|
||||
begin
|
||||
h:='#'+IntToStr(ord(s[i]));
|
||||
if i>1 then h:=''''+h;
|
||||
if (i<length(s)) and (s[i+1]<>'#') then
|
||||
h:=h+'''';
|
||||
s:=LeftStr(s,i-1)+h+copy(s,i+1,length(s));
|
||||
end;
|
||||
else
|
||||
if i=length(s) then
|
||||
s:=s+'''';
|
||||
if s[i]='''' then
|
||||
Insert('''',s,i);
|
||||
if i=1 then
|
||||
s:=''''+s;
|
||||
end;
|
||||
SetCurTokenString(s);
|
||||
end;
|
||||
|
||||
procedure SetInteger(const i: TMaxPrecInt);
|
||||
@ -2076,12 +2100,14 @@ begin
|
||||
case lowercase(Param) of
|
||||
'%date%':
|
||||
begin
|
||||
// 'Y/M/D'
|
||||
DecodeDate(Now,Year,Month,Day);
|
||||
SetStr(IntToStr(Year)+'/'+IntToStr(Month)+'/'+IntToStr(Day));
|
||||
exit;
|
||||
end;
|
||||
'%time%':
|
||||
begin
|
||||
// 'hh:mm:ss'
|
||||
DecodeTime(Now,Hour,Minute,Second,MilliSecond);
|
||||
SetStr(Format('%2d:%2d:%2d',[Hour,Minute,Second]));
|
||||
exit;
|
||||
@ -2102,6 +2128,11 @@ begin
|
||||
SetStr(CompilerVersion);
|
||||
exit;
|
||||
end;
|
||||
'%file%':
|
||||
begin
|
||||
SetStr(CurFilename);
|
||||
exit;
|
||||
end;
|
||||
'%line%':
|
||||
begin
|
||||
SetStr(IntToStr(CurRow));
|
||||
|
@ -2274,6 +2274,7 @@ begin
|
||||
' s:={$I %pas2jstarget%};',
|
||||
' s:={$I %pas2jstargetos%};',
|
||||
' s:={$I %pas2jstargetcpu%};',
|
||||
' s:={$I %file%};',
|
||||
'']);
|
||||
ConvertProgram;
|
||||
CheckSource('TestIncludeVersion',
|
||||
@ -2288,6 +2289,7 @@ begin
|
||||
'$mod.s = "Browser";',
|
||||
'$mod.s = "Browser";',
|
||||
'$mod.s = "ECMAScript5";',
|
||||
'$mod.s = "test1.pp";',
|
||||
'']));
|
||||
end;
|
||||
|
||||
|
@ -2804,7 +2804,9 @@ End.
|
||||
<ul>
|
||||
<li>%date%: current date as string literal, '[yyyy/mm/dd]'</li>
|
||||
<li>%time%: current time as string literal, 'hh:mm:ss'</li>
|
||||
<li>%line%: current source line number as string literal, e.g. '123'</li>
|
||||
<li>%file%: current source filename as string literal, e.g. <i>'unit1.pas'</i></li>
|
||||
<li>%line%: current source line number as string literal, e.g. <i>'123'</i></li>
|
||||
<li>%linenum%: current source line number as integer, e.g. <i>123</i></li>
|
||||
<li>%currentroutine%: name of current routine as string literal</li>
|
||||
<li>%pas2jstarget%, %pas2jstargetos%, %fpctarget%, %fpctargetos%: target os as string literal, e.g. 'Browser'</li>
|
||||
<li>%pas2jstargetcpu%, %fpctargetcpu%: target cpu as string literal, e.g. 'ECMAScript5'</li>
|
||||
|
Loading…
Reference in New Issue
Block a user