mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-08 15:17:27 +01:00
pastojs: if jsvalue then, while jsvalue do, repeat until jsvalue
git-svn-id: trunk@35888 -
This commit is contained in:
parent
99990f3596
commit
9464a009a8
@ -245,7 +245,11 @@ Works:
|
|||||||
- use 0o for octal literals
|
- use 0o for octal literals
|
||||||
|
|
||||||
ToDos:
|
ToDos:
|
||||||
- bark if there is an overload in the same unit with same signature
|
- if jsvalue then
|
||||||
|
- constant evaluation
|
||||||
|
- integer ranges
|
||||||
|
- static arrays
|
||||||
|
- property index specifier
|
||||||
- RTTI
|
- RTTI
|
||||||
- stored false/true
|
- stored false/true
|
||||||
- class property
|
- class property
|
||||||
@ -259,7 +263,6 @@ ToDos:
|
|||||||
- $modeswitch -> define <modeswitch>
|
- $modeswitch -> define <modeswitch>
|
||||||
- $modeswitch- -> turn off
|
- $modeswitch- -> turn off
|
||||||
- check memleaks
|
- check memleaks
|
||||||
- integer range
|
|
||||||
- @@ compare method in delphi mode
|
- @@ compare method in delphi mode
|
||||||
- make records more lightweight
|
- make records more lightweight
|
||||||
- dotted unit names, namespaces
|
- dotted unit names, namespaces
|
||||||
@ -848,6 +851,8 @@ type
|
|||||||
procedure FinishVariable(El: TPasVariable); override;
|
procedure FinishVariable(El: TPasVariable); override;
|
||||||
procedure FinishProcedureType(El: TPasProcedureType); override;
|
procedure FinishProcedureType(El: TPasProcedureType); override;
|
||||||
procedure FinishPropertyOfClass(PropEl: TPasProperty); override;
|
procedure FinishPropertyOfClass(PropEl: TPasProperty); override;
|
||||||
|
procedure CheckConditionExpr(El: TPasExpr;
|
||||||
|
const ResolvedEl: TPasResolverResult); override;
|
||||||
procedure CheckNewInstanceFunction(ClassScope: TPas2JSClassScope); virtual;
|
procedure CheckNewInstanceFunction(ClassScope: TPas2JSClassScope); virtual;
|
||||||
function AddExternalName(const aName: string; El: TPasElement): TPasIdentifier; virtual;
|
function AddExternalName(const aName: string; El: TPasElement): TPasIdentifier; virtual;
|
||||||
function FindExternalName(const aName: String): TPasIdentifier; virtual;
|
function FindExternalName(const aName: String): TPasIdentifier; virtual;
|
||||||
@ -2154,6 +2159,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPas2JSResolver.CheckConditionExpr(El: TPasExpr;
|
||||||
|
const ResolvedEl: TPasResolverResult);
|
||||||
|
begin
|
||||||
|
if (ResolvedEl.BaseType=btCustom) and (IsJSBaseType(ResolvedEl,pbtJSValue)) then
|
||||||
|
exit;
|
||||||
|
inherited CheckConditionExpr(El, ResolvedEl);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPas2JSResolver.CheckNewInstanceFunction(ClassScope: TPas2JSClassScope
|
procedure TPas2JSResolver.CheckNewInstanceFunction(ClassScope: TPas2JSClassScope
|
||||||
);
|
);
|
||||||
var
|
var
|
||||||
|
|||||||
@ -431,6 +431,7 @@ type
|
|||||||
Procedure TestJSValue_AssignToJSValue;
|
Procedure TestJSValue_AssignToJSValue;
|
||||||
Procedure TestJSValue_TypeCastToBaseType;
|
Procedure TestJSValue_TypeCastToBaseType;
|
||||||
Procedure TestJSValue_Equal;
|
Procedure TestJSValue_Equal;
|
||||||
|
Procedure TestJSValue_If;
|
||||||
Procedure TestJSValue_Enum;
|
Procedure TestJSValue_Enum;
|
||||||
Procedure TestJSValue_ClassInstance;
|
Procedure TestJSValue_ClassInstance;
|
||||||
Procedure TestJSValue_ClassOf;
|
Procedure TestJSValue_ClassOf;
|
||||||
@ -10986,6 +10987,31 @@ begin
|
|||||||
'']));
|
'']));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestModule.TestJSValue_If;
|
||||||
|
begin
|
||||||
|
StartProgram(false);
|
||||||
|
Add([
|
||||||
|
'var',
|
||||||
|
' v: jsvalue;',
|
||||||
|
'begin',
|
||||||
|
' if v then ;',
|
||||||
|
' while v do ;',
|
||||||
|
' repeat until v;',
|
||||||
|
'']);
|
||||||
|
ConvertProgram;
|
||||||
|
CheckSource('TestJSValue_If',
|
||||||
|
LinesToStr([ // statements
|
||||||
|
'this.v = undefined;',
|
||||||
|
'']),
|
||||||
|
LinesToStr([ // $mod.$main
|
||||||
|
'if ($mod.v) ;',
|
||||||
|
'while($mod.v){',
|
||||||
|
'};',
|
||||||
|
'do{',
|
||||||
|
'} while(!$mod.v);',
|
||||||
|
'']));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestModule.TestJSValue_Enum;
|
procedure TTestModule.TestJSValue_Enum;
|
||||||
begin
|
begin
|
||||||
StartProgram(false);
|
StartProgram(false);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user