|
@@ -363,8 +363,9 @@ unit FPPas2Js;
|
|
interface
|
|
interface
|
|
|
|
|
|
uses
|
|
uses
|
|
- Classes, SysUtils, math, contnrs, jsbase, jstree, PasTree, PScanner,
|
|
|
|
- PasResolver, PasResolveEval;
|
|
|
|
|
|
+ Classes, SysUtils, math, contnrs,
|
|
|
|
+ jsbase, jstree, jswriter,
|
|
|
|
+ PasTree, PScanner, PasResolveEval, PasResolver;
|
|
|
|
|
|
// message numbers
|
|
// message numbers
|
|
const
|
|
const
|
|
@@ -827,6 +828,8 @@ type
|
|
TPas2JSProcedureScope = class(TPasProcedureScope)
|
|
TPas2JSProcedureScope = class(TPasProcedureScope)
|
|
public
|
|
public
|
|
ResultVarName: string; // valid in implementation ProcScope, empty means use ResolverResultVar
|
|
ResultVarName: string; // valid in implementation ProcScope, empty means use ResolverResultVar
|
|
|
|
+ // Option coStoreProcJS
|
|
|
|
+ BodyJS: string;// stored in ImplScope
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TPas2JSWithExprScope }
|
|
{ TPas2JSWithExprScope }
|
|
@@ -1167,7 +1170,8 @@ type
|
|
coEnumNumbers, // use enum numbers instead of names
|
|
coEnumNumbers, // use enum numbers instead of names
|
|
coUseStrict, // insert 'use strict'
|
|
coUseStrict, // insert 'use strict'
|
|
coNoTypeInfo, // do not generate RTTI
|
|
coNoTypeInfo, // do not generate RTTI
|
|
- coEliminateDeadCode // skip code that is never executed
|
|
|
|
|
|
+ coEliminateDeadCode, // skip code that is never executed
|
|
|
|
+ coStoreProcJS // store references to JS code in procscopes
|
|
);
|
|
);
|
|
TPasToJsConverterOptions = set of TPasToJsConverterOption;
|
|
TPasToJsConverterOptions = set of TPasToJsConverterOption;
|
|
|
|
|
|
@@ -1255,7 +1259,7 @@ type
|
|
Procedure DoError(Id: int64; MsgNumber: integer; const MsgPattern: string; Const Args : Array of Const; El: TPasElement);
|
|
Procedure DoError(Id: int64; MsgNumber: integer; const MsgPattern: string; Const Args : Array of Const; El: TPasElement);
|
|
procedure RaiseNotSupported(El: TPasElement; AContext: TConvertContext; Id: int64; const Msg: string = '');
|
|
procedure RaiseNotSupported(El: TPasElement; AContext: TConvertContext; Id: int64; const Msg: string = '');
|
|
procedure RaiseIdentifierNotFound(Identifier: string; El: TPasElement; Id: int64);
|
|
procedure RaiseIdentifierNotFound(Identifier: string; El: TPasElement; Id: int64);
|
|
- procedure RaiseInconsistency(Id: int64);
|
|
|
|
|
|
+ procedure RaiseInconsistency(Id: int64; El: TPasElement);
|
|
// Computation, value conversions
|
|
// Computation, value conversions
|
|
Function GetExpressionValueType(El: TPasExpr; AContext: TConvertContext ): TJSType; virtual;
|
|
Function GetExpressionValueType(El: TPasExpr; AContext: TConvertContext ): TJSType; virtual;
|
|
Function GetPasIdentValueType(AName: String; AContext: TConvertContext): TJSType; virtual;
|
|
Function GetPasIdentValueType(AName: String; AContext: TConvertContext): TJSType; virtual;
|
|
@@ -1355,6 +1359,7 @@ type
|
|
Function CreateCallRTLFreeLoc(Setter, Getter: TJSElement; Src: TPasElement): TJSElement; virtual;
|
|
Function CreateCallRTLFreeLoc(Setter, Getter: TJSElement; Src: TPasElement): TJSElement; virtual;
|
|
Function CreatePropertyGet(Prop: TPasProperty; Ref: TResolvedReference;
|
|
Function CreatePropertyGet(Prop: TPasProperty; Ref: TResolvedReference;
|
|
AContext: TConvertContext; PosEl: TPasElement): TJSElement; virtual;
|
|
AContext: TConvertContext; PosEl: TPasElement): TJSElement; virtual;
|
|
|
|
+ Procedure StorePrecompiledProcedure(ImplProc: TPasProcedure; JS: TJSElement); virtual;
|
|
// Statements
|
|
// Statements
|
|
Function ConvertImplBlockElements(El: TPasImplBlock; AContext: TConvertContext; NilIfEmpty: boolean): TJSElement; virtual;
|
|
Function ConvertImplBlockElements(El: TPasImplBlock; AContext: TConvertContext; NilIfEmpty: boolean): TJSElement; virtual;
|
|
Function ConvertBeginEndStatement(El: TPasImplBeginBlock; AContext: TConvertContext; NilIfEmpty: boolean): TJSElement; virtual;
|
|
Function ConvertBeginEndStatement(El: TPasImplBeginBlock; AContext: TConvertContext; NilIfEmpty: boolean): TJSElement; virtual;
|
|
@@ -4086,14 +4091,14 @@ begin
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr Ref.Declaration=',GetObjName(Ref.Declaration));
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr Ref.Declaration=',GetObjName(Ref.Declaration));
|
|
Proc:=Ref.Declaration as TPasProcedure;
|
|
Proc:=Ref.Declaration as TPasProcedure;
|
|
if Proc.Name='' then
|
|
if Proc.Name='' then
|
|
- RaiseInconsistency(20170125191914);
|
|
|
|
|
|
+ RaiseInconsistency(20170125191914,Proc);
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr Proc.Name=',Proc.Name);
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr Proc.Name=',Proc.Name);
|
|
ProcScope:=Proc.CustomData as TPasProcedureScope;
|
|
ProcScope:=Proc.CustomData as TPasProcedureScope;
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr ProcScope.Element=',GetObjName(ProcScope.Element),' ProcScope.ClassScope=',GetObjName(ProcScope.ClassScope),' ProcScope.DeclarationProc=',GetObjName(ProcScope.DeclarationProc),' ProcScope.ImplProc=',GetObjName(ProcScope.ImplProc),' ProcScope.CustomData=',GetObjName(ProcScope.CustomData));
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr ProcScope.Element=',GetObjName(ProcScope.Element),' ProcScope.ClassScope=',GetObjName(ProcScope.ClassScope),' ProcScope.DeclarationProc=',GetObjName(ProcScope.DeclarationProc),' ProcScope.ImplProc=',GetObjName(ProcScope.ImplProc),' ProcScope.CustomData=',GetObjName(ProcScope.CustomData));
|
|
ClassScope:=ProcScope.ClassScope;
|
|
ClassScope:=ProcScope.ClassScope;
|
|
aClass:=ClassScope.Element;
|
|
aClass:=ClassScope.Element;
|
|
if aClass.Name='' then
|
|
if aClass.Name='' then
|
|
- RaiseInconsistency(20170125191923);
|
|
|
|
|
|
+ RaiseInconsistency(20170125191923,aClass);
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr aClass.Name=',aClass.Name);
|
|
//writeln('TPasToJSConverter.CreateFreeOrNewInstanceExpr aClass.Name=',aClass.Name);
|
|
C:=CreateCallExpression(Ref.Element);
|
|
C:=CreateCallExpression(Ref.Element);
|
|
ok:=false;
|
|
ok:=false;
|
|
@@ -4775,7 +4780,7 @@ begin
|
|
AContext.Access:=caRead;
|
|
AContext.Access:=caRead;
|
|
Left:=ConvertElement(El.left,AContext);
|
|
Left:=ConvertElement(El.left,AContext);
|
|
if Left=nil then
|
|
if Left=nil then
|
|
- RaiseInconsistency(20170201140821);
|
|
|
|
|
|
+ RaiseInconsistency(20170201140821,El);
|
|
AContext.Access:=OldAccess;
|
|
AContext.Access:=OldAccess;
|
|
// convert right side
|
|
// convert right side
|
|
DotContext:=TDotContext.Create(El,Left,AContext);
|
|
DotContext:=TDotContext.Create(El,Left,AContext);
|
|
@@ -5103,7 +5108,7 @@ begin
|
|
RaiseNotSupported(El,AContext,20161130164955,'built in proc '+ResolverBuiltInProcNames[BuiltInProc.BuiltIn]);
|
|
RaiseNotSupported(El,AContext,20161130164955,'built in proc '+ResolverBuiltInProcNames[BuiltInProc.BuiltIn]);
|
|
end;
|
|
end;
|
|
if Result=nil then
|
|
if Result=nil then
|
|
- RaiseInconsistency(20170214120048);
|
|
|
|
|
|
+ RaiseInconsistency(20170214120048,Decl);
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -5182,7 +5187,7 @@ function TPasToJSConverter.ConvertInheritedExpression(El: TInheritedExpr;
|
|
Result:=nil;
|
|
Result:=nil;
|
|
SelfContext:=AContext.GetSelfContext;
|
|
SelfContext:=AContext.GetSelfContext;
|
|
if SelfContext=nil then
|
|
if SelfContext=nil then
|
|
- RaiseInconsistency(20170418114702);
|
|
|
|
|
|
+ RaiseInconsistency(20170418114702,El);
|
|
SelfName:=SelfContext.GetLocalName(SelfContext.ThisPas);
|
|
SelfName:=SelfContext.GetLocalName(SelfContext.ThisPas);
|
|
|
|
|
|
if Apply and (SelfContext<>AContext) then
|
|
if Apply and (SelfContext<>AContext) then
|
|
@@ -5197,11 +5202,11 @@ function TPasToJSConverter.ConvertInheritedExpression(El: TInheritedExpr;
|
|
// -> use the direct ancestor class of the current proc
|
|
// -> use the direct ancestor class of the current proc
|
|
aClass:=SelfContext.ThisPas as TPasClassType;
|
|
aClass:=SelfContext.ThisPas as TPasClassType;
|
|
if aClass.CustomData=nil then
|
|
if aClass.CustomData=nil then
|
|
- RaiseInconsistency(20170323111252);
|
|
|
|
|
|
+ RaiseInconsistency(20170323111252,aClass);
|
|
ClassScope:=TPasClassScope(aClass.CustomData);
|
|
ClassScope:=TPasClassScope(aClass.CustomData);
|
|
AncestorScope:=ClassScope.AncestorScope;
|
|
AncestorScope:=ClassScope.AncestorScope;
|
|
if AncestorScope=nil then
|
|
if AncestorScope=nil then
|
|
- RaiseInconsistency(20170323111306);
|
|
|
|
|
|
+ RaiseInconsistency(20170323111306,aClass);
|
|
AncestorClass:=AncestorScope.Element as TPasClassType;
|
|
AncestorClass:=AncestorScope.Element as TPasClassType;
|
|
FunName:=CreateReferencePath(AncestorClass,AContext,rpkPathAndName,true)
|
|
FunName:=CreateReferencePath(AncestorClass,AContext,rpkPathAndName,true)
|
|
+'.'+TransformVariableName(AncestorProc,AContext);
|
|
+'.'+TransformVariableName(AncestorProc,AContext);
|
|
@@ -5409,7 +5414,7 @@ var
|
|
// s[index] := value
|
|
// s[index] := value
|
|
AssignContext:=AContext.AccessContext as TAssignContext;
|
|
AssignContext:=AContext.AccessContext as TAssignContext;
|
|
if AssignContext.RightSide=nil then
|
|
if AssignContext.RightSide=nil then
|
|
- RaiseInconsistency(20180123192020);
|
|
|
|
|
|
+ RaiseInconsistency(20180123192020,El);
|
|
|
|
|
|
AssignSt:=nil;
|
|
AssignSt:=nil;
|
|
SetStrCall:=nil;
|
|
SetStrCall:=nil;
|
|
@@ -5654,7 +5659,7 @@ var
|
|
Arg:=nil;
|
|
Arg:=nil;
|
|
inc(ArgNo);
|
|
inc(ArgNo);
|
|
if ArgNo>length(El.Params) then
|
|
if ArgNo>length(El.Params) then
|
|
- RaiseInconsistency(20170206180553);
|
|
|
|
|
|
+ RaiseInconsistency(20170206180553,El);
|
|
end;
|
|
end;
|
|
if ArgNo=length(El.Params) then
|
|
if ArgNo=length(El.Params) then
|
|
break;
|
|
break;
|
|
@@ -5712,7 +5717,7 @@ var
|
|
Result:=true;
|
|
Result:=true;
|
|
// bracket accessor of external class
|
|
// bracket accessor of external class
|
|
if AContext.Resolver.GetPasPropertyArgs(Prop).Count<>1 then
|
|
if AContext.Resolver.GetPasPropertyArgs(Prop).Count<>1 then
|
|
- RaiseInconsistency(20170403003753);
|
|
|
|
|
|
+ RaiseInconsistency(20170403003753,Prop);
|
|
// bracket accessor of external class -> create PathEl[param]
|
|
// bracket accessor of external class -> create PathEl[param]
|
|
Bracket:=TJSBracketMemberExpression(CreateElement(TJSBracketMemberExpression,El.Params[0]));
|
|
Bracket:=TJSBracketMemberExpression(CreateElement(TJSBracketMemberExpression,El.Params[0]));
|
|
try
|
|
try
|
|
@@ -5822,7 +5827,7 @@ var
|
|
{$IFDEF VerbosePas2JS}
|
|
{$IFDEF VerbosePas2JS}
|
|
writeln('TPasToJSConverter.ConvertArrayParams.ConvertIndexedProperty missing default value: Prop=',Prop.Name,' i=',i);
|
|
writeln('TPasToJSConverter.ConvertArrayParams.ConvertIndexedProperty missing default value: Prop=',Prop.Name,' i=',i);
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- RaiseInconsistency(20170206185126);
|
|
|
|
|
|
+ RaiseInconsistency(20170206185126,TargetArg);
|
|
end;
|
|
end;
|
|
AContext.Access:=caRead;
|
|
AContext.Access:=caRead;
|
|
Arg:=ConvertElement(TargetArg.ValueExpr,ArgContext);
|
|
Arg:=ConvertElement(TargetArg.ValueExpr,ArgContext);
|
|
@@ -5932,7 +5937,7 @@ Var
|
|
aClass: TPasClassType;
|
|
aClass: TPasClassType;
|
|
begin
|
|
begin
|
|
if El.Kind<>pekArrayParams then
|
|
if El.Kind<>pekArrayParams then
|
|
- RaiseInconsistency(20170209113713);
|
|
|
|
|
|
+ RaiseInconsistency(20170209113713,El);
|
|
ArgContext:=AContext;
|
|
ArgContext:=AContext;
|
|
while ArgContext is TDotContext do
|
|
while ArgContext is TDotContext do
|
|
ArgContext:=ArgContext.Parent;
|
|
ArgContext:=ArgContext.Parent;
|
|
@@ -5984,7 +5989,7 @@ begin
|
|
// anObject[]
|
|
// anObject[]
|
|
ConvertDefaultProperty(ResolvedEl,ClassScope.DefaultProperty)
|
|
ConvertDefaultProperty(ResolvedEl,ClassScope.DefaultProperty)
|
|
else
|
|
else
|
|
- RaiseInconsistency(20170206180448);
|
|
|
|
|
|
+ RaiseInconsistency(20170206180448,aClass);
|
|
end
|
|
end
|
|
else if TypeEl.ClassType=TPasClassOfType then
|
|
else if TypeEl.ClassType=TPasClassOfType then
|
|
begin
|
|
begin
|
|
@@ -5992,7 +5997,7 @@ begin
|
|
DestType:=AContext.Resolver.ResolveAliasType(TPasClassOfType(TypeEl).DestType);
|
|
DestType:=AContext.Resolver.ResolveAliasType(TPasClassOfType(TypeEl).DestType);
|
|
ClassScope:=DestType.CustomData as TPas2JSClassScope;
|
|
ClassScope:=DestType.CustomData as TPas2JSClassScope;
|
|
if ClassScope.DefaultProperty=nil then
|
|
if ClassScope.DefaultProperty=nil then
|
|
- RaiseInconsistency(20170206180503);
|
|
|
|
|
|
+ RaiseInconsistency(20170206180503,DestType);
|
|
ConvertDefaultProperty(ResolvedEl,ClassScope.DefaultProperty);
|
|
ConvertDefaultProperty(ResolvedEl,ClassScope.DefaultProperty);
|
|
end
|
|
end
|
|
else if TypeEl.ClassType=TPasArrayType then
|
|
else if TypeEl.ClassType=TPasArrayType then
|
|
@@ -6025,7 +6030,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if El.Kind<>pekFuncParams then
|
|
if El.Kind<>pekFuncParams then
|
|
- RaiseInconsistency(20170209113515);
|
|
|
|
|
|
+ RaiseInconsistency(20170209113515,El);
|
|
//writeln('TPasToJSConverter.ConvertFuncParams START pekFuncParams ',GetObjName(El.CustomData),' ',GetObjName(El.Value.CustomData));
|
|
//writeln('TPasToJSConverter.ConvertFuncParams START pekFuncParams ',GetObjName(El.CustomData),' ',GetObjName(El.Value.CustomData));
|
|
Call:=nil;
|
|
Call:=nil;
|
|
Elements:=nil;
|
|
Elements:=nil;
|
|
@@ -6078,7 +6083,7 @@ begin
|
|
RaiseNotSupported(El,AContext,20161130164955,'built in proc '+ResolverBuiltInProcNames[BuiltInProc.BuiltIn]);
|
|
RaiseNotSupported(El,AContext,20161130164955,'built in proc '+ResolverBuiltInProcNames[BuiltInProc.BuiltIn]);
|
|
end;
|
|
end;
|
|
if Result=nil then
|
|
if Result=nil then
|
|
- RaiseInconsistency(20170210121932);
|
|
|
|
|
|
+ RaiseInconsistency(20170210121932,El);
|
|
exit;
|
|
exit;
|
|
end
|
|
end
|
|
else if Decl.CustomData is TResElDataBaseType then
|
|
else if Decl.CustomData is TResElDataBaseType then
|
|
@@ -6318,7 +6323,7 @@ begin
|
|
NewExpr:=nil;
|
|
NewExpr:=nil;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- RaiseInconsistency(20170323083214);
|
|
|
|
|
|
+ RaiseInconsistency(20170323083214,Proc);
|
|
finally
|
|
finally
|
|
ExtNameEl.Free;
|
|
ExtNameEl.Free;
|
|
NewExpr.Free;
|
|
NewExpr.Free;
|
|
@@ -6367,7 +6372,7 @@ begin
|
|
{$IFDEF VerbosePas2JS}
|
|
{$IFDEF VerbosePas2JS}
|
|
writeln('TPasToJSConverter.ConvertTObjectFree With=',GetObjName(WithExprScope.Expr));
|
|
writeln('TPasToJSConverter.ConvertTObjectFree With=',GetObjName(WithExprScope.Expr));
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- RaiseInconsistency(20170517092248);
|
|
|
|
|
|
+ RaiseInconsistency(20170517092248,Bin);
|
|
end;
|
|
end;
|
|
|
|
|
|
LeftJS:=ConvertElement(Bin.left,AContext);
|
|
LeftJS:=ConvertElement(Bin.left,AContext);
|
|
@@ -6379,7 +6384,7 @@ begin
|
|
begin
|
|
begin
|
|
aName:=TJSPrimaryExpressionIdent(LeftJS).Name;
|
|
aName:=TJSPrimaryExpressionIdent(LeftJS).Name;
|
|
if Pos('.',aName)>0 then
|
|
if Pos('.',aName)>0 then
|
|
- RaiseInconsistency(20170516173832);
|
|
|
|
|
|
+ RaiseInconsistency(20170516173832,Bin.left);
|
|
// v.free
|
|
// v.free
|
|
// -> v=rtl.freeLoc(v);
|
|
// -> v=rtl.freeLoc(v);
|
|
Getter:=LeftJS;
|
|
Getter:=LeftJS;
|
|
@@ -6704,7 +6709,7 @@ var
|
|
ArgEl: TPasExpr;
|
|
ArgEl: TPasExpr;
|
|
begin
|
|
begin
|
|
if El.Kind<>pekSet then
|
|
if El.Kind<>pekSet then
|
|
- RaiseInconsistency(20170209112737);
|
|
|
|
|
|
+ RaiseInconsistency(20170209112737,El);
|
|
if AContext.Access<>caRead then
|
|
if AContext.Access<>caRead then
|
|
DoError(20170209112926,nCantWriteSetLiteral,sCantWriteSetLiteral,[],El);
|
|
DoError(20170209112926,nCantWriteSetLiteral,sCantWriteSetLiteral,[],El);
|
|
if length(El.Params)=0 then
|
|
if length(El.Params)=0 then
|
|
@@ -6840,7 +6845,7 @@ begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
Param0:=El.Params[0];
|
|
Param0:=El.Params[0];
|
|
if AContext.Access<>caRead then
|
|
if AContext.Access<>caRead then
|
|
- RaiseInconsistency(20170213213621);
|
|
|
|
|
|
+ RaiseInconsistency(20170213213621,El);
|
|
AContext.Resolver.ComputeElement(Param0,ResolvedParam0,[rcNoImplicitProc]);
|
|
AContext.Resolver.ComputeElement(Param0,ResolvedParam0,[rcNoImplicitProc]);
|
|
{$IFDEF VerbosePasResolver}
|
|
{$IFDEF VerbosePasResolver}
|
|
writeln('TPasToJSConverter.ConvertBuiltInSetLength ',GetResolverResultDbg(ResolvedParam0));
|
|
writeln('TPasToJSConverter.ConvertBuiltInSetLength ',GetResolverResultDbg(ResolvedParam0));
|
|
@@ -7107,7 +7112,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if AContext.Resolver=nil then
|
|
if AContext.Resolver=nil then
|
|
- RaiseInconsistency(20170210105235);
|
|
|
|
|
|
+ RaiseInconsistency(20170210105235,El);
|
|
Param:=El.Params[0];
|
|
Param:=El.Params[0];
|
|
AContext.Resolver.ComputeElement(Param,ParamResolved,[rcNoImplicitProcType]);
|
|
AContext.Resolver.ComputeElement(Param,ParamResolved,[rcNoImplicitProcType]);
|
|
{$IFDEF VerbosePas2JS}
|
|
{$IFDEF VerbosePas2JS}
|
|
@@ -7164,7 +7169,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if AContext.Resolver=nil then
|
|
if AContext.Resolver=nil then
|
|
- RaiseInconsistency(20170325185847);
|
|
|
|
|
|
+ RaiseInconsistency(20170325185847,El);
|
|
Param:=El.Params[0];
|
|
Param:=El.Params[0];
|
|
AContext.Resolver.ComputeElement(Param,ParamResolved,[]);
|
|
AContext.Resolver.ComputeElement(Param,ParamResolved,[]);
|
|
if ParamResolved.BaseType in btAllJSInteger then
|
|
if ParamResolved.BaseType in btAllJSInteger then
|
|
@@ -7192,7 +7197,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if AContext.Resolver=nil then
|
|
if AContext.Resolver=nil then
|
|
- RaiseInconsistency(20170210105235);
|
|
|
|
|
|
+ RaiseInconsistency(20170210105235,El);
|
|
Param:=El.Params[0];
|
|
Param:=El.Params[0];
|
|
AContext.Resolver.ComputeElement(Param,ParamResolved,[]);
|
|
AContext.Resolver.ComputeElement(Param,ParamResolved,[]);
|
|
if ParamResolved.BaseType=btChar then
|
|
if ParamResolved.BaseType=btChar then
|
|
@@ -7218,7 +7223,7 @@ begin
|
|
Minus:=TJSAdditiveExpressionMinus(CreateElement(TJSAdditiveExpressionMinus,Param));
|
|
Minus:=TJSAdditiveExpressionMinus(CreateElement(TJSAdditiveExpressionMinus,Param));
|
|
Call.AddArg(Minus);
|
|
Call.AddArg(Minus);
|
|
if length(SubParams.Params)<>1 then
|
|
if length(SubParams.Params)<>1 then
|
|
- RaiseInconsistency(20170405231706);
|
|
|
|
|
|
+ RaiseInconsistency(20170405231706,El);
|
|
Minus.A:=ConvertElement(SubParams.Params[0],AContext);
|
|
Minus.A:=ConvertElement(SubParams.Params[0],AContext);
|
|
Minus.B:=CreateLiteralNumber(Param,1);
|
|
Minus.B:=CreateLiteralNumber(Param,1);
|
|
Result:=Call;
|
|
Result:=Call;
|
|
@@ -7295,7 +7300,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if AContext.Resolver=nil then
|
|
if AContext.Resolver=nil then
|
|
- RaiseInconsistency(20170210120659);
|
|
|
|
|
|
+ RaiseInconsistency(20170210120659,El);
|
|
Param:=El.Params[0];
|
|
Param:=El.Params[0];
|
|
AContext.Resolver.ComputeElement(Param,ResolvedEl,[]);
|
|
AContext.Resolver.ComputeElement(Param,ResolvedEl,[]);
|
|
case ResolvedEl.BaseType of
|
|
case ResolvedEl.BaseType of
|
|
@@ -7456,7 +7461,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if AContext.Resolver=nil then
|
|
if AContext.Resolver=nil then
|
|
- RaiseInconsistency(20170210120648);
|
|
|
|
|
|
+ RaiseInconsistency(20170210120648,El);
|
|
Param:=El.Params[0];
|
|
Param:=El.Params[0];
|
|
AContext.Resolver.ComputeElement(Param,ResolvedEl,[]);
|
|
AContext.Resolver.ComputeElement(Param,ResolvedEl,[]);
|
|
if (ResolvedEl.BaseType in btAllJSInteger)
|
|
if (ResolvedEl.BaseType in btAllJSInteger)
|
|
@@ -7655,7 +7660,7 @@ var
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
if length(El.Params)<1 then
|
|
if length(El.Params)<1 then
|
|
- RaiseInconsistency(20170331000332);
|
|
|
|
|
|
+ RaiseInconsistency(20170331000332,El);
|
|
if length(El.Params)=1 then
|
|
if length(El.Params)=1 then
|
|
begin
|
|
begin
|
|
// concat(array1) -> array1
|
|
// concat(array1) -> array1
|
|
@@ -7727,9 +7732,9 @@ begin
|
|
Param:=El.Params[0];
|
|
Param:=El.Params[0];
|
|
AContext.Resolver.ComputeElement(El,ParamResolved,[]);
|
|
AContext.Resolver.ComputeElement(El,ParamResolved,[]);
|
|
if ParamResolved.BaseType<>btContext then
|
|
if ParamResolved.BaseType<>btContext then
|
|
- RaiseInconsistency(20170401003242);
|
|
|
|
|
|
+ RaiseInconsistency(20170401003242,El);
|
|
if ParamResolved.TypeEl.ClassType<>TPasArrayType then
|
|
if ParamResolved.TypeEl.ClassType<>TPasArrayType then
|
|
- RaiseInconsistency(20170401003256);
|
|
|
|
|
|
+ RaiseInconsistency(20170401003256,El);
|
|
ArrayType:=TPasArrayType(ParamResolved.TypeEl);
|
|
ArrayType:=TPasArrayType(ParamResolved.TypeEl);
|
|
AContext.Resolver.ComputeElement(ArrayType.ElType,ElTypeResolved,[rcType]);
|
|
AContext.Resolver.ComputeElement(ArrayType.ElType,ElTypeResolved,[rcType]);
|
|
// rtl.arrayCopy(type,src,start,count)
|
|
// rtl.arrayCopy(type,src,start,count)
|
|
@@ -8014,7 +8019,7 @@ var
|
|
Ident: TJSPrimaryExpressionIdent;
|
|
Ident: TJSPrimaryExpressionIdent;
|
|
begin
|
|
begin
|
|
if AName='' then
|
|
if AName='' then
|
|
- RaiseInconsistency(20170402230134);
|
|
|
|
|
|
+ RaiseInconsistency(20170402230134,Src);
|
|
p:=PosLast('.',AName);
|
|
p:=PosLast('.',AName);
|
|
if p>0 then
|
|
if p>0 then
|
|
begin
|
|
begin
|
|
@@ -8764,7 +8769,7 @@ begin
|
|
// module.$rtti.$Class("classname");
|
|
// module.$rtti.$Class("classname");
|
|
Result:=CreateRTTINewType(aClass,FBuiltInNames[pbifnRTTINewClass],true,AContext,ObjLit);
|
|
Result:=CreateRTTINewType(aClass,FBuiltInNames[pbifnRTTINewClass],true,AContext,ObjLit);
|
|
if ObjLit<>nil then
|
|
if ObjLit<>nil then
|
|
- RaiseInconsistency(20170412093427);
|
|
|
|
|
|
+ RaiseInconsistency(20170412093427,El);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TPasToJSConverter.ConvertClassExternalType(El: TPasClassType;
|
|
function TPasToJSConverter.ConvertClassExternalType(El: TPasClassType;
|
|
@@ -8846,7 +8851,7 @@ begin
|
|
// prepend module.$rtti.$Class("classname");
|
|
// prepend module.$rtti.$Class("classname");
|
|
Call:=CreateRTTINewType(DestType,FBuiltInNames[pbifnRTTINewClass],true,AContext,ObjLit);
|
|
Call:=CreateRTTINewType(DestType,FBuiltInNames[pbifnRTTINewClass],true,AContext,ObjLit);
|
|
if ObjLit<>nil then
|
|
if ObjLit<>nil then
|
|
- RaiseInconsistency(20170412102654);
|
|
|
|
|
|
+ RaiseInconsistency(20170412102654,El);
|
|
List:=TJSStatementList(CreateElement(TJSStatementList,El));
|
|
List:=TJSStatementList(CreateElement(TJSStatementList,El));
|
|
List.A:=Call;
|
|
List.A:=Call;
|
|
List.B:=Result;
|
|
List.B:=Result;
|
|
@@ -9488,7 +9493,7 @@ Var
|
|
n, i:Integer;
|
|
n, i:Integer;
|
|
AssignSt: TJSSimpleAssignStatement;
|
|
AssignSt: TJSSimpleAssignStatement;
|
|
FuncContext: TFunctionContext;
|
|
FuncContext: TFunctionContext;
|
|
- ProcScope, ImplProcScope: TPasProcedureScope;
|
|
|
|
|
|
+ ProcScope, ImplProcScope: TPas2JSProcedureScope;
|
|
Arg: TPasArgument;
|
|
Arg: TPasArgument;
|
|
SelfSt: TJSVariableStatement;
|
|
SelfSt: TJSVariableStatement;
|
|
ImplProc: TPasProcedure;
|
|
ImplProc: TPasProcedure;
|
|
@@ -9504,7 +9509,7 @@ begin
|
|
if El.IsAbstract then exit;
|
|
if El.IsAbstract then exit;
|
|
if El.IsExternal then exit;
|
|
if El.IsExternal then exit;
|
|
|
|
|
|
- ProcScope:=TPasProcedureScope(El.CustomData);
|
|
|
|
|
|
+ ProcScope:=TPas2JSProcedureScope(El.CustomData);
|
|
if ProcScope.DeclarationProc<>nil then
|
|
if ProcScope.DeclarationProc<>nil then
|
|
exit;
|
|
exit;
|
|
|
|
|
|
@@ -9515,7 +9520,7 @@ begin
|
|
ImplProc:=El;
|
|
ImplProc:=El;
|
|
if ProcScope.ImplProc<>nil then
|
|
if ProcScope.ImplProc<>nil then
|
|
ImplProc:=ProcScope.ImplProc;
|
|
ImplProc:=ProcScope.ImplProc;
|
|
- ImplProcScope:=TPasProcedureScope(ImplProc.CustomData);
|
|
|
|
|
|
+ ImplProcScope:=TPas2JSProcedureScope(ImplProc.CustomData);
|
|
|
|
|
|
AssignSt:=nil;
|
|
AssignSt:=nil;
|
|
if AContext.IsGlobal then
|
|
if AContext.IsGlobal then
|
|
@@ -9535,6 +9540,7 @@ begin
|
|
Result:=FS;
|
|
Result:=FS;
|
|
FD.Name:=TJSString(TransformVariableName(El,AContext));
|
|
FD.Name:=TJSString(TransformVariableName(El,AContext));
|
|
end;
|
|
end;
|
|
|
|
+
|
|
for n := 0 to El.ProcType.Args.Count - 1 do
|
|
for n := 0 to El.ProcType.Args.Count - 1 do
|
|
begin
|
|
begin
|
|
Arg:=TPasArgument(El.ProcType.Args[n]);
|
|
Arg:=TPasArgument(El.ProcType.Args[n]);
|
|
@@ -9625,6 +9631,9 @@ begin
|
|
FuncContext.Free;
|
|
FuncContext.Free;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
+
|
|
|
|
+ if coStoreProcJS in Options then
|
|
|
|
+ StorePrecompiledProcedure(ImplProc,Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TPasToJSConverter.ConvertBeginEndStatement(El: TPasImplBeginBlock;
|
|
function TPasToJSConverter.ConvertBeginEndStatement(El: TPasImplBeginBlock;
|
|
@@ -10062,7 +10071,7 @@ begin
|
|
// create implementation declarations
|
|
// create implementation declarations
|
|
ImplDecl:=ConvertDeclarations(El.ImplementationSection,ImplContext);
|
|
ImplDecl:=ConvertDeclarations(El.ImplementationSection,ImplContext);
|
|
if ImplDecl<>nil then
|
|
if ImplDecl<>nil then
|
|
- RaiseInconsistency(20170910175032); // elements should have been added directly
|
|
|
|
|
|
+ RaiseInconsistency(20170910175032,El); // elements should have been added directly
|
|
if Src.Statements[Src.Statements.Count-1].Node=ImplVarSt then
|
|
if Src.Statements[Src.Statements.Count-1].Node=ImplVarSt then
|
|
exit; // no implementation
|
|
exit; // no implementation
|
|
// add impl declarations
|
|
// add impl declarations
|
|
@@ -10095,9 +10104,9 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if Left=nil then
|
|
if Left=nil then
|
|
- RaiseInconsistency(20170201140827);
|
|
|
|
|
|
+ RaiseInconsistency(20170201140827,aParent);
|
|
if Right=nil then
|
|
if Right=nil then
|
|
- RaiseInconsistency(20170211192018);
|
|
|
|
|
|
+ RaiseInconsistency(20170211192018,aParent);
|
|
ok:=false;
|
|
ok:=false;
|
|
try
|
|
try
|
|
// create a TJSDotMemberExpression of Left and the left-most identifier of Right
|
|
// create a TJSDotMemberExpression of Left and the left-most identifier of Right
|
|
@@ -10160,7 +10169,7 @@ begin
|
|
{$IFDEF VerbosePas2JS}
|
|
{$IFDEF VerbosePas2JS}
|
|
writeln('TPasToJSConverter.CreateDotExpression Right=',GetObjName(Right),' RightParent=',GetObjName(RightParent),' Result=',GetObjName(Result));
|
|
writeln('TPasToJSConverter.CreateDotExpression Right=',GetObjName(Right),' RightParent=',GetObjName(RightParent),' Result=',GetObjName(Result));
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- RaiseInconsistency(20170129141307);
|
|
|
|
|
|
+ RaiseInconsistency(20170129141307,aParent);
|
|
end;
|
|
end;
|
|
Dot.MExpr := Left;
|
|
Dot.MExpr := Left;
|
|
Dot.Name := TJSPrimaryExpressionIdent(Right).Name;
|
|
Dot.Name := TJSPrimaryExpressionIdent(Right).Name;
|
|
@@ -10261,7 +10270,7 @@ var
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if not (ResolvedEl.IdentEl is TPasProcedure) then
|
|
if not (ResolvedEl.IdentEl is TPasProcedure) then
|
|
- RaiseInconsistency(20170215140756);
|
|
|
|
|
|
+ RaiseInconsistency(20170215140756,El);
|
|
|
|
|
|
Target:=ConvertElement(El,AContext);
|
|
Target:=ConvertElement(El,AContext);
|
|
|
|
|
|
@@ -10370,7 +10379,7 @@ begin
|
|
if AssignContext.RightSide<>nil then
|
|
if AssignContext.RightSide<>nil then
|
|
begin
|
|
begin
|
|
LHS.Free;
|
|
LHS.Free;
|
|
- RaiseInconsistency(20170207215447);
|
|
|
|
|
|
+ RaiseInconsistency(20170207215447,LeftEl);
|
|
end;
|
|
end;
|
|
Result:=LHS;
|
|
Result:=LHS;
|
|
end
|
|
end
|
|
@@ -10502,7 +10511,7 @@ begin
|
|
// get module path
|
|
// get module path
|
|
aModule:=El.GetModule;
|
|
aModule:=El.GetModule;
|
|
if aModule=nil then
|
|
if aModule=nil then
|
|
- RaiseInconsistency(20170418115552);
|
|
|
|
|
|
+ RaiseInconsistency(20170418115552,El);
|
|
RttiPath:=AContext.GetLocalName(aModule);
|
|
RttiPath:=AContext.GetLocalName(aModule);
|
|
if RttiPath='' then
|
|
if RttiPath='' then
|
|
RttiPath:=TransformModuleName(aContext.GetRootModule,true,AContext);
|
|
RttiPath:=TransformModuleName(aContext.GetRootModule,true,AContext);
|
|
@@ -10730,7 +10739,7 @@ begin
|
|
try
|
|
try
|
|
// stored <const bool>
|
|
// stored <const bool>
|
|
if StoredValue.Kind<>revkBool then
|
|
if StoredValue.Kind<>revkBool then
|
|
- RaiseInconsistency(20170924082845);
|
|
|
|
|
|
+ RaiseInconsistency(20170924082845,Prop);
|
|
StoredExpr:=nil;
|
|
StoredExpr:=nil;
|
|
if TResEvalBool(StoredValue).B then
|
|
if TResEvalBool(StoredValue).B then
|
|
inc(Flags,pfStoredTrue)
|
|
inc(Flags,pfStoredTrue)
|
|
@@ -11016,6 +11025,29 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasToJSConverter.StorePrecompiledProcedure(ImplProc: TPasProcedure;
|
|
|
|
+ JS: TJSElement);
|
|
|
|
+var
|
|
|
|
+ ImplScope: TPas2JSProcedureScope;
|
|
|
|
+ aWriter: TBufferWriter;
|
|
|
|
+ aJSWriter: TJSWriter;
|
|
|
|
+begin
|
|
|
|
+ ImplScope:=TPas2JSProcedureScope(ImplProc.CustomData);
|
|
|
|
+ if ImplScope.ImplProc<>nil then
|
|
|
|
+ RaiseInconsistency(20180228124545,ImplProc);
|
|
|
|
+ aJSWriter:=nil;
|
|
|
|
+ aWriter:=TBufferWriter.Create(1000);
|
|
|
|
+ try
|
|
|
|
+ aJSWriter:=TJSWriter.Create(aWriter);
|
|
|
|
+ aJSWriter.IndentSize:=2;
|
|
|
|
+ aJSWriter.WriteJS(JS);
|
|
|
|
+ ImplScope.BodyJS:=aWriter.AsAnsistring;
|
|
|
|
+ finally
|
|
|
|
+ aJSWriter.Free;
|
|
|
|
+ aWriter.Free;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasToJSConverter.ConvertImplBlock(El: TPasImplBlock;
|
|
function TPasToJSConverter.ConvertImplBlock(El: TPasImplBlock;
|
|
AContext: TConvertContext): TJSElement;
|
|
AContext: TConvertContext): TJSElement;
|
|
|
|
|
|
@@ -11232,7 +11264,7 @@ begin
|
|
begin
|
|
begin
|
|
// left side is a Setter -> RightSide was already inserted as parameter
|
|
// left side is a Setter -> RightSide was already inserted as parameter
|
|
if AssignContext.RightSide<>nil then
|
|
if AssignContext.RightSide<>nil then
|
|
- RaiseInconsistency(20170207215544);
|
|
|
|
|
|
+ RaiseInconsistency(20170207215544,El.left);
|
|
Result:=LHS;
|
|
Result:=LHS;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
@@ -11719,7 +11751,7 @@ Var
|
|
begin
|
|
begin
|
|
Result:=Nil;
|
|
Result:=Nil;
|
|
if AContext.Access<>caRead then
|
|
if AContext.Access<>caRead then
|
|
- RaiseInconsistency(20170213213740);
|
|
|
|
|
|
+ RaiseInconsistency(20170213213740,El);
|
|
ForScope:=El.CustomData as TPasForLoopScope; // can be nil!
|
|
ForScope:=El.CustomData as TPasForLoopScope; // can be nil!
|
|
case El.LoopType of
|
|
case El.LoopType of
|
|
ltNormal,ltDown: ;
|
|
ltNormal,ltDown: ;
|
|
@@ -12054,7 +12086,7 @@ begin
|
|
// $with1.X = 3;
|
|
// $with1.X = 3;
|
|
FuncContext:=TFunctionContext(AContext.GetContextOfType(TFunctionContext));
|
|
FuncContext:=TFunctionContext(AContext.GetContextOfType(TFunctionContext));
|
|
if FuncContext=nil then
|
|
if FuncContext=nil then
|
|
- RaiseInconsistency(20170212003759);
|
|
|
|
|
|
+ RaiseInconsistency(20170212003759,El);
|
|
FirstSt:=nil;
|
|
FirstSt:=nil;
|
|
LastSt:=nil;
|
|
LastSt:=nil;
|
|
try
|
|
try
|
|
@@ -12167,7 +12199,7 @@ begin
|
|
Result:=false;
|
|
Result:=false;
|
|
if aClass.Parent=nil then exit;
|
|
if aClass.Parent=nil then exit;
|
|
if not aClass.Parent.InheritsFrom(TPasDeclarations) then
|
|
if not aClass.Parent.InheritsFrom(TPasDeclarations) then
|
|
- RaiseInconsistency(20170412101457);
|
|
|
|
|
|
+ RaiseInconsistency(20170412101457,aClass);
|
|
Decls:=TPasDeclarations(aClass.Parent);
|
|
Decls:=TPasDeclarations(aClass.Parent);
|
|
Types:=Decls.Types;
|
|
Types:=Decls.Types;
|
|
for i:=0 to Types.Count-1 do
|
|
for i:=0 to Types.Count-1 do
|
|
@@ -12190,11 +12222,6 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TPasToJSConverter.RaiseInconsistency(Id: int64);
|
|
|
|
-begin
|
|
|
|
- raise Exception.Create('TPasToJSConverter.RaiseInconsistency['+IntToStr(Id)+']: you found a bug');
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
function TPasToJSConverter.CreateUnary(Members: array of string; E: TJSElement): TJSUnary;
|
|
function TPasToJSConverter.CreateUnary(Members: array of string; E: TJSElement): TJSUnary;
|
|
var
|
|
var
|
|
unary: TJSUnary;
|
|
unary: TJSUnary;
|
|
@@ -12384,7 +12411,7 @@ begin
|
|
begin
|
|
begin
|
|
if AContext.Resolver=nil then
|
|
if AContext.Resolver=nil then
|
|
exit(CreateLiteralUndefined(El));
|
|
exit(CreateLiteralUndefined(El));
|
|
- RaiseInconsistency(20170415185745);
|
|
|
|
|
|
+ RaiseInconsistency(20170415185745,El);
|
|
end;
|
|
end;
|
|
Result:=ConvertElement(Expr,AContext);
|
|
Result:=ConvertElement(Expr,AContext);
|
|
if Result=nil then
|
|
if Result=nil then
|
|
@@ -12662,7 +12689,7 @@ var
|
|
JS: TJSString;
|
|
JS: TJSString;
|
|
begin
|
|
begin
|
|
if Lit.Value.ValueType<>jstString then
|
|
if Lit.Value.ValueType<>jstString then
|
|
- RaiseInconsistency(20171112020856);
|
|
|
|
|
|
+ RaiseInconsistency(20171112020856,ErrorEl);
|
|
if Lit.Value.CustomValue<>'' then
|
|
if Lit.Value.CustomValue<>'' then
|
|
JS:=Lit.Value.CustomValue
|
|
JS:=Lit.Value.CustomValue
|
|
else
|
|
else
|
|
@@ -12814,7 +12841,7 @@ var
|
|
BinExpr: TJSBinaryExpression;
|
|
BinExpr: TJSBinaryExpression;
|
|
begin
|
|
begin
|
|
if not (OpCode in [eopEqual,eopNotEqual]) then
|
|
if not (OpCode in [eopEqual,eopNotEqual]) then
|
|
- RaiseInconsistency(20170401184819);
|
|
|
|
|
|
+ RaiseInconsistency(20170401184819,El);
|
|
Call:=CreateCallExpression(El);
|
|
Call:=CreateCallExpression(El);
|
|
Call.Expr:=CreateMemberExpression([FBuiltInNames[pbivnRTL],FBuiltInNames[pbifnArray_Length]]);
|
|
Call.Expr:=CreateMemberExpression([FBuiltInNames[pbivnRTL],FBuiltInNames[pbifnArray_Length]]);
|
|
Call.AddArg(JSArray);
|
|
Call.AddArg(JSArray);
|
|
@@ -13018,7 +13045,7 @@ begin
|
|
// in other unit -> use pas.unitname.$impl
|
|
// in other unit -> use pas.unitname.$impl
|
|
FoundModule:=El.GetModule;
|
|
FoundModule:=El.GetModule;
|
|
if FoundModule=nil then
|
|
if FoundModule=nil then
|
|
- RaiseInconsistency(20161024192755);
|
|
|
|
|
|
+ RaiseInconsistency(20161024192755,El);
|
|
Prepend(Result,TransformModuleName(FoundModule,true,AContext)
|
|
Prepend(Result,TransformModuleName(FoundModule,true,AContext)
|
|
+'.'+FBuiltInNames[pbivnImplementation]);
|
|
+'.'+FBuiltInNames[pbivnImplementation]);
|
|
end;
|
|
end;
|
|
@@ -13334,7 +13361,7 @@ begin
|
|
{$IFDEF VerbosePas2JS}
|
|
{$IFDEF VerbosePas2JS}
|
|
writeln('TPasToJSConverter.CreateProcedureCallArg FullGetter=',GetObjName(FullGetter),' Getter=',GetObjName(ParamContext.Getter),' Setter=',GetObjName(ParamContext.Setter));
|
|
writeln('TPasToJSConverter.CreateProcedureCallArg FullGetter=',GetObjName(FullGetter),' Getter=',GetObjName(ParamContext.Getter),' Setter=',GetObjName(ParamContext.Setter));
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- RaiseInconsistency(20170213222941);
|
|
|
|
|
|
+ RaiseInconsistency(20170213222941,El);
|
|
end;
|
|
end;
|
|
|
|
|
|
// create "{p:Result,get:function(){return this.p.Getter},set:function(v){this.p.Setter(v);}}"
|
|
// create "{p:Result,get:function(){return this.p.Getter},set:function(v){this.p.Setter(v);}}"
|
|
@@ -13344,7 +13371,7 @@ begin
|
|
begin
|
|
begin
|
|
// create "{get:function(){return FullGetter;},set:function(v){FullGetter=v;}}"
|
|
// create "{get:function(){return FullGetter;},set:function(v){FullGetter=v;}}"
|
|
if (ParamContext.Getter<>nil) and (ParamContext.Getter<>FullGetter) then
|
|
if (ParamContext.Getter<>nil) and (ParamContext.Getter<>FullGetter) then
|
|
- RaiseInconsistency(20170213224339);
|
|
|
|
|
|
+ RaiseInconsistency(20170213224339,El);
|
|
GetPath:=String(TJSPrimaryExpressionIdent(FullGetter).Name);
|
|
GetPath:=String(TJSPrimaryExpressionIdent(FullGetter).Name);
|
|
GetDotPos:=PosLast('.',GetPath);
|
|
GetDotPos:=PosLast('.',GetPath);
|
|
if GetDotPos>0 then
|
|
if GetDotPos>0 then
|
|
@@ -13471,7 +13498,7 @@ begin
|
|
else if (SetExpr.ClassType=TJSCallExpression) then
|
|
else if (SetExpr.ClassType=TJSCallExpression) then
|
|
// has already the form Func(v)
|
|
// has already the form Func(v)
|
|
else
|
|
else
|
|
- RaiseInconsistency(20170213225940);
|
|
|
|
|
|
+ RaiseInconsistency(20170213225940,El);
|
|
|
|
|
|
// add p:GetPathExpr
|
|
// add p:GetPathExpr
|
|
AddVar(GetPathName,GetPathExpr);
|
|
AddVar(GetPathName,GetPathExpr);
|
|
@@ -13717,7 +13744,7 @@ begin
|
|
if El=nil then
|
|
if El=nil then
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
- RaiseInconsistency(20161024190203);
|
|
|
|
|
|
+ RaiseInconsistency(20161024190203,El);
|
|
end;
|
|
end;
|
|
C:=El.ClassType;
|
|
C:=El.ClassType;
|
|
if (C=TPasConst) then
|
|
if (C=TPasConst) then
|
|
@@ -14067,7 +14094,7 @@ begin
|
|
// module.$rtti.$Record("typename",{});
|
|
// module.$rtti.$Record("typename",{});
|
|
Call:=CreateRTTINewType(El,FBuiltInNames[pbifnRTTINewRecord],false,AContext,ObjLit);
|
|
Call:=CreateRTTINewType(El,FBuiltInNames[pbifnRTTINewRecord],false,AContext,ObjLit);
|
|
if ObjLit=nil then
|
|
if ObjLit=nil then
|
|
- RaiseInconsistency(20170412124804);
|
|
|
|
|
|
+ RaiseInconsistency(20170412124804,El);
|
|
if El.Members.Count>0 then
|
|
if El.Members.Count>0 then
|
|
begin
|
|
begin
|
|
// module.$rtti.$Record("typename",{}).addFields(
|
|
// module.$rtti.$Record("typename",{}).addFields(
|
|
@@ -14168,6 +14195,23 @@ begin
|
|
raise E;
|
|
raise E;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasToJSConverter.RaiseInconsistency(Id: int64; El: TPasElement);
|
|
|
|
+var
|
|
|
|
+ s: String;
|
|
|
|
+begin
|
|
|
|
+ s:='TPasToJSConverter.RaiseInconsistency['+IntToStr(Id)+']: you found a bug';
|
|
|
|
+ if El<>nil then
|
|
|
|
+ begin
|
|
|
|
+ s:=s+El.FullName;
|
|
|
|
+ if El.Name<>'' then
|
|
|
|
+ s:=s+El.Name
|
|
|
|
+ else
|
|
|
|
+ s:=s+GetElementTypeName(El);
|
|
|
|
+ s:=s+' at '+TPas2JSResolver.GetDbgSourcePosStr(El);
|
|
|
|
+ end;
|
|
|
|
+ raise Exception.Create(s);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasToJSConverter.TransformVariableName(El: TPasElement;
|
|
function TPasToJSConverter.TransformVariableName(El: TPasElement;
|
|
const AName: String; AContext: TConvertContext): String;
|
|
const AName: String; AContext: TConvertContext): String;
|
|
var
|
|
var
|
|
@@ -14176,7 +14220,7 @@ var
|
|
begin
|
|
begin
|
|
if AContext=nil then ;
|
|
if AContext=nil then ;
|
|
if Pos('.',AName)>0 then
|
|
if Pos('.',AName)>0 then
|
|
- RaiseInconsistency(20170203164711);
|
|
|
|
|
|
+ RaiseInconsistency(20170203164711,El);
|
|
if UseLowerCase then
|
|
if UseLowerCase then
|
|
Result:=LowerCase(AName)
|
|
Result:=LowerCase(AName)
|
|
else
|
|
else
|
|
@@ -14299,7 +14343,7 @@ begin
|
|
Result:='';
|
|
Result:='';
|
|
El:=AContext.Resolver.ResolveAliasType(El);
|
|
El:=AContext.Resolver.ResolveAliasType(El);
|
|
if El=nil then
|
|
if El=nil then
|
|
- RaiseInconsistency(20170409172756);
|
|
|
|
|
|
+ RaiseInconsistency(20170409172756,El);
|
|
if El=AContext.PasElement then
|
|
if El=AContext.PasElement then
|
|
begin
|
|
begin
|
|
// referring to itself
|
|
// referring to itself
|