Smart pascal source code
type
TBase = class
procedure Func; virtual;
end;
type
TChild = class(TBase)
procedure Func; reintroduce;
end;
type
TSubChild = class(TChild)
procedure Func;
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
};
var TSubChild = {
$ClassName:"TSubChild",$Parent:TChild
,$Init:function ($) {
TChild.$Init($);
}
,Func$2:function(Self) {
WriteLn((TObject.ClassName($Check(Self,"").ClassType)+" finally"));
}
,Destroy:TObject.Destroy
};
var o = null;
/* <<< main JS >>> */
TBase.Func($Check(TObject.Create($New(TBase)),""));
TChild.Func$1(TObject.Create($New(TChild)));
TSubChild.Func$2(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,""));