Smart pascal source code
type
TBase = class
procedure Func; virtual;
end;
type
TChild = class(TBase)
procedure Func; reintroduce; virtual;
end;
type
TSubChild = class(TChild)
procedure Func; override;
end;
procedure TBase.Func;
begin
WriteLn(ClassName + ' here');
end;
procedure TChild.Func;
begin
WriteLn(ClassName + ' now here');
end;
procedure TSubChild.Func;
begin
WriteLn(ClassName + ' finally');
end;
TBase.Create.Func;
TChild.Create.Func;
TSubChild.Create.Func;
var o: TBase;
o := TBase.Create;
o.Func;
o := TChild.Create;
o.Func;
o := TSubChild.Create;
o.Func;
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
TBase here
TChild now here
TSubChild finally
TBase here
TChild here
TSubChild here
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TBase = {
$ClassName:"TBase",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
}
,Func:function(Self) {
WriteLn((TObject.ClassName($Check(Self,"").ClassType)+" here"));
}
,Destroy:TObject.Destroy
};
var TChild = {
$ClassName:"TChild",$Parent:TBase
,$Init:function ($) {
TBase.$Init($);
}
,Func$1:function(Self) {
WriteLn((TObject.ClassName($Check(Self,"").ClassType)+" now here"));
}
,Destroy:TObject.Destroy
,Func$1$:function($){return $.ClassType.Func$1($)}
};
var TSubChild = {
$ClassName:"TSubChild",$Parent:TChild
,$Init:function ($) {
TChild.$Init($);
}
,Func$1:function(Self) {
WriteLn((TObject.ClassName($Check(Self,"").ClassType)+" finally"));
}
,Destroy:TObject.Destroy
,Func$1$:function($){return $.ClassType.Func$1($)}
};
var o = null;
/* <<< main JS >>> */
TBase.Func($Check(TObject.Create($New(TBase)),""));
TChild.Func$1$($Check(TObject.Create($New(TChild)),""));
TChild.Func$1$($Check(TObject.Create($New(TSubChild)),""));
o = TObject.Create($New(TBase));
TBase.Func($Check(o,""));
o = TObject.Create($New(TChild));
TBase.Func($Check(o,""));
o = TObject.Create($New(TSubChild));
TBase.Func($Check(o,""));