* Fix compilation

git-svn-id: trunk@36817 -
This commit is contained in:
michael 2017-08-02 11:11:54 +00:00
parent 1729d6a848
commit cccff83bab
2 changed files with 21 additions and 61 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<Version Value="10"/>
<General>
<Flags>
<SaveOnlyProjectUnits Value="True"/>
@ -19,9 +19,6 @@
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
@ -37,12 +34,10 @@
<Unit0>
<Filename Value="pas2js.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pas2js"/>
</Unit0>
<Unit1>
<Filename Value="fppas2js.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fppas2js"/>
</Unit1>
</Units>
</ProjectOptions>
@ -55,12 +50,6 @@
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -18,79 +18,50 @@
program pas2js;
uses
sysutils, classes, pparser, fppas2js, pastree, jstree, jswriter;
sysutils, classes, pparser, fppas2js, pastree, jstree, jswriter, pasresolver;
Type
{ TContainer }
TContainer = Class(TPasTreeContainer)
public
function CreateElement(AClass: TPTreeElement; const AName: String;
AParent: TPasElement; AVisibility: TPasMemberVisibility;
const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
overload; override;
function FindElement(const AName: String): TPasElement; override;
end;
{ TConvertPascal }
TConvertPascal = Class(TComponent)
Procedure ConvertSource(ASource, ADest : String);
end;
{ TContainer }
function TContainer.CreateElement(AClass: TPTreeElement; const AName: String;
AParent: TPasElement; AVisibility: TPasMemberVisibility;
const ASourceFilename: String; ASourceLinenumber: Integer): TPasElement;
begin
Result:=AClass.Create(AName,AParent);
end;
function TContainer.FindElement(const AName: String): TPasElement;
begin
Result:=Nil;
end;
{ TConvertPascal }
Procedure TConvertPascal.ConvertSource(ASource, ADest: String);
Var
p : TPasParser;
C : TPAsTreeContainer;
C : TPas2JSResolver;
M : TPasModule;
CV : TPasToJSConverter;
JS : TJSElement;
W : TJSWriter;
begin
C:=TContainer.Create;
W:=nil;
M:=Nil;
CV:=Nil;
C:=TPas2JSResolver.Create;
try
M:=ParseSource(C,ASource,'','',True);
try
CV:=TPasToJSConverter.Create;
try
JS:=CV.ConvertElement(M);
If JS=nil then
Writeln('No result');
finally
CV.Free;
end;
M:=ParseSource(C,ASource,'','',[poUseStreams]);
CV:=TPasToJSConverter.Create;
JS:=CV.ConvertPasElement(M,C);
If JS=nil then
Writeln('No result')
else
begin
W:=TJSWriter.Create(ADest);
try
W.Options:=[woUseUTF8,woCompactArrayLiterals,woCompactObjectLiterals,woCompactArguments];
W.IndentSize:=2;
W.WriteJS(JS);
finally
W.Free;
end;
finally
M.Free;
end;
W.Options:=[woUseUTF8,woCompactArrayLiterals,woCompactObjectLiterals,woCompactArguments];
W.IndentSize:=2;
W.WriteJS(JS);
end
finally
W.Free;
CV.Free;
M.Free;
C.Free;
end;