[Pas2js] Directive {$I %LINE%} - Feature request

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Jan 25 22:24:01 CET 2018


On Thu, 25 Jan 2018 14:32:43 -0600 (CST)
warleyalex via Pas2js <pas2js at lists.freepascal.org> wrote:

> >   Function GetCurrentLineNumber: String;
> >   begin
> >     Result := {$I %LINE%};
> >   end;  
> 
> It doesn't make sense to me either.
> ---------
> 
> In Smart Pascal compiler, If we check this Compiler options "[ x ] Emit
> source locations"
> the compiler will emit a verbose JS with source locations. 

Do you mean as comments in the JS?
I guess pas2js does not need that, as its code has pretty much the same
structure and identifiers as the Pascal files and source maps are so
comfortable.

 
> procedure TTest001.CheckRomanNumber;
> begin
>   Equal('DCLXVI', FField, 'an error has occurred at '+{$I %FUNCTION%} + '
> line: '+{$I %LINE%});
> end;
> 
> will emit this verbose JS:
> -------------------------------------------------------------------------------------
> /// procedure TTest001.CheckRomanNumber()
> ///  [line: 87, column: 4, file: TestFramework]
>  CheckRomanNumber:function(Self) {
>       TAbstractTestCase.Equal$2(Self,"DCLXVI",Self.FField,"an error has
> occurred at   
>                                             "+"TTest001.CheckRomanNumber"+"
> line: "+"89");
> }
> -------------------------------------------------------------------------------------
> Pas2JS could have this feature.

Implementing the fpc include macros is planned. Although it has low
priority for me. 
It's open source, so patches are welcome. :)


Mattias


More information about the Pas2js mailing list