Pas2JS pascal source code
type
TList = class
Field: array of String;
end;
type
TContainer = class
A: array of TList;
end;
var
c := new TContainer;
var
i := new TList;
i.Field.Add('a', 'b');
c.A.Add(i);
i := new TList;
i.Field.Add('c', 'd', 'e');
c.A.Add(i);
for var list in c.A do
for var s in list.Field do
WriteLn(s);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
a
b
c
d
e
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TObject={
$ClassName: "TObject",
$Parent: null,
ClassName: function (s) { return s.$ClassName },
ClassType: function (s) { return s },
ClassParent: function (s) { return s.$Parent },
$Init: function () {},
Create: function (s) { return s },
Destroy: function (s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s.prop },
Destroy$: function(s) { return s.ClassType.Destroy(s) },
Free: function (s) { if (s!==null) s.ClassType.Destroy(s) }
}
var Exception={
$ClassName: "Exception",
$Parent: TObject,
$Init: function () { FMessage="" },
Create: function (s,Msg) { s.FMessage=Msg; return s }
}
function $New(c) { var i={ClassType:c}; c.$Init(i); return i }
function $DIdxR(a,i,z) {
if (i<0) throw Exception.Create($New(Exception),"Lower bound exceeded! Index "+i.toString()+z);
if (i>a.length) throw Exception.Create($New(Exception),"Upper bound exceeded! Index "+i.toString()+z);
return a[i];
}
function $Check(i,z) { if (i) return i; throw Exception.Create($New(Exception),"Object not instantiated"+z); }
function WriteLn(value) {
if (window.console) { window.console.log(value); } };
var TList = {
$ClassName:"TList",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.Field = [];
}
,Destroy:TObject.Destroy
};
var TContainer = {
$ClassName:"TContainer",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.A$1 = [];
}
,Destroy:TObject.Destroy
};
var a$1 = [];
var c = null,
i = null,
a$2 = 0;
var list = null,
a$3 = 0;
var s = "";
/* <<< main JS >>> */
c = TObject.Create($New(TContainer));
i = TObject.Create($New(TList));
$Check(i,"").Field.push("a", "b");
$Check(c,"").A$1.push(i);
i = TObject.Create($New(TList));
$Check(i,"").Field.push("c", "d", "e");
$Check(c,"").A$1.push(i);
var a$4 = [];
a$1 = $Check(c,"").A$1;
var $temp1;
for(a$2=0,$temp1=a$1.length;a$2<$temp1;a$2++) {
list = $DIdxR(a$1,a$2,"");
a$4 = $Check(list,"").Field;
var $temp2;
for(a$3=0,$temp2=a$4.length;a$3<$temp2;a$3++) {
s = $DIdxR(a$4,a$3,"");
WriteLn(s);
}
}