pastojs: started filer

git-svn-id: trunk@38049 -
This commit is contained in:
Mattias Gaertner 2018-01-26 19:20:25 +00:00
parent ae5e851f7f
commit adbb998377
13 changed files with 249 additions and 6 deletions

2
.gitattributes vendored
View File

@ -6885,6 +6885,7 @@ packages/pastojs/src/fppjssrcmap.pp svneol=native#text/plain
packages/pastojs/src/pas2js_defines.inc svneol=native#text/plain
packages/pastojs/src/pas2jscompiler.pp svneol=native#text/plain
packages/pastojs/src/pas2jsfilecache.pp svneol=native#text/plain
packages/pastojs/src/pas2jsfiler.pp svneol=native#text/plain
packages/pastojs/src/pas2jsfileutils.pp svneol=native#text/plain
packages/pastojs/src/pas2jsfileutilsunix.inc svneol=native#text/plain
packages/pastojs/src/pas2jsfileutilswin.inc svneol=native#text/plain
@ -6892,6 +6893,7 @@ packages/pastojs/src/pas2jslibcompiler.pp svneol=native#text/plain
packages/pastojs/src/pas2jslogger.pp svneol=native#text/plain
packages/pastojs/src/pas2jspparser.pp svneol=native#text/plain
packages/pastojs/tests/tcconverter.pp svneol=native#text/plain
packages/pastojs/tests/tcfiler.pas svneol=native#text/plain
packages/pastojs/tests/tcmodules.pas svneol=native#text/plain
packages/pastojs/tests/tcoptimizations.pas svneol=native#text/plain
packages/pastojs/tests/tcsrcmap.pas svneol=native#text/plain

View File

@ -282,6 +282,7 @@ ToDos:
a:=[];
- bug:
v:=a[0] gives Local variable "a" is assigned but never used
- setlength(dynarray) modeswitch to create a copy
- range checks:
- compile time: warnings to errors
- proc args enum, custom enum, custom int

View File

@ -1,4 +1,17 @@
{ Author: Mattias Gaertner 2017 mattias@freepascal.org
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Abstract:
TPas2jsFileResolver extends TFileResolver and searches source files.

View File

@ -0,0 +1,50 @@
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Abstract:
Write and read a precompiled module.
Store whole unit, except all
procedure declarations, proc bodies, finalization/initialization sections are
replaced by
-precompiled code
-lists of references
-local consts
The useanalyzer needs the references - TPas2jsUseAnalyzer.
Due to uses cycles, ability to stop read interface
ReadContinueImplementation
}
unit Pas2JsFiler;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FPPas2Js, PasResolver, PasTree;
type
TPasToJsFiler = class
public
constructor Create; virtual;
destructor Destroy; override;
procedure WriteModule(aResolver: TPasResolver);
end;
implementation
end.

View File

@ -1,4 +1,17 @@
{ Author: Mattias Gaertner 2017 mattias@freepascal.org
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Abstract:
Low level file path handling.

View File

@ -1,4 +1,19 @@
{%MainUnit pas2jsfileutils.pas}
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
}
function FilenameIsAbsolute(const aFilename: string): boolean;
begin

View File

@ -1,5 +1,19 @@
{%MainUnit pas2jsfileutils.pas}
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
}
{$IF DEFINED(UTF8_RTL) AND NOT DEFINED(WINCE)}
{$DEFINE ArgsWAsUTF8}
{$ENDIF}

View File

@ -1,3 +1,18 @@
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Michael Van Canneyt
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
}
unit pas2jslibcompiler;
{$mode objfpc}

View File

@ -1,4 +1,17 @@
{ Author: Mattias Gaertner 2017 mattias@freepascal.org
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Abstract:
Logging to stdout or file.

View File

@ -1,4 +1,17 @@
{ Author: Mattias Gaertner 2017 mattias@freepascal.org
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
Pascal to Javascript converter class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Abstract:
Extends the FCL Pascal parser for the language subset of pas2js.

View File

@ -0,0 +1,85 @@
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2014 by Michael Van Canneyt
Unit tests for Pascal-to-Javascript precompile class.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************
Examples:
./testpas2js --suite=TTestPrecompile.TestPC_EmptyUnit
}
unit tcfiler;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testregistry,
PasTree, PScanner, PasResolver,
FPPas2Js,
tcmodules;
type
{ TCustomTestPrecompile }
TCustomTestPrecompile = Class(TCustomTestModule)
protected
procedure SetUp; override;
procedure TearDown; override;
procedure WriteUnit; virtual;
public
end;
{ TTestPrecompile }
TTestPrecompile = class(TCustomTestPrecompile)
published
procedure TestPC_EmptyUnit;
end;
implementation
{ TCustomTestPrecompile }
procedure TCustomTestPrecompile.SetUp;
begin
inherited SetUp;
end;
procedure TCustomTestPrecompile.TearDown;
begin
inherited TearDown;
end;
procedure TCustomTestPrecompile.WriteUnit;
begin
end;
{ TTestPrecompile }
procedure TTestPrecompile.TestPC_EmptyUnit;
begin
StartUnit(false);
Add('interface');
Add('implementation');
ConvertUnit;
WriteUnit;
end;
Initialization
RegisterTests([TTestPrecompile]);
end.

View File

@ -32,7 +32,7 @@
<PackageName Value="FCL"/>
</Item2>
</RequiredPackages>
<Units Count="7">
<Units Count="9">
<Unit0>
<Filename Value="testpas2js.pp"/>
<IsPartOfProject Value="True"/>
@ -63,6 +63,14 @@
<IsPartOfProject Value="True"/>
<UnitName Value="FPPJsSrcMap"/>
</Unit6>
<Unit7>
<Filename Value="tcfiler.pas"/>
<IsPartOfProject Value="True"/>
</Unit7>
<Unit8>
<Filename Value="../src/pas2jsfiler.pas"/>
<IsPartOfProject Value="True"/>
</Unit8>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -17,7 +17,8 @@ program testpas2js;
{$mode objfpc}{$H+}
uses
Classes, consoletestrunner, tcconverter, tcmodules, tcoptimizations, tcsrcmap;
Classes, consoletestrunner, tcconverter, tcmodules, tcoptimizations, tcsrcmap,
tcfiler, pas2jsfiler;
type