Browse Source

pastojs: added $i %linenum%

git-svn-id: trunk@40486 -
Mattias Gaertner 6 years ago
parent
commit
a82e5bab50
2 changed files with 19 additions and 2 deletions
  1. 11 0
      packages/pastojs/src/fppas2js.pp
  2. 8 2
      packages/pastojs/tests/tcmodules.pas

+ 11 - 0
packages/pastojs/src/fppas2js.pp

@@ -2060,6 +2060,12 @@ function TPas2jsPasScanner.HandleInclude(const Param: String): TToken;
     SetCurTokenString(''''+s+'''');
     SetCurTokenString(''''+s+'''');
   end;
   end;
 
 
+  procedure SetInteger(const i: TMaxPrecInt);
+  begin
+    Result:=tkNumber;
+    SetCurTokenString(IntToStr(i));
+  end;
+
 var
 var
   Year, Month, Day, Hour, Minute, Second, MilliSecond: word;
   Year, Month, Day, Hour, Minute, Second, MilliSecond: word;
   i: Integer;
   i: Integer;
@@ -2101,6 +2107,11 @@ begin
         SetStr(IntToStr(CurRow));
         SetStr(IntToStr(CurRow));
         exit;
         exit;
       end;
       end;
+    '%linenum%':
+      begin
+        SetInteger(CurRow);
+        exit;
+      end;
     '%currentroutine%':
     '%currentroutine%':
       begin
       begin
         if Resolver<>nil then
         if Resolver<>nil then

+ 8 - 2
packages/pastojs/tests/tcmodules.pas

@@ -2263,9 +2263,12 @@ procedure TTestModule.TestIncludeVersion;
 begin
 begin
   StartProgram(false);
   StartProgram(false);
   Add([
   Add([
-  'var s: string;',
+  'var',
+  '  s: string;',
+  '  i: word;',
   'begin',
   'begin',
   '  s:={$I %line%};',
   '  s:={$I %line%};',
+  '  i:={$I %linenum%};',
   '  s:={$I %currentroutine%};',
   '  s:={$I %currentroutine%};',
   '  s:={$I %pas2jsversion%};',
   '  s:={$I %pas2jsversion%};',
   '  s:={$I %pas2jstarget%};',
   '  s:={$I %pas2jstarget%};',
@@ -2274,9 +2277,12 @@ begin
   '']);
   '']);
   ConvertProgram;
   ConvertProgram;
   CheckSource('TestIncludeVersion',
   CheckSource('TestIncludeVersion',
+    LinesToStr([
     'this.s="";',
     'this.s="";',
+    'this.i = 0;']),
     LinesToStr([
     LinesToStr([
-    '$mod.s = "5";',
+    '$mod.s = "7";',
+    '$mod.i = 8;',
     '$mod.s = "<anonymous>";',
     '$mod.s = "<anonymous>";',
     '$mod.s = "Comp.Ver.tcmodules";',
     '$mod.s = "Comp.Ver.tcmodules";',
     '$mod.s = "Browser";',
     '$mod.s = "Browser";',