mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-06 15:07:27 +01:00
pastojs: started filer
git-svn-id: trunk@38049 -
This commit is contained in:
parent
ae5e851f7f
commit
adbb998377
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
50
packages/pastojs/src/pas2jsfiler.pp
Normal file
50
packages/pastojs/src/pas2jsfiler.pp
Normal 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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
85
packages/pastojs/tests/tcfiler.pas
Normal file
85
packages/pastojs/tests/tcfiler.pas
Normal 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.
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user