Smart pascal source code
function FuncInt(i: Integer): Integer;
begin
Result := i + 1;
end;
function FuncFloat(f: Float): Float;
begin
Result := f + 1.5;
end;
function FuncString(s: String): String;
begin
Result := s + s;
end;
function FuncBool(b: Boolean): Boolean;
begin
Result := not b;
end;
function FuncObj(o: TObject): TObject;
begin
Result := if Assigned(o) then o else TObject.Create;
end;
type
TRecord = record
x: Integer;
end;
function FuncRec(i: Integer): TRecord;
begin
Result.x := i;
end;
function FuncRec2: TRecord;
begin
Result := FuncRec(2);
end;
WriteLn(FuncInt(10));
WriteLn(FuncFloat(10));
WriteLn(FuncString('10'));
WriteLn(FuncBool(False));
WriteLn(FuncObj(nil).ClassName);
WriteLn(FuncRec(10).x);
WriteLn(FuncRec2.x);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
11
11.5
1010
True
TObject
10
2
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
function ClassName$1(Self$1) {
return "Helper1."+TObject.ClassName($Check(Self$1,""));
}
function Copy$TRecord(s,d) {
d.x=s.x;
return d;
}
function Clone$TRecord($) {
return {
x:$.x
}
}
function FuncString(s) {
return s+s;
};
function FuncRec2() {
return FuncRec(2);
};
function FuncRec(i) {
var Result = {x:0};
Result.x = i;
return Result
};
function FuncObj(o) {
return (o)?o:TObject.Create($New(TObject));
};
function FuncInt(i$1) {
return i$1+1;
};
function FuncFloat(f) {
return f+1.5;
};
function FuncBool(b) {
return !b;
};
/* <<< main JS >>> */
WriteLn(FuncInt(10));
WriteLn(FuncFloat(10));
WriteLn(FuncString("10"));
WriteLn(FuncBool(false));
WriteLn(ClassName$1($ToClassType(FuncObj(null))));
WriteLn(FuncRec(10).x);
WriteLn(FuncRec2().x);