Smart pascal source code
type
TPersistent = class
fString: string;
function GetOwner: TPersistent;
function GetNamePath: String;
end;
function TPersistent.GetOwner: TPersistent;
begin
result := nil;
end;
function TPersistent.GetNamePath: string;
var S: String;
begin
result := ClassName;
if (GetOwner <> nil) then
begin
S := GetOwner.GetNamePath;
if S <> '' then
result := S + '.' + result;
end;
end;
var p := TPersistent.Create;
WriteLn(p.GetNamePath);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
Errors >>>>
Hint: "result" does not match case of declaration ("Result") [line: 10, column: 5]
Hint: "s" does not match case of declaration ("S") [line: 20, column: 7]
Hint: "s" does not match case of declaration ("S") [line: 21, column: 10]
Result >>>>
TPersistent
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TPersistent = {
$ClassName:"TPersistent",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.fString = "";
}
,GetOwner:function(Self) {
return null;
}
,GetNamePath:function(Self) {
var Result = "";
var S = "";
Result = TObject.ClassName($Check(Self,"").ClassType);
if (TPersistent.GetOwner(Self)!==null) {
S = TPersistent.GetNamePath(TPersistent.GetOwner(Self));
if (S!="") {
Result = S+"."+Result;
}
}
return Result
}
,Destroy:TObject.Destroy
};
var p = null;
/* <<< main JS >>> */
p = TObject.Create($New(TPersistent));
WriteLn(TPersistent.GetNamePath(p));