Smart pascal source code
type
TStatic = class
static const MyConst = 'hello';
class procedure WriteLnMe; virtual;
begin
WriteLn('world');
end;
end;
type
TStaticClass = class of TStatic;
type
TSubStatic = class(TStatic)
class procedure WriteLnMe; override;
begin
WriteLn(MyConst + ' ');
inherited;
end;
end;
WriteLn('const = ' + TStatic.MyConst);
TStatic.WriteLnMe;
TSubStatic.WriteLnMe;
var c: TStaticClass;
c := TStatic;
c.WriteLnMe;
c := TSubStatic;
c.WriteLnMe;
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
const = hello
world
hello world
world
hello world
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TStatic = {
$ClassName:"TStatic",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
}
,WriteLnMe:function(Self) {
WriteLn("world");
}
,Destroy:TObject.Destroy
,WriteLnMe$:function($){return $.WriteLnMe($)}
};
var TSubStatic = {
$ClassName:"TSubStatic",$Parent:TStatic
,$Init:function ($) {
TStatic.$Init($);
}
,WriteLnMe:function(Self) {
WriteLn("hello ");
TStatic.WriteLnMe($Check(Self,""));
}
,Destroy:TObject.Destroy
,WriteLnMe$:function($){return $.WriteLnMe($)}
};
var c = null;
/* <<< main JS >>> */
WriteLn("const = hello");
TStatic.WriteLnMe$($Check(TStatic,""));
TStatic.WriteLnMe$($Check(TSubStatic,""));
c = TStatic;
TStatic.WriteLnMe$($Check(c,""));
c = TSubStatic;
TStatic.WriteLnMe$($Check(c,""));