|
@@ -159,6 +159,7 @@ Works:
|
|
- methods
|
|
- methods
|
|
- mode delphi: proctype:=proc
|
|
- mode delphi: proctype:=proc
|
|
- mode delphi: functype=funcresulttype
|
|
- mode delphi: functype=funcresulttype
|
|
|
|
+ - nested functions
|
|
- class-of
|
|
- class-of
|
|
- assign := nil, var
|
|
- assign := nil, var
|
|
- call class method
|
|
- call class method
|
|
@@ -186,9 +187,6 @@ Works:
|
|
- Pascal descendant can override newinstance
|
|
- Pascal descendant can override newinstance
|
|
- any class can be typecasted to any root class
|
|
- any class can be typecasted to any root class
|
|
- class instances cannot access external class members (e.g. static class functions)
|
|
- class instances cannot access external class members (e.g. static class functions)
|
|
-- ECMAScript6:
|
|
|
|
- - use 0b for binary literals
|
|
|
|
- - use 0o for octal literals
|
|
|
|
- jsvalue
|
|
- jsvalue
|
|
- init as undefined
|
|
- init as undefined
|
|
- assign to jsvalue := integer, string, boolean, double, char
|
|
- assign to jsvalue := integer, string, boolean, double, char
|
|
@@ -207,9 +205,11 @@ Works:
|
|
allow type casting to any array
|
|
allow type casting to any array
|
|
- parameter, result type, assign from/to untyped
|
|
- parameter, result type, assign from/to untyped
|
|
- operators equal, not equal
|
|
- operators equal, not equal
|
|
|
|
+- ECMAScript6:
|
|
|
|
+ - use 0b for binary literals
|
|
|
|
+ - use 0o for octal literals
|
|
|
|
|
|
ToDos:
|
|
ToDos:
|
|
-- proc type of nested function
|
|
|
|
- [] operator of external class 'Array'
|
|
- [] operator of external class 'Array'
|
|
- FuncName:= (instead of Result:=)
|
|
- FuncName:= (instead of Result:=)
|
|
- ord(s[i]) -> s.charCodeAt(i)
|
|
- ord(s[i]) -> s.charCodeAt(i)
|
|
@@ -225,6 +225,7 @@ ToDos:
|
|
- pointer of record
|
|
- pointer of record
|
|
- nested types in class
|
|
- nested types in class
|
|
- asm: pas() - useful for overloads and protect an identifier from optimization
|
|
- asm: pas() - useful for overloads and protect an identifier from optimization
|
|
|
|
+- source maps
|
|
|
|
|
|
Not in Version 1.0:
|
|
Not in Version 1.0:
|
|
- write, writeln
|
|
- write, writeln
|
|
@@ -616,7 +617,8 @@ const
|
|
proPropertyAsVarParam,
|
|
proPropertyAsVarParam,
|
|
proClassOfIs,
|
|
proClassOfIs,
|
|
proExtClassInstanceNoTypeMembers,
|
|
proExtClassInstanceNoTypeMembers,
|
|
- proOpenAsDynArrays
|
|
|
|
|
|
+ proOpenAsDynArrays,
|
|
|
|
+ proProcTypeWithoutIsNested
|
|
];
|
|
];
|
|
type
|
|
type
|
|
TPas2JSResolver = class(TPasResolver)
|
|
TPas2JSResolver = class(TPasResolver)
|
|
@@ -1531,8 +1533,8 @@ begin
|
|
|
|
|
|
// check pmPublic
|
|
// check pmPublic
|
|
if [pmPublic,pmExternal]<=Proc.Modifiers then
|
|
if [pmPublic,pmExternal]<=Proc.Modifiers then
|
|
- RaiseMsg(20170324150149,nInvalidProcModifiers,
|
|
|
|
- sInvalidProcModifiers,[Proc.ElementTypeName,'public, external'],Proc);
|
|
|
|
|
|
+ RaiseMsg(20170324150149,nInvalidXModifiersY,
|
|
|
|
+ sInvalidXModifiersY,[Proc.ElementTypeName,'public, external'],Proc);
|
|
if (Proc.PublicName<>nil) then
|
|
if (Proc.PublicName<>nil) then
|
|
RaiseMsg(20170324150417,nPasElementNotSupported,sPasElementNotSupported,
|
|
RaiseMsg(20170324150417,nPasElementNotSupported,sPasElementNotSupported,
|
|
['public name'],Proc.PublicName);
|
|
['public name'],Proc.PublicName);
|
|
@@ -1549,8 +1551,8 @@ begin
|
|
if not (pmExternal in Proc.Modifiers) then
|
|
if not (pmExternal in Proc.Modifiers) then
|
|
begin
|
|
begin
|
|
if Proc.LibrarySymbolName<>nil then
|
|
if Proc.LibrarySymbolName<>nil then
|
|
- RaiseMsg(20170322142158,nInvalidProcModifiers,
|
|
|
|
- sInvalidProcModifiers,[Proc.ElementTypeName,'symbol name'],Proc.LibrarySymbolName);
|
|
|
|
|
|
+ RaiseMsg(20170322142158,nInvalidXModifiersY,
|
|
|
|
+ sInvalidXModifiersY,[Proc.ElementTypeName,'symbol name'],Proc.LibrarySymbolName);
|
|
Proc.Modifiers:=Proc.Modifiers+[pmExternal];
|
|
Proc.Modifiers:=Proc.Modifiers+[pmExternal];
|
|
Proc.LibrarySymbolName:=TPrimitiveExpr.Create(El,pekString,''''+Proc.Name+'''');
|
|
Proc.LibrarySymbolName:=TPrimitiveExpr.Create(El,pekString,''''+Proc.Name+'''');
|
|
end;
|
|
end;
|
|
@@ -1563,7 +1565,7 @@ begin
|
|
begin
|
|
begin
|
|
if Proc.IsVirtual then
|
|
if Proc.IsVirtual then
|
|
// constructor of external class can't be overriden -> forbid virtual
|
|
// constructor of external class can't be overriden -> forbid virtual
|
|
- RaiseMsg(20170323100447,nInvalidProcModifiers,sInvalidProcModifiers,
|
|
|
|
|
|
+ RaiseMsg(20170323100447,nInvalidXModifiersY,sInvalidXModifiersY,
|
|
[Proc.ElementTypeName,'virtual,external'],Proc);
|
|
[Proc.ElementTypeName,'virtual,external'],Proc);
|
|
if CompareText(Proc.Name,'new')=0 then
|
|
if CompareText(Proc.Name,'new')=0 then
|
|
begin
|
|
begin
|
|
@@ -1576,7 +1578,7 @@ begin
|
|
RaiseMsg(20170322164357,nNoArgumentsAllowedForExternalObjectConstructor,
|
|
RaiseMsg(20170322164357,nNoArgumentsAllowedForExternalObjectConstructor,
|
|
sNoArgumentsAllowedForExternalObjectConstructor,[],TPasArgument(El.Args[0]));
|
|
sNoArgumentsAllowedForExternalObjectConstructor,[],TPasArgument(El.Args[0]));
|
|
if pmVirtual in Proc.Modifiers then
|
|
if pmVirtual in Proc.Modifiers then
|
|
- RaiseMsg(20170322183141,nInvalidProcModifiers,sInvalidProcModifiers,
|
|
|
|
|
|
+ RaiseMsg(20170322183141,nInvalidXModifiersY,sInvalidXModifiersY,
|
|
[Proc.ElementTypeName,'virtual'],Proc.ProcType);
|
|
[Proc.ElementTypeName,'virtual'],Proc.ProcType);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
@@ -1610,7 +1612,7 @@ begin
|
|
|
|
|
|
// external override -> unneeded information, probably a bug
|
|
// external override -> unneeded information, probably a bug
|
|
if Proc.IsOverride then
|
|
if Proc.IsOverride then
|
|
- RaiseMsg(20170321101715,nInvalidProcModifiers,sInvalidProcModifiers,
|
|
|
|
|
|
+ RaiseMsg(20170321101715,nInvalidXModifiersY,sInvalidXModifiersY,
|
|
[Proc.ElementTypeName,'override,external'],Proc);
|
|
[Proc.ElementTypeName,'override,external'],Proc);
|
|
|
|
|
|
if Proc.LibraryExpr<>nil then
|
|
if Proc.LibraryExpr<>nil then
|
|
@@ -1622,7 +1624,7 @@ begin
|
|
|
|
|
|
for pm in [pmAssembler,pmForward,pmNoReturn,pmInline] do
|
|
for pm in [pmAssembler,pmForward,pmNoReturn,pmInline] do
|
|
if pm in Proc.Modifiers then
|
|
if pm in Proc.Modifiers then
|
|
- RaiseMsg(20170323100842,nInvalidProcModifiers,sInvalidProcModifiers,
|
|
|
|
|
|
+ RaiseMsg(20170323100842,nInvalidXModifiersY,sInvalidXModifiersY,
|
|
[Proc.ElementTypeName,ModifierNames[pm]],Proc);
|
|
[Proc.ElementTypeName,ModifierNames[pm]],Proc);
|
|
|
|
|
|
// compute external name
|
|
// compute external name
|
|
@@ -6164,7 +6166,7 @@ begin
|
|
For i:=0 to El.Members.Count-1 do
|
|
For i:=0 to El.Members.Count-1 do
|
|
begin
|
|
begin
|
|
P:=TPasElement(El.Members[i]);
|
|
P:=TPasElement(El.Members[i]);
|
|
- writeln('TPasToJSConverter.ConvertClassType class El[',i,']=',GetObjName(P));
|
|
|
|
|
|
+ //writeln('TPasToJSConverter.ConvertClassType class El[',i,']=',GetObjName(P));
|
|
if not IsMemberNeeded(P) then continue;
|
|
if not IsMemberNeeded(P) then continue;
|
|
C:=P.ClassType;
|
|
C:=P.ClassType;
|
|
NewEl:=nil;
|
|
NewEl:=nil;
|
|
@@ -6970,7 +6972,7 @@ begin
|
|
Call:=CreateCallExpression(El);
|
|
Call:=CreateCallExpression(El);
|
|
// "rtl.createCallback"
|
|
// "rtl.createCallback"
|
|
Call.Expr:=CreateMemberExpression([FBuiltInNames[pbivnRTL],FBuiltInNames[pbifnProcType_Create]]);
|
|
Call.Expr:=CreateMemberExpression([FBuiltInNames[pbivnRTL],FBuiltInNames[pbifnProcType_Create]]);
|
|
- // add scope as parameter
|
|
|
|
|
|
+ // add parameters
|
|
Scope:=ConvertElement(El,AContext);
|
|
Scope:=ConvertElement(El,AContext);
|
|
{$IFDEF VerbosePas2JS}
|
|
{$IFDEF VerbosePas2JS}
|
|
writeln('TPasToJSConverter.CreateCallback ',GetObjName(Scope));
|
|
writeln('TPasToJSConverter.CreateCallback ',GetObjName(Scope));
|
|
@@ -6979,7 +6981,7 @@ begin
|
|
// the last element of Scope is the proc, chomp that off
|
|
// the last element of Scope is the proc, chomp that off
|
|
if Scope.ClassType=TJSDotMemberExpression then
|
|
if Scope.ClassType=TJSDotMemberExpression then
|
|
begin
|
|
begin
|
|
- // chomp dot member
|
|
|
|
|
|
+ // chomp dot member -> rtl.createCallback(scope,"FunName")
|
|
DotExpr:=TJSDotMemberExpression(Scope);
|
|
DotExpr:=TJSDotMemberExpression(Scope);
|
|
Scope:=DotExpr.MExpr;
|
|
Scope:=DotExpr.MExpr;
|
|
DotExpr.MExpr:=nil;
|
|
DotExpr.MExpr:=nil;
|
|
@@ -6992,22 +6994,33 @@ begin
|
|
DoError(20170215161802,nInvalidFunctionReference,sInvalidFunctionReference,[],El);
|
|
DoError(20170215161802,nInvalidFunctionReference,sInvalidFunctionReference,[],El);
|
|
end;
|
|
end;
|
|
FreeAndNil(DotExpr);
|
|
FreeAndNil(DotExpr);
|
|
|
|
+ Call.Args.Elements.AddElement.Expr:=Scope;
|
|
|
|
+ // add function name as parameter
|
|
|
|
+ Call.Args.Elements.AddElement.Expr:=CreateLiteralString(El,FunName);
|
|
end
|
|
end
|
|
else if Scope.ClassType=TJSPrimaryExpressionIdent then
|
|
else if Scope.ClassType=TJSPrimaryExpressionIdent then
|
|
begin
|
|
begin
|
|
- // chomp dotted identifier
|
|
|
|
Prim:=TJSPrimaryExpressionIdent(Scope);
|
|
Prim:=TJSPrimaryExpressionIdent(Scope);
|
|
aName:=String(Prim.Name);
|
|
aName:=String(Prim.Name);
|
|
DotPos:=PosLast('.',aName);
|
|
DotPos:=PosLast('.',aName);
|
|
- if DotPos<1 then
|
|
|
|
|
|
+ if DotPos>0 then
|
|
begin
|
|
begin
|
|
- {$IFDEF VerbosePas2JS}
|
|
|
|
- writeln('TPasToJSConverter.CreateCallback Scope=',GetObjName(Scope),' Name="',String(aName),'"');
|
|
|
|
- {$ENDIF}
|
|
|
|
- DoError(20170215161410,nInvalidFunctionReference,sInvalidFunctionReference,[],El);
|
|
|
|
|
|
+ // chomp dotted identifier -> rtl.createCallback(scope,"FunName")
|
|
|
|
+ FunName:=copy(aName,DotPos+1);
|
|
|
|
+ Prim.Name:=TJSString(LeftStr(aName,DotPos-1));
|
|
|
|
+ Call.Args.Elements.AddElement.Expr:=Prim;
|
|
|
|
+ // add function name as parameter
|
|
|
|
+ Call.Args.Elements.AddElement.Expr:=CreateLiteralString(El,FunName);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ // nested proc -> rtl.createCallback(this,FunName)
|
|
|
|
+ FunName:=aName;
|
|
|
|
+ Prim.Name:='this';
|
|
|
|
+ Call.Args.Elements.AddElement.Expr:=Prim;
|
|
|
|
+ // add function as parameter
|
|
|
|
+ Call.Args.Elements.AddElement.Expr:=CreateBuiltInIdentifierExpr(FunName);
|
|
end;
|
|
end;
|
|
- FunName:=copy(aName,DotPos+1);
|
|
|
|
- Prim.Name:=TJSString(LeftStr(aName,DotPos-1));
|
|
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
@@ -7016,10 +7029,6 @@ begin
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
RaiseNotSupported(El,AContext,20170215161210);
|
|
RaiseNotSupported(El,AContext,20170215161210);
|
|
end;
|
|
end;
|
|
- Call.Args.Elements.AddElement.Expr:=Scope;
|
|
|
|
-
|
|
|
|
- // add function name as parameter
|
|
|
|
- Call.Args.Elements.AddElement.Expr:=CreateLiteralString(El,FunName);
|
|
|
|
|
|
|
|
Result:=Call;
|
|
Result:=Call;
|
|
finally
|
|
finally
|