pastojs: jsvalue:=anonymousfunction

git-svn-id: trunk@40594 -
This commit is contained in:
Mattias Gaertner 2018-12-19 21:49:49 +00:00
parent b7c1732039
commit 36f3508614
2 changed files with 19 additions and 9 deletions

View File

@ -362,6 +362,9 @@ Works:
- procedure val(const string; var enumtype; out int) - procedure val(const string; var enumtype; out int)
ToDos: ToDos:
- cmd line param to set modeswitch
- Result:=inherited;
- move local types to unit scope
- records: - records:
- move local types to global - move local types to global
- use rtl.createRecord to create a record type - use rtl.createRecord to create a record type
@ -370,7 +373,6 @@ ToDos:
- advanced records: - advanced records:
- functions - functions
- rtti - rtti
- cmd line param to set modeswitch
- bug: DoIt(typeinfo(i)) where DoIt is in another unit and has TTypeInfo - bug: DoIt(typeinfo(i)) where DoIt is in another unit and has TTypeInfo
- setlength(dynarray) modeswitch to not create a copy - setlength(dynarray) modeswitch to not create a copy
- 'new', 'Function' -> class var use .prototype - 'new', 'Function' -> class var use .prototype
@ -387,11 +389,9 @@ ToDos:
- 1 as TEnum, ERangeError - 1 as TEnum, ERangeError
- ifthen<T> - ifthen<T>
- stdcall of methods: pass original 'this' as first parameter - stdcall of methods: pass original 'this' as first parameter
- move local types to unit scope
- property read Arr[0] https://bugs.freepascal.org/view.php?id=33416 - property read Arr[0] https://bugs.freepascal.org/view.php?id=33416
- write, writeln - write, writeln
- array of const - array of const
- Result:=inherited;
- call array of proc element without () - call array of proc element without ()
- enums with custom values - enums with custom values
- library - library
@ -428,14 +428,11 @@ ToDos:
-O2 CSE -O2 CSE
-O3 DFA -O3 DFA
- objects - objects
- advanced records
- TPasClassRecordType as ancestor
- class helpers, type helpers, record helpers, array helpers - class helpers, type helpers, record helpers, array helpers
- generics - generics
- operator overloading - operator overloading
- operator enumerator - operator enumerator
- inline - inline
- anonymous functions
- extended RTTI - extended RTTI
- attributes - attributes
@ -3949,7 +3946,7 @@ var
TIName: String; TIName: String;
begin begin
Result:=cIncompatible; Result:=cIncompatible;
//writeln('TPas2JSResolver.CheckAssignCompatibilityCustom ',GetResolverResultDbg(LHS)); //writeln('TPas2JSResolver.CheckAssignCompatibilityCustom LHS=',GetResolverResultDbg(LHS),' RHS=',GetResolverResultDbg(RHS));
if LHS.BaseType=btCustom then if LHS.BaseType=btCustom then
begin begin
if not (LHS.LoTypeEl is TPasUnresolvedSymbolRef) then if not (LHS.LoTypeEl is TPasUnresolvedSymbolRef) then
@ -3977,7 +3974,12 @@ begin
Result:=cExact; Result:=cExact;
end end
else if RHS.BaseType=btContext then else if RHS.BaseType=btContext then
Result:=cJSValueConversion; Result:=cJSValueConversion
else if (RHS.BaseType=btProc) and (RHS.IdentEl=nil) then
begin
// JSValue:=anonymousproc
Result:=cExact;
end;
end end
else if RHS.BaseType=btContext then else if RHS.BaseType=btContext then
begin begin
@ -3987,7 +3989,7 @@ begin
if RHS.IdentEl.ClassType=TPasClassType then if RHS.IdentEl.ClassType=TPasClassType then
Result:=cJSValueConversion; // RHS is a class type Result:=cJSValueConversion; // RHS is a class type
end; end;
end; end
end; end;
end end
else if (LHS.BaseType=btContext) then else if (LHS.BaseType=btContext) then

View File

@ -4070,6 +4070,9 @@ begin
'procedure DoMore(f,g: TProc);', 'procedure DoMore(f,g: TProc);',
'begin', 'begin',
'end;', 'end;',
'procedure DoOdd(v: jsvalue);',
'begin',
'end;',
'procedure DoIt(f: TFunc);', 'procedure DoIt(f: TFunc);',
'begin', 'begin',
' DoIt(function(b:word): word', ' DoIt(function(b:word): word',
@ -4077,6 +4080,7 @@ begin
' Result:=1+b;', ' Result:=1+b;',
' end);', ' end);',
' DoMore(procedure begin end, procedure begin end);', ' DoMore(procedure begin end, procedure begin end);',
' DoOdd(procedure begin end);',
'end;', 'end;',
'begin', 'begin',
' DoMore(procedure begin end,', ' DoMore(procedure begin end,',
@ -4089,6 +4093,8 @@ begin
LinesToStr([ // statements LinesToStr([ // statements
'this.DoMore = function (f, g) {', 'this.DoMore = function (f, g) {',
'};', '};',
'this.DoOdd = function (v) {',
'};',
'this.DoIt = function (f) {', 'this.DoIt = function (f) {',
' $mod.DoIt(function (b) {', ' $mod.DoIt(function (b) {',
' var Result = 0;', ' var Result = 0;',
@ -4098,6 +4104,8 @@ begin
' $mod.DoMore(function () {', ' $mod.DoMore(function () {',
' }, function () {', ' }, function () {',
' });', ' });',
' $mod.DoOdd(function () {',
' });',
'};', '};',
'']), '']),
LinesToStr([ LinesToStr([