mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-15 12:29:32 +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;
|
function TPas2jsPasScanner.HandleInclude(const Param: String): TToken;
|
||||||
|
|
||||||
procedure SetStr(const s: string);
|
procedure SetStr(s: string);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
h: String;
|
||||||
begin
|
begin
|
||||||
Result:=tkString;
|
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;
|
end;
|
||||||
|
|
||||||
procedure SetInteger(const i: TMaxPrecInt);
|
procedure SetInteger(const i: TMaxPrecInt);
|
||||||
@ -2076,12 +2100,14 @@ begin
|
|||||||
case lowercase(Param) of
|
case lowercase(Param) of
|
||||||
'%date%':
|
'%date%':
|
||||||
begin
|
begin
|
||||||
|
// 'Y/M/D'
|
||||||
DecodeDate(Now,Year,Month,Day);
|
DecodeDate(Now,Year,Month,Day);
|
||||||
SetStr(IntToStr(Year)+'/'+IntToStr(Month)+'/'+IntToStr(Day));
|
SetStr(IntToStr(Year)+'/'+IntToStr(Month)+'/'+IntToStr(Day));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
'%time%':
|
'%time%':
|
||||||
begin
|
begin
|
||||||
|
// 'hh:mm:ss'
|
||||||
DecodeTime(Now,Hour,Minute,Second,MilliSecond);
|
DecodeTime(Now,Hour,Minute,Second,MilliSecond);
|
||||||
SetStr(Format('%2d:%2d:%2d',[Hour,Minute,Second]));
|
SetStr(Format('%2d:%2d:%2d',[Hour,Minute,Second]));
|
||||||
exit;
|
exit;
|
||||||
@ -2102,6 +2128,11 @@ begin
|
|||||||
SetStr(CompilerVersion);
|
SetStr(CompilerVersion);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
'%file%':
|
||||||
|
begin
|
||||||
|
SetStr(CurFilename);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
'%line%':
|
'%line%':
|
||||||
begin
|
begin
|
||||||
SetStr(IntToStr(CurRow));
|
SetStr(IntToStr(CurRow));
|
||||||
|
@ -2274,6 +2274,7 @@ begin
|
|||||||
' s:={$I %pas2jstarget%};',
|
' s:={$I %pas2jstarget%};',
|
||||||
' s:={$I %pas2jstargetos%};',
|
' s:={$I %pas2jstargetos%};',
|
||||||
' s:={$I %pas2jstargetcpu%};',
|
' s:={$I %pas2jstargetcpu%};',
|
||||||
|
' s:={$I %file%};',
|
||||||
'']);
|
'']);
|
||||||
ConvertProgram;
|
ConvertProgram;
|
||||||
CheckSource('TestIncludeVersion',
|
CheckSource('TestIncludeVersion',
|
||||||
@ -2288,6 +2289,7 @@ begin
|
|||||||
'$mod.s = "Browser";',
|
'$mod.s = "Browser";',
|
||||||
'$mod.s = "Browser";',
|
'$mod.s = "Browser";',
|
||||||
'$mod.s = "ECMAScript5";',
|
'$mod.s = "ECMAScript5";',
|
||||||
|
'$mod.s = "test1.pp";',
|
||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2804,7 +2804,9 @@ End.
|
|||||||
<ul>
|
<ul>
|
||||||
<li>%date%: current date as string literal, '[yyyy/mm/dd]'</li>
|
<li>%date%: current date as string literal, '[yyyy/mm/dd]'</li>
|
||||||
<li>%time%: current time as string literal, 'hh:mm:ss'</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>%currentroutine%: name of current routine as string literal</li>
|
||||||
<li>%pas2jstarget%, %pas2jstargetos%, %fpctarget%, %fpctargetos%: target os as string literal, e.g. 'Browser'</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>
|
<li>%pas2jstargetcpu%, %fpctargetcpu%: target cpu as string literal, e.g. 'ECMAScript5'</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user