pastojs: if then <empty> else ;

git-svn-id: trunk@39929 -
This commit is contained in:
Mattias Gaertner 2018-10-13 20:57:05 +00:00
parent 15dfb9eed3
commit dd81e62f3a
2 changed files with 33 additions and 0 deletions

View File

@ -1726,6 +1726,7 @@ type
Function ConvertExportSymbol(El: TPasExportSymbol; AContext: TConvertContext): TJSElement; virtual;
Function ConvertExpression(El: TPasExpr; AContext: TConvertContext): TJSElement; virtual;
Function ConvertImplBlock(El: TPasImplBlock; AContext: TConvertContext ): TJSElement; virtual;
Function ConvertImplCommand(El: TPasImplCommand; AContext: TConvertContext ): TJSElement; virtual;
Function ConvertLabelMark(El: TPasImplLabelMark; AContext: TConvertContext): TJSElement; virtual;
Function ConvertLabels(El: TPasLabels; AContext: TConvertContext): TJSElement; virtual;
Function ConvertModule(El: TPasModule; AContext: TConvertContext): TJSElement; virtual;
@ -14994,6 +14995,16 @@ begin
RaiseNotSupported(El,AContext,20161024192156);
end;
function TPasToJSConverter.ConvertImplCommand(El: TPasImplCommand;
AContext: TConvertContext): TJSElement;
begin
if El.Command<>'' then
RaiseNotSupported(El,AContext,20181013224809,El.Command);
if not (El.Parent is TPasImplIfElse) then
RaiseNotSupported(El,AContext,20181013224929,GetObjName(El.Parent));
Result:=nil;
end;
function TPasToJSConverter.ConvertPackage(El: TPasPackage;
AContext: TConvertContext): TJSElement;
@ -18501,6 +18512,8 @@ begin
Result:=ConvertProcedure(TPasProcedure(El),AContext)
else if C.InheritsFrom(TPasImplBlock) then
Result:=ConvertImplBlock(TPasImplBlock(El),AContext)
else if C=TPasImplCommand then
Result:=ConvertImplCommand(TPasImplCommand(El),AContext)
else if C.InheritsFrom(TPasModule) then
Result:=ConvertModule(TPasModule(El),AContext)
else If (C=TPasPackage) then

View File

@ -361,6 +361,7 @@ type
Procedure TestBitwiseOperators;
Procedure TestFunctionInt;
Procedure TestFunctionString;
Procedure TestIfThen;
Procedure TestForLoop;
Procedure TestForLoopInsideFunction;
Procedure TestForLoop_ReadVarAfter;
@ -6312,6 +6313,25 @@ begin
]));
end;
procedure TTestModule.TestIfThen;
begin
StartProgram(false);
Add([
'var b: boolean;',
'begin',
' if b then ;',
' if b then else ;']);
ConvertProgram;
CheckSource('TestIfThen',
LinesToStr([ // statements
'this.b = false;',
'']),
LinesToStr([ // this.$main
'if ($mod.b) ;',
'if ($mod.b) ;',
'']));
end;
procedure TTestModule.TestForLoop;
begin
StartProgram(false);