Pas2JS pascal source code
const
primaries: array [3 .. 6] of Integer = [3, 5, 7, 9];
const
colors: array [0 .. 2] of String = ['red', 'green', 'blue'];
type
TMyClass = class
Field: String;
constructor Create(f: String);
begin
Field := f;
end;
procedure DoWriteLn;
begin
WriteLn(Field);
end;
end;
{---- main.pas ----}
var
i: Integer;
c: String;
objs: array of TMyClass;
Begin
objs.Add(new TMyClass('hello'));
objs.Add(TMyClass.Create('world'));
for i in primaries do
WriteLn(i);
for c in colors do
WriteLn(c);
var
o: TMyClass;
for o in objs do
o.DoWriteLn;
for i in primaries step 2 do
WriteLn(i);
{ <<< CONSOLE OUTPUTS >>>
3
5
7
9
red
green
blue
hello
world
3
7
}
var i = 0;
var c = "";
var objs = [];
var a$1 = 0;
var a$2 = 0;
var o = null;
var a$3 = 0;
var a$4 = 0;
objs.push(TMyClass.Create$5($New(TMyClass),"hello"));
objs.push(TMyClass.Create$5($New(TMyClass),"world"));
for(a$1=3;a$1<=6;a$1++) {
i = primaries[(a$1)-3];
WriteLn(i);
}
for(a$2=0;a$2<=2;a$2++) {
c = colors[a$2];
WriteLn(c);
}
var $temp1;
for(a$3=0,$temp1=objs.length;a$3<$temp1;a$3++) {
o = objs[a$3];
TMyClass.DoWriteLn(o);
}
for(a$4=3;a$4<=6;a$4+=2) {
i = primaries[(a$4)-3];
WriteLn(i);
}
/// TMyClass = class (TObject)
/// [line: 41, column: 3, file: uMain]
var TMyClass = {
$ClassName:"TMyClass",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.Field = "";
}
/// constructor TMyClass.Create(f: String)
/// [line: 43, column: 17, file: uMain]
,Create$5:function(Self, f) {
Self.Field = f;
return Self
}
/// procedure TMyClass.DoWriteLn()
/// [line: 47, column: 15, file: uMain]
,DoWriteLn:function(Self) {
WriteLn(Self.Field);
}
,Destroy:TObject.Destroy
};
var colors = ["red","green","blue"],
primaries = [3,5,7,9];