summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattias <mattias@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-09-23 14:31:17 +0000
committermattias <mattias@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-09-23 14:31:17 +0000
commit29d27e13237e8b8fdf2cee276a9b99defe2e114f (patch)
treecc3d79eb541eb71d140e9ce353b68fa9aef9f3be
parentdc37889a2824a162dfb6793844cb60225b46936a (diff)
downloadfpc-29d27e13237e8b8fdf2cee276a9b99defe2e114f.tar.gz
pastojs: optimization ShortRefGlobals
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@46927 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--packages/pastojs/src/fppas2js.pp660
-rw-r--r--packages/pastojs/src/pas2jscompiler.pp108
-rw-r--r--packages/pastojs/src/pas2jsutils.pp2
-rw-r--r--packages/pastojs/tests/tcgenerics.pas136
-rw-r--r--packages/pastojs/tests/tcmodules.pas1400
-rw-r--r--packages/pastojs/tests/tcoptimizations.pas124
-rw-r--r--packages/pastojs/tests/testpas2js.lpi1
7 files changed, 1325 insertions, 1106 deletions
diff --git a/packages/pastojs/src/fppas2js.pp b/packages/pastojs/src/fppas2js.pp
index c60edcd2ab..b1396ee3fe 100644
--- a/packages/pastojs/src/fppas2js.pp
+++ b/packages/pastojs/src/fppas2js.pp
@@ -1364,7 +1364,7 @@ type
coRTLVersionCheckMain, // insert rtl version check into main
coRTLVersionCheckSystem, // insert rtl version check into system unit init
coRTLVersionCheckUnit, // insert rtl version check into every unit init
- coAliasGlobals // use short alias variables for global identifiers
+ coShortRefGlobals // use short local variables for global identifiers
);
TPasToJsConverterOptions = set of TPasToJsConverterOption;
const
@@ -1632,7 +1632,18 @@ type
caAssign, // needs setter, aContext.AccessContext is TAssignContext
caByReference // needs path, getter and setter, aContext.AccessContext is TParamContext
);
+ TCtxVarKind = (
+ cvkNone,
+ cvkGlobal, // e.g. $mod, $impl, class type
+ cvkCurType, // e.g. PasElement is a class, js var is the current class (Self in a class method)
+ cvkInstance, // e.g. PasElement is a class, js var is the current instance (Self in method)
+ cvkHelperTemp // e.g. helper-for getter/setter
+ );
+ TCtxVarKinds = set of TCtxVarKind;
+const
+ cvkAll = [cvkNone..cvkHelperTemp];
+type
TFunctionContext = Class;
{ TConvertContext }
@@ -1655,7 +1666,7 @@ type
function GetRootContext: TConvertContext;
function GetNonDotContext: TConvertContext;
function GetFunctionContext: TFunctionContext;
- function GetLocalName(El: TPasElement; SkipSelf: boolean): string; virtual;
+ function GetLocalName(El: TPasElement; const Filter: TCtxVarKinds): string; virtual;
function GetSelfContext: TFunctionContext;
function GetContextOfPasElement(El: TPasElement): TConvertContext;
function GetFuncContextOfPasElement(El: TPasElement): TFunctionContext;
@@ -1683,18 +1694,11 @@ type
public
Element: TPasElement;
Name: string;
- constructor Create(const aName: string; TheEl: TPasElement);
+ Kind: TCtxVarKind;
+ constructor Create(const aName: string; TheEl: TPasElement; aKind: TCtxVarKind);
end;
TFCLocalVars = array of TFCLocalIdentifier;
- TConvCtxThisKind = (
- cctkNone,
- cctkGlobal, // e.g. $mod, $impl, class type
- cctkCurType, // e.g. class-of
- cctkInstance,
- cctkHelperTemp // e.g. helper-for getter/setter
- );
-
{ TFunctionContext
Module Function: PasElement is TPasProcedure (ImplProc), ThisPas=nil
Method: PasElement is TPasProcedure (ImplProc), ThisPas is TPasMembersType }
@@ -1702,24 +1706,26 @@ type
TFunctionContext = Class(TConvertContext)
public
LocalVars: TFCLocalVars;
- ThisPas: TPasElement;
- ThisKind: TConvCtxThisKind;
+ ThisVar: TFCLocalIdentifier;
IntfElReleases: TFPList; // list of TPasElement, that needs rtl._Release(<El>)
ResultNeedsIntfRelease: boolean;
IntfExprReleaseCount: integer; // >0 means needs $ir
BodySt: TJSElement;
TrySt: TJSTryFinallyStatement;
FinallyFirst, FinallyLast: TJSStatementList;
+ constructor Create(PasEl: TPasElement; JSEl: TJSElement;
+ aParent: TConvertContext); override;
destructor Destroy; override;
- function AddLocalVar(aName: string; El: TPasElement; AutoUnique: boolean): TFCLocalIdentifier;
+ function AddLocalVar(aName: string; El: TPasElement; aKind: TCtxVarKind; AutoUnique: boolean): TFCLocalIdentifier;
+ function AddLocalJSVar(aName: string; AutoUnique: boolean): TFCLocalIdentifier;
procedure Add_InterfaceRelease(El: TPasElement);
function CreateLocalIdentifier(const Prefix: string): string;
function ToString: string; override;
- function GetLocalName(El: TPasElement; SkipSelf: boolean): string; override;
+ function GetLocalName(El: TPasElement; const Filter: TCtxVarKinds): string; override;
function IndexOfLocalVar(const aName: string): integer;
- function IndexOfLocalVar(El: TPasElement): integer;
+ function IndexOfLocalVar(El: TPasElement; const Filter: TCtxVarKinds): integer;
function FindLocalVar(const aName: string; WithParents: boolean): TFCLocalIdentifier;
- function FindLocalIdentifier(El: TPasElement; WithParents: boolean): TFCLocalIdentifier;
+ function FindLocalIdentifier(El: TPasElement; const Filter: TCtxVarKinds): TFCLocalIdentifier;
procedure DoWriteStack(Index: integer); override;
end;
@@ -2022,7 +2028,7 @@ type
Procedure CreateRecordRTTI(El: TPasRecordType; Src: TJSSourceElements;
FuncContext: TFunctionContext; MembersSrc: TJSSourceElements;
MembersFuncContext: TFunctionContext); virtual;
- Function CreateDelayedInitFunction(PosEl: TPasElement; Src: TJSSourceElements;
+ Function CreateDelayedInitMembersFunction(PosEl: TPasElement; Src: TJSSourceElements;
FuncContext: TFunctionContext; out DelaySrc: TJSSourceElements): TFunctionContext; virtual;
// array
Function CreateArrayConcat(ElTypeResolved: TPasResolverResult; PosEl: TPasElement;
@@ -2387,11 +2393,15 @@ end;
destructor TInterfaceSectionContext.Destroy;
var
i: Integer;
+ El: TJSElement;
begin
if ImplHeaderStatements<>nil then
begin
for i:=0 to ImplHeaderStatements.Count-1 do
- TJSElement(ImplHeaderStatements[i]).Free;
+ begin
+ El:=TJSElement(ImplHeaderStatements[i]);
+ El.Free;
+ end;
FreeAndNil(ImplHeaderStatements);
end;
inherited Destroy;
@@ -2683,10 +2693,12 @@ end;
{ TFCLocalIdentifier }
-constructor TFCLocalIdentifier.Create(const aName: string; TheEl: TPasElement);
+constructor TFCLocalIdentifier.Create(const aName: string; TheEl: TPasElement;
+ aKind: TCtxVarKind);
begin
Name:=aName;
Element:=TheEl;
+ Kind:=aKind;
end;
{ TPas2jsPasScanner }
@@ -2852,8 +2864,8 @@ procedure TPas2jsPasScanner.DoHandleOptimization(OptName, OptValue: string);
begin
case lowercase(OptName) of
- 'jsaliasglobals':
- HandleBoolean(coAliasGlobals,true);
+ 'jsshortrefglobals':
+ HandleBoolean(coShortRefGlobals,true);
else
DoLog(mtWarning,nWarnIllegalCompilerDirectiveX,sWarnIllegalCompilerDirectiveX,['optimization '+OptName]);
end;
@@ -7094,7 +7106,7 @@ begin
else if El is TPasVariable then
Result:=vmExternal in TPasVariable(El).VarModifiers
else
- Result:=true;
+ Result:=false;
end;
function TPas2JSResolver.ImplBlockReadsDecl(Block: TPasImplBlock;
@@ -7203,6 +7215,15 @@ end;
{ TFunctionContext }
+constructor TFunctionContext.Create(PasEl: TPasElement; JSEl: TJSElement;
+ aParent: TConvertContext);
+begin
+ inherited Create(PasEl, JSEl, aParent);
+ ThisVar:=TFCLocalIdentifier.Create('this',nil,cvkNone);
+ SetLength(LocalVars,1);
+ LocalVars[0]:=ThisVar;
+end;
+
destructor TFunctionContext.Destroy;
var
i: Integer;
@@ -7210,14 +7231,15 @@ begin
FreeAndNil(IntfElReleases);
for i:=0 to length(LocalVars)-1 do
FreeAndNil(LocalVars[i]);
+ ThisVar:=nil;
inherited Destroy;
end;
function TFunctionContext.AddLocalVar(aName: string; El: TPasElement;
- AutoUnique: boolean): TFCLocalIdentifier;
+ aKind: TCtxVarKind; AutoUnique: boolean): TFCLocalIdentifier;
var
l: Integer;
- Ident: TFCLocalIdentifier;
+ Ident, V: TFCLocalIdentifier;
begin
Ident:=FindLocalVar(aName,true);
if Ident<>nil then
@@ -7229,22 +7251,34 @@ begin
inc(l);
aName:=aName+IntToStr(l);
end
- else if (El=nil) or (Ident.Element<>El) then
- // add alias, same name for two different TPasElements
else
begin
- {$IFDEF VerbosePas2JS}
- writeln('TFunctionContext.AddLocalVar [20200608131330] "'+aName+'" El='+GetObjPath(El));
- {$ENDIF}
- raise EPas2JS.Create('[20200608131330] "'+aName+'" El='+GetObjPath(El));
+ V:=FindLocalVar(aName,false);
+ if V=nil then
+ // overriding parent context
+ else if El<>V.Element then
+ // adding an alias, e.g. "this" for classtype and SelfArg
+ else
+ begin
+ {$IFDEF VerbosePas2JS}
+ writeln('TFunctionContext.AddLocalVar [20200608131330] "'+aName+'" El='+GetObjPath(El),' Old=',GetObjPath(Ident.Element));
+ {$ENDIF}
+ raise EPas2JS.Create('[20200608131330] "'+aName+'" El='+GetObjPath(El));
+ end;
end;
end;
l:=length(LocalVars);
SetLength(LocalVars,l+1);
- Result:=TFCLocalIdentifier.Create(aName,El);
+ Result:=TFCLocalIdentifier.Create(aName,El,aKind);
LocalVars[l]:=Result;
end;
+function TFunctionContext.AddLocalJSVar(aName: string; AutoUnique: boolean
+ ): TFCLocalIdentifier;
+begin
+ Result:=AddLocalVar(aName,nil,cvkNone,AutoUnique);
+end;
+
procedure TFunctionContext.Add_InterfaceRelease(El: TPasElement);
begin
if IntfElReleases=nil then
@@ -7270,41 +7304,55 @@ end;
function TFunctionContext.ToString: string;
var
- V: TFCLocalIdentifier;
+ s: string;
begin
Result:=inherited ToString;
- if ThisPas<>nil then
+ if ThisVar.Element<>nil then
begin
- Result:=Result+' this';
- V:=FindLocalIdentifier(ThisPas,false);
- if V<>nil then
- Result:=Result+'="'+V.Name+'"';
- Result:=Result+'='+GetObjName(ThisPas);
+ str(ThisVar.Kind,s);
+ Result:=Result+' this,Kind='+s+',El='+GetObjPath(ThisVar.Element);
end;
end;
-function TFunctionContext.GetLocalName(El: TPasElement; SkipSelf: boolean
- ): string;
+function TFunctionContext.GetLocalName(El: TPasElement;
+ const Filter: TCtxVarKinds): string;
+
+ function Check(V: TFCLocalIdentifier; FuncCtx: TFunctionContext): boolean;
+ begin
+ Result:=false;
+ if (V.Name<>'') and (V.Element=El) and (V.Kind in Filter) then
+ begin
+ // found a candidate
+ if (V.Name='this') and (FuncCtx<>Self) then
+ exit;
+ if (Filter<>cvkAll) then
+ begin
+ if FindLocalVar(V.Name,true)<>V then
+ exit; // another var in a lower context hides this var
+ end;
+ Result:=true;
+ end;
+ end;
+
var
V: TFCLocalIdentifier;
+ FuncCtx: TFunctionContext;
+ i: Integer;
begin
if El=nil then exit('');
- V:=FindLocalIdentifier(El,false);
- if V<>nil then
- begin
- Result:=V.Name;
- if Result=LocalVarHide then
- exit('');
- if SkipSelf and ((Result='this') or (Result='$Self')) then
- // search further
- else
- exit;
- end
- else if (ThisPas=El) and not SkipSelf then
- exit('this');
- Result:=inherited GetLocalName(El,SkipSelf);
- if Result='this' then
- Result:='';
+ FuncCtx:=Self;
+ repeat
+ if Check(FuncCtx.ThisVar,FuncCtx) then
+ exit('this');
+ for i:=0 to length(FuncCtx.LocalVars)-1 do
+ begin
+ V:=FuncCtx.LocalVars[i];
+ if Check(V,FuncCtx) then
+ exit(V.Name);
+ end;
+ FuncCtx:=FuncCtx.Parent.GetFunctionContext;
+ until FuncCtx=nil;
+ Result:='';
end;
function TFunctionContext.IndexOfLocalVar(const aName: string): integer;
@@ -7316,13 +7364,15 @@ begin
Result:=-1;
end;
-function TFunctionContext.IndexOfLocalVar(El: TPasElement): integer;
+function TFunctionContext.IndexOfLocalVar(El: TPasElement;
+ const Filter: TCtxVarKinds): integer;
var
i: Integer;
begin
if El=nil then exit(-1);
for i:=0 to length(LocalVars)-1 do
- if LocalVars[i].Element=El then exit(i);
+ if (LocalVars[i].Element=El) and (LocalVars[i].Kind in Filter) then
+ exit(i);
Result:=-1;
end;
@@ -7344,20 +7394,13 @@ begin
end;
function TFunctionContext.FindLocalIdentifier(El: TPasElement;
- WithParents: boolean): TFCLocalIdentifier;
+ const Filter: TCtxVarKinds): TFCLocalIdentifier;
var
i: Integer;
- ParentFC: TFunctionContext;
begin
- i:=IndexOfLocalVar(El);
+ i:=IndexOfLocalVar(El,Filter);
if i>=0 then
exit(LocalVars[i]);
- if (not WithParents) or (Parent=nil) then
- exit(nil);
- ParentFC:=Parent.GetFunctionContext;
- if ParentFC=nil then
- exit(nil);
- Result:=ParentFC.FindLocalIdentifier(El,true);
end;
procedure TFunctionContext.DoWriteStack(Index: integer);
@@ -7367,7 +7410,7 @@ begin
inherited DoWriteStack(Index);
{AllowWriteln}
for i:=0 to length(LocalVars)-1 do
- writeln(' ',i,' ',LocalVars[i].Name,': ',GetObjName(LocalVars[i].Element));
+ writeln(' ',i,' ',LocalVars[i].Name,': ',GetObjName(LocalVars[i].Element),' ',LocalVars[i].Kind);
{AllowWriteln-}
end;
@@ -7421,11 +7464,11 @@ begin
Result:=TFunctionContext(GetContextOfType(TFunctionContext));
end;
-function TConvertContext.GetLocalName(El: TPasElement; SkipSelf: boolean
- ): string;
+function TConvertContext.GetLocalName(El: TPasElement;
+ const Filter: TCtxVarKinds): string;
begin
if Parent<>nil then
- Result:=Parent.GetLocalName(El,SkipSelf)
+ Result:=Parent.GetLocalName(El,Filter)
else
Result:='';
end;
@@ -7434,6 +7477,7 @@ function TConvertContext.GetSelfContext: TFunctionContext;
var
Ctx: TConvertContext;
FuncContext: TFunctionContext;
+ V: TFCLocalIdentifier;
begin
Ctx:=Self;
while Ctx<>nil do
@@ -7441,7 +7485,9 @@ begin
if (Ctx is TFunctionContext) then
begin
FuncContext:=TFunctionContext(Ctx);
- if FuncContext.ThisPas is TPasMembersType then
+ V:=FuncContext.ThisVar;
+ if (V.Element is TPasMembersType)
+ and (V.Kind in [cvkGlobal,cvkCurType,cvkInstance]) then
exit(FuncContext);
end;
Ctx:=Ctx.Parent;
@@ -7764,12 +7810,12 @@ begin
IntfContext:=TSectionContext.Create(El,Src,AContext);
try
// add "var $mod = this;"
- IntfContext.ThisPas:=El;
- IntfContext.ThisKind:=cctkGlobal;
+ IntfContext.ThisVar.Element:=El;
+ IntfContext.ThisVar.Kind:=cvkGlobal;
if El.CustomData is TPasModuleScope then
IntfContext.ScannerBoolSwitches:=TPasModuleScope(El.CustomData).BoolSwitches;
ModVarName:=GetBIName(pbivnModule);
- IntfContext.AddLocalVar(ModVarName,El,false);
+ IntfContext.AddLocalVar(ModVarName,El,cvkGlobal,false);
AddToSourceElements(Src,CreateVarStatement(ModVarName,
CreatePrimitiveDotExpr('this',El),El));
@@ -7797,7 +7843,7 @@ begin
CreateMemberExpression([ModVarName,GetBIName(pbivnImplementation)]),El);
AddToSourceElements(Src,ImplVarSt);
// register local var $impl
- IntfContext.AddLocalVar(GetBIName(pbivnImplementation),El.ImplementationSection,false);
+ IntfContext.AddLocalVar(GetBIName(pbivnImplementation),El.ImplementationSection,cvkGlobal,false);
end;
if Assigned(El.InterfaceSection) then
AddToSourceElements(Src,ConvertDeclarations(El.InterfaceSection,IntfContext));
@@ -9401,7 +9447,7 @@ var
begin
if AContext.IsGlobal then
begin
- ParentName:=AContext.GetLocalName(El.Parent,false);
+ ParentName:=AContext.GetLocalName(El.Parent,[cvkGlobal,cvkCurType,cvkInstance]);
if ParentName='' then
ParentName:='this';
if JSName[1]='[' then
@@ -10031,7 +10077,7 @@ function TPasToJSConverter.ConvertInheritedExpr(El: TInheritedExpr;
SelfContext:=AContext.GetSelfContext;
if SelfContext=nil then
RaiseInconsistency(20170418114702,El);
- SelfName:=SelfContext.GetLocalName(SelfContext.ThisPas,false);
+ SelfName:=AContext.GetLocalName(SelfContext.ThisVar.Element,[cvkCurType,cvkInstance]);
if Apply and (SelfContext<>AContext) then
DoError(20170418204325,nNestedInheritedNeedsParameters,sNestedInheritedNeedsParameters,
@@ -10046,7 +10092,7 @@ function TPasToJSConverter.ConvertInheritedExpr(El: TInheritedExpr;
// ancestor is in an external class
// They could be overriden, without a Pascal declaration
// -> use the direct ancestor class of the current proc
- aClass:=SelfContext.ThisPas as TPasClassType;
+ aClass:=SelfContext.ThisVar.Element as TPasClassType;
if aClass.CustomData=nil then
RaiseInconsistency(20170323111252,aClass);
ClassScope:=TPasClassScope(aClass.CustomData);
@@ -14875,9 +14921,9 @@ begin
if (El.Parent=nil)
or ((El.Parent is TPasSection)
and (El.Parent.ClassType<>TImplementationSection)) then
- OwnerName:=AContext.GetLocalName(El.GetModule,false)
+ OwnerName:=AContext.GetLocalName(El.GetModule,[cvkGlobal])
else
- OwnerName:=AContext.GetLocalName(El.Parent,false);
+ OwnerName:=AContext.GetLocalName(El.Parent,[cvkGlobal]);
if OwnerName='' then
OwnerName:='this';
Call.AddArg(CreatePrimitiveDotExpr(OwnerName,El));
@@ -14939,8 +14985,8 @@ begin
// create context
FuncContext:=TFunctionContext.Create(El,Src,AContext);
FuncContext.IsGlobal:=true;
- FuncContext.ThisPas:=El;
- FuncContext.ThisKind:=cctkGlobal;
+ FuncContext.ThisVar.Element:=El;
+ FuncContext.ThisVar.Kind:=cvkGlobal;
if IntfKind<>'' then
begin
@@ -14953,7 +14999,7 @@ begin
// add class members: types and class vars
if SpecializeDelay then
- DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
+ DelayFuncContext:=CreateDelayedInitMembersFunction(El,Src,FuncContext,DelaySrc);
if El.ObjKind in ([okClass]+okAllHelpers) then
begin
For i:=0 to El.Members.Count-1 do
@@ -14974,11 +15020,11 @@ begin
continue;
end
else if C=TPasConst then
- NewEl:=ConvertConst(TPasConst(P),aContext)
+ NewEl:=ConvertConst(TPasConst(P),FuncContext)
else if C=TPasProperty then
- NewEl:=ConvertProperty(TPasProperty(P),AContext)
+ NewEl:=ConvertProperty(TPasProperty(P),FuncContext)
else if C.InheritsFrom(TPasType) then
- NewEl:=CreateTypeDecl(TPasType(P),aContext)
+ NewEl:=CreateTypeDecl(TPasType(P),FuncContext)
else if C.InheritsFrom(TPasProcedure) then
continue
else if C=TPasMethodResolution then
@@ -15569,6 +15615,8 @@ var
SpecializeDelay: Boolean;
FuncSt: TJSFunctionDeclarationStatement;
AssignSt: TJSSimpleAssignStatement;
+ FuncContext: TFunctionContext;
+ CurContext: TConvertContext;
begin
Result:=nil;
aResolver:=AContext.Resolver;
@@ -15596,6 +15644,7 @@ begin
else
FunName:=GetBIName(pbifnRTTINewProcVar);
Call:=CreateRTTINewType(El,FunName,false,AContext,Obj);
+ FuncContext:=nil;
try
// add "procsig: rtl.newTIProcSignature()"
Prop:=Obj.Elements.AddElement;
@@ -15611,21 +15660,24 @@ begin
AssignSt.LHS:=CreatePrimitiveDotExpr('this.'+GetBIName(pbivnRTTIProcVar_ProcSig),El);
AssignSt.Expr:=InnerCall;
FuncSt.AFunction.Body.A:=AssignSt;
+ FuncContext:=TFunctionContext.Create(El,AssignSt,AContext);
+ CurContext:=FuncContext;
end
else
begin
+ CurContext:=AContext;
Prop.Name:=TJSString(GetBIName(pbivnRTTIProcVar_ProcSig));
Prop.Expr:=InnerCall;
end;
InnerCall.Expr:=CreateMemberExpression([GetBIName(pbivnRTL),GetBIName(pbifnRTTINewProcSig)]);
// add array of arguments
- InnerCall.AddArg(CreateRTTIArgList(El,El.Args,AContext));
+ InnerCall.AddArg(CreateRTTIArgList(El,El.Args,CurContext));
// add resulttype as typeinfo reference
if El is TPasFunctionType then
begin
ResultEl:=TPasFunctionType(El).ResultEl;
- ResultTypeInfo:=CreateTypeInfoRef(ResultEl.ResultType,AContext,ResultEl);
+ ResultTypeInfo:=CreateTypeInfoRef(ResultEl.ResultType,CurContext,ResultEl);
if ResultTypeInfo<>nil then
InnerCall.AddArg(ResultTypeInfo);
end;
@@ -15654,6 +15706,7 @@ begin
Result:=Call;
finally
+ FuncContext.Free;
if Result=nil then
Call.Free;
end;
@@ -15719,6 +15772,7 @@ var
BracketEx: TJSBracketMemberExpression;
ArraySt, CloneEl: TJSElement;
ReturnSt: TJSReturnStatement;
+ FuncContext: TFunctionContext;
begin
Result:=nil;
aResolver:=AContext.Resolver;
@@ -15746,10 +15800,10 @@ begin
// for (var i=0; i<*High(a)*; i++) r.push(a[i].slice(0));
// return r;
// };
- // ToDo: $assign instead of $clone
BracketEx:=nil;
AssignSt:=nil;
Func:=nil;
+ FuncContext:=nil;
try
Index:=0;
RangeEl:=El.Ranges[Index];
@@ -15757,6 +15811,8 @@ begin
Func:=CreateFunctionSt(El,true,true);
Func.AFunction.Params.Add(CloneArrName);
BodySrc:=Func.AFunction.Body.A as TJSSourceElements;
+ FuncContext:=TFunctionContext.Create(El,BodySrc,AContext);
+ FuncContext.IsGlobal:=true;
// var r = [];
VarSt:=CreateVarStatement(CloneResultName,TJSArrayLiteral(CreateElement(TJSArrayLiteral,El)),El);
AddToSourceElements(BodySrc,VarSt);
@@ -15789,15 +15845,15 @@ begin
if ElTypeLo is TPasArrayType then
begin
if length(TPasArrayType(ElTypeLo).Ranges)=0 then
- RaiseNotSupported(El,AContext,20180218223414,GetObjName(ElTypeLo));
- CloneEl:=CreateCloneStaticArray(El,TPasArrayType(ElTypeLo),BracketEx,AContext);
+ RaiseNotSupported(El,FuncContext,20180218223414,GetObjName(ElTypeLo));
+ CloneEl:=CreateCloneStaticArray(El,TPasArrayType(ElTypeLo),BracketEx,FuncContext);
end
else if ElTypeLo is TPasRecordType then
- CloneEl:=CreateRecordCallClone(El,TPasRecordType(ElTypeLo),BracketEx,AContext)
+ CloneEl:=CreateRecordCallClone(El,TPasRecordType(ElTypeLo),BracketEx,FuncContext)
else if ElTypeLo is TPasSetType then
CloneEl:=CreateReferencedSet(El,BracketEx)
else
- RaiseNotSupported(El,AContext,20180218223618,GetObjName(ElTypeLo));
+ RaiseNotSupported(El,FuncContext,20180218223618,GetObjName(ElTypeLo));
Call.AddArg(CloneEl);
BracketEx:=nil;
// return r;
@@ -15836,6 +15892,7 @@ begin
BracketEx.Free;
Func.Free;
ArraySt.Free;
+ FuncContext.Free;
end;
end;
@@ -16041,7 +16098,7 @@ Var
AssignSt: TJSSimpleAssignStatement;
FuncContext, ConstContext: TFunctionContext;
ProcScope, ImplProcScope: TPas2JSProcedureScope;
- Arg: TPasArgument;
+ Arg, SelfArg: TPasArgument;
SelfSt: TJSVariableStatement;
ImplProc: TPasProcedure;
BodyPas: TProcedureBody;
@@ -16054,6 +16111,7 @@ Var
ArgTypeEl, HelperForType: TPasType;
aResolver: TPas2JSResolver;
IsClassConDestructor: Boolean;
+ ThisKind: TCtxVarKind;
begin
Result:=nil;
@@ -16150,7 +16208,10 @@ begin
if ProcScope.ClassRecScope<>nil then
begin
+ ThisKind:=cvkNone;
+ SelfArg:=nil;
// method or class method
+ //writeln('TPasToJSConverter.ConvertProcedure El=',GetObjPath(El),' IsStatic=',El.IsStatic);
if not AContext.IsGlobal then
begin
// nested sub procedure -> no 'this'
@@ -16165,30 +16226,36 @@ begin
begin
// helper method
HelperForType:=aResolver.ResolveAliasType(TPasClassType(ThisPas).HelperForType);
+ ThisPas:=HelperForType;
if HelperForType is TPasMembersType then
begin
// 'this' in a class/record helper method is the class (instance)
- ThisPas:=HelperForType;
- FuncContext.ThisKind:=cctkInstance;
+ ThisKind:=cvkInstance;
end
else
begin
// 'this' in a type helper is a temporary getter/setter JS object
- ThisPas:=nil;
- FuncContext.ThisKind:=cctkHelperTemp;
+ ThisKind:=cvkHelperTemp;
end;
end
else if aResolver.IsClassMethod(El) then
- FuncContext.ThisKind:=cctkCurType
+ ThisKind:=cvkCurType
else
- FuncContext.ThisKind:=cctkInstance;
+ ThisKind:=cvkInstance;
+ if ProcScope.ImplProc<>nil then
+ SelfArg:=TPas2JSProcedureScope(ProcScope.ImplProc.CustomData).SelfArg
+ else
+ SelfArg:=ProcScope.SelfArg;
+ //writeln('TPasToJSConverter.ConvertProcedure El=',GetObjPath(El),' SelfArg=',GetObjPath(SelfArg));
end;
- FuncContext.ThisPas:=ThisPas;
+ FuncContext.ThisVar.Element:=ThisPas;
+ FuncContext.ThisVar.Kind:=ThisKind;
if ThisPas<>nil then
begin
+
if (bsObjectChecks in FuncContext.ScannerBoolSwitches)
- and (ThisPas is TPasMembersType) then
+ and (ThisKind in [cvkGlobal,cvkInstance,cvkCurType]) then
begin
// rtl.checkMethodCall(this,<class>)
Call:=CreateCallExpression(PosEl);
@@ -16199,30 +16266,27 @@ begin
ClassPath:=CreateReferencePath(ProcScope.ClassRecScope.Element,AContext,rpkPathAndName);
Call.AddArg(CreatePrimitiveDotExpr(ClassPath,PosEl));
end;
- end;
- if (ImplProc.Body.Functions.Count>0)
- or aResolver.HasAnonymousFunctions(ImplProc.Body.Body) then
- begin
- // has nested procs -> add "var $Self = this;"
- if ThisPas<>nil then
- FuncContext.AddLocalVar(GetBIName(pbivnSelf),ThisPas,false)
- else
+
+ //writeln('TPasToJSConverter.ConvertProcedure El=',GetObjPath(El),' SelfArg=',GetObjPath(SelfArg),' ThisPas=',GetObjPath(ThisPas));
+ if (ImplProc.Body.Functions.Count>0)
+ or aResolver.HasAnonymousFunctions(ImplProc.Body.Body) then
begin
- // e.g. in a type helper, where 'this' is a not a Pascal element, but a temp JS getter/setter object
- end;
- SelfSt:=CreateVarStatement(GetBIName(pbivnSelf),
- CreatePrimitiveDotExpr('this',ImplProc),ImplProc);
- AddBodyStatement(SelfSt,PosEl);
- if (ImplProcScope.SelfArg<>nil) and (ImplProcScope.SelfArg<>ThisPas) then
+ // has nested procs -> add "var $Self = this;"
+ FuncContext.AddLocalVar(GetBIName(pbivnSelf),ThisPas,ThisKind,false);
+ SelfSt:=CreateVarStatement(GetBIName(pbivnSelf),
+ CreatePrimitiveDotExpr('this',ImplProc),ImplProc);
+ AddBodyStatement(SelfSt,PosEl);
+ if (SelfArg<>nil) and (ThisPas<>SelfArg) then
+ begin
+ // add alias (two PasElements for "this")
+ FuncContext.AddLocalVar(GetBIName(pbivnSelf),SelfArg,ThisKind,false);
+ end;
+ end
+ else if (SelfArg<>nil) and (ThisPas<>SelfArg) then
begin
- // redirect Pascal-Self to JS-Self
- FuncContext.AddLocalVar(GetBIName(pbivnSelf),ImplProcScope.SelfArg,false);
+ // add alias (two PasElements for "this")
+ FuncContext.AddLocalVar('this',SelfArg,ThisKind,false);
end;
- end
- else if ImplProcScope.SelfArg<>nil then
- begin
- // no nested procs -> redirect Pascal-Self to JS-this
- FuncContext.AddLocalVar('this',ImplProcScope.SelfArg,false);
end;
end;
@@ -16592,7 +16656,7 @@ begin
FuncCtx:=AContext.GetFunctionContext;
if FuncCtx=nil then
RaiseNotSupported(El,AContext,20200608132048);
- TmpVar:=FuncCtx.AddLocalVar('$tmp',El.CaseExpr,true);
+ TmpVar:=FuncCtx.AddLocalVar('$tmp',El.CaseExpr,cvkNone,true);
VarSt:=TJSVariableStatement(CreateElement(TJSVariableStatement,El.CaseExpr));
StList.A:=VarSt;
VarDecl:=TJSVarDeclaration(CreateElement(TJSVarDeclaration,El.CaseExpr));
@@ -16818,7 +16882,7 @@ begin
try
IntfContext.ImplContext:=ImplContext;
// ToDo: IntfContext.ThisPas:=El;
- // ToDo: IntfContext.ThisKind:=cctkGlobal;
+ // ToDo: IntfContext.ThisKind:=cvkGlobal;
// add pending impl header statements
if IntfContext.ImplHeaderStatements<>nil then
@@ -17392,7 +17456,7 @@ begin
end;
end;
-function TPasToJSConverter.CreateDelayedInitFunction(PosEl: TPasElement;
+function TPasToJSConverter.CreateDelayedInitMembersFunction(PosEl: TPasElement;
Src: TJSSourceElements; FuncContext: TFunctionContext; out
DelaySrc: TJSSourceElements): TFunctionContext;
var
@@ -17408,7 +17472,8 @@ begin
DelaySrc:=TJSSourceElements(FunDecl.AFunction.Body.A);
Result:=TFunctionContext.Create(PosEl,DelaySrc,FuncContext);
Result.IsGlobal:=true;
- Result.ThisPas:=PosEl;
+ Result.ThisVar.Element:=PosEl;
+ Result.ThisVar.Kind:=cvkCurType;
end;
function TPasToJSConverter.CreateArrayConcat(
@@ -17953,7 +18018,8 @@ begin
New_Src:=TJSSourceElements(CreateElement(TJSSourceElements, El));
New_FuncContext:=TFunctionContext.Create(El,New_Src,ClassContext);
try
- New_FuncContext.ThisPas:=El;
+ New_FuncContext.ThisVar.Element:=El;
+ New_FuncContext.ThisVar.Kind:=cvkCurType;
New_FuncContext.IsGlobal:=true;
// add class members
@@ -18235,7 +18301,7 @@ begin
if SelfScope=nil then
RaiseNotSupported(PosEl,AContext,20190205230919);
if SelfScope.SelfArg<>nil then
- TargetName:=AContext.GetLocalName(SelfScope.SelfArg,false)
+ TargetName:=AContext.GetLocalName(SelfScope.SelfArg,cvkAll)
else if SelfScope.ClassRecScope<>nil then
begin
TargetName:=CreateReferencePath(SelfScope.ClassRecScope.Element,
@@ -18547,7 +18613,7 @@ begin
CreateIdentifierExpr(GetEnumeratorFunc,AContext),true);
end;
// var $in=
- CurInVar:=FuncContext.AddLocalVar(GetBIName(pbivnLoopIn),El.VariableName,true);
+ CurInVar:=FuncContext.AddLocalVar(GetBIName(pbivnLoopIn),El.VariableName,cvkNone,true);
VarSt.A:=CreateVarDecl(CurInVar.Name,Call,PosEl);
PosEl:=El.VariableName;
@@ -19500,7 +19566,7 @@ begin
RaiseNotSupported(El,FuncContext,20190223211808,GetObjName(El));
// add $r to local vars, to avoid name clashes and for nicer debugging
- FuncContext.AddLocalVar(GetBIName(pbivnRTTILocal),nil,false);
+ FuncContext.AddLocalJSVar(GetBIName(pbivnRTTILocal),false);
if NeedLocalVar then
CreateLocalvar;
@@ -19563,9 +19629,11 @@ var
RetSt: TJSReturnStatement;
Call: TJSCallExpression;
FunName: String;
+ FuncContext: TFunctionContext;
begin
aResolver:=aContext.Resolver;
GetterJS:=nil;
+ FuncContext:=nil;
try
for i:=0 to length(Prop.Implements)-1 do
begin
@@ -19600,10 +19668,16 @@ begin
if not (PropType is TPasClassType) then
RaiseInconsistency(20180327190442,Prop);
+ if FuncContext<>nil then
+ FreeAndNil(FuncContext);
+ FuncContext:=TFunctionContext.Create(Prop,RetSt,AContext);
+ FuncContext.ThisVar.Element:=ClassEl;
+ FuncContext.ThisVar.Kind:=cvkInstance;
+
// check property getter
if aResolver.GetPasPropertyArgs(Prop).Count>0 then
RaiseNotSupported(Prop,aContext,20180327191159);
- GetterJS:=CreatePropertyGet(Prop,nil,aContext,Prop);
+ GetterJS:=CreatePropertyGet(Prop,nil,FuncContext,Prop);
case TPasClassType(PropType).ObjKind of
okClass:
@@ -19626,7 +19700,7 @@ begin
Call.Expr:=CreateMemberExpression([GetBIName(pbivnRTL),FunName]);
Call.AddArg(GetterJS);
GetterJS:=nil;
- Call.AddArg(CreateReferencePathExpr(IntfType,aContext));
+ Call.AddArg(CreateReferencePathExpr(IntfType,FuncContext));
end;
okInterface:
begin
@@ -19636,7 +19710,7 @@ begin
begin
if IsInterfaceRef(GetterJS) then
// 'guid': function(){ return this.GetIntf(); },
- GetterJS:=RemoveIntfRef(TJSCallExpression(GetterJS),aContext)
+ GetterJS:=RemoveIntfRef(TJSCallExpression(GetterJS),FuncContext)
else
begin
// 'guid': function(){ return rtl._AddRef(this.FField); },
@@ -19652,17 +19726,18 @@ begin
// 'guid': function(){ return this.GetIntf(); },
end;
else
- RaiseNotSupported(Prop,aContext,20180406085053,InterfaceTypeNames[TPasClassType(IntfType).InterfaceType]);
+ RaiseNotSupported(Prop,FuncContext,20180406085053,InterfaceTypeNames[TPasClassType(IntfType).InterfaceType]);
end;
RetSt.Expr:=GetterJS;
GetterJS:=nil;
end;
else
- RaiseNotSupported(Prop,aContext,20180327190538,ObjKindNames[TPasClassType(PropType).ObjKind]);
+ RaiseNotSupported(Prop,FuncContext,20180327190538,ObjKindNames[TPasClassType(PropType).ObjKind]);
end;
end;
finally
+ FuncContext.Free;
GetterJS.Free;
end;
end;
@@ -20147,7 +20222,7 @@ var
Result:=CreatePrimitiveDotExpr(WithExprScope.WithVarName,Expr)
else if SelfScope<>nil then
begin
- Path:=AContext.GetLocalName(SelfScope.SelfArg,false);
+ Path:=AContext.GetLocalName(SelfScope.SelfArg,cvkAll);
Result:=CreatePrimitiveDotExpr(Path,Expr);
end
else if Left=nil then
@@ -20768,7 +20843,8 @@ begin
New_Src:=TJSSourceElements(CreateElement(TJSSourceElements, El));
New_FuncContext:=TFunctionContext.Create(El,New_Src,AContext);
try
- New_FuncContext.ThisPas:=El;
+ New_FuncContext.ThisVar.Element:=El;
+ New_FuncContext.ThisVar.Kind:=cvkCurType;
New_FuncContext.IsGlobal:=true;
// Note: a newinstance call looks like this: THelper.$new("NewHlp", [3]);
@@ -21921,15 +21997,15 @@ begin
else
begin
if HasInVar then
- CurInVarName:=FuncContext.AddLocalVar(GetBIName(pbivnLoopIn),nil,true).Name
+ CurInVarName:=FuncContext.AddLocalJSVar(GetBIName(pbivnLoopIn),true).Name
else
CurInVarName:='';
if HasLoopVar then
- CurLoopVarName:=FuncContext.AddLocalVar(GetBIName(pbivnLoop),nil,true).Name
+ CurLoopVarName:=FuncContext.AddLocalJSVar(GetBIName(pbivnLoop),true).Name
else
CurLoopVarName:='';
if HasEndVar then
- CurEndVarName:=FuncContext.AddLocalVar(GetBIName(pbivnLoopEnd),nil,true).Name
+ CurEndVarName:=FuncContext.AddLocalJSVar(GetBIName(pbivnLoopEnd),true).Name
else
CurEndVarName:='';
end;
@@ -22268,7 +22344,7 @@ begin
else
begin
// create unique local var name
- WithExprScope.WithVarName:=FuncContext.AddLocalVar(GetBIName(pbivnWith),nil,true).Name;
+ WithExprScope.WithVarName:=FuncContext.AddLocalJSVar(GetBIName(pbivnWith),true).Name;
// create local "var $with1 = expr;"
V:=CreateVarStatement(WithExprScope.WithVarName,Expr,PasExpr);
AddToStatementList(FirstSt,LastSt,V,PasExpr);
@@ -23628,17 +23704,12 @@ var
aPath:=Prefix+aPath;
end;
- function PrependClassOrRecName(var Path: string; ClassOrRec: TPasMembersType): boolean;
- // returns true if no parent path needed
+ procedure PrependClassOrRecName(var Path: string; ClassOrRec: TPasMembersType);
begin
if (ClassOrRec.ClassType=TPasClassType) and TPasClassType(ClassOrRec).IsExternal then
- begin
- Prepend(Path,TPasClassType(ClassOrRec).ExternalName);
- exit(true);
- end;
- Prepend(Path,CreateGlobalTypePath(ClassOrRec,AContext));
- //Prepend(Path,ClassOrRec.Name);
- Result:=true;
+ Prepend(Path,TPasClassType(ClassOrRec).ExternalName)
+ else
+ Prepend(Path,CreateGlobalTypePath(ClassOrRec,AContext));
end;
function NeedsWithExpr: boolean;
@@ -23660,18 +23731,16 @@ var
Result:=true;
end;
- function IsClassProc(Proc: TPasElement): boolean;
+ function ProcSelfIsInstance(Proc: TPasElement): boolean;
var
C: TClass;
begin
if Proc=nil then exit(false);
C:=Proc.ClassType;
- Result:=(C=TPasClassFunction) or (C=TPasClassProcedure)
- or (C=TPasClassOperator)
- or (C=TPasClassConstructor) or (C=TPasClassDestructor);
+ Result:=(C=TPasFunction) or (C=TPasProcedure) or (C=TPasConstructor) or (C=TPasDestructor);
end;
- function IsNonStaticClassProc(Proc: TPasElement): boolean;
+ function ProcSelfIsClassType(Proc: TPasElement): boolean;
var
C: TClass;
begin
@@ -23765,6 +23834,8 @@ var
SelfContext: TFunctionContext;
ElClass: TClass;
IsClassRec: Boolean;
+ VarKinds: TCtxVarKinds;
+ Proc: TPasProcedure;
begin
Result:='';
{$IFDEF VerbosePas2JS}
@@ -23796,7 +23867,7 @@ begin
Append_GetClass(El);
end;
end
- else if IsNonStaticClassProc(El)
+ else if ProcSelfIsClassType(El)
and aResolver.ResolvedElIsClassOrRecordInstance(Dot.LeftResolved) then
// accessing a class method from an object, 'this' must be the class/record
Append_GetClass(El);
@@ -23841,7 +23912,7 @@ begin
RaiseNotSupported(WithData.Expr,AContext,20190209092506,GetObjName(El));
Prepend(Result,WithData.WithVarName);
if not (wesfOnlyTypeMembers in WithData.Flags)
- and IsNonStaticClassProc(El) then
+ and ProcSelfIsClassType(El) then
begin
// with Obj do NonStaticClassMethod -> append .$class
Append_GetClass(El);
@@ -23851,149 +23922,168 @@ begin
begin
// neither Dot nor With context, nor local, nor external,
// -> translate a Pascal identifier to the JS path
+ // Examples: this.name, $Self.name, this.sub.name, globalpath.name
if El.Parent=nil then
RaiseNotSupported(El,AContext,20170201172141,GetObjName(El));
- El:=ImplToDecl(El);
- if Kind=rpkPathAndName then
+ if (coShortRefGlobals in Options) and (El is TPasType) and (Kind=rpkPathAndName) then
begin
- if El is TPasType then
- begin
- Result:=CreateGlobalTypePath(TPasType(El),AContext);
- exit;
- end;
+ Result:=CreateGlobalTypePath(TPasType(El),AContext);
+ exit;
end;
+ El:=ImplToDecl(El);
+
CurEl:=El;
- ParentEl:=CurEl.Parent;
- while ParentEl<>nil do
- begin
+ repeat
+ ParentEl:=CurEl.Parent;
+ if ParentEl=nil then break;
+ if ParentEl is TProcedureBody then break;
ParentEl:=ImplToDecl(ParentEl);
IsClassRec:=(ParentEl.ClassType=TPasClassType)
or (ParentEl.ClassType=TPasRecordType);
- // check if ParentEl has a JS var
- ShortName:=AContext.GetLocalName(ParentEl,false);
- //writeln('TPasToJSConverter.CreateReferencePath El=',GetObjName(El),' ParentEl=',GetObjName(ParentEl),' ShortName=',ShortName);
-
if IsClassRec then
begin
- // parent is a class or record declaration
+ // Not in a Pascal dotscope and accessing a class member.
+ // Possible results: this.v, module.path.path.v, this.$class.v, $Self.v
+ // In nested proc 'this' can have another name, e.g. '$Self'
if (ParentEl.ClassType=TPasClassType)
- and (TPasClassType(ParentEl).HelperForType<>nil)
- and (El=CurEl)
- and aResolver.IsHelperForMember(CurEl) then
+ and (TPasClassType(ParentEl).HelperForType<>nil) then
begin
- // external helper proc/var -> redirect to helper-for-type
- ParentEl:=aResolver.ResolveAliasType(TPasClassType(ParentEl).HelperForType);
- IsClassRec:=(ParentEl.ClassType=TPasClassType)
- or (ParentEl.ClassType=TPasRecordType);
- if not IsClassRec then
- RaiseNotSupported(El,AContext,20190926091356);
- ShortName:=AContext.GetLocalName(ParentEl,false);
+ if (El=CurEl)
+ and aResolver.IsHelperForMember(CurEl) then
+ begin
+ // external helper proc/var -> redirect to helper-for-type
+ ParentEl:=aResolver.ResolveAliasType(TPasClassType(ParentEl).HelperForType);
+ IsClassRec:=(ParentEl.ClassType=TPasClassType)
+ or (ParentEl.ClassType=TPasRecordType);
+ if not IsClassRec then
+ RaiseNotSupported(El,AContext,20190926091356);
+ end
+ else
+ begin
+ // helper members cannot be accessed via "this"
+ PrependClassOrRecName(Result,TPasMembersType(ParentEl));
+ break;
+ end;
end;
if Full then
begin
- if PrependClassOrRecName(Result,TPasMembersType(ParentEl)) then break;
+ PrependClassOrRecName(Result,TPasMembersType(ParentEl));
+ break;
+ end;
+
+ if El is TPasVariable then
+ begin
+ if TPasVariable(El).VarModifiers*[vmClass, vmStatic]<>[] then
+ VarKinds:=[cvkGlobal,cvkCurType,cvkInstance]
+ else
+ VarKinds:=[cvkInstance];
+ end
+ else if El is TPasProcedure then
+ begin
+ Proc:=TPasProcedure(El);
+ if ProcSelfIsInstance(Proc) then
+ VarKinds:=[cvkCurType,cvkInstance]
+ else
+ VarKinds:=[cvkGlobal,cvkCurType,cvkInstance];
end
else
+ VarKinds:=[cvkGlobal,cvkCurType,cvkInstance];
+ if VarKinds<>[cvkGlobal] then
begin
- // Not in a Pascal dotscope and accessing a class member.
- // Possible results: this.v, module.path.path.v, this.$class.v, $Self.v
- // In nested proc 'this' can have another name, e.g. '$Self'
+ // Pascal uses implicit Self -> use "this" if available
SelfContext:=AContext.GetSelfContext;
- if ShortName<>'' then
- Prepend(Result,ShortName)
- else if CurEl is TPasType then
- begin
- if PrependClassOrRecName(Result,TPasMembersType(ParentEl)) then break;
- end
- else if El<>CurEl then
- begin
- if PrependClassOrRecName(Result,TPasMembersType(ParentEl)) then break;
- end
- else if (ParentEl.ClassType=TPasClassType)
- and (TPasClassType(ParentEl).HelperForType<>nil) then
+ if (SelfContext<>nil)
+ and IsA(TPasType(SelfContext.ThisVar.Element),TPasMembersType(ParentEl)) then
begin
- // helpers have no self
- if PrependClassOrRecName(Result,TPasMembersType(ParentEl)) then break;
- end
- else if (SelfContext<>nil)
- and IsA(TPasType(SelfContext.ThisPas),TPasMembersType(ParentEl)) then
- begin
- ShortName:=AContext.GetLocalName(SelfContext.ThisPas,false);
+ ShortName:=AContext.GetLocalName(SelfContext.ThisVar.Element,VarKinds);
if ShortName='' then
begin
- if PrependClassOrRecName(Result,TPasMembersType(ParentEl)) then break;
- end
- else
- Prepend(Result,ShortName);
- end
- else
- begin
- if PrependClassOrRecName(Result,TPasMembersType(ParentEl)) then break;
- // missing JS var for Self
- //{$IFDEF VerbosePas2JS}
- //{AllowWriteln}
- //writeln('TPasToJSConverter.CreateReferencePath missing JS var for Self: El=',GetElementDbgPath(El),':',El.ClassName,' CurParentEl=',GetElementDbgPath(ParentEl),':',ParentEl.ClassName,' AContext:');
- //AContext.WriteStack;
- //if Ref<>nil then
- // writeln('TPasToJSConverter.CreateReferencePath Ref=',GetObjName(Ref.Element),' at ',aResolver.GetElementSourcePosStr(Ref.Element));
- //{AllowWriteln-}
- //{$ENDIF}
- //RaiseNotSupported(El,AContext,20180125004049);
- end;
- if (El=CurEl) and (SelfContext<>nil)
- and (SelfContext.PasElement is TPasProcedure)
- and not IsClassProc(SelfContext.PasElement) then
- begin
- // inside a method -> Self is a class instance
- if IsNonStaticClassProc(El)
- and (TPasClassType(El.Parent).HelperForType=nil) then
- Append_GetClass(El); // accessing a class function
- end;
- if ShortName<>'' then
+ if not (cvkGlobal in VarKinds) then
+ begin
+ {$IFDEF VerbosePas2JS}
+ {AllowWriteln}
+ AContext.WriteStack;
+ writeln('TPasToJSConverter.CreateReferencePath SelfContext.ThisVar=',GetObjPath(SelfContext.ThisVar.Element),' El=',GetObjPath(El));
+ {AllowWriteln-}
+ {$ENDIF}
+ RaiseNotSupported(El,AContext,20200920214421);
+ end;
+ // e.g. inside a static function inside a record accessing a class var of the record
+ PrependClassOrRecName(Result,TPasMembersType(ParentEl));
+ break;
+ end;
+ if ProcSelfIsInstance(SelfContext.PasElement) then
+ begin
+ // inside a method -> Self is a class instance
+ if ProcSelfIsClassType(El) then
+ Append_GetClass(El); // accessing a class function -> this.$class.procname
+ end;
+ Prepend(Result,ShortName);
break;
+ end;
+ end;
+
+ ShortName:=AContext.GetLocalName(ParentEl,VarKinds);
+ //writeln('TPasToJSConverter.CreateReferencePath NOT USING SELF ',GetObjPath(El),' ShortName=',ShortName);
+ if ShortName<>'' then
+ begin
+ Prepend(Result,ShortName);
+ break;
+ end
+ else if (ParentEl.ClassType=TPasClassType) and TPasClassType(ParentEl).IsExternal then
+ begin
+ Prepend(Result,TPasClassType(ParentEl).ExternalName);
+ break;
+ end
+ else if coShortRefGlobals in Options then
+ begin
+ PrependClassOrRecName(Result,TPasMembersType(ParentEl));
+ break;
+ end
+ else
+ begin
+ ShortName:=TransformElToJSName(ParentEl,AContext);
+ Prepend(Result,ShortName);
end;
end
- else if (ShortName<>'') then
- begin
- Prepend(Result,ShortName);
- break;
- end
- else if ParentEl.ClassType=TImplementationSection then
- begin
- // element is in an implementation section (not program/library section)
- // in other unit -> use pas.unitname.$impl
- FoundModule:=ParentEl.GetModule;
- if FoundModule=nil then
- RaiseInconsistency(20161024192755,El);
- Prepend(Result,TransformModuleName(FoundModule,true,AContext)
- +'.'+GetBIName(pbivnImplementation));
- break;
- end
- else if ParentEl is TPasModule then
- begin
- // element is in an unit interface or program/library section
- Prepend(Result,TransformModuleName(TPasModule(ParentEl),true,AContext));
- break;
- end
- else if ParentEl.ClassType=TPasEnumType then
+ else
begin
- if (ShortName<>'') and not Full then
+ // check if ParentEl has a JS var
+ ShortName:=AContext.GetLocalName(ParentEl,[cvkGlobal]);
+ if (ShortName<>'') then
begin
Prepend(Result,ShortName);
break;
end
- else
+ else if ParentEl.ClassType=TImplementationSection then
+ begin
+ // element is in an implementation section (not program/library section)
+ // in other unit -> use pas.unitname.$impl
+ FoundModule:=ParentEl.GetModule;
+ if FoundModule=nil then
+ RaiseInconsistency(20161024192755,El);
+ Prepend(Result,TransformModuleName(FoundModule,true,AContext)
+ +'.'+GetBIName(pbivnImplementation));
+ break;
+ end
+ else if ParentEl is TPasModule then
+ begin
+ // element is in an unit interface or program/library section
+ Prepend(Result,TransformModuleName(TPasModule(ParentEl),true,AContext));
+ break;
+ end
+ else if ParentEl.ClassType=TPasEnumType then
+ begin
Prepend(Result,ParentEl.Name);
+ end;
end;
CurEl:=ParentEl;
- ParentEl:=CurEl.Parent;
- if ParentEl is TProcedureBody then break;
- end;
+ until false;
end;
case Kind of
@@ -24036,16 +24126,16 @@ var
aType: TPasType;
Parent: TPasElement;
CurModule: TPasModule;
- AliasGlobals: Boolean;
+ ShortRefGlobals: Boolean;
begin
aType:=AContext.Resolver.ResolveAliasType(El);
- Result:=AContext.GetLocalName(aType,true);
+ Result:=AContext.GetLocalName(aType,[cvkGlobal]);
if Result<>'' then
exit; // already exists
- AliasGlobals:=coAliasGlobals in Options;
+ ShortRefGlobals:=coShortRefGlobals in Options;
Parent:=El.Parent;
- Result:=AContext.GetLocalName(Parent,AliasGlobals);
+ Result:=AContext.GetLocalName(Parent,[cvkGlobal]);
if Result<>'' then
else if Parent is TPasType then
Result:=CreateGlobalTypePath(TPasType(Parent),AContext)
@@ -24067,7 +24157,7 @@ begin
else
RaiseNotSupported(El,AContext,20200609230526,GetObjName(aType));
Result:=Result+'.'+TransformElToJSName(aType,AContext);
- if AliasGlobals then
+ if ShortRefGlobals then
Result:=CreateGlobalAlias(El,Result,AContext);
end;
@@ -25239,9 +25329,9 @@ begin
if (El.Parent=nil)
or ((El.Parent is TPasSection)
and (El.Parent.ClassType<>TImplementationSection)) then
- JSParentName:=AContext.GetLocalName(El.GetModule,false)
+ JSParentName:=AContext.GetLocalName(El.GetModule,[cvkGlobal])
else
- JSParentName:=AContext.GetLocalName(El.Parent,false);
+ JSParentName:=AContext.GetLocalName(El.Parent,[cvkGlobal]);
if JSParentName='' then
JSParentName:='this';
Call.AddArg(CreatePrimitiveDotExpr(JSParentName,El));
@@ -25258,7 +25348,8 @@ begin
// create context
FuncContext:=TFunctionContext.Create(El,Src,AContext);
FuncContext.IsGlobal:=true;
- FuncContext.ThisPas:=El;
+ FuncContext.ThisVar.Element:=El;
+ FuncContext.ThisVar.Kind:=cvkGlobal;
// init fields
NewFields:=TFPList.Create;
@@ -25266,7 +25357,7 @@ begin
Methods:=TFPList.Create;
IsComplex:=false;
if SpecializeDelay then
- DelayFuncContext:=CreateDelayedInitFunction(El,Src,FuncContext,DelaySrc);
+ DelayFuncContext:=CreateDelayedInitMembersFunction(El,Src,FuncContext,DelaySrc);
for i:=0 to El.Members.Count-1 do
begin
P:=TPasElement(El.Members[i]);
@@ -25524,8 +25615,11 @@ begin
aType:=AContext.Resolver.ResolveAliasType(TPasType(El))
else
aType:=TPasType(El);
- Result:=TransformToJSName(El,GetOverloadName(aType,AContext),
- CanClashWithGlobal(aType),AContext);
+ if (aType.ClassType=TPasClassType) and TPasClassType(aType).IsExternal then
+ Result:=TPasClassType(aType).ExternalName
+ else
+ Result:=TransformToJSName(El,GetOverloadName(aType,AContext),
+ CanClashWithGlobal(aType),AContext);
end
else
Result:=TransformToJSName(El,GetOverloadName(El,AContext),
@@ -25540,7 +25634,7 @@ var
begin
if AddModulesPrefix then
begin
- Result:=AContext.GetLocalName(El,false);
+ Result:=AContext.GetLocalName(El,[cvkGlobal]);
if Result<>'' then exit;
end;
if El is TPasProgram then
@@ -25568,7 +25662,7 @@ begin
else
Result:=GetBIName(pbivnModules)+'.'+Result;
- if coAliasGlobals in Options then
+ if coShortRefGlobals in Options then
Result:=CreateGlobalAlias(El,Result,AContext);
end;
end;
@@ -25802,9 +25896,15 @@ begin
if (CompareText(Result,'Self')=0) and (Arg.Parent is TPasProcedure) then
begin
// hidden self argument
- Result:=AContext.GetLocalName(Arg,false);
+ Result:=AContext.GetLocalName(Arg,cvkAll);
if Result='' then
+ begin
+ {$IFDEF VerbosePas2JS}
+ writeln('TPasToJSConverter.TransformArgName Arg=',GetObjPath(Arg));
+ AContext.WriteStack;
+ {$ENDIF}
RaiseNotSupported(Arg,AContext,20190205190114,GetObjName(Arg.Parent));
+ end;
end
else
Result:=TransformToJSName(Arg,Result,true,AContext);
@@ -25848,7 +25948,7 @@ begin
else
RaiseNotSupported(El,AContext,20200608160225);
Result:=FuncContext.CreateLocalIdentifier(Result);
- SectionContext.AddLocalVar(Result,El,false);
+ SectionContext.AddLocalVar(Result,El,cvkGlobal,false);
// ToDo: check if from a unit used by impl uses section
if aResolver.ImplementationUsesUnit(ElModule) then
diff --git a/packages/pastojs/src/pas2jscompiler.pp b/packages/pastojs/src/pas2jscompiler.pp
index 7a6e051d7d..01f31b00a3 100644
--- a/packages/pastojs/src/pas2jscompiler.pp
+++ b/packages/pastojs/src/pas2jscompiler.pp
@@ -38,6 +38,7 @@ uses
Classes, SysUtils, contnrs,
jsbase, jstree, jswriter, JSSrcMap, fpjson,
PScanner, PParser, PasTree, PasResolver, PasResolveEval, PasUseAnalyzer,
+ Pas2JSUtils,
pas2jsresstrfile, pas2jsresources, pas2jshtmlresources, pas2jsjsresources,
FPPas2Js, FPPJsSrcMap, Pas2jsLogger, Pas2jsFS, Pas2jsPParser, Pas2jsUseAnalyzer;
@@ -96,6 +97,7 @@ const
nPostProcessorFinished = 143; sPostProcessorFinished = 'Post processor finished';
nRTLIdentifierChanged = 144; sRTLIdentifierChanged = 'RTL identifier %s changed from %s to %s';
nSkipNoConstResourcestring = 145; sSkipNoConstResourcestring = 'Resource string %s is not a constant, not adding to resourcestrings file.';
+ nUnknownOptimizationOption = 146; sUnknownOptimizationOption = 'unknown -Oo option %s';
// Note: error numbers 201+ are used by Pas2jsFileCache
//------------------------------------------------------------------------------
@@ -133,9 +135,10 @@ type
coWriteMsgToStdErr,
coPrecompile, // create precompile file
// optimizations
- coEnumValuesAsNumbers,
- coKeepNotUsedPrivates,
- coKeepNotUsedDeclarationsWPO,
+ coEnumValuesAsNumbers, // -O1
+ coKeepNotUsedPrivates, // -O-
+ coKeepNotUsedDeclarationsWPO, // -O-
+ coShortRefGlobals, // -O2
// source map
coSourceMapCreate,
coSourceMapInclude,
@@ -160,9 +163,10 @@ const
DefaultResourceMode = rmHTML;
coShowAll = [coShowErrors..coShowDebug];
- coO1Enable = [coEnumValuesAsNumbers];
- coO1Disable = [coKeepNotUsedPrivates,coKeepNotUsedDeclarationsWPO];
-
+ coAllOptimizations = [coEnumValuesAsNumbers..coShortRefGlobals];
+ coO0 = [coKeepNotUsedPrivates,coKeepNotUsedDeclarationsWPO];
+ coO1 = [coEnumValuesAsNumbers];
+ coO2 = coO1+[coShortRefGlobals];
p2jscoCaption: array[TP2jsCompilerOption] of string = (
// only used by experts or programs parsing the pas2js output, no need for resourcestrings
@@ -195,6 +199,7 @@ const
'Enum values as numbers',
'Keep not used private declarations',
'Keep not used declarations (WPO)',
+ 'Create short local variables for globals',
'Create source map',
'Include Pascal sources in source map',
'Do not shorten filenames in source map',
@@ -532,7 +537,6 @@ type
function GetTargetProcessor: TPasToJsProcessor;
function GetWriteDebugLog: boolean;
function GetWriteMsgToStdErr: boolean;
- function HandleOptionOptimization(C: Char; aValue: String): Boolean;
function IndexOfInsertJSFilename(const aFilename: string): integer;
procedure InsertCustomJSFiles(aWriter: TPas2JSMapper);
function LoadUsedUnit(Info: TLoadUnitInfo; Context: TPas2jsCompilerFile): TPas2jsCompilerFile;
@@ -607,6 +611,7 @@ type
function HandleOptionM(aValue: String; Quick: Boolean): Boolean; virtual;
procedure HandleOptionConfigFile(aPos: Integer; const aFileName: string); virtual;
procedure HandleOptionInfo(aValue: string);
+ function HandleOptionOptimization(C: Char; aValue: String): Boolean;
// DoWriteJSFile: return false to use the default write function.
function DoWriteJSFile(const DestFilename: String; aWriter: TPas2JSMapper): Boolean; virtual;
procedure Compile(StartTime: TDateTime);
@@ -730,9 +735,9 @@ function GetCompiledTargetOS: string;
function GetCompiledTargetCPU: string;
implementation
-// !! No filesystem units here.
-uses pas2jsutils;
+// !! No filesystem units here.
+//uses ;
function GetCompiledDate: string;
@@ -1048,6 +1053,8 @@ begin
if coEnumValuesAsNumbers in Compiler.Options then
Include(Result,fppas2js.coEnumNumbers);
+ if coShortRefGlobals in Compiler.Options then
+ Include(Result,fppas2js.coShortRefGlobals);
if coLowerCase in Compiler.Options then
Include(Result,fppas2js.coLowerCase)
@@ -3292,6 +3299,8 @@ begin
r(mtWarning,nPostProcessorWarnX,sPostProcessorWarnX);
r(mtInfo,nPostProcessorFinished,sPostProcessorFinished);
r(mtInfo,nRTLIdentifierChanged,sRTLIdentifierChanged);
+ r(mtNote,nSkipNoConstResourcestring,sSkipNoConstResourcestring);
+ r(mtWarning,nUnknownOptimizationOption,sUnknownOptimizationOption);
Pas2jsPParser.RegisterMessages(Log);
end;
@@ -3353,39 +3362,6 @@ begin
end;
end;
-function TPas2jsCompiler.HandleOptionOptimization(C: Char; aValue: String): Boolean;
-Var
- Enable: Boolean;
-begin
- Result:=True;
- case C of
- '-': Options:=Options-coO1Enable+coO1Disable;
- '1': Options:=Options+coO1Enable-coO1Disable;
- 'o':
- begin
- if aValue='' then
- ParamFatal('missing -Oo option');
- Enable:=true;
- c:=aValue[length(aValue)];
- if c in ['+','-'] then
- begin
- Enable:=c='+';
- Delete(aValue,length(aValue),1);
- end;
- Case LowerCase(avalue) of
- 'enumnumbers': SetOption(coEnumValuesAsNumbers,Enable);
- 'emovenotusedprivates': SetOption(coKeepNotUsedPrivates,not Enable);
- 'removenotuseddeclarations': SetOption(coKeepNotUsedDeclarationsWPO,not Enable)
- else
- Result:=False;
- end;
- end;
- else
- Result:=False;
- end;
-
-end;
-
function TPas2jsCompiler.HandleOptionJ(C: Char; aValue: String;
Quick, FromCmdLine: Boolean): Boolean;
@@ -3636,10 +3612,8 @@ begin
end;
procedure TPas2jsCompiler.HandleOptionConfigFile(aPos: Integer; const aFileName: string);
-
Var
FN: String;
-
begin
// load extra config file
if aFilename='' then
@@ -3651,7 +3625,6 @@ begin
end;
procedure TPas2jsCompiler.HandleOptionInfo(aValue: string);
-
Var
InfoMsg: String;
@@ -3727,9 +3700,9 @@ begin
Log.LogPlain(PasToJsProcessorNames[pr]);
'm':
begin
- // write list of supported modeswitches
- for ms in (msAllPas2jsModeSwitches-AllLanguageModes) do
- Log.LogPlain(SModeSwitchNames[ms]);
+ // write list of supported modeswitches
+ for ms in (msAllPas2jsModeSwitches-AllLanguageModes) do
+ Log.LogPlain(SModeSwitchNames[ms]);
end;
'o':
begin
@@ -3737,6 +3710,7 @@ begin
Log.LogPlain('EnumNumbers');
Log.LogPlain('RemoveNotUsedPrivates');
Log.LogPlain('RemoveNotUsedDeclarations');
+ Log.LogPlain('ShortRefGlobals');
end;
't':
// write list of supported targets
@@ -3762,6 +3736,40 @@ begin
Log.LogPlain(InfoMsg);
end;
+function TPas2jsCompiler.HandleOptionOptimization(C: Char; aValue: String): Boolean;
+Var
+ Enable: Boolean;
+begin
+ Result:=True;
+ case C of
+ '-': Options:=Options-coAllOptimizations+coO0;
+ '1': Options:=Options-coAllOptimizations+coO1;
+ '2': Options:=Options-coAllOptimizations+coO2;
+ 'o':
+ begin
+ if aValue='' then
+ ParamFatal('missing -Oo option');
+ Enable:=true;
+ c:=aValue[length(aValue)];
+ if c in ['+','-'] then
+ begin
+ Enable:=c='+';
+ Delete(aValue,length(aValue),1);
+ end;
+ Case LowerCase(aValue) of
+ 'enumnumbers': SetOption(coEnumValuesAsNumbers,Enable);
+ 'removenotusedprivates': SetOption(coKeepNotUsedPrivates,not Enable);
+ 'removenotuseddeclarations': SetOption(coKeepNotUsedDeclarationsWPO,not Enable);
+ 'shortrefglobals': SetOption(coShortRefGlobals,not Enable);
+ else
+ Log.LogMsgIgnoreFilter(nUnknownOptimizationOption,[QuoteStr(aValue)]);
+ end;
+ end;
+ else
+ Result:=False;
+ end;
+end;
+
procedure TPas2jsCompiler.ReadParam(Param: string; Quick, FromCmdLine: boolean);
procedure UnknownParam;
@@ -4724,11 +4732,12 @@ begin
w(' -O<x> : Optimizations:');
w(' -O- : Disable optimizations');
w(' -O1 : Level 1 optimizations (quick and debugger friendly)');
- //w(' -O2 : Level 2 optimizations (Level 1 + not debugger friendly)');
+ w(' -O2 : Level 2 optimizations (Level 1 + not debugger friendly)');
w(' -Oo<x>: Enable or disable optimization. The x is case insensitive:');
w(' -OoEnumNumbers[-]: write enum value as number instead of name. Default in -O1.');
w(' -OoRemoveNotUsedPrivates[-]: Default is enabled');
w(' -OoRemoveNotUsedDeclarations[-]: Default enabled for programs with -Jc');
+ w(' -OoShortRefGlobals[-]: Insert JS local var for types and modules. Default enabled in -O2');
w(' -P<x> : Set target processor. Case insensitive:');
w(' -Pecmascript5: default');
w(' -Pecmascript6');
@@ -4955,6 +4964,7 @@ begin
Log.LogPlain('Supported Optimizations:');
Log.LogPlain(' EnumNumbers');
Log.LogPlain(' RemoveNotUsedPrivates');
+ Log.LogPlain(' ShortRefGlobals');
Log.LogLn;
Log.LogPlain('Supported Whole Program Optimizations:');
Log.LogPlain(' RemoveNotUsedDeclarations');
diff --git a/packages/pastojs/src/pas2jsutils.pp b/packages/pastojs/src/pas2jsutils.pp
index 0c4ab96fa7..232a6bce34 100644
--- a/packages/pastojs/src/pas2jsutils.pp
+++ b/packages/pastojs/src/pas2jsutils.pp
@@ -1,4 +1,4 @@
-unit pas2jsutils;
+unit Pas2JSUtils;
{
This file is part of the Free Component Library (FCL)
Copyright (c) 2018 Mattias Gaertner mattias@freepascal.org
diff --git a/packages/pastojs/tests/tcgenerics.pas b/packages/pastojs/tests/tcgenerics.pas
index 3beb9a68c9..e0307d0621 100644
--- a/packages/pastojs/tests/tcgenerics.pas
+++ b/packages/pastojs/tests/tcgenerics.pas
@@ -102,7 +102,7 @@ begin
ConvertProgram;
CheckSource('TestGen_RecordEmpty',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecA$G1", function () {',
+ 'rtl.recNewT(this, "TRecA$G1", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -110,8 +110,8 @@ begin
' return this;',
' };',
'});',
- 'this.a = $mod.TRecA$G1.$new();',
- 'this.b = $mod.TRecA$G1.$new();',
+ 'this.a = this.TRecA$G1.$new();',
+ 'this.b = this.TRecA$G1.$new();',
'']),
LinesToStr([ // $mod.$main
'if ($mod.a.$eq($mod.b)) ;'
@@ -144,7 +144,7 @@ begin
ConvertProgram;
CheckSource('TestGen_Record_ClassProc',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint$G1", function () {',
+ 'rtl.recNewT(this, "TPoint$G1", function () {',
' this.x = 0;',
' this.$eq = function (b) {',
' return true;',
@@ -159,7 +159,7 @@ begin
' $mod.TPoint$G1.Fly();',
' };',
'}, true);',
- 'this.p = $mod.TPoint$G1.$new();',
+ 'this.p = this.TPoint$G1.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.TPoint$G1.x = $mod.p.x + 10;',
@@ -187,7 +187,7 @@ begin
ConvertProgram;
CheckSource('TestGen_Record_ClassVarRecord_Program',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TBird", function () {',
+ 'rtl.recNewT(this, "TBird", function () {',
' this.b = 0;',
' this.$eq = function (b) {',
' return this.b === b.b;',
@@ -197,7 +197,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.recNewT($mod, "TAnt$G1", function () {',
+ 'rtl.recNewT(this, "TAnt$G1", function () {',
' this.x = $mod.TBird.$new();',
' this.$eq = function (b) {',
' return true;',
@@ -206,7 +206,7 @@ begin
' return this;',
' };',
'}, true);',
- 'this.f = $mod.TAnt$G1.$new();',
+ 'this.f = this.TAnt$G1.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.f.x.b = $mod.f.x.b + 10;',
@@ -244,7 +244,7 @@ begin
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
' var $impl = $mod.$impl;',
- ' rtl.recNewT($mod, "TAnt$G1", function () {',
+ ' rtl.recNewT(this, "TAnt$G1", function () {',
' this.$initSpec = function () {',
' this.x = $impl.TBird.$new();',
' this.a = rtl.arraySetLength(null, $impl.TBird, 2);',
@@ -307,7 +307,7 @@ begin
CheckSource('TestGen_Record_RTTI_UnitImpl',
LinesToStr([ // statements
'var $impl = $mod.$impl;',
- 'rtl.recNewT($mod, "TAnt$G1", function () {',
+ 'rtl.recNewT(this, "TAnt$G1", function () {',
' var $r = $mod.$rtti.$Record("TAnt<Test1.TBird>", {});',
' this.$initSpec = function () {',
' this.x = $impl.TBird.$new();',
@@ -356,13 +356,13 @@ begin
ConvertProgram;
CheckSource('TestGen_ClassEmpty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
'});',
'this.a = null;',
'this.b = null;',
@@ -390,13 +390,13 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_EmptyMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.Fly = function (w) {',
' var Result = 0;',
' return Result;',
@@ -449,13 +449,13 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_TList',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TList$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TList$G1", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FItems = [];',
@@ -518,19 +518,19 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_TCustomList',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TCustomList$G2", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCustomList$G2", this.TObject, function () {',
' this.PrepareAddingItem = function () {',
' var Result = 0;',
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TList$G1", $mod.TCustomList$G2, function () {',
+ 'rtl.createClass(this, "TList$G1", this.TCustomList$G2, function () {',
' this.Add = function () {',
' var Result = 0;',
' Result = this.PrepareAddingItem();',
@@ -559,15 +559,15 @@ begin
ConvertProgram;
CheckSource('TestGen_ClassAncestor',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G2", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G2", this.TObject, function () {',
'});',
- 'rtl.createClass($mod, "TEagle$G1", $mod.TBird$G2, function () {',
+ 'rtl.createClass(this, "TEagle$G1", this.TBird$G2, function () {',
'});',
'this.a = null;',
'']),
@@ -598,13 +598,13 @@ begin
CheckSource('TestGen_Class_TypeInfo',
LinesToStr([ // statements
'$mod.$rtti.$Class("TBird<System.Word>");',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.m = 0;',
@@ -643,7 +643,7 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_TypeOverload',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -674,13 +674,13 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_ClassProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.fSize = 0;',
'});',
'']),
@@ -724,13 +724,13 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_ClassProc',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TPoint$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TPoint$G1", this.TObject, function () {',
' this.x = 0;',
' this.Fly = function () {',
' $mod.TPoint$G1.x = $mod.TPoint$G1.x + 3;',
@@ -787,20 +787,20 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_ClassConstructor',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
'this.count = 0;',
- 'rtl.createClass($mod, "TPoint$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TPoint$G1", this.TObject, function () {',
' this.x = 0;',
' this.Fly = function () {',
' };',
'});',
'this.r = null;',
- 'rtl.createClass($mod, "TPoint$G2", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TPoint$G2", this.TObject, function () {',
' this.x = 0;',
' this.Fly = function () {',
' };',
@@ -845,19 +845,19 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_TypeCastSpecializesWarn',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.F = 0;',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G2", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G2", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.F = "";',
@@ -893,19 +893,19 @@ begin
ConvertProgram;
CheckSource('TestGen_Class_TypeCastSpecializesJSValueNoWarn',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.F = 0;',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G2", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G2", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.F = undefined;',
@@ -1001,7 +1001,7 @@ begin
LinesToStr([ // statements
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
- ' rtl.createClass($mod, "TBird$G1", pas.system.TObject, function () {',
+ ' rtl.createClass(this, "TBird$G1", pas.system.TObject, function () {',
' this.c = 13;',
' var c$1 = 14;',
' this.Create$1 = function (w) {',
@@ -1012,7 +1012,7 @@ begin
' return this;',
' };',
' });',
- ' rtl.createClass($mod, "TBird$G2", pas.system.TObject, function () {',
+ ' rtl.createClass(this, "TBird$G2", pas.system.TObject, function () {',
' this.c = 13;',
' var c$1 = 14;',
' this.Create$1 = function (w) {',
@@ -1072,15 +1072,15 @@ begin
LinesToStr([ // statements
'$mod.$rtti.$Class("TAnt<System.Word>");',
'$mod.$rtti.$Class("TFish<System.Word>");',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TPersistent", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TPersistent", this.TObject, function () {',
'});',
- 'rtl.createClass($mod, "TAnt$G2", $mod.TPersistent, function () {',
+ 'rtl.createClass(this, "TAnt$G2", this.TPersistent, function () {',
' this.$init = function () {',
' $mod.TPersistent.$init.call(this);',
' this.f = null;',
@@ -1092,7 +1092,7 @@ begin
' var $r = this.$rtti;',
' $r.addField("f", $mod.$rtti["TFish<System.Word>"]);',
'}, "TAnt<System.Word>");',
- 'rtl.createClass($mod, "TFish$G2", $mod.TPersistent, function () {',
+ 'rtl.createClass(this, "TFish$G2", this.TPersistent, function () {',
' this.$init = function () {',
' $mod.TPersistent.$init.call(this);',
' this.a = null;',
@@ -1144,7 +1144,7 @@ begin
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
' var $impl = $mod.$impl;',
- ' rtl.createClass($mod, "TAnt$G1", pas.system.TObject, function () {',
+ ' rtl.createClass(this, "TAnt$G1", pas.system.TObject, function () {',
' this.$initSpec = function () {',
' this.x = $impl.TBird.$new();',
' this.a = rtl.arraySetLength(null, $impl.TBird, 2);',
@@ -1312,11 +1312,11 @@ begin
ConvertProgram;
CheckSource('TestGen_ExtClass_RTTI',
LinesToStr([ // statements
- '$mod.$rtti.$ExtClass("TGJSSET<System.JSValue>", {',
+ 'this.$rtti.$ExtClass("TGJSSET<System.JSValue>", {',
' jsclass: "SET"',
'});',
- '$mod.$rtti.$RefToProcVar("TJSSetEventProc", {',
- ' procsig: rtl.newTIProcSig([["value", rtl.jsvalue], ["key", rtl.nativeint], ["set_", $mod.$rtti["TGJSSET<System.JSValue>"]]])',
+ 'this.$rtti.$RefToProcVar("TJSSetEventProc", {',
+ ' procsig: rtl.newTIProcSig([["value", rtl.jsvalue], ["key", rtl.nativeint], ["set_", this.$rtti["TGJSSET<System.JSValue>"]]])',
'});',
'this.p = null;',
'']),
@@ -1358,7 +1358,7 @@ begin
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
' var $impl = $mod.$impl;',
- ' $mod.$rtti.$ExtClass("TAnt<UnitA.TBird>", {',
+ ' this.$rtti.$ExtClass("TAnt<UnitA.TBird>", {',
' jsclass: "SET"',
' });',
' $mod.$implcode = function () {',
@@ -1422,15 +1422,15 @@ begin
ConvertProgram;
CheckSource('TestGen_ClassInterface_Corba',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{00000000-0000-0000-C000-000000000046}", [], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{00000000-0000-0000-C000-000000000046}", [], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createInterface($mod, "IBird$G2", "{33AB51C6-6240-3BDF-B4B0-D48A593EAB0A}", ["GetSize", "SetSize", "DoIt"], $mod.IUnknown);',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createInterface(this, "IBird$G2", "{33AB51C6-6240-3BDF-B4B0-D48A593EAB0A}", ["GetSize", "SetSize", "DoIt"], this.IUnknown);',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird$G2);',
'});',
'this.BirdIntf = null;',
@@ -1461,9 +1461,9 @@ begin
ConvertProgram;
CheckSource('TestGen_ClassInterface_InterfacedObject',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IComparer$G2", "{505778ED-F783-4456-9691-32F419CC5E18}", ["Compare"], pas.system.IUnknown);',
+ 'rtl.createInterface(this, "IComparer$G2", "{505778ED-F783-4456-9691-32F419CC5E18}", ["Compare"], pas.system.IUnknown);',
'this.aComparer = null;',
- 'rtl.createClass($mod, "TComparer$G1", pas.system.TInterfacedObject, function () {',
+ 'rtl.createClass(this, "TComparer$G1", pas.system.TInterfacedObject, function () {',
' this.Compare = function (Left, Right) {',
' var Result = 0;',
' return Result;',
@@ -1497,7 +1497,7 @@ begin
ConvertProgram;
CheckSource('TestGen_InlineSpec_Constructor',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -1506,7 +1506,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
'});',
'this.b = null;',
'']),
@@ -1546,13 +1546,13 @@ begin
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
' var $impl = $mod.$impl;',
- ' rtl.createClass($mod, "TBird$G1", pas.system.TObject, function () {',
+ ' rtl.createClass(this, "TBird$G1", pas.system.TObject, function () {',
' this.Fly = function () {',
' $impl.DoIt();',
' };',
' });',
' this.b = null;',
- ' rtl.createClass($mod, "TBird$G2", pas.system.TObject, function () {',
+ ' rtl.createClass(this, "TBird$G2", pas.system.TObject, function () {',
' this.Fly = function () {',
' $impl.DoIt();',
' };',
@@ -1589,13 +1589,13 @@ begin
ConvertProgram;
CheckSource('TestGen_IntAssignTemplVar',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.m = 0;',
@@ -1636,14 +1636,14 @@ begin
ConvertProgram;
CheckSource('TestGen_TypeCastDotField',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
'this.o = null;',
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.Field = 0;',
@@ -1682,7 +1682,7 @@ begin
ConvertProgram;
CheckSource('TestGen_HelperForArray',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "TWordArrHelper", null, function () {',
+ 'rtl.createHelper(this, "TWordArrHelper", null, function () {',
' this.Fly = function (w) {',
' };',
'});',
@@ -2013,7 +2013,7 @@ begin
ConvertProgram;
CheckSource('TestGenMethod_ObjFPC',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -2069,13 +2069,13 @@ begin
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
' var $impl = $mod.$impl;',
- ' $mod.$rtti.$DynArray("TDyn<UnitA.TBird>", {});',
+ ' this.$rtti.$DynArray("TDyn<UnitA.TBird>", {});',
' this.TStatic$G1$clone = function (a) {',
' var r = [];',
' for (var i = 0; i < 2; i++) r.push($impl.TBird.$clone(a[i]));',
' return r;',
' };',
- ' $mod.$rtti.$StaticArray("TStatic<UnitA.TBird>", {',
+ ' this.$rtti.$StaticArray("TStatic<UnitA.TBird>", {',
' dims: [2]',
' });',
' $mod.$implcode = function () {',
@@ -2195,7 +2195,7 @@ begin
'rtl.module("UnitA", ["system"], function () {',
' var $mod = this;',
' var $impl = $mod.$impl;',
- ' $mod.$rtti.$ProcVar("TAnt<UnitA.TBird>", {',
+ ' this.$rtti.$ProcVar("TAnt<UnitA.TBird>", {',
' init: function () {',
' this.procsig = rtl.newTIProcSig([["a", $mod.$rtti["TBird"], 2]], $mod.$rtti["TBird"]);',
' }',
diff --git a/packages/pastojs/tests/tcmodules.pas b/packages/pastojs/tests/tcmodules.pas
index 1c846598ae..899da0629b 100644
--- a/packages/pastojs/tests/tcmodules.pas
+++ b/packages/pastojs/tests/tcmodules.pas
@@ -539,6 +539,7 @@ type
Procedure TestClass_ExternalOverrideFail;
Procedure TestClass_ExternalVar;
Procedure TestClass_Const;
+ Procedure TestClass_ConstEnum;
Procedure TestClass_LocalConstDuplicate_Prg;
Procedure TestClass_LocalConstDuplicate_Unit;
// ToDo: Procedure TestAdvRecord_LocalConstDuplicate;
@@ -2522,13 +2523,13 @@ begin
LinesToStr([
'rtl.module("TEST.UnitA", ["system"], function () {',
' var $mod = this;',
- ' rtl.createClass($mod, "TObject", null, function () {',
+ ' rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
' });',
- ' rtl.createClass($mod, "TTestA", $mod.TObject, function () {',
+ ' rtl.createClass(this, "TTestA", this.TObject, function () {',
' });',
'}, ["TEST.UnitB"]);'
]));
@@ -2536,7 +2537,7 @@ begin
LinesToStr([
'rtl.module("TEST.UnitB", ["system","TEST.UnitA"], function () {',
' var $mod = this;',
- ' rtl.createClass($mod, "TTestB", pas["TEST.UnitA"].TTestA, function () {',
+ ' rtl.createClass(this, "TTestB", pas["TEST.UnitA"].TTestA, function () {',
' });',
'});'
]));
@@ -4480,7 +4481,7 @@ begin
ConvertUnit;
CheckSource('TestProc_OverloadUnitCycle',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TEagle", pas.Unit2.TObject, function () {',
+ 'rtl.createClass(this, "TEagle", pas.Unit2.TObject, function () {',
' this.DoIt = function (b) {',
' };',
' this.DoIt$1 = function (i) {',
@@ -4648,7 +4649,7 @@ begin
ConvertProgram;
CheckSource('TestProc_LocalVarAbsolute',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Index = 0;',
' };',
@@ -4976,7 +4977,7 @@ begin
ConvertProgram;
CheckSource('TestAnonymousProc_With',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.b = false;',
' };',
@@ -5020,7 +5021,7 @@ begin
ConvertProgram;
CheckSource('TestAnonymousProc_ExceptOn',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.b = false;',
' };',
@@ -5080,7 +5081,7 @@ begin
ConvertProgram;
CheckSource('TestAnonymousProc_Nested',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.i = 0;',
' };',
@@ -5193,7 +5194,7 @@ begin
ConvertProgram;
CheckSource('TestAnonymousProc_Class',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Size = 0;',
' };',
@@ -5265,7 +5266,7 @@ begin
Add(' e:=green;');
Add(' e:=default(TMyEnum);');
ConvertProgram;
- CheckSource('TestEnumName',
+ CheckSource('TestEnum_Name',
LinesToStr([ // statements
'this.TMyEnum = {',
' "0":"Red",',
@@ -5276,7 +5277,7 @@ begin
' Blue:2',
' };',
'this.e = 0;',
- 'this.f = $mod.TMyEnum.Blue;'
+ 'this.f = this.TMyEnum.Blue;'
]),
LinesToStr([
'$mod.e=$mod.TMyEnum.Green;',
@@ -5704,7 +5705,7 @@ begin
'this.c = 0;',
'this.s = {};',
'this.t = {};',
- 'this.u = rtl.createSet($mod.TColor.Red);'
+ 'this.u = rtl.createSet(this.TColor.Red);'
]),
LinesToStr([
'$mod.s={};',
@@ -6044,7 +6045,7 @@ begin
' "1": "Blue",',
' Blue: 1',
'};',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -6086,7 +6087,7 @@ begin
' "1": "Blue",',
' Blue: 1',
'};',
- 'this.Orange = $mod.TEnum.Red;',
+ 'this.Orange = this.TEnum.Red;',
'this.Enum = 0;',
'this.Enums = {};',
'']),
@@ -6164,7 +6165,7 @@ begin
' "1": "green",',
' green: 1',
'};',
- 'this.favorite = $mod.TFlags$a.red;',
+ 'this.favorite = this.TFlags$a.red;',
'this.f = {};',
'this.i = 0;',
'']),
@@ -6249,8 +6250,8 @@ begin
' "2": "green",',
' green: 2',
'};',
- 'this.teAny = rtl.createSet(null, $mod.TEnum.red, $mod.TEnum.green);',
- 'this.teRedBlue = rtl.createSet(null, $mod.TEnum.red, $mod.TEnum.green - 1);',
+ 'this.teAny = rtl.createSet(null, this.TEnum.red, this.TEnum.green);',
+ 'this.teRedBlue = rtl.createSet(null, this.TEnum.red, this.TEnum.green - 1);',
'this.e = 0;',
'this.s = {};',
'']),
@@ -6292,7 +6293,7 @@ begin
CheckSource('TestSet_ConstChar',
LinesToStr([ // statements
'this.LowChars = rtl.createSet(null, 97, 122);',
- 'this.Chars = rtl.unionSet($mod.LowChars, rtl.createSet(null, 65, 90));',
+ 'this.Chars = rtl.unionSet(this.LowChars, rtl.createSet(null, 65, 90));',
'this.sc = rtl.createSet(1040, 1071);',
'this.c = "";',
'this.s = "";',
@@ -6328,7 +6329,7 @@ begin
CheckSource('TestSet_ConstInt',
LinesToStr([ // statements
'this.Months = rtl.createSet(null, 1, 12);',
- 'this.Mirror = rtl.unionSet(rtl.createSet(null, -12, -1), $mod.Months);',
+ 'this.Mirror = rtl.unionSet(rtl.createSet(null, -12, -1), this.Months);',
'this.i = 0;',
'']),
LinesToStr([
@@ -6908,7 +6909,7 @@ begin
'this.s3 = rtl.createSet(null, 1, 3);',
'this.s4 = rtl.createSet(null, -128, 127);',
'this.s5 = rtl.createSet(null, -128 + 1, 127 - 1);',
- 'this.s6 = 1 in $mod.s2;',
+ 'this.s6 = 1 in this.s2;',
'this.i = 0;',
'this.i2 = 0;',
'']),
@@ -7120,10 +7121,10 @@ begin
CheckSource('TestCurrency',
LinesToStr([
'this.a = 27000;',
- 'this.b = $mod.a + 17000;',
+ 'this.b = this.a + 17000;',
'this.MinSafeIntCurrency = -92233720368.5477;',
'this.MaxSafeIntCurrency = 92233720368.5477;',
- 'this.c = $mod.b;',
+ 'this.c = this.b;',
'this.i = 0;',
'this.d = 0.0;',
'this.j = undefined;',
@@ -8283,19 +8284,19 @@ begin
ConvertProgram;
CheckSource('TestTryExcept',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "Exception", $mod.TObject, function () {',
+ 'rtl.createClass(this, "Exception", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.Msg = "";',
' };',
'});',
- 'rtl.createClass($mod, "EInvalidCast", $mod.Exception, function () {',
+ 'rtl.createClass(this, "EInvalidCast", this.Exception, function () {',
'});',
'this.vI = 0;'
]),
@@ -8353,13 +8354,13 @@ begin
ConvertProgram;
CheckSource('TestTryExcept_ReservedWords',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "Exception", $mod.TObject, function () {',
+ 'rtl.createClass(this, "Exception", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.Symbol = "";',
@@ -8400,7 +8401,7 @@ begin
ConvertProgram;
CheckSource('TestIfThenRaiseElse',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -9139,7 +9140,7 @@ begin
ConvertProgram;
CheckSource('TestArrayOfRecord',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.Int = 0;',
' this.$eq = function (b) {',
' return this.Int === b.Int;',
@@ -9152,7 +9153,7 @@ begin
'this.DoIt = function (vd, vc, vv) {',
'};',
'this.Arr = [];',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'this.i = 0;'
]),
LinesToStr([ // $mod.$main
@@ -9185,7 +9186,7 @@ begin
ConvertProgram;
CheckSource('TestArray_StaticRecord',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.Int = 0;',
' this.$eq = function (b) {',
' return this.Int === b.Int;',
@@ -9200,7 +9201,7 @@ begin
' for (var i = 0; i < 2; i++) r.push($mod.TRec.$clone(a[i]));',
' return r;',
'};',
- 'this.Arr = rtl.arraySetLength(null, $mod.TRec, 2);',
+ 'this.Arr = rtl.arraySetLength(null, this.TRec, 2);',
'']),
LinesToStr([ // $mod.$main
'$mod.Arr[0].Int = 2 + 1 + 2;']));
@@ -9595,7 +9596,7 @@ begin
ConvertProgram;
CheckSource('TestArray_SetLengthProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -9848,7 +9849,7 @@ begin
' "1": "small",',
' small: 1',
'};',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -9928,7 +9929,7 @@ begin
' "1": "small",',
' small: 1',
'};',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -10003,7 +10004,7 @@ begin
' "1": "small",',
' small: 1',
'};',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -10073,7 +10074,7 @@ begin
'this.OneStr = [7];',
'this.Chars = ["a", "o", "c"];',
'this.Names = ["a", "foo"];',
- 'this.NameCount = 0 + (rtl.length($mod.Names) - 1) + rtl.length($mod.Names);',
+ 'this.NameCount = 0 + (rtl.length(this.Names) - 1) + rtl.length(this.Names);',
'this.i = 0;',
'']),
LinesToStr([ // $mod.$main
@@ -10119,7 +10120,7 @@ begin
'this.OneStr = rtl.arrayConcatN([7],[8]);',
'this.Chars = ["a", "o", "c"];',
'this.Names = ["a", "a"];',
- 'this.NameCount = 0 + (rtl.length($mod.Names) - 1) + rtl.length($mod.Names);',
+ 'this.NameCount = 0 + (rtl.length(this.Names) - 1) + rtl.length(this.Names);',
'']),
LinesToStr([ // $mod.$main
'']));
@@ -10352,7 +10353,7 @@ begin
ConvertProgram;
CheckSource('TestArray_ForInArrOfString',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -10555,13 +10556,13 @@ begin
ConvertProgram;
CheckSource('TestArrayOfConst_PassObj',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
'this.Say = function (args) {',
'};',
'this.o = null;',
@@ -10594,7 +10595,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_Empty',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecA", function () {',
+ 'rtl.recNewT(this, "TRecA", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -10602,8 +10603,8 @@ begin
' return this;',
' };',
'});',
- 'this.a = $mod.TRecA.$new();',
- 'this.b = $mod.TRecA.$new();',
+ 'this.a = this.TRecA.$new();',
+ 'this.b = this.TRecA.$new();',
'']),
LinesToStr([ // $mod.$main
'if ($mod.a.$eq($mod.b)) ;'
@@ -10623,7 +10624,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_Var',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecA", function () {',
+ 'rtl.recNewT(this, "TRecA", function () {',
' this.Bold = 0;',
' this.$eq = function (b) {',
' return this.Bold === b.Bold;',
@@ -10633,7 +10634,7 @@ begin
' return this;',
' };',
'});',
- 'this.Rec = $mod.TRecA.$new();',
+ 'this.Rec = this.TRecA.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.Rec.Bold = 123;'
@@ -10657,7 +10658,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_VarExternal',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecA", function () {',
+ 'rtl.recNewT(this, "TRecA", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return (this.i === b.i) && (this.length === b.length);',
@@ -10668,7 +10669,7 @@ begin
' return this;',
' };',
'});',
- 'this.Rec = $mod.TRecA.$new();',
+ 'this.Rec = this.TRecA.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.Rec.length = $mod.Rec.length;'
@@ -10695,7 +10696,7 @@ begin
ConvertProgram;
CheckSource('TestWithRecordDo',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.vI = 0;',
' this.$eq = function (b) {',
' return this.vI === b.vI;',
@@ -10706,7 +10707,7 @@ begin
' };',
'});',
'this.Int = 0;',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'']),
LinesToStr([ // $mod.$main
'var $with = $mod.r;',
@@ -10749,7 +10750,7 @@ begin
' "1": "green",',
' green: 1',
'};',
- 'rtl.recNewT($mod, "TSmallRec", function () {',
+ 'rtl.recNewT(this, "TSmallRec", function () {',
' this.N = 0;',
' this.$eq = function (b) {',
' return this.N === b.N;',
@@ -10759,7 +10760,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.recNewT($mod, "TBigRec", function () {',
+ 'rtl.recNewT(this, "TBigRec", function () {',
' this.Int = 0;',
' this.D = 0.0;',
' this.$new = function () {',
@@ -10783,8 +10784,8 @@ begin
' return this;',
' };',
'});',
- 'this.r = $mod.TBigRec.$new();',
- 'this.s = $mod.TBigRec.$new();',
+ 'this.r = this.TBigRec.$new();',
+ 'this.s = this.TBigRec.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.r.$assign($mod.s);',
@@ -10830,7 +10831,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_AsParams',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecord", function () {',
+ 'rtl.recNewT(this, "TRecord", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -10860,7 +10861,7 @@ begin
' $mod.DoIt($mod.TRecord.$clone(vL), vL, vL, vL);',
' U.i = 3;',
'};',
- 'this.i = $mod.TRecord.$new();'
+ 'this.i = this.TRecord.$new();'
]),
LinesToStr([
'$mod.DoIt($mod.TRecord.$clone($mod.i), $mod.i, $mod.i, $mod.i);',
@@ -10891,7 +10892,7 @@ begin
CheckResolverUnexpectedHints();
CheckSource('TestRecord_ConstRef',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -10936,7 +10937,7 @@ begin
ConvertProgram;
CheckSource('TestRecordElement_AsParams',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecord", function () {',
+ 'rtl.recNewT(this, "TRecord", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -10958,7 +10959,7 @@ begin
' }',
' });',
'};',
- 'this.r = $mod.TRecord.$new();'
+ 'this.r = this.TRecord.$new();'
]),
LinesToStr([
'$mod.DoIt($mod.r.i,$mod.r.i,{',
@@ -10994,7 +10995,7 @@ begin
ConvertProgram;
CheckSource('TestRecordElementFromFuncResult_AsParams',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecord", function () {',
+ 'rtl.recNewT(this, "TRecord", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -11036,7 +11037,7 @@ begin
ConvertProgram;
CheckSource('TestRecordElementFromWith_AsParams',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecord", function () {',
+ 'rtl.recNewT(this, "TRecord", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -11048,7 +11049,7 @@ begin
'});',
'this.DoIt = function (vG,vH,vI) {',
'};',
- 'this.r = $mod.TRecord.$new();'
+ 'this.r = this.TRecord.$new();'
]),
LinesToStr([
'var $with = $mod.r;',
@@ -11095,7 +11096,7 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- 'rtl.recNewT($mod, "TRecord", function () {',
+ 'rtl.recNewT(this, "TRecord", function () {',
' this.i = 0;',
' this.Event = null;',
' this.$new = function () {',
@@ -11113,7 +11114,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.recNewT($mod, "TNested", function () {',
+ 'rtl.recNewT(this, "TNested", function () {',
' this.$new = function () {',
' var r = Object.create(this);',
' r.r = $mod.TRecord.$new();',
@@ -11128,8 +11129,8 @@ begin
' };',
'});',
'this.b = false;',
- 'this.r = $mod.TRecord.$new();',
- 'this.s = $mod.TRecord.$new();',
+ 'this.r = this.TRecord.$new();',
+ 'this.s = this.TRecord.$new();',
'']),
LinesToStr([
'$mod.b = $mod.r.$eq($mod.s);',
@@ -11168,7 +11169,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_JSValue',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRecord", function () {',
+ 'rtl.recNewT(this, "TRecord", function () {',
' this.i = 0;',
' this.$eq = function (b) {',
' return this.i === b.i;',
@@ -11186,7 +11187,7 @@ begin
' if (v) ;',
'};',
'this.Jv = undefined;',
- 'this.Rec = $mod.TRecord.$new();',
+ 'this.Rec = this.TRecord.$new();',
'']),
LinesToStr([
'$mod.Rec.$assign(rtl.getObject($mod.Jv));',
@@ -11231,7 +11232,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_FieldArray',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$new = function () {',
' var r = Object.create(this);',
' r.a = [];',
@@ -11284,7 +11285,7 @@ begin
ConvertProgram;
CheckSource('TestRecord_Const',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
' this.$eq = function (b) {',
@@ -11296,7 +11297,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.i = 0;',
' this.$new = function () {',
' var r = Object.create(this);',
@@ -11318,20 +11319,20 @@ begin
' return this;',
' };',
'});',
- 'this.r = $mod.TRec.$clone({',
+ 'this.r = this.TRec.$clone({',
' i: 1,',
' a: [2, 3],',
' s: [4, 5],',
' m: [[11, 12], [13, 14]],',
- ' p: $mod.TPoint.$clone({',
+ ' p: this.TPoint.$clone({',
' x: 21,',
' y: 22',
' })',
'});',
- 'this.p = [$mod.TPoint.$clone({',
+ 'this.p = [this.TPoint.$clone({',
' x: 1,',
' y: 2',
- '}), $mod.TPoint.$clone({',
+ '}), this.TPoint.$clone({',
' x: 3,',
' y: 4',
'})];',
@@ -11436,7 +11437,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_Function',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
' this.$eq = function (b) {',
@@ -11456,8 +11457,8 @@ begin
' return Result;',
' };',
'});',
- 'this.p = $mod.TPoint.$new();',
- 'this.q = $mod.TPoint.$new();',
+ 'this.p = this.TPoint.$new();',
+ 'this.q = this.TPoint.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.p.Add($mod.q);',
@@ -11499,7 +11500,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_Property',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
' this.$eq = function (b) {',
@@ -11522,8 +11523,8 @@ begin
'});',
'this.SetSize = function (Value) {',
'};',
- 'this.p = $mod.TPoint.$new();',
- 'this.q = $mod.TPoint.$new();',
+ 'this.p = this.TPoint.$new();',
+ 'this.q = this.TPoint.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.p.SetSize($mod.q.GetSize());',
@@ -11560,7 +11561,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_PropertyDefault',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -11576,7 +11577,7 @@ begin
' this.SetItems = function (Index, Value) {',
' };',
'});',
- 'this.p = $mod.TPoint.$new();',
+ 'this.p = this.TPoint.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.p.SetItems(1, $mod.p.GetItems(2));',
@@ -11625,7 +11626,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_Property_ClassMethod',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.Fx = 0;',
' this.Fy = 0;',
' this.$eq = function (b) {',
@@ -11646,7 +11647,7 @@ begin
' $mod.TRec.SetInt($mod.TRec.GetInt() + 1);',
' };',
'}, true);',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.TRec.Fy = $mod.TRec.Fx + 1;',
@@ -11692,7 +11693,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_Const',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
' this.Count = 0;',
@@ -11705,7 +11706,7 @@ begin
' return this;',
' };',
'}, true);',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.i = 0;',
' this.$new = function () {',
' var r = Object.create(this);',
@@ -11727,20 +11728,20 @@ begin
' return this;',
' };',
'});',
- 'this.r = $mod.TRec.$clone({',
+ 'this.r = this.TRec.$clone({',
' i: 1,',
' a: [2, 3],',
' s: [4, 5],',
' m: [[11, 12], [13, 14]],',
- ' p: $mod.TPoint.$clone({',
+ ' p: this.TPoint.$clone({',
' x: 21,',
' y: 0',
' })',
'});',
- 'this.p = [$mod.TPoint.$clone({',
+ 'this.p = [this.TPoint.$clone({',
' x: 1,',
' y: 2',
- '}), $mod.TPoint.$clone({',
+ '}), this.TPoint.$clone({',
' x: 3,',
' y: 4',
'})];',
@@ -11782,7 +11783,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_ExternalField',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TCar", function () {',
+ 'rtl.recNewT(this, "TCar", function () {',
' this.$eq = function (b) {',
' return (this.$Intern === b.$Intern) && (this.$Intern2 === b.$Intern2) && (this["A B"] === b["A B"]);',
' };',
@@ -11798,7 +11799,7 @@ begin
' this["A B"] = this["A B"] + 3;',
' };',
'});',
- 'this.Rec = $mod.TCar.$clone({',
+ 'this.Rec = this.TCar.$clone({',
' $Intern: 11,',
' $Intern2: 12,',
' "A B": 13',
@@ -11856,7 +11857,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_SubRecord',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
@@ -11895,9 +11896,9 @@ begin
' this.TPoint.Count = this.p.Count + 2;',
' };',
'}, true);',
- 'this.r = $mod.TRec.$clone({',
+ 'this.r = this.TRec.$clone({',
' i: 1,',
- ' p: $mod.TRec.TPoint.$clone({',
+ ' p: this.TRec.TPoint.$clone({',
' x: 21,',
' y: 22',
' })',
@@ -11945,14 +11946,14 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_SubClass',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.recNewT($mod, "TPoint", function () {',
- ' rtl.createClass(this, "TBird", $mod.TObject, function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
+ ' rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' this.DoIt();',
' this.DoIt();',
@@ -12023,7 +12024,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_Constructor',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
' this.$eq = function (b) {',
@@ -12040,7 +12041,7 @@ begin
' return this;',
' };',
'}, true);',
- 'this.r = $mod.TPoint.$new();',
+ 'this.r = this.TPoint.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.r.$assign($mod.TPoint.$new().Create(1, 2));',
@@ -12083,7 +12084,7 @@ begin
ConvertProgram;
CheckSource('TestAdvRecord_ClassConstructor_Program',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.$eq = function (b) {',
' return true;',
@@ -12095,7 +12096,7 @@ begin
' };',
'}, true);',
'this.count = 0;',
- 'this.r = $mod.TPoint.$new();',
+ 'this.r = this.TPoint.$new();',
'']),
LinesToStr([ // $mod.$main
'(function () {',
@@ -12141,7 +12142,7 @@ begin
CheckSource('TestAdvRecord_ClassConstructor_Unit',
LinesToStr([ // statements
'var $impl = $mod.$impl;',
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.$eq = function (b) {',
' return true;',
@@ -12193,7 +12194,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectDefaultConstructor',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12232,7 +12233,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectConstructorWithParams',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12271,7 +12272,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectConstructorWithDefaultParam',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12280,7 +12281,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TTest", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TTest", this.TObject, function () {',
' this.Create$1 = function (Par) {',
' return this;',
' };',
@@ -12314,7 +12315,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Var',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' this.vI = 0;',
' };',
@@ -12362,7 +12363,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Method',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' this.vI = 0;',
' this.Sub = null;',
@@ -12432,7 +12433,7 @@ begin
CheckSource('TestClass_Implementation',
LinesToStr([ // statements
'var $impl = $mod.$impl;',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12492,7 +12493,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Inheritance',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12501,9 +12502,9 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod,"TClassA",$mod.TObject,function(){',
+ 'rtl.createClass(this,"TClassA",this.TObject,function(){',
'});',
- 'rtl.createClass($mod,"TClassB",$mod.TObject,function(){',
+ 'rtl.createClass(this,"TClassB",this.TObject,function(){',
' this.ProcB = function () {',
' };',
'});',
@@ -12544,15 +12545,15 @@ begin
ConvertProgram;
CheckSource('TestClass_TypeAlias',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IObject", "{B92D5841-6F2A-306A-8000-000000000000}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{4B0D080B-C0F6-387B-AE88-F10981585074}", [], $mod.IObject);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IObject", "{B92D5841-6F2A-306A-8000-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{4B0D080B-C0F6-387B-AE88-F10981585074}", [], this.IObject);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
'});',
'this.oObj = null;',
'this.oBird = null;',
@@ -12576,7 +12577,7 @@ begin
ConvertProgram;
CheckSource('TestClass_AbstractMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12630,7 +12631,7 @@ begin
ConvertProgram;
CheckSource('TestClass_CallInherited_ProcNoParams',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12640,7 +12641,7 @@ begin
' this.DoIt = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TA", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TA", this.TObject, function () {',
' this.DoAbstract = function () {',
' $mod.TObject.DoVirtual.call(this);',
' };',
@@ -12712,7 +12713,7 @@ begin
ConvertProgram;
CheckSource('TestClass_CallInherited_WithParams',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12728,7 +12729,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TClassA", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TClassA", this.TObject, function () {',
' this.DoAbstract = function (pA,pB) {',
' $mod.TObject.DoVirtual.call(this,pA,pB);',
' $mod.TObject.DoVirtual.call(this,pA,0);',
@@ -12807,7 +12808,7 @@ begin
ConvertProgram;
CheckSource('TestClass_CallInheritedConstructor',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -12820,7 +12821,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TA", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TA", this.TObject, function () {',
' this.Create = function () {',
' $mod.TObject.Create.call(this);',
' $mod.TObject.Create.call(this);',
@@ -12891,7 +12892,7 @@ begin
ConvertProgram;
CheckSource('TestClass_ClassVar_Assign',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.vI = 0;',
' this.Sub = null;',
' this.$init = function () {',
@@ -12979,7 +12980,7 @@ begin
ConvertProgram;
CheckSource('TestClass_CallClassMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod,"TObject",null,function(){',
+ 'rtl.createClass(this,"TObject",null,function(){',
' this.vI = 0;',
' this.Sub = null;',
' this.$init = function () {',
@@ -13061,7 +13062,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Property',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Fx = 0;',
' this.Fy = 0;',
@@ -13155,7 +13156,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Property_ClassMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.Fx = 0;',
' this.Fy = 0;',
' this.$init = function () {',
@@ -13170,7 +13171,7 @@ begin
' this.SetInt = function (Value) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObject.Fx = 3;',
' $mod.TObject.Fy = this.Fx + 1;',
@@ -13239,7 +13240,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Property_Indexed',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FItems = [];',
' };',
@@ -13307,7 +13308,7 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -13372,7 +13373,7 @@ begin
ConvertProgram;
CheckSource('TestClass_PropertyOfTypeArray',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FItems = [];',
' };',
@@ -13448,13 +13449,13 @@ begin
ConvertProgram;
CheckSource('TestClass_PropertyDefault',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FItems = [];',
@@ -13521,17 +13522,17 @@ begin
ConvertProgram;
CheckSource('TestClass_PropertyDefault_TypecastToOtherDefault',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TAlphaList", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TAlphaList", this.TObject, function () {',
'});',
- 'rtl.createClass($mod, "TBetaList", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBetaList", this.TObject, function () {',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' var List = null;',
' if (List.GetAlphas(true).GetBetas(3) === null) ;',
@@ -13571,14 +13572,14 @@ begin
ConvertProgram;
CheckSource('TestClass_PropertyOverride',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FItem = 0;',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TCar", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCar", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FBag = 0;',
@@ -13630,7 +13631,7 @@ begin
ConvertProgram;
CheckSource('TestClass_PropertyIncVisibility',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TBird", pas.unit1.TObject, function () {',
+ 'rtl.createClass(this, "TBird", pas.unit1.TObject, function () {',
'});',
'this.DoIt = function (i) {',
'};',
@@ -13658,7 +13659,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Assigned',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -13705,7 +13706,7 @@ begin
ConvertProgram;
CheckSource('TestClass_WithClassDoCreate',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.aBool = false;',
' this.Arr = [];',
@@ -13771,7 +13772,7 @@ begin
ConvertProgram;
CheckSource('TestClass_WithClassInstDoProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FInt = 0;',
' };',
@@ -13832,7 +13833,7 @@ begin
ConvertProgram;
CheckSource('TestClass_WithClassInstDoPropertyWithParams',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -13889,7 +13890,7 @@ begin
ConvertProgram;
CheckSource('TestClass_WithClassInstDoFunc',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -13947,7 +13948,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TypeCast',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Next = null;',
' };',
@@ -13958,7 +13959,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TControl", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TControl", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.Arr = [];',
@@ -14018,7 +14019,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TypeCastUntypedParam',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -14083,7 +14084,7 @@ begin
ConvertProgram;
CheckSource('TestClass_Overloads',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -14132,7 +14133,7 @@ begin
ConvertProgram;
CheckSource('TestClass_OverloadsAncestor',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -14144,7 +14145,7 @@ begin
' this.DoIt$1 = function (vA, vB) {',
' };',
'});',
- 'rtl.createClass($mod, "TCar", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCar", this.TObject, function () {',
' this.DoIt$2 = function (vA) {',
' this.DoIt$2(1);',
' this.DoIt$3(1, 2);',
@@ -14193,7 +14194,7 @@ begin
ConvertProgram;
CheckSource('TestClass_OverloadConstructor',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -14207,7 +14208,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TCar", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCar", this.TObject, function () {',
' this.Create$2 = function (vA) {',
' this.Create$2(1);',
' this.Create$3(1, 2);',
@@ -14269,13 +14270,13 @@ begin
ConvertProgram;
CheckSource('TestClass_OverloadDelphiOverride',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.GetValue = function () {',
' var Result = 0;',
' if (3 === this.GetValue()) ;',
@@ -14287,7 +14288,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TEagle", $mod.TBird, function () {',
+ 'rtl.createClass(this, "TEagle", this.TBird, function () {',
' this.GetValue = function () {',
' var Result = 0;',
' if (13 === this.GetValue()) ;',
@@ -14351,13 +14352,13 @@ begin
ConvertProgram;
CheckSource('TestClass_ReintroduceVarDelphi',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TAnimal", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TAnimal", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.A = 0;',
@@ -14367,14 +14368,14 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TAnimal, function () {',
+ 'rtl.createClass(this, "TBird", this.TAnimal, function () {',
' this.$init = function () {',
' $mod.TAnimal.$init.call(this);',
' this.A$1 = 0.0;',
' this.B$1 = false;',
' };',
'});',
- 'rtl.createClass($mod, "TEagle", $mod.TBird, function () {',
+ 'rtl.createClass(this, "TEagle", this.TBird, function () {',
' this.$init = function () {',
' $mod.TBird.$init.call(this);',
' this.B$2 = 0.0;',
@@ -14423,20 +14424,20 @@ begin
ConvertProgram;
CheckSource('TestClass_ReintroducedVar',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Some = 0;',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TMobile", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TMobile", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.Some$1 = "";',
' };',
'});',
- 'rtl.createClass($mod, "TCar", $mod.TMobile, function () {',
+ 'rtl.createClass(this, "TCar", this.TMobile, function () {',
' this.Some$2 = function () {',
' this.Some$2();',
' this.Some$3(1);',
@@ -14472,7 +14473,7 @@ begin
ConvertProgram;
CheckSource('TestClass_RaiseDescendant',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -14481,9 +14482,9 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "Exception", $mod.TObject, function () {',
+ 'rtl.createClass(this, "Exception", this.TObject, function () {',
'});',
- 'rtl.createClass($mod, "EConvertError", $mod.Exception, function () {',
+ 'rtl.createClass(this, "EConvertError", this.Exception, function () {',
'});',
'this.AssertConv = function (Msg) {',
' var Result = null;',
@@ -14546,7 +14547,7 @@ begin
CheckSource('TestClass_ExternalMethod',
LinesToStr([
'var $impl = $mod.$impl;',
- 'rtl.createClass($mod, "TCar", pas.unit2.TObject, function () {',
+ 'rtl.createClass(this, "TCar", pas.unit2.TObject, function () {',
' this.DoIt = function () {',
' this.$DoIntern();',
' this.$DoIntern();',
@@ -14649,7 +14650,7 @@ begin
CheckSource('TestClass_ExternalVar',
LinesToStr([
'var $impl = $mod.$impl;',
- 'rtl.createClass($mod, "TCar", pas.unit2.TObject, function () {',
+ 'rtl.createClass(this, "TCar", pas.unit2.TObject, function () {',
' this.DoIt = function () {',
' this.$Intern = this.$Intern + 1;',
' this.$Intern2 = this.$Intern2 + 2;',
@@ -14674,51 +14675,52 @@ end;
procedure TTestModule.TestClass_Const;
begin
StartProgram(false);
- Add('type');
- Add(' integer = longint;');
- Add(' TClass = class of TObject;');
- Add(' TObject = class');
- Add(' public');
- Add(' const cI: integer = 3;');
- Add(' procedure DoIt;');
- Add(' class procedure DoMore;');
- Add(' end;');
- Add('procedure tobject.doit;');
- Add('begin');
- Add(' if cI=4 then;');
- Add(' if 5=cI then;');
- Add(' if Self.cI=6 then;');
- Add(' if 7=Self.cI then;');
- Add(' with Self do begin');
- Add(' if cI=11 then;');
- Add(' if 12=cI then;');
- Add(' end;');
- Add('end;');
- Add('class procedure tobject.domore;');
- Add('begin');
- Add(' if cI=8 then;');
- Add(' if Self.cI=9 then;');
- Add(' if 10=cI then;');
- Add(' if 11=Self.cI then;');
- Add(' with Self do begin');
- Add(' if cI=13 then;');
- Add(' if 14=cI then;');
- Add(' end;');
- Add('end;');
- Add('var');
- Add(' Obj: TObject;');
- Add(' Cla: TClass;');
- Add('begin');
- Add(' if TObject.cI=21 then ;');
- Add(' if Obj.cI=22 then ;');
- Add(' if Cla.cI=23 then ;');
- Add(' with obj do if ci=24 then;');
- Add(' with TObject do if ci=25 then;');
- Add(' with Cla do if ci=26 then;');
+ Add([
+ 'type',
+ ' integer = longint;',
+ ' TClass = class of TObject;',
+ ' TObject = class',
+ ' public',
+ ' const cI: integer = 3;',
+ ' procedure DoIt;',
+ ' class procedure DoMore;',
+ ' end;',
+ 'procedure tobject.doit;',
+ 'begin',
+ ' if cI=4 then;',
+ ' if 5=cI then;',
+ ' if Self.cI=6 then;',
+ ' if 7=Self.cI then;',
+ ' with Self do begin',
+ ' if cI=11 then;',
+ ' if 12=cI then;',
+ ' end;',
+ 'end;',
+ 'class procedure tobject.domore;',
+ 'begin',
+ ' if cI=8 then;',
+ ' if Self.cI=9 then;',
+ ' if 10=cI then;',
+ ' if 11=Self.cI then;',
+ ' with Self do begin',
+ ' if cI=13 then;',
+ ' if 14=cI then;',
+ ' end;',
+ 'end;',
+ 'var',
+ ' Obj: TObject;',
+ ' Cla: TClass;',
+ 'begin',
+ ' if TObject.cI=21 then ;',
+ ' if Obj.cI=22 then ;',
+ ' if Cla.cI=23 then ;',
+ ' with obj do if ci=24 then;',
+ ' with TObject do if ci=25 then;',
+ ' with Cla do if ci=26 then;']);
ConvertProgram;
CheckSource('TestClass_Const',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.cI = 3;',
' this.$init = function () {',
' };',
@@ -14757,6 +14759,70 @@ begin
'']));
end;
+procedure TTestModule.TestClass_ConstEnum;
+begin
+ StartProgram(false);
+ Add([
+ 'type',
+ ' TEnum = (red,blue);',
+ ' TObject = class',
+ ' end;',
+ ' TAnimal = class',
+ ' public',
+ ' type TSubEnum = (light,dark);',
+ ' const a = high(TEnum);',
+ ' const b = high(TSubEnum);',
+ ' end;',
+ ' TBird = class(TAnimal)',
+ ' public',
+ ' const c = high(TEnum);',
+ ' const d = high(TSubEnum);',
+ ' end;',
+ ' TAnt = class',
+ ' public',
+ ' const e = high(TEnum);',
+ ' const f = high(TBird.TSubEnum);',
+ ' end;',
+ 'begin',
+ '']);
+ ConvertProgram;
+ CheckSource('TestClass_ConstEnum',
+ LinesToStr([
+ 'this.TEnum = {',
+ ' "0": "red",',
+ ' red: 0,',
+ ' "1": "blue",',
+ ' blue: 1',
+ '};',
+ 'rtl.createClass(this, "TObject", null, function () {',
+ ' this.$init = function () {',
+ ' };',
+ ' this.$final = function () {',
+ ' };',
+ '});',
+ 'rtl.createClass(this, "TAnimal", this.TObject, function () {',
+ ' this.TSubEnum = {',
+ ' "0": "light",',
+ ' light: 0,',
+ ' "1": "dark",',
+ ' dark: 1',
+ ' };',
+ ' this.a = $mod.TEnum.blue;',
+ ' this.b = this.TSubEnum.dark;',
+ '});',
+ 'rtl.createClass(this, "TBird", this.TAnimal, function () {',
+ ' this.c = $mod.TEnum.blue;',
+ ' this.d = this.TSubEnum.dark;',
+ '});',
+ 'rtl.createClass(this, "TAnt", this.TObject, function () {',
+ ' this.e = $mod.TEnum.blue;',
+ ' this.f = $mod.TAnimal.TSubEnum.dark;',
+ '});',
+ '']),
+ LinesToStr([
+ '']));
+end;
+
procedure TTestModule.TestClass_LocalConstDuplicate_Prg;
begin
StartProgram(false);
@@ -14790,7 +14856,7 @@ begin
ConvertProgram;
CheckSource('TestClass_LocalConstDuplicate_Prg',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.cI = 3;',
' this.$init = function () {',
' };',
@@ -14805,7 +14871,7 @@ begin
' if (cI$2 === this.cI) ;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' var cI$3 = 6;',
' this.Go = function () {',
' if (cI$3 === this.cI) ;',
@@ -14850,7 +14916,7 @@ begin
ConvertUnit;
CheckSource('TestClass_LocalConstDuplicate_Unit',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.cI = 3;',
' this.$init = function () {',
' };',
@@ -14865,7 +14931,7 @@ begin
' if (cI$2 === this.cI) ;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' var cI$3 = 6;',
' this.Go = function () {',
' if (cI$3 === this.cI) ;',
@@ -14950,7 +15016,7 @@ begin
ConvertProgram;
CheckSource('TestClass_NestedProcSelf',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.State = 0;',
' this.$init = function () {',
' this.Key = 0;',
@@ -14969,12 +15035,12 @@ begin
' $Self.SetSize($Self.GetSize() + 8);',
' };',
' Sub();',
- ' $Self.Key = $Self.Key + 12;',
+ ' this.Key = this.Key + 12;',
' $Self.Key = $Self.Key + 13;',
- ' $mod.TObject.State = $Self.State + 14;',
+ ' $mod.TObject.State = this.State + 14;',
' $mod.TObject.State = $Self.State + 15;',
' $mod.TObject.State = $mod.TObject.State + 16;',
- ' $Self.SetSize($Self.GetSize() + 17);',
+ ' this.SetSize(this.GetSize() + 17);',
' $Self.SetSize($Self.GetSize() + 18);',
' };',
'});',
@@ -15024,7 +15090,7 @@ begin
ConvertProgram;
CheckSource('TestClass_NestedProcSelf2',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.State = 0;',
' this.$init = function () {',
' this.Key = 0;',
@@ -15032,7 +15098,7 @@ begin
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' var $Self = this;',
' function Sub() {',
@@ -15045,12 +15111,12 @@ begin
' $Self.SetSize($Self.GetSize() + 8);',
' };',
' Sub();',
- ' $Self.Key = $Self.Key + 12;',
+ ' this.Key = this.Key + 12;',
' $Self.Key = $Self.Key + 13;',
- ' $mod.TObject.State = $Self.State + 14;',
+ ' $mod.TObject.State = this.State + 14;',
' $mod.TObject.State = $Self.State + 15;',
' $mod.TObject.State = $mod.TObject.State + 16;',
- ' $Self.SetSize($Self.GetSize() + 17);',
+ ' this.SetSize(this.GetSize() + 17);',
' $Self.SetSize($Self.GetSize() + 18);',
' };',
'});',
@@ -15095,7 +15161,7 @@ begin
ConvertProgram;
CheckSource('TestClass_NestedProcClassSelf',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.State = 0;',
' this.$init = function () {',
' };',
@@ -15112,10 +15178,10 @@ begin
' $mod.TObject.SetSize($mod.TObject.GetSize() + 7);',
' };',
' Sub();',
- ' $mod.TObject.State = $Self.State + 12;',
+ ' $mod.TObject.State = this.State + 12;',
' $mod.TObject.State = $Self.State + 13;',
' $mod.TObject.State = $mod.TObject.State + 14;',
- ' $Self.SetSize($Self.GetSize() + 15);',
+ ' this.SetSize(this.GetSize() + 15);',
' $Self.SetSize($Self.GetSize() + 16);',
' $mod.TObject.SetSize($mod.TObject.GetSize() + 17);',
' };',
@@ -15156,7 +15222,7 @@ begin
ConvertProgram;
CheckSource('TestClass_NestedProcCallInherited',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -15166,7 +15232,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function (k) {',
' var $Self = this;',
' var Result = 0;',
@@ -15174,8 +15240,8 @@ begin
' $mod.TObject.DoIt.call($Self, true);',
' };',
' Sub();',
- ' $mod.TObject.DoIt.apply($Self, arguments);',
- ' $mod.TObject.DoIt.call($Self, true);',
+ ' $mod.TObject.DoIt.apply(this, arguments);',
+ ' $mod.TObject.DoIt.call(this, true);',
' return Result;',
' };',
'});',
@@ -15226,7 +15292,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectFree',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Obj = null;',
' };',
@@ -15287,7 +15353,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectFree_VarArg',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Obj = null;',
' };',
@@ -15323,7 +15389,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectFreeNewInstance',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -15360,7 +15426,7 @@ begin
ConvertProgram;
CheckSource('TestClass_TObjectFreeLowerCase',
LinesToStr([ // statements
- 'rtl.createClass($mod, "tobject", null, function () {',
+ 'rtl.createClass(this, "tobject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -15448,13 +15514,13 @@ begin
ConvertProgram;
CheckSource('TestClass_ForIn',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TEnumerator", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TEnumerator", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FCurrent = null;',
@@ -15468,7 +15534,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.GetEnumerator = function () {',
' var Result = null;',
' return Result;',
@@ -15523,13 +15589,13 @@ begin
ConvertProgram;
CheckSource('TestClass_Message',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.recNewT($mod, "THopMsg", function () {',
+ 'rtl.recNewT(this, "THopMsg", function () {',
' this.DispInt = 0;',
' this.$eq = function (b) {',
' return this.DispInt === b.DispInt;',
@@ -15539,7 +15605,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.recNewT($mod, "TPutMsg", function () {',
+ 'rtl.recNewT(this, "TPutMsg", function () {',
' this.DispStr = "";',
' this.$eq = function (b) {',
' return this.DispStr === b.DispStr;',
@@ -15549,7 +15615,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Run$1 = function (Msg) {',
' };',
' this.$msgint = {',
@@ -15620,7 +15686,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_Create',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -15656,7 +15722,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_Call',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -15690,7 +15756,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_Assign',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.ClassType = null;',
' };',
@@ -15727,13 +15793,13 @@ begin
ConvertProgram;
CheckSource('TestClassOf_Is',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TCar", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCar", this.TObject, function () {',
'});',
'this.Obj = null;',
'this.C = null;',
@@ -15773,7 +15839,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_Compare',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.ClassType = null;',
' };',
@@ -15816,7 +15882,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_ClassVar',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.id = 0;',
' this.$init = function () {',
' };',
@@ -15850,7 +15916,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_ClassMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -15910,7 +15976,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_ClassProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.FA = 0;',
' this.$init = function () {',
' };',
@@ -15967,7 +16033,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_ClassMethodSelf',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.GlobalId = 0;',
' this.$init = function () {',
' };',
@@ -16035,7 +16101,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_TypeCast',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -16045,14 +16111,14 @@ begin
' this.DoIt$1();',
' };',
'});',
- 'rtl.createClass($mod, "TMobile", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TMobile", this.TObject, function () {',
' this.DoIt$1 = function () {',
' this.DoIt();',
' this.DoIt$1();',
' this.DoIt$2();',
' };',
'});',
- 'rtl.createClass($mod, "TCar", $mod.TMobile, function () {',
+ 'rtl.createClass(this, "TCar", this.TMobile, function () {',
' this.DoIt$2 = function () {',
' };',
'});',
@@ -16097,7 +16163,7 @@ begin
ConvertProgram;
CheckSource('TestClassOf_ImplicitFunctionCall',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -16143,16 +16209,16 @@ begin
ConvertProgram;
CheckSource('TestClassOf_Const',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "THawk", $mod.TObject, function () {',
+ 'rtl.createClass(this, "THawk", this.TObject, function () {',
'});',
- 'this.Hawk = $mod.THawk;',
- 'this.DefaultBirdClasses = [$mod.TObject, $mod.THawk];',
+ 'this.Hawk = this.THawk;',
+ 'this.DefaultBirdClasses = [this.TObject, this.THawk];',
'']),
LinesToStr([ // $mod.$main
'']));
@@ -16177,14 +16243,14 @@ begin
ConvertProgram;
CheckSource('TestNestedClass_Alias',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' $mod.$rtti.$inherited("TObject.TNested", rtl.longint, {});',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- '$mod.$rtti.$inherited("TAlias", $mod.$rtti["TObject.TNested"], {});',
+ 'this.$rtti.$inherited("TAlias", this.$rtti["TObject.TNested"], {});',
'this.i = 3;',
'this.j = 4;',
'']),
@@ -16222,7 +16288,7 @@ begin
ConvertProgram;
CheckSource('TestNestedClass_Record',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
@@ -16248,7 +16314,7 @@ begin
' p.$assign(t);',
' };',
'});',
- 'this.p = $mod.TObject.TPoint.$clone({',
+ 'this.p = this.TObject.TPoint.$clone({',
' x: 2,',
' y: 4',
'});',
@@ -16304,13 +16370,13 @@ begin
ConvertProgram;
CheckSource('TestNestedClass_Class',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.createClass(this, "TLeg", $mod.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
@@ -16667,7 +16733,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_NonExternalOverride',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtC", ExtObjB, "", function () {',
+ 'rtl.createClassExt(this, "TExtC", ExtObjB, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -16732,7 +16798,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_SameNamePublishedProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FSwiper = null;',
' };',
@@ -16776,7 +16842,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_NonExternalOverride',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtB", ExtA, "", function () {',
+ 'rtl.createClassExt(this, "TExtB", ExtA, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -16823,14 +16889,14 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_PropertyDate',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtB", ExtA, "", function () {',
+ 'rtl.createClassExt(this, "TExtB", ExtA, "", function () {',
' this.$init = function () {',
' this.FDate = "";',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FDate = "";',
' };',
@@ -16889,7 +16955,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_ClassProperty',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtB", ExtA, "", function () {',
+ 'rtl.createClassExt(this, "TExtB", ExtA, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -16951,7 +17017,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_ClassOf',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtC", ExtB, "", function () {',
+ 'rtl.createClassExt(this, "TExtC", ExtB, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17038,7 +17104,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_Is',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtC", ExtB, "", function () {',
+ 'rtl.createClassExt(this, "TExtC", ExtB, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17089,7 +17155,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_Is',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TExtC", ExtB, "", function () {',
+ 'rtl.createClassExt(this, "TExtC", ExtB, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17464,7 +17530,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_ReintroduceOverload',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TMyA", ExtA, "", function () {',
+ 'rtl.createClassExt(this, "TMyA", ExtA, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17510,7 +17576,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_ReintroduceOverload',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TMyC", ExtB, "", function () {',
+ 'rtl.createClassExt(this, "TMyC", ExtB, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17564,7 +17630,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_NewInstance',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TMyB", ExtA, "NewInstance", function () {',
+ 'rtl.createClassExt(this, "TMyB", ExtA, "NewInstance", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17679,7 +17745,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_JSFunctionPasDescendant',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TBird", ExtA, "", function () {',
+ 'rtl.createClassExt(this, "TBird", ExtA, "", function () {',
' this.Legs = 0;',
' this.$init = function () {',
' this.Size = 0;',
@@ -17691,7 +17757,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClassExt($mod, "TEagle", $mod.TBird, "", function () {',
+ 'rtl.createClassExt(this, "TEagle", this.TBird, "", function () {',
' this.Create$1 = function (b) {',
' $mod.TBird.Create.call(this, b);',
' return this;',
@@ -17737,7 +17803,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_PascalProperty',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TControl", ExtA, "", function () {',
+ 'rtl.createClassExt(this, "TControl", ExtA, "", function () {',
' this.$init = function () {',
' this.FOnClick = null;',
' };',
@@ -17797,14 +17863,14 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_TypeCastToRootClass',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TChild", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TChild", this.TObject, function () {',
'});',
'this.Obj = null;',
'this.Child = null;',
@@ -17867,17 +17933,17 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_TypeCastToJSObject',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{4B0D080B-C0F6-396E-AE88-000B87785074}", [], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{4B0D080B-C0F6-396E-AE88-000B87785074}", [], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TChild", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TChild", this.TObject, function () {',
'});',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -17890,7 +17956,7 @@ begin
'this.i = null;',
'this.Bird = null;',
'this.j = null;',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'this.c = null;',
'']),
LinesToStr([ // $mod.$main
@@ -17977,7 +18043,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_TypeCastToJSFunction',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -17987,8 +18053,8 @@ begin
' function Sub() {',
' };',
' var f = null;',
- ' f = $Self.DoIt;',
- ' f = $Self.DoIt.bind(null, 13);',
+ ' f = this.DoIt;',
+ ' f = this.DoIt.bind(null, 13);',
' f = Sub;',
' f = $mod.GetIt;',
' };',
@@ -18191,7 +18257,7 @@ begin
ConvertProgram;
CheckSource('TestExternalClass_BracketAccessor_Call',
LinesToStr([ // statements
- 'rtl.createClassExt($mod, "TMyArr", Array2, "", function () {',
+ 'rtl.createClassExt(this, "TMyArr", Array2, "", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -18514,15 +18580,15 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_Corba',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{00000000-0000-0000-C000-000000000046}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{5BD1A53B-69BB-37EE-AF32-BEFB86D85B03}", ["GetSize", "SetSize", "DoIt"], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{00000000-0000-0000-C000-000000000046}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{5BD1A53B-69BB-37EE-AF32-BEFB86D85B03}", ["GetSize", "SetSize", "DoIt"], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird);',
'});',
'this.BirdIntf = null;',
@@ -18584,15 +18650,15 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_Overloads',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-BDC4-8A2AE2C59400}", ["DoIt", "DoIt$1"], null);',
- 'rtl.createInterface($mod, "IBird", "{8285DD5E-EA3E-396E-AE88-000B86AABF05}", ["DoIt$2"], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-BDC4-8A2AE2C59400}", ["DoIt", "DoIt$1"], null);',
+ 'rtl.createInterface(this, "IBird", "{8285DD5E-EA3E-396E-AE88-000B86AABF05}", ["DoIt$2"], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function (o) {',
' };',
' this.DoIt$1 = function (s) {',
@@ -18681,9 +18747,9 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_AncestorIntf',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-BDC4-8A2800000000}", ["DoIt"], null);',
- 'rtl.createInterface($mod, "IBird", "{B92D5841-6264-3AE3-BF20-000000000000}", ["Fly"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-BDC4-8A2800000000}", ["DoIt"], null);',
+ 'rtl.createInterface(this, "IBird", "{B92D5841-6264-3AE3-BF20-000000000000}", ["Fly"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -18692,7 +18758,7 @@ begin
' };',
' rtl.addIntf(this, $mod.IUnknown);',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Fly = function (i) {',
' };',
' rtl.addIntf(this, $mod.IBird);',
@@ -18726,8 +18792,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_ImplReintroduce',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IBird", "{B92D5841-6264-3AE2-8594-000000000000}", ["DoIt"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IBird", "{B92D5841-6264-3AE2-8594-000000000000}", ["DoIt"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -18735,7 +18801,7 @@ begin
' this.DoIt = function (i) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt$1 = function (i) {',
' };',
' rtl.addIntf(this, $mod.IBird, {',
@@ -18782,15 +18848,15 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_MethodResolution',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-BDD7-23D600000000}", ["Walk"], null);',
- 'rtl.createInterface($mod, "IBird", "{CF8A4986-80F6-396E-AE88-000B86AAE208}", ["Walk$1", "Fly"], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-BDD7-23D600000000}", ["Walk"], null);',
+ 'rtl.createInterface(this, "IBird", "{CF8A4986-80F6-396E-AE88-000B86AAE208}", ["Walk$1", "Fly"], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Hop = function (i) {',
' };',
' this.Move = function (s) {',
@@ -18835,10 +18901,10 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_AncestorLess',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{8F2D5841-758A-322B-BDDF-21CD521DD723}", ["_AddRef", "Walk"], null);',
- 'rtl.createInterface($mod, "IBird", "{CCE11D4C-6504-3AEE-AE88-000B86AAE675}", [], $mod.IUnknown);',
- 'rtl.createInterface($mod, "IDog", "{CCE11D4C-6504-3AEE-AE88-000B8E5FC675}", [], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{8F2D5841-758A-322B-BDDF-21CD521DD723}", ["_AddRef", "Walk"], null);',
+ 'rtl.createInterface(this, "IBird", "{CCE11D4C-6504-3AEE-AE88-000B86AAE675}", [], this.IUnknown);',
+ 'rtl.createInterface(this, "IDog", "{CCE11D4C-6504-3AEE-AE88-000B8E5FC675}", [], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -18846,7 +18912,7 @@ begin
' rtl.addIntf(this, $mod.IBird);',
' rtl.addIntf(this, $mod.IDog);',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IUnknown);',
' rtl.addIntf(this, $mod.IBird);',
' rtl.addIntf(this, $mod.IDog);',
@@ -18886,25 +18952,25 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_MethodOverride',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D6D98E5B-8A10-4FEC-856A-7BFC847FE74B}", ["Go"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D6D98E5B-8A10-4FEC-856A-7BFC847FE74B}", ["Go"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
' rtl.addIntf(this, $mod.IUnknown);',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Go = function () {',
' };',
' rtl.addIntf(this, $mod.IUnknown);',
'});',
- 'rtl.createClass($mod, "TCat", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCat", this.TObject, function () {',
' this.Go = function () {',
' };',
' rtl.addIntf(this, $mod.IUnknown);',
'});',
- 'rtl.createClass($mod, "TDog", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TDog", this.TObject, function () {',
' this.Go = function () {',
' };',
' rtl.addIntf(this, $mod.IUnknown);',
@@ -18949,26 +19015,26 @@ begin
'begin',
'']);
ConvertProgram;
- CheckSource('TestClassInterface_Delegation',
+ CheckSource('TestClassInterface_Corba_Delegation',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{478D080B-C0F6-396E-AE88-000B87785B07}", ["Fly"], $mod.IUnknown);',
- 'rtl.createInterface($mod, "IEagle", "{489289DE-FDE2-34A6-8288-39119022B1B4}", [], $mod.IBird);',
- 'rtl.createInterface($mod, "IDove", "{489289DE-FDE2-34A6-8288-39118EF16074}", [], $mod.IBird);',
- 'rtl.createInterface($mod, "ISwallow", "{B89289DE-FDE2-34A6-8288-3911CBDCB359}", [], $mod.IBird);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{478D080B-C0F6-396E-AE88-000B87785B07}", ["Fly"], this.IUnknown);',
+ 'rtl.createInterface(this, "IEagle", "{489289DE-FDE2-34A6-8288-39119022B1B4}", [], this.IBird);',
+ 'rtl.createInterface(this, "IDove", "{489289DE-FDE2-34A6-8288-39118EF16074}", [], this.IBird);',
+ 'rtl.createInterface(this, "ISwallow", "{B89289DE-FDE2-34A6-8288-3911CBDCB359}", [], this.IBird);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird);',
' rtl.addIntf(this, $mod.IEagle);',
' rtl.addIntf(this, $mod.IDove);',
' rtl.addIntf(this, $mod.ISwallow);',
'});',
- 'rtl.createClass($mod, "TBat", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBat", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FBirdIntf = null;',
@@ -19036,26 +19102,26 @@ begin
'begin',
'']);
ConvertProgram;
- CheckSource('TestClassInterface_DelegationStatic',
+ CheckSource('TestClassInterface_Corba_DelegationStatic',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{478D080B-C0F6-396E-AE88-000B87785B07}", ["Fly"], $mod.IUnknown);',
- 'rtl.createInterface($mod, "IEagle", "{489289DE-FDE2-34A6-8288-39119022B1B4}", [], $mod.IBird);',
- 'rtl.createInterface($mod, "IDove", "{489289DE-FDE2-34A6-8288-39118EF16074}", [], $mod.IBird);',
- 'rtl.createInterface($mod, "ISwallow", "{B89289DE-FDE2-34A6-8288-3911CBDCB359}", [], $mod.IBird);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{478D080B-C0F6-396E-AE88-000B87785B07}", ["Fly"], this.IUnknown);',
+ 'rtl.createInterface(this, "IEagle", "{489289DE-FDE2-34A6-8288-39119022B1B4}", [], this.IBird);',
+ 'rtl.createInterface(this, "IDove", "{489289DE-FDE2-34A6-8288-39118EF16074}", [], this.IBird);',
+ 'rtl.createInterface(this, "ISwallow", "{B89289DE-FDE2-34A6-8288-3911CBDCB359}", [], this.IBird);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird);',
' rtl.addIntf(this, $mod.IEagle);',
' rtl.addIntf(this, $mod.IDove);',
' rtl.addIntf(this, $mod.ISwallow);',
'});',
- 'rtl.createClass($mod, "TBat", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBat", this.TObject, function () {',
' this.FBirdIntf = null;',
' this.FDoveObj = null;',
' this.$intfmaps = {',
@@ -19128,15 +19194,15 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_Corba_Operators',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{D53FED90-DE59-3202-B1AE-000B87785B08}", ["GetItems", "SetItems"], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{D53FED90-DE59-3202-B1AE-000B87785B08}", ["GetItems", "SetItems"], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird);',
'});',
'this.IntfVar = null;',
@@ -19203,15 +19269,15 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_Corba_Args',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createInterface($mod, "IBird", "{4B0D080B-C0F6-396E-AE88-000B87785074}", [], $mod.IUnknown);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createInterface(this, "IBird", "{4B0D080B-C0F6-396E-AE88-000B87785074}", [], this.IUnknown);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird);',
'});',
'this.DoIt = function (u, i, j) {',
@@ -19297,16 +19363,16 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_Corba_ForIn',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Id = 0;',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createInterface($mod, "IEnumerator", "{95D7745D-ED61-3F13-BBE4-07708161999E}", ["GetCurrent", "MoveNext"], $mod.IUnknown);',
- 'rtl.createInterface($mod, "IEnumerable", "{8CC9D45D-ED7D-3B73-96B6-290B931BB19E}", ["GetEnumerator"], $mod.IUnknown);',
+ 'rtl.createInterface(this, "IEnumerator", "{95D7745D-ED61-3F13-BBE4-07708161999E}", ["GetCurrent", "MoveNext"], this.IUnknown);',
+ 'rtl.createInterface(this, "IEnumerable", "{8CC9D45D-ED7D-3B73-96B6-290B931BB19E}", ["GetEnumerator"], this.IUnknown);',
'this.o = null;',
'this.i = null;',
'']),
@@ -19358,8 +19424,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_AssignVar',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19416,8 +19482,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_AssignArg',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19462,8 +19528,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_FunctionResult',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19525,8 +19591,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_InheritedFuncResult',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19537,7 +19603,7 @@ begin
' };',
' rtl.addIntf(this, $mod.IUnknown);',
'});',
- 'rtl.createClass($mod, "TMouse", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TMouse", this.TObject, function () {',
' this.GetIntf = function () {',
' var Result = null;',
' var i = null;',
@@ -19597,8 +19663,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_IsAsTypeCasts',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19658,8 +19724,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_PassAsArg',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19769,8 +19835,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_PassToUntypedParam',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19868,8 +19934,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_FunctionInExpr',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -19955,8 +20021,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_Property',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FAnt = null;',
' };',
@@ -20036,7 +20102,7 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_IntfProperty',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{385F5482-571B-338C-8130-4E97F330543B}", [',
+ 'rtl.createInterface(this, "IUnknown", "{385F5482-571B-338C-8130-4E97F330543B}", [',
' "_AddRef",',
' "_Release",',
' "GetBird",',
@@ -20044,7 +20110,7 @@ begin
' "GetItems",',
' "SetItems"',
'], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -20115,24 +20181,24 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_Delegation',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createInterface($mod, "IBird", "{CC440C7F-7623-3DEE-AE88-000B86AAF108}", ["Fly"], $mod.IUnknown);',
- 'rtl.createInterface($mod, "IEagle", "{4B6A41C9-B020-3D7C-B688-96D19022B1B4}", [], $mod.IBird);',
- 'rtl.createInterface($mod, "IDove", "{4B6A41C9-B020-3D7C-B688-96D18EF16074}", [], $mod.IBird);',
- 'rtl.createInterface($mod, "ISwallow", "{BB6A41C9-B020-3D7C-B688-96D1CBDCB359}", [], $mod.IBird);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createInterface(this, "IBird", "{CC440C7F-7623-3DEE-AE88-000B86AAF108}", ["Fly"], this.IUnknown);',
+ 'rtl.createInterface(this, "IEagle", "{4B6A41C9-B020-3D7C-B688-96D19022B1B4}", [], this.IBird);',
+ 'rtl.createInterface(this, "IDove", "{4B6A41C9-B020-3D7C-B688-96D18EF16074}", [], this.IBird);',
+ 'rtl.createInterface(this, "ISwallow", "{BB6A41C9-B020-3D7C-B688-96D1CBDCB359}", [], this.IBird);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' rtl.addIntf(this, $mod.IBird);',
' rtl.addIntf(this, $mod.IEagle);',
' rtl.addIntf(this, $mod.IDove);',
' rtl.addIntf(this, $mod.ISwallow);',
'});',
- 'rtl.createClass($mod, "TBat", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBat", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FBirdIntf = null;',
@@ -20195,8 +20261,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_With',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB00D-C6B6-39FB-BDDF-21CD521DDFA9}", ["_AddRef", "_Release", "GetAnt"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB00D-C6B6-39FB-BDDF-21CD521DDFA9}", ["_AddRef", "_Release", "GetAnt"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -20247,16 +20313,16 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_COM_ForIn',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{B92D5841-758A-322B-B800-000000000000}", [], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.Id = 0;',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createInterface($mod, "IEnumerator", "{95D7745D-ED61-3F13-BBE4-07708161999E}", ["GetCurrent", "MoveNext"], $mod.IUnknown);',
- 'rtl.createInterface($mod, "IEnumerable", "{8CC9D45D-ED7D-3B73-96B6-290B931BB19E}", ["GetEnumerator"], $mod.IUnknown);',
+ 'rtl.createInterface(this, "IEnumerator", "{95D7745D-ED61-3F13-BBE4-07708161999E}", ["GetCurrent", "MoveNext"], this.IUnknown);',
+ 'rtl.createInterface(this, "IEnumerable", "{8CC9D45D-ED7D-3B73-96B6-290B931BB19E}", ["GetEnumerator"], this.IUnknown);',
'this.o = null;',
'this.i = null;',
'']),
@@ -20423,14 +20489,14 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_GUID',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{F31DB68F-3010-D355-4EBA-CDD4EF4A737C}", [], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{F31DB68F-3010-D355-4EBA-CDD4EF4A737C}", [], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.recNewT($mod, "TGUID", function () {',
+ 'rtl.recNewT(this, "TGUID", function () {',
' this.D1 = 0;',
' this.D2 = 0;',
' this.D3 = 0;',
@@ -20453,7 +20519,7 @@ begin
'this.DoStr = function (s) {',
'};',
'this.i = null;',
- 'this.g = $mod.TGUID.$clone({',
+ 'this.g = this.TGUID.$clone({',
' D1: 0xD91C9AF4,',
' D2: 0x3C93,',
' D3: 0x420F,',
@@ -20544,8 +20610,8 @@ begin
ConvertProgram;
CheckSource('TestClassInterface_GUIDProperty',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{F31DB68F-3010-D355-4EBA-CDD4EF4A737C}", [], null);',
- 'rtl.recNewT($mod, "TGUID", function () {',
+ 'rtl.createInterface(this, "IUnknown", "{F31DB68F-3010-D355-4EBA-CDD4EF4A737C}", [], null);',
+ 'rtl.recNewT(this, "TGUID", function () {',
' this.D1 = 0;',
' this.D2 = 0;',
' this.D3 = 0;',
@@ -20561,7 +20627,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -20642,13 +20708,13 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ClassVar',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.One = 1;',
' this.Two = 2;',
' this.Glob = 0;',
@@ -20718,14 +20784,14 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Method_AccessInstanceFields',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FSize = 0;',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var Result = 0;',
' Result = this.FSize;',
@@ -20802,7 +20868,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Method_Call',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -20821,7 +20887,7 @@ begin
' $mod.THelper.Foo.call(o, 5);',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var Result = 0;',
' this.Run(10);',
@@ -20898,7 +20964,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Method_Nested_Call',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -20915,7 +20981,7 @@ begin
' };',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var $Self = this;',
' var Result = 0;',
@@ -20991,7 +21057,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ClassMethod_Call',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -21005,7 +21071,7 @@ begin
' $mod.THelper.Foo.call(this, 1);',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var Result = 0;',
' this.Run(10);',
@@ -21062,13 +21128,13 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ClassOf',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var Result = 0;',
' return Result;',
@@ -21157,7 +21223,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_MethodRefObjFPC',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -21174,7 +21240,7 @@ begin
' $mod.r = $mod.THelper.Run;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function (w) {',
' $mod.f = rtl.createCallback(this, $mod.THelper.Fly);',
' $mod.g = rtl.createCallback(this.$class, $mod.THelper.Glide);',
@@ -21250,7 +21316,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Constructor',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -21262,7 +21328,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.NewHlp = function (w) {',
' this.Create();',
' $mod.TObject.$create("Create");',
@@ -21347,7 +21413,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_InheritedObjFPC',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -21355,19 +21421,19 @@ begin
' this.Fly = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.Fly = function () {',
' $mod.TObject.Fly.call(this);',
' $mod.TObject.Fly.call(this);',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Fly$1 = function () {',
' $mod.TObjHelper.Fly.call(this);',
' $mod.TObjHelper.Fly.call(this);',
' };',
'});',
- 'rtl.createHelper($mod, "TBirdHelper", null, function () {',
+ 'rtl.createHelper(this, "TBirdHelper", null, function () {',
' this.Fly = function () {',
' $mod.TBird.Fly$1.call(this);',
' $mod.TBird.Fly$1.call(this);',
@@ -21375,7 +21441,7 @@ begin
' this.Walk = function (w) {',
' };',
'});',
- 'rtl.createHelper($mod, "TEagleHelper", $mod.TBirdHelper, function () {',
+ 'rtl.createHelper(this, "TEagleHelper", this.TBirdHelper, function () {',
' this.Fly$1 = function () {',
' $mod.TBird.Fly$1.call(this);',
' $mod.TBird.Fly$1.call(this);',
@@ -21472,7 +21538,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Property',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FSize = 0;',
' };',
@@ -21496,7 +21562,7 @@ begin
' this.SetSpeed = function (Value) {',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.GetLeft = function () {',
' var Result = 0;',
' this.FSize = this.FSize + 11;',
@@ -21513,7 +21579,7 @@ begin
' this.SetLeft = function (Value) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObjHelper.SetLeft.call(this, $mod.TObjHelper.GetLeft.call(this) + 11);',
' $mod.TObjHelper.SetLeft.call(this, $mod.TObjHelper.GetLeft.call(this) + 21);',
@@ -21604,7 +21670,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Property_Array',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -21623,7 +21689,7 @@ begin
' this.SetSpeed = function (Index, Value) {',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.GetSize = function (Index) {',
' var Result = 0;',
' $mod.TObjHelper.SetSize.call(this, true, $mod.TObjHelper.GetSize.call(this, false) + 11);',
@@ -21637,7 +21703,7 @@ begin
' this.SetSize = function (Index, Value) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObjHelper.SetSize.call(this, true, $mod.TObjHelper.GetSize.call(this, false) + 11);',
' $mod.TObjHelper.SetSize.call(this, true, $mod.TObjHelper.GetSize.call(this, false) + 21);',
@@ -21700,7 +21766,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Property_Array_Default',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -21713,11 +21779,11 @@ begin
' this.SetSpeed = function (Index, Value) {',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
'});',
- 'rtl.createHelper($mod, "TBirdHelper", null, function () {',
+ 'rtl.createHelper(this, "TBirdHelper", null, function () {',
' this.GetSize = function (Index) {',
' var Result = false;',
' $mod.TBirdHelper.SetSize.call(this, 1, !$mod.TBirdHelper.GetSize.call(this, 2));',
@@ -21762,13 +21828,13 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_Property_Array_DefaultDefault',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.GetItems = function (Index) {',
' var Result = null;',
' $mod.TObjHelper.SetItems.call($mod.TObjHelper.GetItems.call(this, 1), 2, $mod.TObjHelper.GetItems.call($mod.TObjHelper.GetItems.call(this, 3), 4));',
@@ -21881,7 +21947,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ClassProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.FSize = 0;',
' this.$init = function () {',
' };',
@@ -21901,7 +21967,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.GetLeft = function () {',
' var Result = 0;',
' $mod.TObject.FSize = this.FSize + 11;',
@@ -21918,7 +21984,7 @@ begin
' this.SetLeft = function (Value) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObjHelper.SetLeft.call(this, $mod.TObjHelper.GetLeft.call(this) + 11);',
' $mod.TObjHelper.SetLeft.call(this, $mod.TObjHelper.GetLeft.call(this) + 21);',
@@ -22046,7 +22112,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ClassPropertyStatic',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -22060,7 +22126,7 @@ begin
' this.SetSpeed = function (Value) {',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.GetLeft = function () {',
' var Result = 0;',
' $mod.TObject.SetSpeed($mod.TObject.GetSpeed() + 12);',
@@ -22070,7 +22136,7 @@ begin
' this.SetLeft = function (Value) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObjHelper.SetLeft($mod.TObjHelper.GetLeft() + 11);',
' };',
@@ -22197,7 +22263,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ClassProperty_Array',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -22213,7 +22279,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createHelper($mod, "TObjHelper", null, function () {',
+ 'rtl.createHelper(this, "TObjHelper", null, function () {',
' this.GetSize = function (Index) {',
' var Result = 0;',
' $mod.TObjHelper.SetSize.call(this, true, $mod.TObjHelper.GetSize.call(this, false) + 11);',
@@ -22227,7 +22293,7 @@ begin
' this.SetSize = function (Index, Value) {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObjHelper.SetSize.call(this, true, $mod.TObjHelper.GetSize.call(this, false) + 11);',
' $mod.TObjHelper.SetSize.call(this, true, $mod.TObjHelper.GetSize.call(this, false) + 21);',
@@ -22293,13 +22359,13 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_ForIn',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TEnumerator", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TEnumerator", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FCurrent = null;',
@@ -22313,9 +22379,9 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
'});',
- 'rtl.createHelper($mod, "TBirdHelper", null, function () {',
+ 'rtl.createHelper(this, "TBirdHelper", null, function () {',
' this.GetEnumerator = function () {',
' var Result = null;',
' return Result;',
@@ -22389,7 +22455,7 @@ begin
ConvertProgram;
CheckSource('TestClassHelper_PassProperty',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FField = null;',
' };',
@@ -22397,7 +22463,7 @@ begin
' this.FField = undefined;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function () {',
' $mod.THelper.Fly.call(this.FField);',
' $mod.THelper.Run.call(this.FField.$class);',
@@ -22479,7 +22545,7 @@ begin
ConvertProgram;
CheckSource('TestExtClassHelper_ClassVar',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.One = 1;',
' this.Two = 2;',
' this.Glob = 0;',
@@ -22572,7 +22638,7 @@ begin
ConvertProgram;
CheckSource('TestExtClassHelper_Method_Call',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var Result = 0;',
' this.Run(10);',
@@ -22685,7 +22751,7 @@ begin
ConvertProgram;
CheckSource('TestRecordHelper_ClassVar',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -22693,7 +22759,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.One = 1;',
' this.Two = 2;',
' this.Glob = 0;',
@@ -22716,7 +22782,7 @@ begin
' return Result;',
' };',
'});',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.THelper.Two = 1;',
@@ -22789,7 +22855,7 @@ begin
ConvertProgram;
CheckSource('TestRecordHelper_Method_Call',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -22808,7 +22874,7 @@ begin
' $mod.THelper.Foo.call(this, 4);',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Foo = function (w) {',
' var Result = 0;',
' this.Run(10);',
@@ -22826,7 +22892,7 @@ begin
' return Result;',
' };',
'});',
- 'this.Rec = $mod.TRec.$new();',
+ 'this.Rec = this.TRec.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.THelper.Foo.call($mod.Rec, 1);',
@@ -22874,7 +22940,7 @@ begin
ConvertProgram;
CheckSource('TestRecordHelper_Constructor',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -22887,7 +22953,7 @@ begin
' return this;',
' };',
'}, true);',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.NewHlp = function (w) {',
' this.Create(2);',
' $mod.TRec.$new().Create(3);',
@@ -22899,7 +22965,7 @@ begin
' return this[fn].apply($mod.TRec.$new(), args);',
' };',
'});',
- 'this.Rec = $mod.TRec.$new();',
+ 'this.Rec = this.TRec.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.THelper.NewHlp.call($mod.Rec, 2);',
@@ -22959,7 +23025,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_ClassVar',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.One = 1;',
' this.Two = 2;',
' this.Glob = 0;',
@@ -23031,7 +23097,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassResultElement',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' };',
' this.DoSome = function (e) {',
@@ -23114,7 +23180,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassArgs',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' };',
'});',
@@ -23191,7 +23257,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassVarConst',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' };',
'});',
@@ -23280,7 +23346,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassFuncResult',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' };',
'});',
@@ -23382,7 +23448,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassPropertyField',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FField = 0;',
' };',
@@ -23431,7 +23497,7 @@ begin
' $mod.THelper.Run();',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function () {',
' };',
' this.Run = function () {',
@@ -23527,7 +23593,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassPropertyGetter',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FField = 0;',
' };',
@@ -23578,7 +23644,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function () {',
' };',
' this.Run = function () {',
@@ -23661,7 +23727,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassClassPropertyField',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.FField = 0;',
' this.$init = function () {',
' };',
@@ -23734,7 +23800,7 @@ begin
' }, 7);',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function (n) {',
' };',
'});',
@@ -23834,7 +23900,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassClassPropertyGetterStatic',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.FField = 0;',
' this.$init = function () {',
' };',
@@ -23882,7 +23948,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function (n) {',
' };',
'});',
@@ -23959,7 +24025,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_PassClassPropertyGetterNonStatic',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.FField = 0;',
' this.$init = function () {',
' };',
@@ -24006,7 +24072,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function (n) {',
' };',
'});',
@@ -24110,7 +24176,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Property',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.GetSize = function () {',
' var Result = 0;',
' Result = $mod.THelper.GetSize.call(this) + 1;',
@@ -24205,7 +24271,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Property_Array',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.GetItems = function (Index) {',
' var Result = false;',
' Result = $mod.THelper.GetItems.call(this, 1);',
@@ -24286,7 +24352,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_ClassProperty',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.GetSize = function () {',
' var Result = 0;',
' Result = $mod.THelper.GetSize() + 1;',
@@ -24334,7 +24400,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_ClassProperty_Array',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.GetItems = function (Index) {',
' var Result = false;',
' Result = $mod.THelper.GetItems(1);',
@@ -24378,7 +24444,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_ClassMethod',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoStatic = function () {',
' $mod.THelper.DoStatic();',
' $mod.THelper.DoStatic();',
@@ -24433,7 +24499,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Constructor',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Init = function (e) {',
' this.set(e);',
' $mod.THelper.Init.call(this, e + 1);',
@@ -24498,7 +24564,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Word',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' this.set(e);',
' this.set(this.get() + 1);',
@@ -24542,7 +24608,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Boolean',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Run = function (e) {',
' this.set(e);',
' this.set(!this.get());',
@@ -24588,7 +24654,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_WordBool',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Run = function (e) {',
' var i = 0;',
' i = (this.get() ? 1 : 0);',
@@ -24645,7 +24711,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Double',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.NPI = 3.141592;',
' this.ToStr = function () {',
' var Result = "";',
@@ -24731,14 +24797,14 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_NativeInt',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelperI", null, function () {',
+ 'rtl.createHelper(this, "THelperI", null, function () {',
' this.ToStr = function () {',
' var Result = "";',
' Result = "" + this.get();',
' return Result;',
' };',
'});',
- 'rtl.createHelper($mod, "THelperU", null, function () {',
+ 'rtl.createHelper(this, "THelperU", null, function () {',
' this.ToStr = function () {',
' var Result = "";',
' Result = "" + this.get();',
@@ -24818,13 +24884,13 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_StringChar',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "TStringHelper", null, function () {',
+ 'rtl.createHelper(this, "TStringHelper", null, function () {',
' this.DoIt = function (e) {',
' this.set(rtl.setCharAt(this.get(), 0, "c"));',
' this.set(rtl.setCharAt(this.get(), 1, this.get().charAt(2)));',
' };',
'});',
- 'rtl.createHelper($mod, "TCharHelper", null, function () {',
+ 'rtl.createHelper(this, "TCharHelper", null, function () {',
' this.Fly = function () {',
' this.set("c");',
' };',
@@ -24882,7 +24948,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_JSValue',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.ToStr = function () {',
' var Result = "";',
' return Result;',
@@ -24949,7 +25015,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_Array',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' this.get()[1] = true;',
' this.get()[2] = !this.get()[3];',
@@ -25018,7 +25084,7 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' this.set($mod.TEnum.red);',
' this.set(this.get() + 1);',
@@ -25116,7 +25182,7 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.DoIt = function (e) {',
' this.set({});',
' this.set(rtl.createSet($mod.TEnum.red));',
@@ -25219,15 +25285,15 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_InterfaceType',
LinesToStr([ // statements
- 'rtl.createInterface($mod, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createInterface(this, "IUnknown", "{D7ADB0E1-758A-322B-BDDF-21CD521DDFA9}", ["_AddRef", "_Release"], null);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
' rtl.addIntf(this, $mod.IUnknown);',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Fly = function (e) {',
' var $ir = rtl.createIntfRefs();',
' try {',
@@ -25318,7 +25384,7 @@ begin
ConvertProgram;
CheckSource('TestTypeHelper_NestedSelf',
LinesToStr([ // statements
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.Run = function (Value) {',
' var $Self = this;',
' function Sub(i) {',
@@ -25774,7 +25840,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_MethodFPC',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -25831,7 +25897,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_MethodDelphi',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -25925,7 +25991,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_PropertyFPC',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FOnFoo = null;',
' };',
@@ -26067,7 +26133,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_PropertyDelphi',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FOnFoo = null;',
' };',
@@ -26193,7 +26259,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_WithClassInstDoPropertyFPC',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FOnFoo = null;',
' };',
@@ -26361,7 +26427,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_Nested',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -26477,7 +26543,7 @@ begin
ConvertProgram;
CheckSource('TestProcType_ReferenceToMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -26869,7 +26935,7 @@ begin
ConvertProgram;
CheckSource('TestPointer',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -26921,7 +26987,7 @@ begin
ConvertProgram;
CheckSource('TestPointer_Proc',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -27121,7 +27187,7 @@ begin
ConvertProgram;
CheckSource('TestPointer_Record',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.x = 0;',
' this.$eq = function (b) {',
' return this.x === b.x;',
@@ -27131,7 +27197,7 @@ begin
' return this;',
' };',
'});',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'this.p = null;',
'this.q = null;',
'this.Ptr = null;',
@@ -27184,9 +27250,9 @@ begin
' DoIt(@r,p,p);',
'']);
ConvertProgram;
- CheckSource('TestPointer_Record',
+ CheckSource('TestPointer_RecordArg',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.x = 0;',
' this.$eq = function (b) {',
' return this.x === b.x;',
@@ -27210,7 +27276,7 @@ begin
' p.x = p.x;',
' return Result;',
'};',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'this.p = null;',
'']),
LinesToStr([ // $mod.$main
@@ -27380,7 +27446,7 @@ begin
ConvertProgram;
CheckSource('TestJSValue_TypecastToJSValue',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -27391,7 +27457,7 @@ begin
'this.Fly = function (v) {',
'};',
'this.a = [];',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'this.s = {};',
'']),
LinesToStr([ // $mod.$main
@@ -27608,7 +27674,7 @@ begin
ConvertProgram;
CheckSource('TestJSValue_ClassInstance',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -27652,13 +27718,13 @@ begin
ConvertProgram;
CheckSource('TestJSValue_ClassOf',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
'});',
'this.v = undefined;',
'this.c = null;',
@@ -27764,7 +27830,7 @@ begin
' "1": "small",',
' small: 1',
'};',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -27994,7 +28060,7 @@ begin
ConvertProgram;
CheckSource('TestJSValue_ProcType_Assign',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -28073,7 +28139,7 @@ begin
ConvertProgram;
CheckSource('TestJSValue_ProcType_Equal',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -28468,7 +28534,7 @@ begin
ConvertProgram;
CheckSource('TestJSValue_OverloadPointer',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -28531,12 +28597,12 @@ begin
ConvertProgram;
CheckSource('TestRTTI_IntRange',
LinesToStr([ // statements
- '$mod.$rtti.$Int("TGraphicsColor", {',
+ 'this.$rtti.$Int("TGraphicsColor", {',
' minvalue: -2147483648,',
' maxvalue: 2147483647,',
' ordtype: 4',
'});',
- '$mod.$rtti.$inherited("TColor", $mod.$rtti["TGraphicsColor"], {});',
+ 'this.$rtti.$inherited("TColor", this.$rtti["TGraphicsColor"], {});',
'this.p = null;',
'this.k = 0;',
'']),
@@ -28565,7 +28631,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Double',
LinesToStr([ // statements
- '$mod.$rtti.$inherited("TFloat", rtl.double, {});',
+ 'this.$rtti.$inherited("TFloat", rtl.double, {});',
'this.p = null;',
'']),
LinesToStr([ // $mod.$main
@@ -28591,24 +28657,24 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ProcType',
LinesToStr([ // statements
- '$mod.$rtti.$ProcVar("TProcA", {',
+ 'this.$rtti.$ProcVar("TProcA", {',
' procsig: rtl.newTIProcSig(null)',
'});',
- '$mod.$rtti.$MethodVar("TMethodB", {',
+ 'this.$rtti.$MethodVar("TMethodB", {',
' procsig: rtl.newTIProcSig(null),',
' methodkind: 0',
'});',
- '$mod.$rtti.$ProcVar("TProcC", {',
+ 'this.$rtti.$ProcVar("TProcC", {',
' procsig: rtl.newTIProcSig(null, 2)',
'});',
- '$mod.$rtti.$ProcVar("TProcD", {',
+ 'this.$rtti.$ProcVar("TProcD", {',
' procsig: rtl.newTIProcSig([["i", rtl.longint], ["j", rtl.string, 2], ["c", rtl.char, 1], ["d", rtl.double, 4]])',
'});',
- '$mod.$rtti.$ProcVar("TProcE", {',
+ 'this.$rtti.$ProcVar("TProcE", {',
' procsig: rtl.newTIProcSig(null, rtl.nativeint)',
'});',
- '$mod.$rtti.$ProcVar("TProcF", {',
- ' procsig: rtl.newTIProcSig([["p", $mod.$rtti["TProcA"], 2]], rtl.nativeuint)',
+ 'this.$rtti.$ProcVar("TProcF", {',
+ ' procsig: rtl.newTIProcSig([["p", this.$rtti["TProcA"], 2]], rtl.nativeuint)',
'});',
'this.p = null;',
'']),
@@ -28643,7 +28709,7 @@ begin
CheckSource('TestRTTI_ProcType_ArgFromOtherUnit',
LinesToStr([ // statements
'var $impl = $mod.$impl;',
- '$mod.$rtti.$ProcVar("TProcA", {',
+ 'this.$rtti.$ProcVar("TProcA", {',
' procsig: rtl.newTIProcSig([["o", pas.unit2.$rtti["TObject"]]], pas.unit2.$rtti["TObject"])',
'});',
'']),
@@ -28680,17 +28746,17 @@ begin
' "1": "dark",',
' dark: 1',
'};',
- '$mod.$rtti.$Enum("TFlag", {',
+ 'this.$rtti.$Enum("TFlag", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
' enumtype: this.TFlag',
'});',
- '$mod.$rtti.$Set("TFlags", {',
- ' comptype: $mod.$rtti["TFlag"]',
+ 'this.$rtti.$Set("TFlags", {',
+ ' comptype: this.$rtti["TFlag"]',
'});',
- '$mod.$rtti.$ProcVar("TProc", {',
- ' procsig: rtl.newTIProcSig([["f", $mod.$rtti["TFlags"]]], $mod.$rtti["TFlag"])',
+ 'this.$rtti.$ProcVar("TProc", {',
+ ' procsig: rtl.newTIProcSig([["f", this.$rtti["TFlags"]]], this.$rtti["TFlag"])',
'});',
'this.p = null;',
'']),
@@ -28736,14 +28802,14 @@ begin
' "1": "green",',
' green: 1',
'};',
- '$mod.$rtti.$Enum("TFlags$a", {',
+ 'this.$rtti.$Enum("TFlags$a", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
' enumtype: this.TFlags$a',
'});',
- '$mod.$rtti.$Set("TFlags", {',
- ' comptype: $mod.$rtti["TFlags$a"]',
+ 'this.$rtti.$Set("TFlags", {',
+ ' comptype: this.$rtti["TFlags$a"]',
'});',
'this.f = {};',
'']),
@@ -28775,26 +28841,26 @@ begin
' "1": "dark",',
' dark: 1',
'};',
- '$mod.$rtti.$Enum("TFlag", {',
+ 'this.$rtti.$Enum("TFlag", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
' enumtype: this.TFlag',
'});',
- '$mod.$rtti.$StaticArray("TFlagNames", {',
+ 'this.$rtti.$StaticArray("TFlagNames", {',
' dims: [2],',
' eltype: rtl.string',
'});',
- '$mod.$rtti.$StaticArray("TBoolNames", {',
+ 'this.$rtti.$StaticArray("TBoolNames", {',
' dims: [2],',
' eltype: rtl.string',
'});',
- '$mod.$rtti.$StaticArray("TByteArray", {',
+ 'this.$rtti.$StaticArray("TByteArray", {',
' dims: [32768],',
' eltype: rtl.byte',
'});',
- '$mod.$rtti.$ProcVar("TProc", {',
- ' procsig: rtl.newTIProcSig([["f", $mod.$rtti["TBoolNames"]]], $mod.$rtti["TFlagNames"])',
+ 'this.$rtti.$ProcVar("TProc", {',
+ ' procsig: rtl.newTIProcSig([["f", this.$rtti["TBoolNames"]]], this.$rtti["TFlagNames"])',
'});',
'this.p = null;',
'']),
@@ -28819,14 +28885,14 @@ begin
ConvertProgram;
CheckSource('TestRTTI_DynArray',
LinesToStr([ // statements
- '$mod.$rtti.$DynArray("TArrStr", {',
+ 'this.$rtti.$DynArray("TArrStr", {',
' eltype: rtl.string',
'});',
- '$mod.$rtti.$DynArray("TArr2Dim", {',
- ' eltype: $mod.$rtti["TArrStr"]',
+ 'this.$rtti.$DynArray("TArr2Dim", {',
+ ' eltype: this.$rtti["TArrStr"]',
'});',
- '$mod.$rtti.$ProcVar("TProc", {',
- ' procsig: rtl.newTIProcSig([["f", $mod.$rtti["TArrStr"]]], $mod.$rtti["TArr2Dim"])',
+ 'this.$rtti.$ProcVar("TProc", {',
+ ' procsig: rtl.newTIProcSig([["f", this.$rtti["TArrStr"]]], this.$rtti["TArr2Dim"])',
'});',
'this.p = null;',
'']),
@@ -28847,11 +28913,11 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ArrayNestedAnonymous',
LinesToStr([ // statements
- '$mod.$rtti.$DynArray("TArr$a", {',
+ 'this.$rtti.$DynArray("TArr$a", {',
' eltype: rtl.longint',
'});',
- '$mod.$rtti.$DynArray("TArr", {',
- ' eltype: $mod.$rtti["TArr$a"]',
+ 'this.$rtti.$DynArray("TArr", {',
+ ' eltype: this.$rtti["TArr$a"]',
'});',
'this.a = [];',
'']),
@@ -28969,7 +29035,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_Field',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FPropA = "";',
' this.VarLI = 0;',
@@ -29035,7 +29101,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_Method',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -29068,7 +29134,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_MethodOpenArray',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -29114,7 +29180,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_Property',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FColor = 0;',
' this.FColorStored = false;',
@@ -29183,7 +29249,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_PropertyParams',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -29225,8 +29291,8 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_OtherUnit_TypeAlias',
LinesToStr([ // statements
- '$mod.$rtti.$inherited("TColorTypeAlias", pas.unit1.$rtti["TColor"], {});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'this.$rtti.$inherited("TColorTypeAlias", pas.unit1.$rtti["TColor"], {});',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.fColor = 0;',
' this.fAlias = 0;',
@@ -29261,7 +29327,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Class_OmitRTTI',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FA = 0;',
' };',
@@ -29303,13 +29369,13 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- '$mod.$rtti.$Enum("TEnum", {',
+ 'this.$rtti.$Enum("TEnum", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
' enumtype: this.TEnum',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FB = false;',
' };',
@@ -29376,7 +29442,7 @@ begin
CheckSource('TestRTTI_StoredModifier',
LinesToStr([ // statements
'this.ConstB = true;',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FB = false;',
' };',
@@ -29446,7 +29512,7 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- '$mod.$rtti.$Enum("TEnum", {',
+ 'this.$rtti.$Enum("TEnum", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
@@ -29454,7 +29520,7 @@ begin
'});',
'this.CB = true || false;',
'this.CI = 1 + 2;',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FB = false;',
' this.FI = 0;',
@@ -29568,17 +29634,17 @@ begin
' "1": "blue",',
' blue: 1',
'};',
- '$mod.$rtti.$Enum("TEnum", {',
+ 'this.$rtti.$Enum("TEnum", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
' enumtype: this.TEnum',
'});',
- '$mod.$rtti.$Set("TSet", {',
- ' comptype: $mod.$rtti["TEnum"]',
+ 'this.$rtti.$Set("TSet", {',
+ ' comptype: this.$rtti["TEnum"]',
'});',
- 'this.CSet = rtl.createSet($mod.TEnum.red, $mod.TEnum.blue);',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'this.CSet = rtl.createSet(this.TEnum.red, this.TEnum.blue);',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FSet = {};',
' };',
@@ -29652,14 +29718,14 @@ begin
ConvertProgram;
CheckSource('TestRTTI_DefaultValueRangeType',
LinesToStr([ // statements
- '$mod.$rtti.$Int("TRg", {',
+ 'this.$rtti.$Int("TRg", {',
' minvalue: -1,',
' maxvalue: 1,',
' ordtype: 0',
'});',
'this.l = -1;',
'this.h = 1;',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FV = 0;',
' };',
@@ -29702,7 +29768,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_DefaultValueInherit',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FA = 0;',
' this.FB = 0;',
@@ -29710,7 +29776,7 @@ begin
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' var $r = this.$rtti;',
' $r.addProperty(',
' "A",',
@@ -29747,7 +29813,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_OverrideMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -29755,7 +29821,7 @@ begin
' var $r = this.$rtti;',
' $r.addMethod("DoIt", 0, null);',
'});',
- 'rtl.createClass($mod, "TSky", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TSky", this.TObject, function () {',
' this.DoIt = function () {',
' };',
'});',
@@ -29787,7 +29853,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ReintroduceMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -29797,7 +29863,7 @@ begin
' var $r = this.$rtti;',
' $r.addMethod("DoIt", 0, null);',
'});',
- 'rtl.createClass($mod, "TSky", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TSky", this.TObject, function () {',
' this.DoIt = function () {',
' $mod.TObject.DoIt.call(this);',
' };',
@@ -29828,7 +29894,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_OverrideMethod',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FFlag = 0;',
' };',
@@ -29837,7 +29903,7 @@ begin
' var $r = this.$rtti;',
' $r.addProperty("Flag", 0, rtl.longint, "FFlag", "");',
'});',
- 'rtl.createClass($mod, "TSky", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TSky", this.TObject, function () {',
' var $r = this.$rtti;',
' $r.addProperty("Flag", 0, rtl.longint, "", "FFlag");',
'});',
@@ -29871,17 +29937,17 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ClassForward',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- '$mod.$rtti.$Class("TBridge");',
- '$mod.$rtti.$ProcVar("TProc", {',
- ' procsig: rtl.newTIProcSig(null, $mod.$rtti["TBridge"])',
+ 'this.$rtti.$Class("TBridge");',
+ 'this.$rtti.$ProcVar("TProc", {',
+ ' procsig: rtl.newTIProcSig(null, this.$rtti["TBridge"])',
'});',
- 'rtl.createClass($mod, "TOger", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TOger", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FBridge = null;',
@@ -29895,7 +29961,7 @@ begin
' $r.addMethod("SetBridge", 0, [["Value", $mod.$rtti["TBridge"]]]);',
' $r.addProperty("Bridge", 2, $mod.$rtti["TBridge"], "FBridge", "SetBridge");',
'});',
- 'rtl.createClass($mod, "TBridge", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBridge", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FOger = null;',
@@ -29937,14 +30003,14 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ClassOf',
LinesToStr([ // statements
- '$mod.$rtti.$Class("TObject");',
- '$mod.$rtti.$ClassRef("TClass", {',
- ' instancetype: $mod.$rtti["TObject"]',
+ 'this.$rtti.$Class("TObject");',
+ 'this.$rtti.$ClassRef("TClass", {',
+ ' instancetype: this.$rtti["TObject"]',
'});',
- '$mod.$rtti.$ProcVar("TProcA", {',
- ' procsig: rtl.newTIProcSig(null, $mod.$rtti["TClass"])',
+ 'this.$rtti.$ProcVar("TProcA", {',
+ ' procsig: rtl.newTIProcSig(null, this.$rtti["TClass"])',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.C = null;',
' };',
@@ -29954,22 +30020,22 @@ begin
' var $r = this.$rtti;',
' $r.addField("C", $mod.$rtti["TClass"]);',
'});',
- '$mod.$rtti.$Class("TFox");',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'this.$rtti.$Class("TFox");',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
'});',
- '$mod.$rtti.$ClassRef("TBirds", {',
- ' instancetype: $mod.$rtti["TBird"]',
+ 'this.$rtti.$ClassRef("TBirds", {',
+ ' instancetype: this.$rtti["TBird"]',
'});',
- 'rtl.createClass($mod, "TFox", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TFox", this.TObject, function () {',
'});',
- '$mod.$rtti.$ClassRef("TFoxes", {',
- ' instancetype: $mod.$rtti["TFox"]',
+ 'this.$rtti.$ClassRef("TFoxes", {',
+ ' instancetype: this.$rtti["TFox"]',
'});',
- '$mod.$rtti.$Class("TCow");',
- '$mod.$rtti.$ClassRef("TCows", {',
- ' instancetype: $mod.$rtti["TCow"]',
+ 'this.$rtti.$Class("TCow");',
+ 'this.$rtti.$ClassRef("TCows", {',
+ ' instancetype: this.$rtti["TCow"]',
'});',
- 'rtl.createClass($mod, "TCow", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCow", this.TObject, function () {',
'});',
'']),
LinesToStr([ // $mod.$main
@@ -29994,7 +30060,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Record',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TPoint", function () {',
+ 'rtl.recNewT(this, "TPoint", function () {',
' this.x = 0;',
' this.y = 0;',
' this.$eq = function (b) {',
@@ -30010,7 +30076,7 @@ begin
' $r.addField("y", rtl.longint);',
'});',
'this.p = null;',
- 'this.r = $mod.TPoint.$new();',
+ 'this.r = this.TPoint.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.p = $mod.$rtti["TPoint"];',
@@ -30037,7 +30103,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Record',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TFloatRec", function () {',
+ 'rtl.recNewT(this, "TFloatRec", function () {',
' this.$new = function () {',
' var r = Object.create(this);',
' r.c = [];',
@@ -30060,7 +30126,7 @@ begin
' $r.addField("d", $mod.$rtti["TFloatRec.d$a"]);',
'});',
'this.p = null;',
- 'this.r = $mod.TFloatRec.$new();',
+ 'this.r = this.TFloatRec.$new();',
'']),
LinesToStr([ // $mod.$main
'$mod.p = $mod.$rtti["TFloatRec"];',
@@ -30221,19 +30287,19 @@ begin
ConvertProgram;
CheckSource('TestRTTI_TypeInfo_Type_BaseTypes',
LinesToStr([ // statements
- '$mod.$rtti.$inherited("TCaption", rtl.string, {});',
- '$mod.$rtti.$inherited("TYesNo", rtl.boolean, {});',
- '$mod.$rtti.$inherited("TLetter", rtl.char, {});',
- '$mod.$rtti.$inherited("TFloat", rtl.double, {});',
- '$mod.$rtti.$inherited("TPtr", rtl.pointer, {});',
- '$mod.$rtti.$inherited("TShortInt", rtl.shortint, {});',
- '$mod.$rtti.$inherited("TByte", rtl.byte, {});',
- '$mod.$rtti.$inherited("TSmallInt", rtl.smallint, {});',
- '$mod.$rtti.$inherited("TWord", rtl.word, {});',
- '$mod.$rtti.$inherited("TInt32", rtl.longint, {});',
- '$mod.$rtti.$inherited("TDWord", rtl.longword, {});',
- '$mod.$rtti.$inherited("TValue", rtl.jsvalue, {});',
- '$mod.$rtti.$inherited("TAliasValue", $mod.$rtti["TValue"], {});',
+ 'this.$rtti.$inherited("TCaption", rtl.string, {});',
+ 'this.$rtti.$inherited("TYesNo", rtl.boolean, {});',
+ 'this.$rtti.$inherited("TLetter", rtl.char, {});',
+ 'this.$rtti.$inherited("TFloat", rtl.double, {});',
+ 'this.$rtti.$inherited("TPtr", rtl.pointer, {});',
+ 'this.$rtti.$inherited("TShortInt", rtl.shortint, {});',
+ 'this.$rtti.$inherited("TByte", rtl.byte, {});',
+ 'this.$rtti.$inherited("TSmallInt", rtl.smallint, {});',
+ 'this.$rtti.$inherited("TWord", rtl.word, {});',
+ 'this.$rtti.$inherited("TInt32", rtl.longint, {});',
+ 'this.$rtti.$inherited("TDWord", rtl.longword, {});',
+ 'this.$rtti.$inherited("TValue", rtl.jsvalue, {});',
+ 'this.$rtti.$inherited("TAliasValue", this.$rtti["TValue"], {});',
'this.p = null;',
'this.a = undefined;',
'']),
@@ -30310,14 +30376,14 @@ begin
' "1": "down",',
' down: 1',
'};',
- '$mod.$rtti.$Enum("TFlag", {',
+ 'this.$rtti.$Enum("TFlag", {',
' minvalue: 0,',
' maxvalue: 1,',
' ordtype: 1,',
' enumtype: this.TFlag',
'});',
- '$mod.$rtti.$Set("TFlags", {',
- ' comptype: $mod.$rtti["TFlag"]',
+ 'this.$rtti.$Set("TFlags", {',
+ ' comptype: this.$rtti["TFlag"]',
'});',
'this.ti = null;',
'this.tiInt = null;',
@@ -30372,17 +30438,17 @@ begin
ConvertProgram;
CheckSource('TestRTTI_TypeInfo_ExtTypeInfoClasses2',
LinesToStr([ // statements
- '$mod.$rtti.$StaticArray("TStaticArr", {',
+ 'this.$rtti.$StaticArray("TStaticArr", {',
' dims: [2],',
' eltype: rtl.string',
'});',
- '$mod.$rtti.$DynArray("TDynArr", {',
+ 'this.$rtti.$DynArray("TDynArr", {',
' eltype: rtl.string',
'});',
- '$mod.$rtti.$ProcVar("TProc", {',
+ 'this.$rtti.$ProcVar("TProc", {',
' procsig: rtl.newTIProcSig(null)',
'});',
- '$mod.$rtti.$MethodVar("TMethod", {',
+ 'this.$rtti.$MethodVar("TMethod", {',
' procsig: rtl.newTIProcSig(null),',
' methodkind: 0',
'});',
@@ -30436,7 +30502,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_TypeInfo_ExtTypeInfoClasses3',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -30445,16 +30511,16 @@ begin
' };',
' $mod.$rtti.$Record("TRec", {});',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- '$mod.$rtti.$ClassRef("TClass", {',
- ' instancetype: $mod.$rtti["TObject"]',
+ 'this.$rtti.$ClassRef("TClass", {',
+ ' instancetype: this.$rtti["TObject"]',
'});',
- 'this.Rec = $mod.TRec.$new();',
+ 'this.Rec = this.TRec.$new();',
'this.tiRecord = null;',
'this.Obj = null;',
'this.tiClass = null;',
@@ -30508,11 +30574,11 @@ begin
ConvertProgram;
CheckSource('TestRTTI_TypeInfo_FunctionClassType',
LinesToStr([ // statements
- '$mod.$rtti.$Class("TObject");',
- '$mod.$rtti.$ClassRef("TClass", {',
- ' instancetype: $mod.$rtti["TObject"]',
+ 'this.$rtti.$Class("TObject");',
+ 'this.$rtti.$ClassRef("TClass", {',
+ ' instancetype: this.$rtti["TObject"]',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -30652,7 +30718,7 @@ begin
CheckSource('TestRTTI_Interface_Corba',
LinesToStr([ // statements
'rtl.createInterface(',
- ' $mod,',
+ ' this,',
' "IUnknown",',
' "{B92D5841-758A-322B-B800-000000000000}",',
' [],',
@@ -30661,7 +30727,7 @@ begin
' }',
');',
'rtl.createInterface(',
- ' $mod,',
+ ' this,',
' "IBird",',
' "{D32D5841-6264-3AE3-A2C9-B91CE922C9B9}",',
' ["GetItem", "SetItem"],',
@@ -30716,7 +30782,7 @@ begin
ConvertProgram;
CheckSource('TestRTTI_Interface_COM',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TGuid", function () {',
+ 'rtl.recNewT(this, "TGuid", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -30726,7 +30792,7 @@ begin
' $mod.$rtti.$Record("TGuid", {});',
'});',
'rtl.createInterface(',
- ' $mod,',
+ ' this,',
' "IUnknown",',
' "{D7ADB00D-1A9B-3EDC-B123-730E661DDFA9}",',
' ["QueryInterface", "_AddRef", "_Release"],',
@@ -30740,11 +30806,11 @@ begin
' }',
');',
'rtl.createInterface(',
- ' $mod,',
+ ' this,',
' "IBird",',
' "{9CC77572-0E45-3594-9A88-9E8D865C9E0A}",',
' ["GetItem", "SetItem"],',
- ' $mod.IUnknown,',
+ ' this.IUnknown,',
' function () {',
' var $r = this.$rtti;',
' $r.addMethod("GetItem", 1, null, rtl.longint);',
@@ -30787,13 +30853,13 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ClassHelper',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.GetItem = function () {',
' var Result = 0;',
' return Result;',
@@ -30828,11 +30894,11 @@ begin
ConvertProgram;
CheckSource('TestRTTI_ExternalClass',
LinesToStr([ // statements
- '$mod.$rtti.$ExtClass("TJSObject", {',
+ 'this.$rtti.$ExtClass("TJSObject", {',
' jsclass: "Object"',
'});',
- '$mod.$rtti.$ExtClass("TJSArray", {',
- ' ancestor: $mod.$rtti["TJSObject"],',
+ 'this.$rtti.$ExtClass("TJSArray", {',
+ ' ancestor: this.$rtti["TJSObject"],',
' jsclass: "Array"',
'});',
'this.p = null;',
@@ -31000,7 +31066,7 @@ begin
ConvertProgram;
CheckSource('TestAttributes_Members',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -31009,12 +31075,12 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TCustomAttribute", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCustomAttribute", this.TObject, function () {',
' this.Create$1 = function (Id) {',
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.$init = function () {',
' $mod.TObject.$init.call(this);',
' this.FField = 0;',
@@ -31037,7 +31103,7 @@ begin
' attr: [$mod.TCustomAttribute, "Create$1", [15]]',
' });',
'});',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.Size = 0;',
' this.$eq = function (b) {',
' return this.Size === b.Size;',
@@ -31094,7 +31160,7 @@ begin
ConvertProgram;
CheckSource('TestAttributes_Types',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -31103,13 +31169,13 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TCustomAttribute", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TCustomAttribute", this.TObject, function () {',
'});',
- 'rtl.createClass($mod, "TMyClass", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TMyClass", this.TObject, function () {',
' var $r = this.$rtti;',
' $r.attr = [$mod.TCustomAttribute, "Create", [1]];',
'});',
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.$eq = function (b) {',
' return true;',
' };',
@@ -31120,8 +31186,8 @@ begin
' attr: [$mod.TCustomAttribute, "Create", [2]]',
' });',
'});',
- '$mod.$rtti.$inherited("TInt", rtl.word, {',
- ' attr: [$mod.TCustomAttribute, "Create", [3]]',
+ 'this.$rtti.$inherited("TInt", rtl.word, {',
+ ' attr: [this.TCustomAttribute, "Create", [3]]',
'});',
'this.p = null;',
'']),
@@ -31264,7 +31330,7 @@ begin
ConvertProgram;
CheckSource('TestCheckMethodCall',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -31274,7 +31340,7 @@ begin
' $mod.b = rtl.asExt($mod.o, $mod.TBird, 1);',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
'});',
'this.o = null;',
'this.c = null;',
@@ -31463,7 +31529,7 @@ begin
' "1": "green",',
' green: 1',
'};',
- 'this.e = $mod.TEnum.red;',
+ 'this.e = this.TEnum.red;',
'this.DoIt = function (p) {',
' rtl.rc(p, 0, 1);',
' $mod.e = rtl.rc(p, 0, 1);',
@@ -31515,7 +31581,7 @@ begin
' "1": "green",',
' green: 1',
'};',
- 'this.e = $mod.TEnum.red;',
+ 'this.e = this.TEnum.red;',
'this.DoIt = function (p) {',
' rtl.rc(p, 0, 1);',
' $mod.e = rtl.rc(p, 0, 1);',
@@ -31664,7 +31730,7 @@ begin
ConvertProgram;
CheckSource('TestRangeChecks_ArrayIndex',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.A = [];',
' };',
@@ -31727,7 +31793,7 @@ begin
ConvertProgram;
CheckSource('TestRangeChecks_ArrayOfRecIndex',
LinesToStr([ // statements
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.x = 0;',
' this.$eq = function (b) {',
' return this.x === b.x;',
@@ -31737,7 +31803,7 @@ begin
' return this;',
' };',
'});',
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.A = [];',
' };',
@@ -31786,7 +31852,7 @@ begin
ConvertProgram;
CheckSource('TestRangeChecks_StringIndex',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.S = "";',
' };',
@@ -31885,14 +31951,14 @@ begin
ConvertProgram;
CheckSource('TestRangeChecks_AssignInt',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FSize = 0;',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createHelper($mod, "THelper", null, function () {',
+ 'rtl.createHelper(this, "THelper", null, function () {',
' this.SetIt = function (w) {',
' rtl.rc(w, 0, 65535);',
' this.set(w);',
@@ -32034,13 +32100,13 @@ begin
ConvertProgram;
CheckSource('TestAsync_CallResultIsPromise',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Fly = async function () {',
' var Result = 0;',
' Result = 3;',
@@ -32403,7 +32469,7 @@ begin
ConvertProgram;
CheckSource('TestAsync_Inherited',
LinesToStr([ // statements
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -32413,7 +32479,7 @@ begin
' return Result;',
' };',
'});',
- 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
+ 'rtl.createClass(this, "TBird", this.TObject, function () {',
' this.Run = async function (w) {',
' var Result = 0;',
' var p = null;',
diff --git a/packages/pastojs/tests/tcoptimizations.pas b/packages/pastojs/tests/tcoptimizations.pas
index bc01348cd2..5523f2dbcc 100644
--- a/packages/pastojs/tests/tcoptimizations.pas
+++ b/packages/pastojs/tests/tcoptimizations.pas
@@ -17,7 +17,7 @@
./testpas2js --suite=TTestOptimizations
./testpas2js --suite=TTestOptimizations.TestOmitLocalVar
}
-unit tcoptimizations;
+unit TCOptimizations;
{$mode objfpc}{$H+}
@@ -26,7 +26,7 @@ interface
uses
Classes, SysUtils, testregistry, fppas2js, pastree,
PScanner, Pas2jsUseAnalyzer, PasResolver, PasResolveEval,
- tcmodules;
+ TCModules;
type
@@ -56,17 +56,10 @@ type
TTestOptimizations = class(TCustomTestOptimizations)
published
- // unit optimization: jsaliasglobals
- procedure TestOptAliasGlobals_Program;
- procedure TestOptAliasGlobals_Unit_FromIntfImpl_ToIntfImpl;
- // ToDo: external var, const, class
- // ToDo: RTTI
- // ToDo: typeinfo(var), typeinfo(type)
- // ToDo: resourcestring
- // ToDo: Global EnumType, EnumValue, EnumType.Value, unit.EnumType.Value
- // ToDo: Nested EnumType: EnumValue, EnumType.Value, unit.aType.EnumType.Value, aType.EnumType.Value, Instance.EnumType.Value
- // ToDo: Instance.RecordType, Instance.RecordType.ClassVar
- // ToDo: ClassVarRecord
+ // unit optimization: jsshortrefglobals
+ procedure TestOptShortRefGlobals_Program;
+ procedure TestOptShortRefGlobals_Unit_FromIntfImpl_ToIntfImpl;
+ procedure TestOptShortRefGlobals_Property;
// Whole Program Optimization
procedure TestWPO_OmitLocalVar;
@@ -199,7 +192,7 @@ end;
{ TTestOptimizations }
-procedure TTestOptimizations.TestOptAliasGlobals_Program;
+procedure TTestOptimizations.TestOptShortRefGlobals_Program;
begin
AddModuleWithIntfImplSrc('UnitA.pas',
LinesToStr([
@@ -224,7 +217,7 @@ begin
StartProgram(true,[supTObject]);
Add([
- '{$optimization JSAliasGlobals}',
+ '{$optimization JSShortRefGlobals}',
'uses unita;',
'type',
' TEagle = class(TBird)',
@@ -249,12 +242,12 @@ begin
' c:=cRedBlue;',
'']);
ConvertProgram;
- CheckSource('TestOptAliasGlobals_Program',
+ CheckSource('TestOptShortRefGlobals_Program',
LinesToStr([
'var $lm = pas.UnitA;',
'var $lt = $lm.TBird;',
'var $lt1 = $lm.TRec;',
- 'rtl.createClass($mod, "TEagle", $lt, function () {',
+ 'rtl.createClass(this, "TEagle", $lt, function () {',
' this.Run = function (w) {',
' var Result = 0;',
' return Result;',
@@ -277,7 +270,7 @@ begin
'']));
end;
-procedure TTestOptimizations.TestOptAliasGlobals_Unit_FromIntfImpl_ToIntfImpl;
+procedure TTestOptimizations.TestOptShortRefGlobals_Unit_FromIntfImpl_ToIntfImpl;
begin
AddModuleWithIntfImplSrc('UnitA.pas',
LinesToStr([
@@ -311,7 +304,7 @@ begin
'']));
StartUnit(true,[supTObject]);
Add([
- '{$optimization JSAliasGlobals}',
+ '{$optimization JSShortRefGlobals}',
'interface',
'uses unita;',
'type',
@@ -354,7 +347,7 @@ begin
' RedAnt.Run;',
'']);
ConvertUnit;
- CheckSource('TestOptAliasGlobals_Unit_FromIntfImpl_ToIntfImpl',
+ CheckSource('TestOptShortRefGlobals_Unit_FromIntfImpl_ToIntfImpl',
LinesToStr([
'var $impl = $mod.$impl;',
'var $lm = pas.UnitA;',
@@ -363,7 +356,7 @@ begin
'var $lt1 = null;',
'var $lt2 = null;',
'var $lt3 = null;',
- 'rtl.createClass($mod, "TEagle", $lt, function () {',
+ 'rtl.createClass(this, "TEagle", $lt, function () {',
' this.Fly = function () {',
' $impl.TRedAnt.$create("Create");',
' $lt1.$create("Create");',
@@ -402,6 +395,55 @@ begin
'']));
end;
+procedure TTestOptimizations.TestOptShortRefGlobals_Property;
+begin
+ AddModuleWithIntfImplSrc('UnitA.pas',
+ LinesToStr([
+ 'type',
+ ' TBird = class',
+ ' FWing: TObject;',
+ ' class var FLeg: TObject;',
+ ' public',
+ ' property Wing: TObject read FWing write FWing;',
+ ' class property Leg: TObject read FLeg write FLeg;',
+ ' end;',
+ '']),
+ LinesToStr([
+ '']));
+ StartUnit(true,[supTObject]);
+ Add([
+ '{$optimization JSShortRefGlobals}',
+ 'interface',
+ 'uses unita;',
+ 'type',
+ ' TEagle = class(TBird)', // intf-JS to intf-uses
+ ' procedure Fly(o: TObject);',
+ ' end;',
+ 'implementation',
+ 'procedure TEagle.Fly(o: TObject);',
+ 'begin',
+ ' Fly(Wing);',
+ ' Fly(Leg);',
+ 'end;',
+ '']);
+ ConvertUnit;
+ CheckSource('TestOptShortRefGlobals_Property',
+ LinesToStr([
+ 'var $lm = pas.UnitA;',
+ 'var $lt = $lm.TBird;',
+ 'rtl.createClass(this, "TEagle", $lt, function () {',
+ ' this.Fly = function (o) {',
+ ' this.Fly(this.FWing);',
+ ' this.Fly(this.FLeg);',
+ ' };',
+ '});',
+ '']),
+ LinesToStr([
+ '']),
+ LinesToStr([
+ '']));
+end;
+
procedure TTestOptimizations.TestWPO_OmitLocalVar;
begin
StartProgram(false);
@@ -605,7 +647,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitRecordMember',
LinesToStr([
- 'rtl.recNewT($mod, "TRec", function () {',
+ 'rtl.recNewT(this, "TRec", function () {',
' this.a = 0;',
' this.$eq = function (b) {',
' return this.a === b.a;',
@@ -615,7 +657,7 @@ begin
' return this;',
' };',
'});',
- 'this.r = $mod.TRec.$new();',
+ 'this.r = this.TRec.$new();',
'']),
LinesToStr([
'$mod.r.a = 3;',
@@ -653,7 +695,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_TObject',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -693,7 +735,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_Class_TObject',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -725,7 +767,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassField',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.a = 0;',
' };',
@@ -754,7 +796,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassMethod',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -784,7 +826,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassMethod',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -820,7 +862,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassPropertyGetter1',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FFoo = false;',
' };',
@@ -851,7 +893,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassPropertyGetter2',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FFoo = false;',
' };',
@@ -892,7 +934,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassPropertySetter1',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FFoo = false;',
' };',
@@ -923,7 +965,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_OmitClassPropertySetter2',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FFoo = false;',
' };',
@@ -970,7 +1012,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_Class_KeepNewInstance',
LinesToStr([
- 'rtl.createClassExt($mod, "TBird", Object, "NewInstance", function () {',
+ 'rtl.createClassExt(this, "TBird", Object, "NewInstance", function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -1019,7 +1061,7 @@ begin
ConvertProgram;
CheckSource('TestWPO_CallInherited',
LinesToStr([
- 'rtl.createClass($mod, "TObject", null, function () {',
+ 'rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' };',
' this.$final = function () {',
@@ -1029,7 +1071,7 @@ begin
' this.DoB = function () {',
' };',
'});',
- ' rtl.createClass($mod, "TMobile", $mod.TObject, function () {',
+ ' rtl.createClass(this, "TMobile", this.TObject, function () {',
' this.DoA$1 = function () {',
' $mod.TObject.DoA.call(this);',
' };',
@@ -1096,7 +1138,7 @@ begin
LinesToStr([
'rtl.module("system", [], function () {',
' var $mod = this;',
- ' rtl.recNewT($mod, "TVarRec", function () {',
+ ' rtl.recNewT(this, "TVarRec", function () {',
' this.VType = 0;',
' this.VJSValue = undefined;',
' this.$eq = function (b) {',
@@ -1175,7 +1217,7 @@ begin
LinesToStr([
'rtl.module("unit1", ["system"], function () {',
' var $mod = this;',
- ' rtl.createClass($mod, "TObject", null, function () {',
+ ' rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.FA = 0;',
' };',
@@ -1250,7 +1292,7 @@ begin
'rtl.module("program",["system"],function () {',
' var $mod = this;',
' this.gcBlack = 0;',
- ' rtl.createClass($mod,"TObject",null,function () {',
+ ' rtl.createClass(this,"TObject",null,function () {',
' this.$init = function () {',
' this.FColor = 0;',
' };',
@@ -1294,10 +1336,10 @@ begin
ExpectedSrc:=LinesToStr([
'rtl.module("program", ["system"], function () {',
' var $mod = this;',
- ' $mod.$rtti.$DynArray("TArrB", {',
+ ' this.$rtti.$DynArray("TArrB", {',
' eltype: rtl.string',
' });',
- ' rtl.createClass($mod, "TObject", null, function () {',
+ ' rtl.createClass(this, "TObject", null, function () {',
' this.$init = function () {',
' this.PublicA = [];',
' this.PublishedB = [];',
@@ -1339,7 +1381,7 @@ begin
ExpectedSrc:=LinesToStr([
'rtl.module("program", ["system"], function () {',
' var $mod = this;',
- ' $mod.$rtti.$DynArray("TArrB", {',
+ ' this.$rtti.$DynArray("TArrB", {',
' eltype: rtl.string',
' });',
' this.A = [];',
diff --git a/packages/pastojs/tests/testpas2js.lpi b/packages/pastojs/tests/testpas2js.lpi
index 05dc286e13..97d1d48f1b 100644
--- a/packages/pastojs/tests/testpas2js.lpi
+++ b/packages/pastojs/tests/testpas2js.lpi
@@ -59,6 +59,7 @@
<Unit4>
<Filename Value="tcoptimizations.pas"/>
<IsPartOfProject Value="True"/>
+ <UnitName Value="TCOptimizations"/>
</Unit4>
<Unit5>
<Filename Value="tcsrcmap.pas"/>