mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-18 05:00:07 +02: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
|
||||
|
||||
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
|
||||
- stored false/true
|
||||
- class property
|
||||
@ -259,7 +263,6 @@ ToDos:
|
||||
- $modeswitch -> define <modeswitch>
|
||||
- $modeswitch- -> turn off
|
||||
- check memleaks
|
||||
- integer range
|
||||
- @@ compare method in delphi mode
|
||||
- make records more lightweight
|
||||
- dotted unit names, namespaces
|
||||
@ -848,6 +851,8 @@ type
|
||||
procedure FinishVariable(El: TPasVariable); override;
|
||||
procedure FinishProcedureType(El: TPasProcedureType); override;
|
||||
procedure FinishPropertyOfClass(PropEl: TPasProperty); override;
|
||||
procedure CheckConditionExpr(El: TPasExpr;
|
||||
const ResolvedEl: TPasResolverResult); override;
|
||||
procedure CheckNewInstanceFunction(ClassScope: TPas2JSClassScope); virtual;
|
||||
function AddExternalName(const aName: string; El: TPasElement): TPasIdentifier; virtual;
|
||||
function FindExternalName(const aName: String): TPasIdentifier; virtual;
|
||||
@ -2154,6 +2159,14 @@ begin
|
||||
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
|
||||
);
|
||||
var
|
||||
|
@ -431,6 +431,7 @@ type
|
||||
Procedure TestJSValue_AssignToJSValue;
|
||||
Procedure TestJSValue_TypeCastToBaseType;
|
||||
Procedure TestJSValue_Equal;
|
||||
Procedure TestJSValue_If;
|
||||
Procedure TestJSValue_Enum;
|
||||
Procedure TestJSValue_ClassInstance;
|
||||
Procedure TestJSValue_ClassOf;
|
||||
@ -10986,6 +10987,31 @@ begin
|
||||
'']));
|
||||
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;
|
||||
begin
|
||||
StartProgram(false);
|
||||
|
Loading…
Reference in New Issue
Block a user