diff --git a/package.json b/package.json
index ee5cd81..d5483e8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ts2pas",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "A tool to convert TypeScript definition files to DWScript based Object Pascal headers",
"main": "ts2pas.js",
"dependencies": {
diff --git a/src/ts2pas (Test).spr b/src/ts2pas (Test).spr
new file mode 100644
index 0000000..9bcb3a6
--- /dev/null
+++ b/src/ts2pas (Test).spr
@@ -0,0 +1,21 @@
+uses
+ ts2pas.Main;
+
+(*
+ConvertFile('TypeScriptDefs\abs');
+ConvertFile('TypeScriptDefs\absolute');
+ConvertFile('TypeScriptDefs\accounting');
+ConvertFile('TypeScriptDefs\acc-wizard');
+ConvertFile('TypeScriptDefs\AmCharts');
+ConvertFile('TypeScriptDefs\amplifyjs');
+(*
+ConvertFile('TypeScriptDefs\amazon-product-api');
+*)
+ConvertFile('TypeScriptDefs\dijit');
+*)
+//ConvertFile('TypeScriptDefs\ExtJS');
+//ConvertFile('TypeScriptDefs\node');
+//ConvertFile('TypeScriptDefs\flot');
+//ConvertFile('TypeScriptDefs\box2dweb');
+//ConvertFile('TypeScriptDefs\angular');
+//ConvertFile('TypeScriptDefs\typescript');
diff --git a/src/ts2pas (Test).sproj b/src/ts2pas (Test).sproj
new file mode 100644
index 0000000..eb91556
--- /dev/null
+++ b/src/ts2pas (Test).sproj
@@ -0,0 +1,126 @@
+
+
+ ts2pas
+ T00:00:00.000
+ 2016-01-23T03:12:14.811
+ Christian-W. Budde
+ TypeScript to Object Pascal translator
+ TypeScript, Object Pascal
+ https://github.com/CWBudde/ts2pa
+
+ 0
+ 0
+ 0
+
+
+
+ 1
+ default
+ 1
+
+
+ 0
+ 1
+ 1
+
+
+ com.smartmobilestudio.app
+ http://*/*
https://*/*
tel:*
sms:*
mailto:*
geo:*
+
+
+
+
+ 1
+ 1
+ 1
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+
+ DEBUG
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ Android-Holo.css
+ 0
+ 0
+
+
+
+
+ 0
+ 1
+
+ 0
+ 1
+ 3
+ node.exe
+ %output%
+
+
+
+
+ ts2pas (Test)
+ 2016-01-10T13:59:49.570Z
+ 2016-01-23T03:07:53.888
+ ts2pas (Test).spr
+
+
+ ts2pas.Translator
+ 2016-01-10T17:45:44.843Z
+ 2016-01-23T03:12:14.809
+ ts2pas.Translator.pas
+
+
+ ts2pas.Declarations
+ 2016-01-11T22:20:28.821Z
+ 2016-01-23T02:56:33.129
+ ts2pas.Declarations.pas
+
+
+ ts2pas.Main
+ 2016-01-23T01:44:37.996Z
+ 2016-01-23T01:45:35.497
+ ts2pas.Main.pas
+
+
+ Node.js
+ Node.js Project
+
+ 12590
+ 06:14:44.174
+ 00:17:13.670
+ 03:20:03.837
+ 00:00:00.000
+ 00:00:00.000
+
+
+
\ No newline at end of file
diff --git a/src/ts2pas.Declarations.pas b/src/ts2pas.Declarations.pas
index 45dc43d..4a6499f 100644
--- a/src/ts2pas.Declarations.pas
+++ b/src/ts2pas.Declarations.pas
@@ -65,22 +65,27 @@ TTypeOfType = class(TCustomNamedType)
property &Type: TCustomType;
end;
- TVariantType = class(TCustomNamedType)
+ TPredefinedType = class(TCustomNamedType)
+ protected
+ function GetAsCode: String; override;
+ end;
+
+ TVariantType = class(TPredefinedType)
protected
function GetName: String; override;
end;
- TFloatType = class(TCustomNamedType)
+ TFloatType = class(TPredefinedType)
protected
function GetName: String; override;
end;
- TStringType = class(TCustomNamedType)
+ TStringType = class(TPredefinedType)
protected
function GetName: String; override;
end;
- TBooleanType = class(TCustomNamedType)
+ TBooleanType = class(TPredefinedType)
protected
function GetName: String; override;
end;
@@ -190,9 +195,11 @@ TFieldDeclaration = class(TCustomTypeMember)
amProtected
);
- TParameter = class
+ TParameter = class(TNamedDeclaration)
+ protected
+ function GetAsCode: String; override;
+ public
property AccessibilityModifier: TAccessibilityModifier;
- property BindingIdentifier: String;
property &Type: TCustomType;
property IsOptional: Boolean;
property IsRest: Boolean;
@@ -253,7 +260,6 @@ TInterfaceDeclaration = class(TCustomDeclaration)
property Name: String;
property Extends: array of TTypeReference;
property &Type: TObjectType;
- property Members: array of TCustomTypeMember;
end;
TClassDeclaration = class(TInterfaceDeclaration)
@@ -261,6 +267,7 @@ TClassDeclaration = class(TInterfaceDeclaration)
function GetAsCode: String; override;
public
property Implements: array of String;
+ property Members: array of TCustomTypeMember;
end;
TImportDeclaration = class(TNamedDeclaration)
@@ -281,11 +288,10 @@ TCallSignature = class(TCustomDeclaration)
- TAmbientBinding = class(TCustomDeclaration)
+ TAmbientBinding = class(TNamedDeclaration)
protected
function GetAsCode: String; override;
public
- property BindingIdentifier: String;
property &Type: TCustomType;
end;
@@ -297,11 +303,10 @@ TAmbientVariableDeclaration = class(TCustomDeclaration)
property AmbientBindingList: array of TAmbientBinding;
end;
- TAmbientFunctionDeclaration = class(TCustomDeclaration)
+ TAmbientFunctionDeclaration = class(TNamedDeclaration)
protected
function GetAsCode: String; override;
public
- property BindingIdentifier: String;
property CallSignature: TCallSignature;
end;
@@ -370,6 +375,21 @@ implementation
NodeJS.Core;
+function Escape(Name: String): String;
+begin
+ case LowerCase(Name) of
+ 'type':
+ Result := '&type';
+ 'export':
+ Result := '&export';
+ 'label':
+ Result := '&label';
+ else
+ Result := Name;
+ end;
+end;
+
+
{ TCustomDeclaration }
constructor TCustomDeclaration.Create(Owner: IDeclarationOwner);
@@ -417,7 +437,15 @@ function TUnionType.GetAsCode: String;
function TCustomNamedType.GetAsCode: String;
begin
- Result := Name;
+(*
+ case LowerCase(Name) of
+ 'date':
+ Result := 'JDate';
+ else
+ Result := Escape(Name);
+ end;
+*)
+ Result := 'J' + Name;
end;
@@ -429,6 +457,14 @@ function TTypeOfType.GetName: String;
end;
+{ TPredefinedType }
+
+function TPredefinedType.GetAsCode: String;
+begin
+ Result := Name;
+end;
+
+
{ TVariantType }
function TVariantType.GetName: String;
@@ -457,7 +493,7 @@ function TBooleanType.GetName: String;
function TStringType.GetName: String;
begin
- Result := 'Boolean';
+ Result := 'String';
end;
@@ -526,13 +562,8 @@ function TAmbientDeclaration.GetAsCode: String;
end;
if Variables.Count > 0 then
- begin
- Result += 'var' + CRLF;
- BeginIndention;
for var Variable in Variables do
Result := Result + Variable.AsCode;
- EndIndention;
- end;
end;
@@ -540,7 +571,7 @@ function TAmbientDeclaration.GetAsCode: String;
function TDefinitionDeclaration.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TDefinitionDeclaration.GetAsCode');
end;
@@ -548,7 +579,7 @@ function TDefinitionDeclaration.GetAsCode: String;
function TEnumerationItem.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TEnumerationItem.GetAsCode');
end;
@@ -556,7 +587,7 @@ function TEnumerationItem.GetAsCode: String;
function TEnumerationDeclaration.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TEnumerationDeclaration.GetAsCode');
end;
@@ -572,7 +603,7 @@ function TFunctionDeclaration.GetAsCode: String;
function TFieldDeclaration.GetAsCode: String;
begin
- Result := GetIndentionString + Name + ': ' + &Type.AsCode + ';';
+ Result := GetIndentionString + Escape(Name) + ': ' + &Type.AsCode + ';';
if Nullable then
Result += ' // nullable';
@@ -599,7 +630,7 @@ function TConstructorDeclaration.GetAsCode: String;
function TIndexDeclaration.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TIndexDeclaration.GetAsCode');
end;
@@ -635,7 +666,7 @@ function TCallbackDeclaration.GetAsCode: String;
function TFunctionParameter.GetAsCode: String;
begin
- Result := Name + ': ';
+ Result := Escape(Name) + ': ';
if Assigned(&Type) then
Result += &Type.AsCode
else
@@ -677,7 +708,7 @@ function TObjectType.GetAsCode: String;
function TImportDeclaration.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TImportDeclaration.GetAsCode');
end;
@@ -685,7 +716,7 @@ function TImportDeclaration.GetAsCode: String;
function TVariableDeclaration.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TVariableDeclaration.GetAsCode');
end;
@@ -733,11 +764,27 @@ function TModuleDeclaration.GetAsCode: String;
+{ TParameter }
+
+function TParameter.GetAsCode: String;
+begin
+ Result := Name + ': ' + &Type.AsCode;
+ if DefaultValue <> '' then
+ Result += ' = ' + DefaultValue;
+end;
+
+
{ TCallSignature }
function TCallSignature.GetAsCode: String;
begin
+ Result := '(';
+ for var Parameter in ParameterList do
+ Result += Parameter.AsCode;
+ Result += ')';
+ if Assigned(&Type) then
+ Result += ': ' + &Type.AsCode;
end;
@@ -745,7 +792,7 @@ function TCallSignature.GetAsCode: String;
function TAmbientBinding.GetAsCode: String;
begin
-
+ Result := Name + ': ' + &Type.AsCode;
end;
@@ -753,9 +800,11 @@ function TAmbientBinding.GetAsCode: String;
function TAmbientVariableDeclaration.GetAsCode: String;
begin
- Result := if IsConst then 'const ' else 'var ';
+ Result := if IsConst then 'const' else 'var';
+ Result += ' ';
for var AmbientBinding in AmbientBindingList do
Result += AmbientBinding.AsCode;
+ Result += ';' + CRLF;
end;
@@ -763,7 +812,9 @@ function TAmbientVariableDeclaration.GetAsCode: String;
function TAmbientFunctionDeclaration.GetAsCode: String;
begin
- //Result := &Type.AsCode;
+ Result := if Assigned(CallSignature.&Type) then 'function' else 'procedure';
+ Result += ' ' + Name + CallSignature.AsCode;
+ Result += ';' + CRLF;
end;
@@ -771,7 +822,22 @@ function TAmbientFunctionDeclaration.GetAsCode: String;
function TAmbientModuleDeclaration.GetAsCode: String;
begin
- //Result := &Type.AsCode;
+ Result := '//' + IdentifierPath + CRLF + CRLF;
+// property IdentifierPath: String;
+ for var Variable in Variables do
+ Result += Variable.AsCode;
+
+ for var &Function in Functions do
+ Result += &Function.AsCode;
+
+ for var &Class in Classes do
+ Result += &Class.AsCode;
+
+ for var Module in Modules do
+ Result += Module.AsCode;
+
+ for var &Interface in Interfaces do
+ Result += Module.AsCode;
end;
@@ -779,28 +845,75 @@ function TAmbientModuleDeclaration.GetAsCode: String;
function TClassDeclaration.GetAsCode: String;
begin
+ Result := 'type' + CRLF;
+ BeginIndention;
+ Result += GetIndentionString + 'J' + Name + ' = class external ''' + Name + '''';
+ if Extends.Count > 0 then
+ begin
+ Result += '(';
+ Result += Extends[0].AsCode;
+ for var Index := Low(Extends) + 1 to High(Extends) do
+ Result += ', ' + Extends[Index].AsCode;
+ Result += ')';
+ end;
+ Result += CRLF;
+ BeginIndention;
+ for var Member in Members do
+ Result += Member.AsCode;
+ EndIndention;
+
+ Result += GetIndentionString + 'end;' + CRLF + CRLF;
+ EndIndention;
end;
{ TInterfaceDeclaration }
function TInterfaceDeclaration.GetAsCode: String;
begin
+ Result := 'type' + CRLF;
+ BeginIndention;
+ Result += GetIndentionString + Name + ' = class external';
+ if Extends.Count > 0 then
+ begin
+ Result += '(';
+ Result += Extends[0].AsCode;
+ for var Index := Low(Extends) + 1 to High(Extends) do
+ Result += ', ' + Extends[Index].AsCode;
+ Result += ')';
+ end;
+ Result += CRLF;
+ Result += &Type.AsCode;
+ EndIndention;
end;
{ TTypeParameter }
function TTypeParameter.GetAsCode: String;
begin
-
+ Console.Log('not implemented: TTypeParameter.GetAsCode');
end;
{ TTypeArgument }
function TTypeArgument.GetAsCode: String;
begin
+ Console.Log('not implemented: TTypeArgument.GetAsCode');
+end;
+
+{ TTypeReference }
+function TTypeReference.GetAsCode: String;
+begin
+ Result := Name;
+ if Arguments.Length > 0 then
+ begin
+ Result += ' {' + Arguments[0].AsCode;
+ for var Index := Low(Arguments) + 1 to High(Arguments) do
+ Result += ', ' + Arguments[Index].AsCode;
+ Result += '} ';
+ end;
end;
end.
diff --git a/src/ts2pas.Translator.pas b/src/ts2pas.Translator.pas
index 74d7f3e..e91fb91 100644
--- a/src/ts2pas.Translator.pas
+++ b/src/ts2pas.Translator.pas
@@ -341,7 +341,7 @@ function TTranslator.ReadPrimaryType: TCustomType;
end;
TSyntaxKind.StringLiteral:
begin
- Result := TNamedType.Create(Self as IDeclarationOwner, CurrentTokenText);
+ Result := TNamedType.Create(Self as IDeclarationOwner, FScanner.getTokenValue);
ReadToken;
end;
TSyntaxKind.AnyKeyword:
@@ -888,7 +888,8 @@ function TTranslator.ReadParameter: TParameter;
TSyntaxKind.ProtectedKeyword, TSyntaxKind.DotDotDotToken]);
// create parameter
- Result := TParameter.Create;
+ Result := TParameter.Create(Self as IDeclarationOwner);
+ Result.Name := CurrentTokenText;
Result.IsRest := CurrentToken = TSyntaxKind.DotDotDotToken;
if Result.IsRest then
@@ -896,7 +897,7 @@ function TTranslator.ReadParameter: TParameter;
// handle rest parameter
ReadIdentifier(True);
- Result.BindingIdentifier := CurrentTokenText;
+ Result.Name := CurrentTokenText;
// the next token must be a colon
if ReadToken(TSyntaxKind.ColonToken) then
@@ -1120,7 +1121,7 @@ function TTranslator.ReadAmbientBinding: TAmbientBinding;
ReadIdentifier(True);
Result := TAmbientBinding.Create(Self as IDeclarationOwner);
- Result.BindingIdentifier := CurrentTokenText;
+ Result.Name := CurrentTokenText;
// eventually read type
if ReadToken(TSyntaxKind.ColonToken) then
@@ -1141,7 +1142,7 @@ function TTranslator.ReadAmbientFunctionDeclaration: TAmbientFunctionDeclaration
// read function name
ReadIdentifier(True);
- Result.BindingIdentifier := CurrentTokenText;
+ Result.Name := CurrentTokenText;
// now read
Result.CallSignature := ReadCallSignature;
@@ -1162,7 +1163,7 @@ function TTranslator.ReadAmbientClassMember: TCustomTypeMember;
else
begin
// create a interface member
- var MemberName := CurrentTokenText;
+ var MemberName := FScanner.getTokenValue;
ReadToken([TSyntaxKind.LessThanToken, TSyntaxKind.QuestionToken,
TSyntaxKind.ColonToken, TSyntaxKind.OpenParenToken], True);
@@ -1310,7 +1311,7 @@ function TTranslator.ReadAmbientModuleDeclaration: TAmbientModuleDeclaration;
ReadIdentifier([TSyntaxKind.StringLiteral], True);
Result.IdentifierPath := ReadIdentifierPath;
- {$IFDEF DEBUG} Console.Log('Read module: ' + Result.IdentifierPath); {$ENDIF}
+ {$IFDEF DEBUG} Console.Log('Read ambient module: ' + Result.IdentifierPath); {$ENDIF}
// ensure that the next token is an open brace
AssumeToken(TSyntaxKind.OpenBraceToken);
@@ -1421,14 +1422,14 @@ function TTranslator.BuildPascalHeader: String;
Result := 'unit ' + Name + ';' + CRLF + CRLF;
Result += 'interface' + CRLF + CRLF;
- for var Declaration in FDeclarations do
- Result := Result + Declaration.AsCode;
-
for var Module in FModules do
Result := Result + Module.AsCode;
for var &Interface in FInterfaces do
Result := Result + &Interface.AsCode;
+
+ for var Declaration in FDeclarations do
+ Result := Result + Declaration.AsCode;
end;
function TTranslator.Translate(Source: String): String;
diff --git a/src/ts2pas.spr b/src/ts2pas.spr
index b08a417..37489f0 100644
--- a/src/ts2pas.spr
+++ b/src/ts2pas.spr
@@ -4,11 +4,8 @@ uses
var userArgs := Process.argv;
userArgs.Delete(0, 2);
-if userArgs.Length = 0 then
-begin
- asm
- return "Usage: ts2pas inputfile [outputfile]";
- end;
+if userArgs.Length = 0 then asm
+ return "Usage: ts2pas inputfile [outputfile]";
end;
var InputFile := userArgs[0];
@@ -17,20 +14,3 @@ if userArgs.length = 2 then
OutputFile := userArgs[1];
ConvertFile(inputFile, outputfile);
-
-(*
-ConvertFile('TypeScriptDefs\abs');
-ConvertFile('TypeScriptDefs\absolute');
-ConvertFile('TypeScriptDefs\accounting');
-ConvertFile('TypeScriptDefs\acc-wizard');
-ConvertFile('TypeScriptDefs\AmCharts');
-ConvertFile('TypeScriptDefs\amplifyjs');
-ConvertFile('TypeScriptDefs\amazon-product-api');
-ConvertFile('TypeScriptDefs\dijit');
-*)
-//ConvertFile('TypeScriptDefs\ExtJS');
-//ConvertFile('TypeScriptDefs\node');
-// ConvertFile('TypeScriptDefs\flot');
-// ConvertFile('TypeScriptDefs\box2dweb');
-//ConvertFile('TypeScriptDefs\angular');
-//ConvertFile('TypeScriptDefs\typescript');
diff --git a/src/ts2pas.sproj b/src/ts2pas.sproj
index 304ae20..647b448 100644
--- a/src/ts2pas.sproj
+++ b/src/ts2pas.sproj
@@ -2,7 +2,7 @@
ts2pas
T00:00:00.000
- 2016-01-23T01:45:58.596
+ 2016-01-23T03:22:14.712
Christian-W. Budde
TypeScript to Object Pascal translator
TypeScript, Object Pascal
@@ -36,7 +36,7 @@
- 0
+ 1
0
0
0
@@ -47,7 +47,7 @@
0
1
0
- 0
+ 1
0
0
@@ -90,7 +90,7 @@
ts2pas
2016-01-10T13:59:49.570Z
- 2016-01-23T01:45:58.594
+ 2016-01-23T01:51:35.960
ts2pas.spr
@@ -102,7 +102,7 @@
ts2pas.Declarations
2016-01-11T22:20:28.821Z
- 2016-01-22T23:27:17.488
+ 2016-01-23T01:49:15.569
ts2pas.Declarations.pas
@@ -115,10 +115,10 @@
Node.js
Node.js Project
- 12318
- 05:53:41.320
- 00:15:50.224
- 02:01:54.675
+ 12355
+ 05:54:10.749
+ 00:16:00.419
+ 02:12:20.141
00:00:00.000
00:00:00.000
diff --git a/ts2pas.js b/ts2pas.js
index caa3ca3..5b372cf 100644
--- a/ts2pas.js
+++ b/ts2pas.js
@@ -7,2071 +7,120 @@
* Licensed under the MIT license.
*/
-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 () { var FMessage="" },
- Create: function (s,Msg) { s.FMessage=Msg; return s }
-}
-function stringRepeat(s, n) {
- if (n<1) return '';
- var r = '';
- while (n > 0) {
- if (n & 1) r += s;
- n >>= 1, s += s;
- };
- return r;
-};
-function DupeString(s,n) { return stringRepeat(s,n) }
-function $W(e) { return e.ClassType?e:Exception.Create($New(Exception),e.constructor.name+", "+e.message) }
-function $New(c) { var i={ClassType:c}; c.$Init(i); return i }
-function $Is(o,c) {
- if (o===null) return false;
- return $Inh(o.ClassType,c);
-}
-;
-function $Inh(s,c) {
- if (s===null) return false;
- while ((s)&&(s!==c)) s=s.$Parent;
- return (s)?true:false;
-}
-;
-function $Extend(base, sub, props) {
- function F() {};
- F.prototype = base.prototype;
- sub.prototype = new F();
- sub.prototype.constructor = sub;
- for (var n in props) {
- if (props.hasOwnProperty(n)) {
- sub.prototype[n]=props[n];
- }
- }
-}
-function $AsIntf(o,i) {
- if (o===null) return null;
- var r = o.ClassType.$Intf[i].map(function (e) {
- return function () {
- var arg=Array.prototype.slice.call(arguments);
- arg.splice(0,0,o);
- return e.apply(o, arg);
- }
- });
- r.O = o;
- return r;
-}
-;
-function $As(o,c) {
- if ((o===null)||$Is(o,c)) return o;
- throw Exception.Create($New(Exception),"Cannot cast instance of type \""+o.ClassType.$ClassName+"\" to class \""+c.$ClassName+"\"");
-}
-function JError() {
-}
-$Extend(Object,JError,
- {
- });
-
-function Copy$TwriteFileSyncOptions(s,d) {
- d.encoding=s.encoding;
- d.mode=s.mode;
- d.flag=s.flag;
- return d;
-}
-function Clone$TwriteFileSyncOptions($) {
- return {
- encoding:$.encoding,
- mode:$.mode,
- flag:$.flag
- }
-}
-function Copy$TwriteFileOptions(s,d) {
- d.encoding=s.encoding;
- d.mode=s.mode;
- d.flag=s.flag;
- return d;
-}
-function Clone$TwriteFileOptions($) {
- return {
- encoding:$.encoding,
- mode:$.mode,
- flag:$.flag
- }
-}
-function Copy$TwatchOptions(s,d) {
- d.persistent=s.persistent;
- return d;
-}
-function Clone$TwatchOptions($) {
- return {
- persistent:$.persistent
- }
-}
-function Copy$TwatchFile_listener_object_fs(s,d) {
- d.curr=s.curr;
- d.prev=s.prev;
- return d;
-}
-function Clone$TwatchFile_listener_object_fs($) {
- return {
- curr:$.curr,
- prev:$.prev
- }
-}
-function Copy$TwatchFile_listener_object(s,d) {
- d.curr=s.curr;
- d.prev=s.prev;
- return d;
-}
-function Clone$TwatchFile_listener_object($) {
- return {
- curr:$.curr,
- prev:$.prev
- }
-}
-function Copy$TwatchFileOptions(s,d) {
- d.persistent=s.persistent;
- d.interval=s.interval;
- return d;
-}
-function Clone$TwatchFileOptions($) {
- return {
- persistent:$.persistent,
- interval:$.interval
- }
-}
-function Copy$TreadFileSyncOptions(s,d) {
- d.encoding=s.encoding;
- d.flag=s.flag;
- return d;
-}
-function Clone$TreadFileSyncOptions($) {
- return {
- encoding:$.encoding,
- flag:$.flag
- }
-}
-function Copy$TReadFileOptions(s,d) {
- d.encoding=s.encoding;
- d.flag=s.flag;
- return d;
-}
-function Clone$TReadFileOptions($) {
- return {
- encoding:$.encoding,
- flag:$.flag
- }
-}
-function Copy$TcreateWriteStreamOptions(s,d) {
- d.flags=s.flags;
- d.encoding=s.encoding;
- d.string_=s.string_;
- return d;
-}
-function Clone$TcreateWriteStreamOptions($) {
- return {
- flags:$.flags,
- encoding:$.encoding,
- string_:$.string_
- }
-}
-function Copy$TcreateReadStreamOptions(s,d) {
- d.bufferSize=s.bufferSize;
- d.encoding=s.encoding;
- d.fd=s.fd;
- d.mode=s.mode;
- d.flags=s.flags;
- return d;
-}
-function Clone$TcreateReadStreamOptions($) {
- return {
- bufferSize:$.bufferSize,
- encoding:$.encoding,
- fd:$.fd,
- mode:$.mode,
- flags:$.flags
- }
-}
-function Copy$TappendFileSyncOptions(s,d) {
- d.encoding=s.encoding;
- d.mode=s.mode;
- d.flag=s.flag;
- return d;
-}
-function Clone$TappendFileSyncOptions($) {
- return {
- encoding:$.encoding,
- mode:$.mode,
- flag:$.flag
- }
-}
-function Copy$TappendFileOptions(s,d) {
- d.encoding=s.encoding;
- d.mode=s.mode;
- d.flag=s.flag;
- return d;
-}
-function Clone$TappendFileOptions($) {
- return {
- encoding:$.encoding,
- mode:$.mode,
- flag:$.flag
- }
-}
-function fs() {
- var Result = null;
- Result = require("fs");
- return Result
-};
-function stream() {
- var Result = null;
- Result = require("stream");
- return Result
-};
-function events() {
- var Result = null;
- Result = require("events");
- return Result
-};
-var TTranslator = {
- $ClassName:"TTranslator",$Parent:TObject
- ,$Init:function ($) {
- TObject.$Init($);
- $.NeedsSemicolon = false;
- $.Name = "";
- $.FDeclarations = [];
- $.FInterfaces = [];
- $.FModules = [];
- $.FScanner = $.FSourceFile = null;
- }
- ,a$2:function(Self) {
- return Self.FScanner.getTokenText();
- }
- ,a$1:function(Self) {
- return Self.FScanner.getToken();
- }
- ,AssumeIdentifier:function(Self, AdditionalToken) {
- if (!(Self.FScanner.isIdentifier()||AdditionalToken.indexOf(TTranslator.a$1(Self))>=0)) {
- TTranslator.HandleScanError(Self,0);
- }
- }
- ,AssumeToken$1:function(Self, Tokens) {
- if (!(Tokens.indexOf(TTranslator.a$1(Self))>=0)) {
- TTranslator.HandleScanError(Self,0);
- }
- }
- ,AssumeToken:function(Self, Token) {
- if (TTranslator.a$1(Self)!=Token) {
- TTranslator.HandleScanError(Self,Token);
- }
- }
- ,BuildPascalHeader:function(Self) {
- var Result = "";
- var a$125 = 0;
- var Declaration = null,
- a$126 = 0;
- var Module$1 = null,
- a$127 = 0;
- var Interface = null;
- var a$128 = [],
- a$129 = [],
- a$130 = [];
- Result = "unit "+Self.Name+";"+"\r\n"+"\r\n";
- Result+="interface"+"\r\n"+"\r\n";
- a$130 = Self.FDeclarations;
- var $temp1;
- for(a$125=0,$temp1=a$130.length;a$125<$temp1;a$125++) {
- Declaration = a$130[a$125];
- Result = Result+TCustomDeclaration.GetAsCode$(Declaration);
- }
- a$129 = Self.FModules;
- var $temp2;
- for(a$126=0,$temp2=a$129.length;a$126<$temp2;a$126++) {
- Module$1 = a$129[a$126];
- Result = Result+TCustomDeclaration.GetAsCode$(Module$1);
- }
- a$128 = Self.FInterfaces;
- var $temp3;
- for(a$127=0,$temp3=a$128.length;a$127<$temp3;a$127++) {
- Interface = a$128[a$127];
- Result = Result+TCustomDeclaration.GetAsCode$(Interface);
- }
- return Result
- }
- ,Create$3:function(Self) {
- Self.NeedsSemicolon = false;
- return Self
- }
- ,HandleScanError:function(Self, Expected) {
- var LineChar = null,
- Text$1 = "";
- LineChar = TypeScriptExport.getLineAndCharacterOfPosition(Self.FSourceFile,Self.FScanner.getTokenPos());
- Text$1 = ("Unknown token \""+TTranslator.a$2(Self).toString()+"\" in this context ("+(LineChar.line+1).toString()+":"+(LineChar.character+1).toString()+")");
- if (Expected>0) {
- Text$1+=("; Expected ("+Expected.toString()+")");
- }
- console.trace("");
- throw Exception.Create($New(Exception),Text$1);
- }
- ,ReadAmbientBinding:function(Self) {
- var Result = null;
- TTranslator.ReadIdentifier(Self,true);
- Result = TCustomDeclaration.Create$4$($New(TAmbientBinding),$AsIntf(Self,"IDeclarationOwner"));
- Result.BindingIdentifier = TTranslator.a$2(Self);
- if (TTranslator.ReadToken$1(Self,54,false)) {
- Result.Type = TTranslator.ReadTypeAnnotation(Self);
- }
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeToken$1(Self,[23, 24].slice());
- }
- return Result
- }
- ,ReadAmbientClassDeclaration:function(Self) {
- var Result = null;
- var ClassElementTokens = [],
- Visibility$1 = 0,
- IsStatic$1 = false,
- Member = null;
- TTranslator.AssumeToken(Self,73);
- Result = TCustomDeclaration.Create$4$($New(TAmbientClassDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[83, 106, 15].slice(),true);
- if (TTranslator.a$1(Self)==83) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Extends.push(TTranslator.ReadTypeReference(Self));
- }
- if (TTranslator.a$1(Self)==106) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Implements.push(TTranslator.ReadIdentifierPath(Self));
- while (TTranslator.a$1(Self)==24) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Implements.push(TTranslator.ReadIdentifierPath(Self));
- }
- }
- TTranslator.AssumeToken(Self,15);
- ClassElementTokens.push(92, 9, 82, 16, 23);
- TTranslator.ReadIdentifier$1(Self,ClassElementTokens,false);
- while (TTranslator.a$1(Self)!=16) {
- Visibility$1 = 0;
- switch (TTranslator.a$1(Self)) {
- case 112 :
- Visibility$1 = 0;
- TTranslator.ReadIdentifier$1(Self,[92].slice(),true);
- break;
- case 111 :
- Visibility$1 = 1;
- TTranslator.ReadIdentifier$1(Self,[92].slice(),true);
- break;
- case 110 :
- Visibility$1 = 2;
- TTranslator.ReadIdentifier$1(Self,[92].slice(),true);
- break;
- }
- IsStatic$1 = TTranslator.a$1(Self)==113;
- if (IsStatic$1) {
- TTranslator.ReadIdentifier$1(Self,[92, 17].slice(),true);
- }
- Member = TTranslator.ReadAmbientClassMember(Self);
- Member.Visibility = Visibility$1;
- Member.IsStatic = IsStatic$1;
- Result.Members.push(Member);
- if (TTranslator.a$1(Self)==23) {
- TTranslator.ReadIdentifier$1(Self,ClassElementTokens,false);
- }
- }
- TTranslator.AssumeToken(Self,16);
- return Result
- }
- ,ReadAmbientClassMember:function(Self) {
- var Result = null;
- var MemberName = "",
- Nullable$2 = false;
- TTranslator.AssumeIdentifier(Self,[92, 17, 9, 82].slice());
- if (TTranslator.a$1(Self)==17) {
- Result = TTranslator.ReadCallbackInterface(Self);
- } else {
- MemberName = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[25, 53, 54, 17].slice(),true);
- if (TTranslator.a$1(Self)==25) {
- TTranslator.ReadTypeParameter(Self);
- TTranslator.ReadToken$2(Self,[53, 54, 17].slice(),true);
- }
- Nullable$2 = TTranslator.a$1(Self)==53;
- if (Nullable$2) {
- TTranslator.ReadToken$1(Self,54,true);
- }
- switch (TTranslator.a$1(Self)) {
- case 54 :
- Result = TTranslator.ReadFieldDeclaration(Self);
- $As(Result,TFieldDeclaration).Nullable = Nullable$2;
- break;
- case 17 :
- if ((MemberName).toLowerCase()=="constructor") {
- Result = TTranslator.ReadConstructorDeclaration(Self);
- } else {
- Result = TTranslator.ReadMethodDeclaration(Self);
- }
- break;
- }
- Result.Name = MemberName;
- }
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeToken$1(Self,[23, 24, 16].slice());
- }
- return Result
- }
- ,ReadAmbientDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,122);
- Result = TCustomDeclaration.Create$4$($New(TAmbientDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadToken$2(Self,[102, 108, 74, 87, 73, 81, 125, 126].slice(),true);
- switch (TTranslator.a$1(Self)) {
- case 102 :
- case 108 :
- case 74 :
- Result.Variables.push(TTranslator.ReadAmbientVariableDeclaration(Self));
- break;
- case 87 :
- Result.Functions.push(TTranslator.ReadAmbientFunctionDeclaration(Self));
- break;
- case 73 :
- Result.Classes.push(TTranslator.ReadAmbientClassDeclaration(Self));
- break;
- case 81 :
- Result.Enums.push(TTranslator.ReadAmbientEnumDeclaration(Self));
- break;
- case 125 :
- Result.Modules.push(TTranslator.ReadAmbientModuleDeclaration(Self));
- break;
- case 126 :
- Result.Namespaces.push(TTranslator.ReadAmbientNamespaceDeclaration(Self));
- break;
- }
- return Result
- }
- ,ReadAmbientEnumDeclaration:function(Self) {
- var Result = null;
- return Result
- }
- ,ReadAmbientFunctionDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,87);
- Result = TCustomDeclaration.Create$4$($New(TAmbientFunctionDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.BindingIdentifier = TTranslator.a$2(Self);
- Result.CallSignature = TTranslator.ReadCallSignature(Self);
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeToken$1(Self,[23].slice());
- }
- return Result
- }
- ,ReadAmbientModuleDeclaration:function(Self) {
- var Result = null;
- var ModuleTokens = [],
- ModuleTokens = [82, 102, 87, 73, 107, 81, 125, 89, 16, 23].slice();
- var IsExport = false;
- TTranslator.AssumeToken(Self,125);
- Result = TCustomDeclaration.Create$4$($New(TAmbientModuleDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier$1(Self,[9].slice(),true);
- Result.IdentifierPath = TTranslator.ReadIdentifierPath(Self);
- TTranslator.AssumeToken(Self,15);
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- while (TTranslator.a$1(Self)!=16) {
- IsExport = TTranslator.a$1(Self)==82;
- if (IsExport) {
- TTranslator.ReadToken$2(Self,ModuleTokens.concat([77, 56]),true);
- if (TTranslator.a$1(Self)==77) {
- IsExport = false;
- TTranslator.ReadIdentifier(Self,false);
- TTranslator.ReadToken$1(Self,23,false);
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- }
- if (TTranslator.a$1(Self)==56) {
- IsExport = false;
- TTranslator.ReadIdentifier(Self,false);
- TTranslator.ReadToken$1(Self,23,false);
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- }
- }
- switch (TTranslator.a$1(Self)) {
- case 102 :
- Result.Variables.push(TTranslator.ReadAmbientVariableDeclaration(Self));
- break;
- case 87 :
- Result.Functions.push(TTranslator.ReadAmbientFunctionDeclaration(Self));
- break;
- case 73 :
- Result.Classes.push(TTranslator.ReadAmbientClassDeclaration(Self));
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- break;
- case 125 :
- Result.Modules.push(TTranslator.ReadAmbientModuleDeclaration(Self));
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- break;
- case 107 :
- Result.Interfaces.push(TTranslator.ReadInterfaceDeclaration(Self));
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- break;
- case 89 :
- TTranslator.ReadImportDeclaration(Self);
- if (!Self.NeedsSemicolon) {
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- }
- break;
- }
- if (TTranslator.a$1(Self)==23) {
- TTranslator.ReadToken$2(Self,ModuleTokens,true);
- }
- }
- TTranslator.AssumeToken(Self,16);
- return Result
- }
- ,ReadAmbientNamespaceDeclaration:function(Self) {
- var Result = null;
- return Result
- }
- ,ReadAmbientVariableDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken$1(Self,[102, 108, 74].slice());
- Result = TCustomDeclaration.Create$4$($New(TAmbientVariableDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- Result.IsConst = TTranslator.a$1(Self)==74;
- do {
- Result.AmbientBindingList.push(TTranslator.ReadAmbientBinding(Self));
- } while (!(TTranslator.a$1(Self)==23||(!Self.NeedsSemicolon)&&(!Self.FScanner.isIdentifier())));
- return Result
- }
- ,ReadCallbackInterface:function(Self) {
- var Result = null;
- Result = TCustomDeclaration.Create$4$($New(TCallbackDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- Result.Type = TTranslator.ReadFunctionType(Self);
- TTranslator.AssumeToken$1(Self,[23, 16].slice());
- return Result
- }
- ,ReadCallSignature:function(Self) {
- var Result = null;
- Result = TCustomDeclaration.Create$4$($New(TCallSignature),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadToken$2(Self,[17, 25].slice(),true);
- if (TTranslator.a$1(Self)==25) {
- TTranslator.ReadTypeParameter(Self);
- TTranslator.ReadToken$1(Self,17,true);
- }
- TTranslator.AssumeToken(Self,17);
- TTranslator.ReadIdentifier$1(Self,[112, 110, 111, 22, 18].slice(),true);
- while (TTranslator.a$1(Self)!=18) {
- Result.ParameterList.push(TTranslator.ReadParameter(Self));
- if (TTranslator.a$1(Self)==24) {
- TTranslator.ReadIdentifier$1(Self,[22].slice(),false);
- }
- }
- TTranslator.AssumeToken$1(Self,[18].slice());
- TTranslator.ReadToken$2(Self,[54, 23].slice(),true);
- if (TTranslator.a$1(Self)==54) {
- Result.Type = TTranslator.ReadType(Self);
- }
- return Result
- }
- ,ReadClassDeclaration:function(Self) {
- var Result = null;
- var ClassElementTokens$1 = [],
- Visibility$2 = 0,
- IsStatic$2 = false,
- Member$1 = null;
- TTranslator.AssumeToken(Self,73);
- Result = TCustomDeclaration.Create$4$($New(TClassDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- console.log("Read class: "+Result.Name);
- TTranslator.ReadToken$2(Self,[83, 106, 15].slice(),true);
- if (TTranslator.a$1(Self)==83) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Extends.push(TTranslator.ReadTypeReference(Self));
- }
- if (TTranslator.a$1(Self)==106) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Implements.push(TTranslator.ReadIdentifierPath(Self));
- while (TTranslator.a$1(Self)==24) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Implements.push(TTranslator.ReadIdentifierPath(Self));
- }
- }
- TTranslator.AssumeToken(Self,15);
- TTranslator.AssumeToken(Self,15);
- ClassElementTokens$1.push(92, 9, 82, 16, 23);
- TTranslator.ReadIdentifier$1(Self,ClassElementTokens$1,false);
- while (TTranslator.a$1(Self)!=16) {
- Visibility$2 = 0;
- switch (TTranslator.a$1(Self)) {
- case 112 :
- Visibility$2 = 0;
- TTranslator.ReadIdentifier$1(Self,[92].slice(),true);
- break;
- case 111 :
- Visibility$2 = 1;
- TTranslator.ReadIdentifier$1(Self,[92].slice(),true);
- break;
- case 110 :
- Visibility$2 = 2;
- TTranslator.ReadIdentifier$1(Self,[92].slice(),true);
- break;
- }
- IsStatic$2 = TTranslator.a$1(Self)==113;
- if (IsStatic$2) {
- TTranslator.ReadIdentifier$1(Self,[92, 17].slice(),true);
- }
- Member$1 = TTranslator.ReadAmbientClassMember(Self);
- Member$1.Visibility = Visibility$2;
- Member$1.IsStatic = IsStatic$2;
- Result.Members.push(Member$1);
- if (TTranslator.a$1(Self)==23) {
- TTranslator.ReadIdentifier$1(Self,ClassElementTokens$1,false);
- }
- }
- return Result
- }
- ,ReadClassMember:function(Self) {
- var Result = null;
- var MemberName$1 = "",
- Nullable$3 = false;
- TTranslator.AssumeIdentifier(Self,[92, 17, 9, 82].slice());
- if (TTranslator.a$1(Self)==17) {
- Result = TTranslator.ReadCallbackInterface(Self);
- } else {
- MemberName$1 = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[25, 53, 54, 17].slice(),true);
- if (TTranslator.a$1(Self)==25) {
- TTranslator.ReadTypeParameter(Self);
- TTranslator.ReadToken$2(Self,[53, 54, 17].slice(),true);
- }
- Nullable$3 = TTranslator.a$1(Self)==53;
- if (Nullable$3) {
- TTranslator.ReadToken$1(Self,54,true);
- }
- switch (TTranslator.a$1(Self)) {
- case 54 :
- Result = TTranslator.ReadFieldDeclaration(Self);
- $As(Result,TFieldDeclaration).Nullable = Nullable$3;
- break;
- case 17 :
- if ((MemberName$1).toLowerCase()=="constructor") {
- Result = TTranslator.ReadConstructorDeclaration(Self);
- } else {
- Result = TTranslator.ReadMethodDeclaration(Self);
- }
- break;
- }
- Result.Name = MemberName$1;
- }
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeToken$1(Self,[23, 24, 16].slice());
- }
- return Result
- }
- ,ReadConstructorDeclaration:function(Self) {
- var Result = null;
- Result = TCustomDeclaration.Create$4$($New(TConstructorDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- Result.Type = TTranslator.ReadFunctionType(Self);
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeToken$1(Self,[23, 16].slice());
- }
- return Result
- }
- ,ReadConstructorSignature:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,92);
- Result = TCustomDeclaration.Create$4$($New(TConstructorDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- if (TTranslator.ReadIdentifier(Self,false)) {
- TTranslator.ReadToken$1(Self,17,false);
- }
- TTranslator.AssumeToken(Self,17);
- TTranslator.ReadIdentifier$1(Self,[112, 110, 111, 22, 18].slice(),true);
- while (TTranslator.a$1(Self)!=18) {
- Result.ParameterList.push(TTranslator.ReadParameter(Self));
- if (TTranslator.a$1(Self)==24) {
- TTranslator.ReadIdentifier$1(Self,[22].slice(),false);
- }
- }
- TTranslator.AssumeToken(Self,18);
- TTranslator.ReadToken$1(Self,54,true);
- Result.Type = TTranslator.ReadTypeAnnotation(Self);
- return Result
- }
- ,ReadDefinition:function(Self) {
- while (TTranslator.ReadToken$2(Self,[82, 122, 107, 125, 89, 1].slice(),true)) {
- {var $temp4 = TTranslator.a$1(Self);
- if ($temp4==82) {
- continue;
- }
- else if ($temp4==122) {
- Self.FDeclarations.push(TTranslator.ReadAmbientDeclaration(Self));
- }
- else if ($temp4==107) {
- Self.FInterfaces.push(TTranslator.ReadInterfaceDeclaration(Self));
- }
- else if ($temp4==125) {
- Self.FModules.push(TTranslator.ReadModuleDeclaration(Self));
- }
- else if ($temp4==89) {
- TTranslator.ReadImportDeclaration(Self) }
- else if ($temp4==1) {
- break;
- }
- }
- }
- }
- ,ReadEnumerationDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,81);
- Result = TCustomDeclaration.Create$4$($New(TEnumerationDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$1(Self,15,true);
- TTranslator.ReadIdentifier(Self,true);
- do {
- Result.Items.push(TTranslator.ReadEnumerationItem(Self));
- } while (!(!TTranslator.ReadIdentifier(Self,false)));
- TTranslator.AssumeToken(Self,16);
- return Result
- }
- ,ReadEnumerationItem:function(Self) {
- var Result = null;
- TTranslator.AssumeIdentifier(Self,[]);
- Result = TCustomDeclaration.Create$4$($New(TEnumerationItem),$AsIntf(Self,"IDeclarationOwner"));
- Result.Name = TTranslator.a$2(Self);
- if (TTranslator.ReadToken$1(Self,56,false)) {
- TTranslator.ReadToken$1(Self,8,true);
- Result.Value = TTranslator.a$2(Self);
- TTranslator.ReadToken(Self);
- }
- TTranslator.AssumeToken(Self,24);
- return Result
- }
- ,ReadExportDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,82);
- Result = TCustomDeclaration.Create$4$($New(TExportDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier$1(Self,[77].slice(),true);
- Result.FDefault = TTranslator.a$1(Self)==82||(TTranslator.a$2(Self)).toLowerCase()=="default";
- if (Result.FDefault) {
- TTranslator.ReadIdentifier(Self,true);
- }
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$1(Self,23,true);
- return Result
- }
- ,ReadFieldDeclaration:function(Self) {
- var Result = null;
- Result = TCustomDeclaration.Create$4$($New(TFieldDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- Result.Type = TTranslator.ReadType(Self);
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeIdentifier(Self,[23, 16, 24].slice());
- }
- return Result
- }
- ,ReadFunctionDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,87);
- Result = TCustomDeclaration.Create$4$($New(TFunctionDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$1(Self,17,true);
- Result.Type = TTranslator.ReadFunctionType(Self);
- return Result
- }
- ,ReadFunctionParameter:function(Self) {
- var Result = null;
- var OpenArray = false;
- TTranslator.AssumeIdentifier(Self,[22].slice());
- OpenArray = TTranslator.a$1(Self)==22;
- if (OpenArray) {
- TTranslator.ReadIdentifier(Self,true);
- }
- Result = TCustomDeclaration.Create$4$($New(TFunctionParameter),$AsIntf(Self,"IDeclarationOwner"));
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[53, 54, 18].slice(),true);
- Result.Nullable = TTranslator.a$1(Self)==53;
- if (Result.Nullable) {
- TTranslator.ReadToken$2(Self,[54].slice(),true);
- }
- if (TTranslator.a$1(Self)==54) {
- Result.Type = TTranslator.ReadType(Self);
- }
- return Result
- }
- ,ReadFunctionType:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,17);
- Result = TCustomDeclaration.Create$4$($New(TFunctionType),$AsIntf(Self,"IDeclarationOwner"));
- while (TTranslator.ReadIdentifier$1(Self,[22].slice(),false)) {
- Result.Parameters.push(TTranslator.ReadFunctionParameter(Self));
- TTranslator.AssumeToken$1(Self,[24, 18, 23].slice());
- if (TTranslator.a$1(Self)==18) {
- break;
- }
- }
- TTranslator.AssumeToken$1(Self,[18, 23].slice());
- if (TTranslator.ReadToken$2(Self,[54, 34].slice(),false)) {
- Result.ResultType = TTranslator.ReadType(Self);
- }
- return Result
- }
- ,ReadIdentifier$1:function(Self, AdditionalToken$1, Required) {
- var Result = false;
- TTranslator.ReadToken(Self);
- Result = Self.FScanner.isIdentifier()||AdditionalToken$1.indexOf(TTranslator.a$1(Self))>=0;
- if ((!Result)&&Required) {
- TTranslator.HandleScanError(Self,0);
- }
- return Result
- }
- ,ReadIdentifier:function(Self, Required$1) {
- var Result = false;
- TTranslator.ReadToken(Self);
- Result = Self.FScanner.isIdentifier();
- if ((!Result)&&Required$1) {
- TTranslator.HandleScanError(Self,69);
- }
- return Result
- }
- ,ReadIdentifierPath:function(Self) {
- var Result = "";
- TTranslator.AssumeIdentifier(Self,[9].slice());
- Result = TTranslator.a$2(Self);
- while (TTranslator.ReadToken$1(Self,21,false)) {
- TTranslator.ReadIdentifier(Self,true);
- Result+="."+TTranslator.a$2(Self);
- }
- return Result
- }
- ,ReadImportDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,89);
- Result = TCustomDeclaration.Create$4$($New(TImportDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier$1(Self,[37].slice(),true);
- if (TTranslator.a$1(Self)==37) {
- TTranslator.ReadToken$1(Self,116,true);
- TTranslator.ReadIdentifier(Self,true);
- TTranslator.ReadToken$1(Self,133,true);
- TTranslator.ReadToken$1(Self,9,true);
- } else {
- TTranslator.ReadToken$1(Self,56,true);
- TTranslator.ReadIdentifier(Self,true);
- }
- if (Self.NeedsSemicolon) {
- TTranslator.ReadToken$1(Self,23,true);
- }
- return Result
- }
- ,ReadIndexSignature:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,19);
- Result = TCustomDeclaration.Create$4$($New(TIndexDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- TTranslator.ReadToken$1(Self,54,true);
- TTranslator.ReadToken$2(Self,[130, 128].slice(),true);
- Result.IsStringIndex = TTranslator.a$1(Self)==130;
- TTranslator.ReadToken$1(Self,20,true);
- TTranslator.ReadToken$1(Self,54,true);
- Result.Type = TTranslator.ReadTypeAnnotation(Self);
- return Result
- }
- ,ReadInterfaceDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,107);
- Result = TCustomDeclaration.Create$4$($New(TInterfaceDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[25, 83, 15].slice(),true);
- if (TTranslator.a$1(Self)==25) {
- TTranslator.ReadTypeParameter(Self);
- TTranslator.ReadToken$2(Self,[83, 15].slice(),true);
- }
- while (TTranslator.a$1(Self)==83) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Extends.push(TTranslator.ReadTypeReference(Self));
- while (TTranslator.a$1(Self)==24) {
- TTranslator.ReadIdentifier(Self,true);
- Result.Extends.push(TTranslator.ReadTypeReference(Self));
- }
- }
- TTranslator.AssumeToken(Self,15);
- Result.Type = TTranslator.ReadObjectType(Self);
- TTranslator.AssumeToken(Self,16);
- return Result
- }
- ,ReadMethodDeclaration:function(Self) {
- var Result = null;
- Result = TCustomDeclaration.Create$4$($New(TMethodDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- Result.Type = TTranslator.ReadFunctionType(Self);
- if (Self.NeedsSemicolon) {
- TTranslator.AssumeToken$1(Self,[23, 16].slice());
- }
- return Result
- }
- ,ReadModuleDeclaration:function(Self) {
- var Result = null;
- var ModuleTokens$1 = [],
- ModuleTokens$1 = [73, 82, 81, 89, 125, 87, 107, 102, 23].slice();
- TTranslator.AssumeToken(Self,125);
- Result = TCustomDeclaration.Create$4$($New(TModuleDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier$1(Self,[9].slice(),true);
- Result.Name = TTranslator.ReadIdentifierPath(Self);
- TTranslator.AssumeToken(Self,15);
- TTranslator.ReadToken$2(Self,ModuleTokens$1,true);
- while (TTranslator.a$1(Self)!=16) {
- switch (TTranslator.a$1(Self)) {
- case 73 :
- Result.Classes.push(TTranslator.ReadAmbientClassDeclaration(Self));
- break;
- case 82 :
- Result.Exports.push(TTranslator.ReadExportDeclaration(Self));
- break;
- case 81 :
- TTranslator.ReadEnumerationDeclaration(Self);
- break;
- case 87 :
- Result.Functions.push(TTranslator.ReadFunctionDeclaration(Self));
- break;
- case 89 :
- TTranslator.ReadImportDeclaration(Self);
- break;
- case 125 :
- Result.Modules.push(TTranslator.ReadModuleDeclaration(Self));
- break;
- case 107 :
- Result.Interfaces.push(TTranslator.ReadInterfaceDeclaration(Self));
- break;
- case 102 :
- Result.Variables.push(TTranslator.ReadVariableDeclaration(Self));
- break;
- }
- TTranslator.ReadToken$2(Self,ModuleTokens$1,true);
- }
- TTranslator.AssumeToken(Self,16);
- return Result
- }
- ,ReadObjectType:function(Self) {
- var Result = null;
- var ObjectTokens = [],
- ObjectTokens = [9, 8, 92, 17, 78, 19, 16].slice();
- TTranslator.AssumeToken(Self,15);
- Result = TCustomDeclaration.Create$4$($New(TObjectType),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier$1(Self,ObjectTokens,true);
- while (TTranslator.a$1(Self)!=16) {
- Result.Members.push(TTranslator.ReadTypeMember(Self));
- if (([23,24].indexOf(TTranslator.a$1(Self))>=0)) {
- TTranslator.ReadIdentifier$1(Self,ObjectTokens,true);
- }
- }
- TTranslator.AssumeToken(Self,16);
- return Result
- }
- ,ReadParameter:function(Self) {
- var Result = null;
- TTranslator.AssumeIdentifier(Self,[112, 110, 111, 22].slice());
- Result = TObject.Create($New(TParameter));
- Result.IsRest = TTranslator.a$1(Self)==22;
- if (Result.IsRest) {
- TTranslator.ReadIdentifier(Self,true);
- Result.BindingIdentifier = TTranslator.a$2(Self);
- if (TTranslator.ReadToken$1(Self,54,false)) {
- Result.Type = TTranslator.ReadTypeAnnotation(Self);
- }
- TTranslator.AssumeToken(Self,18);
- return Result;
- }
- TTranslator.AssumeIdentifier(Self,[112, 110, 111].slice());
- switch (TTranslator.a$1(Self)) {
- case 112 :
- Result.AccessibilityModifier = 0;
- TTranslator.ReadIdentifier(Self,false);
- break;
- case 110 :
- Result.AccessibilityModifier = 1;
- TTranslator.ReadIdentifier(Self,false);
- break;
- case 111 :
- Result.AccessibilityModifier = 2;
- TTranslator.ReadIdentifier(Self,false);
- break;
- }
- TTranslator.AssumeIdentifier(Self,[]);
- TTranslator.ReadToken$2(Self,[53, 54, 56, 24, 18].slice(),true);
- Result.IsOptional = TTranslator.a$1(Self)==53;
- if (Result.IsOptional) {
- TTranslator.ReadToken$2(Self,[54, 56, 24, 18].slice(),true);
- }
- if (TTranslator.a$1(Self)==54) {
- Result.Type = TTranslator.ReadType(Self);
- }
- TTranslator.AssumeToken$1(Self,[56, 24, 18].slice());
- if (TTranslator.a$1(Self)==56) {
- TTranslator.ReadIdentifier(Self,true);
- Result.DefaultValue = TTranslator.a$2(Self);
- }
- TTranslator.AssumeToken$1(Self,[24, 18].slice());
- return Result
- }
- ,ReadPrimaryType:function(Self) {
- var Result = null;
- var PrimaryTypeTokens = [],
- PrimaryTypeTokens = [69, 9, 117, 15, 128, 130, 120, 103, 101, 17].slice();
- var OldType = null;
- TTranslator.AssumeToken$1(Self,PrimaryTypeTokens);
- switch (TTranslator.a$1(Self)) {
- case 17 :
- Result = TTranslator.ReadType(Self);
- TTranslator.AssumeToken(Self,18);
- TTranslator.ReadToken(Self);
- break;
- case 69 :
- Result = TNamedType.Create$5($New(TNamedType),$AsIntf(Self,"IDeclarationOwner"),TTranslator.ReadIdentifierPath(Self));
- if (TTranslator.a$1(Self)==25) {
- $As(Result,TNamedType).Arguments.push(TTranslator.ReadTypeArgument(Self));
- TTranslator.ReadToken(Self);
- }
- break;
- case 9 :
- Result = TNamedType.Create$5($New(TNamedType),$AsIntf(Self,"IDeclarationOwner"),TTranslator.a$2(Self));
- TTranslator.ReadToken(Self);
- break;
- case 117 :
- Result = TCustomDeclaration.Create$4$($New(TVariantType),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadToken(Self);
- break;
- case 128 :
- Result = TCustomDeclaration.Create$4$($New(TFloatType),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadToken(Self);
- break;
- case 103 :
- Result = null;
- TTranslator.ReadToken(Self);
- break;
- case 101 :
- Result = TCustomDeclaration.Create$4$($New(TTypeOfType),$AsIntf(Self,"IDeclarationOwner"));
- $As(Result,TTypeOfType).Type = TTranslator.ReadType(Self);
- break;
- case 130 :
- Result = TCustomDeclaration.Create$4$($New(TStringType),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadToken(Self);
- break;
- case 120 :
- Result = TCustomDeclaration.Create$4$($New(TBooleanType),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadToken(Self);
- break;
- case 15 :
- Result = TTranslator.ReadObjectType(Self);
- TTranslator.ReadToken(Self);
- break;
- }
- while (TTranslator.a$1(Self)==19) {
- OldType = Result;
- Result = TCustomDeclaration.Create$4$($New(TArrayType),$AsIntf(Self,"IDeclarationOwner"));
- $As(Result,TArrayType).Type = OldType;
- TTranslator.ReadToken$1(Self,20,true);
- TTranslator.ReadToken(Self);
- }
- return Result
- }
- ,ReadToken$2:function(Self, Tokens$1, Required$2) {
- var Result = false;
- Result = Tokens$1.indexOf(TTranslator.ReadToken(Self))>=0;
- if ((!Result)&&Required$2) {
- TTranslator.HandleScanError(Self,0);
- }
- return Result
- }
- ,ReadToken$1:function(Self, Token$1, Required$3) {
- var Result = false;
- Result = TTranslator.ReadToken(Self)==Token$1;
- if ((!Result)&&Required$3) {
- TTranslator.HandleScanError(Self,Token$1);
- }
- return Result
- }
- ,ReadToken:function(Self) {
- var Result = 0;
- Result = Self.FScanner.scan();
- return Result
- }
- ,ReadType:function(Self) {
- var Result = null;
- var TypeTokens = [],
- OldType$1 = null;
- TypeTokens.push(69, 9, 117, 15, 128, 130, 120, 103, 101, 17);
- TTranslator.ReadToken$2(Self,TypeTokens,true);
- if (TTranslator.a$1(Self)==17) {
- return TTranslator.ReadFunctionType(Self);
- }
- Result = TTranslator.ReadPrimaryType(Self);
- while (TTranslator.a$1(Self)==47) {
- if (!$Is(Result,TUnionType)) {
- OldType$1 = Result;
- Result = TCustomDeclaration.Create$4$($New(TUnionType),$AsIntf(Self,"IDeclarationOwner"));
- $As(Result,TUnionType).Types.push(OldType$1);
- }
- TTranslator.ReadToken$2(Self,TypeTokens,true);
- $As(Result,TUnionType).Types.push(TTranslator.ReadPrimaryType(Self));
- }
- return Result
- }
- ,ReadTypeAnnotation:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,54);
- Result = TTranslator.ReadType(Self);
- return Result
- }
- ,ReadTypeArgument:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,25);
- Result = TCustomDeclaration.Create$4$($New(TTypeArgument),$AsIntf(Self,"IDeclarationOwner"));
- Result.Type = TTranslator.ReadType(Self);
- TTranslator.AssumeToken(Self,27);
- return Result
- }
- ,ReadTypeMember:function(Self) {
- var Result = null;
- var MemberName$2 = "",
- Nullable$4 = false;
- TTranslator.AssumeIdentifier(Self,[9, 8, 110, 92, 78, 17, 19].slice());
- if (TTranslator.a$1(Self)==92) {
- return TTranslator.ReadConstructorSignature(Self);
- }
- if (TTranslator.a$1(Self)==17) {
- return TTranslator.ReadCallbackInterface(Self);
- }
- if (TTranslator.a$1(Self)==19) {
- return TTranslator.ReadIndexSignature(Self);
- }
- if (Self.FScanner.isIdentifier()||([9,8,78].indexOf(Self.FScanner.getToken())>=0)) {
- MemberName$2 = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[53, 54, 17].slice(),true);
- Nullable$4 = TTranslator.a$1(Self)==53;
- if (Nullable$4) {
- TTranslator.ReadToken$1(Self,54,true);
- }
- switch (TTranslator.a$1(Self)) {
- case 54 :
- Result = TTranslator.ReadFieldDeclaration(Self);
- $As(Result,TFieldDeclaration).Nullable = Nullable$4;
- break;
- case 17 :
- Result = TTranslator.ReadMethodDeclaration(Self);
- break;
- }
- Result.Name = MemberName$2;
- }
- return Result
- }
- ,ReadTypeParameter:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,25);
- Result = TCustomDeclaration.Create$4$($New(TTypeParameter),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$2(Self,[83, 27].slice(),true);
- if (TTranslator.a$1(Self)==83) {
- Result.ExtendsType = TTranslator.ReadType(Self);
- TTranslator.AssumeToken(Self,27);
- }
- return Result
- }
- ,ReadTypeReference:function(Self) {
- var Result = null;
- TTranslator.AssumeIdentifier(Self,[]);
- Result = TCustomDeclaration.Create$4$($New(TTypeReference),$AsIntf(Self,"IDeclarationOwner"));
- Result.Name = TTranslator.ReadIdentifierPath(Self);
- return Result
- }
- ,ReadVariableDeclaration:function(Self) {
- var Result = null;
- TTranslator.AssumeToken(Self,102);
- Result = TCustomDeclaration.Create$4$($New(TVariableDeclaration),$AsIntf(Self,"IDeclarationOwner"));
- TTranslator.ReadIdentifier(Self,true);
- Result.Name = TTranslator.a$2(Self);
- TTranslator.ReadToken$1(Self,54,true);
- Result.Type = TTranslator.ReadType(Self);
- return Result
- }
- ,Translate:function(Self, Source) {
- var Result = "";
- Self.FScanner = TypeScriptExport.createScanner(0,true,0,Source);
- Self.FSourceFile = TypeScriptExport.createSourceFile("main",Source,0);
- try {
- TTranslator.ReadDefinition$(Self);
- } catch ($e) {
- var e = $W($e);
- console.error(e.FMessage);
- }
- Result = TTranslator.BuildPascalHeader$(Self);
- return Result
- }
- ,Destroy:TObject.Destroy
- ,BuildPascalHeader$:function($){return $.ClassType.BuildPascalHeader($)}
- ,ReadDefinition$:function($){return $.ClassType.ReadDefinition($)}
-};
-TTranslator.$Intf={
- IDeclarationOwner:[]
-}
-var TNodeFlags = { 1:"Export", 2:"Ambient", 4:"Public", 8:"Private", 16:"Protected", 32:"Static", 64:"Abstract", 128:"Async", 256:"Default", 512:"MultiLine", 1024:"Synthetic", 2048:"DeclarationFile", 4096:"Let", 8192:"Const", 16384:"OctalLiteral", 32768:"Namespace", 65536:"ExportContext", 131072:"ContainsThis" };
-var TJsxFlags = { 1:"None", 2:"IntrinsicNamedElement", 4:"IntrinsicIndexedElement", 8:"ClassElement", 16:"UnknownElement" };
-var TDiagnosticCategory = [ "Warning", "Error", "Message" ];
-var TVisibility = [ "vPublic", "vProtected", "vPrivate" ];
-var TCustomDeclaration = {
- $ClassName:"TCustomDeclaration",$Parent:TObject
- ,$Init:function ($) {
- TObject.$Init($);
- $.FOwner = null;
- }
- ,BeginIndention:function(Self) {
- ++IndentionLevel;
- }
- ,Create$4:function(Self, Owner) {
- Self.FOwner = Owner;
- return Self
- }
- ,EndIndention:function(Self) {
- --IndentionLevel;
- }
- ,GetIndentionString:function(Self) {
- var Result = "";
- Result = DupeString(" ",IndentionLevel);
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4$:function($){return $.ClassType.Create$4.apply($.ClassType, arguments)}
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TCustomType = {
- $ClassName:"TCustomType",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomDeclaration.GetAsCode
-};
-var TCustomNamedType = {
- $ClassName:"TCustomNamedType",$Parent:TCustomType
- ,$Init:function ($) {
- TCustomType.$Init($);
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = TCustomNamedType.GetName$(Self);
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TVariantType = {
- $ClassName:"TVariantType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = "Variant";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomNamedType.GetAsCode
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TNamedDeclaration = {
- $ClassName:"TNamedDeclaration",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Name = "";
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomDeclaration.GetAsCode
-};
-var TVariableDeclaration = {
- $ClassName:"TVariableDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TUnionType = {
- $ClassName:"TUnionType",$Parent:TCustomType
- ,$Init:function ($) {
- TCustomType.$Init($);
- $.Types = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- var a$131 = 0;
- var SubType = null;
- var a$132 = [];
- Result = "Variant {";
- a$132 = Self.Types;
- var $temp5;
- for(a$131=0,$temp5=a$132.length;a$131<$temp5;a$131++) {
- SubType = a$132[a$131];
- Result+=TCustomDeclaration.GetAsCode$(SubType);
- }
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TTypeReference = {
- $ClassName:"TTypeReference",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Name = "";
- $.Arguments = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TTypeParameter = {
- $ClassName:"TTypeParameter",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Name = "";
- $.ExtendsType = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TTypeOfType = {
- $ClassName:"TTypeOfType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- $.Type = null;
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = "type of";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomNamedType.GetAsCode
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TTypeArgument = {
- $ClassName:"TTypeArgument",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Name = "";
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TStringType = {
- $ClassName:"TStringType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = "Boolean";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomNamedType.GetAsCode
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TParameter = {
- $ClassName:"TParameter",$Parent:TObject
- ,$Init:function ($) {
- TObject.$Init($);
- $.DefaultValue = $.BindingIdentifier = "";
- $.IsRest = $.IsOptional = false;
- $.Type = null;
- $.AccessibilityModifier = 0;
- }
- ,Destroy:TObject.Destroy
-};
-var TObjectType = {
- $ClassName:"TObjectType",$Parent:TCustomType
- ,$Init:function ($) {
- TCustomType.$Init($);
- $.Members = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- var a$133 = 0;
- var Member$2 = null;
- var a$134 = [];
- TCustomDeclaration.BeginIndention(Self.ClassType);
- a$134 = Self.Members;
- var $temp6;
- for(a$133=0,$temp6=a$134.length;a$133<$temp6;a$133++) {
- Member$2 = a$134[a$133];
- Result+=TCustomDeclaration.GetAsCode$(Member$2);
- }
- TCustomDeclaration.EndIndention(Self.ClassType);
- Result+=TCustomDeclaration.GetIndentionString(Self.ClassType)+"end;";
- Result+="\r\n"+"\r\n";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TNamespaceDeclaration = {
- $ClassName:"TNamespaceDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomDeclaration.GetAsCode
-};
-var TNamedType = {
- $ClassName:"TNamedType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- $.FName = "";
- $.Arguments = [];
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = Self.FName;
- return Result
- }
- ,Create$5:function(Self, Owner$1, AName) {
- TCustomDeclaration.Create$4(Self,Owner$1);
- Self.FName = AName;
- return Self
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomNamedType.GetAsCode
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TModuleDeclaration = {
- $ClassName:"TModuleDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Modules = [];
- $.Variables = [];
- $.Exports = [];
- $.Functions = [];
- $.Interfaces = [];
- $.Classes = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- var a$135 = 0;
- var Class = null,
- a$136 = 0;
- var Interface$1 = null,
- a$137 = 0;
- var Variable = null;
- if (Self.Classes.length>0) {
- var a$138 = [];
- Result+="type"+"\r\n";
- TCustomDeclaration.BeginIndention(Self.ClassType);
- a$138 = Self.Classes;
- var $temp7;
- for(a$135=0,$temp7=a$138.length;a$135<$temp7;a$135++) {
- Class = a$138[a$135];
- Result = Result+TCustomDeclaration.GetAsCode$(Class);
- }
- TCustomDeclaration.EndIndention(Self.ClassType);
- }
- if (Self.Interfaces.length>0) {
- var a$139 = [];
- Result+="type"+"\r\n";
- TCustomDeclaration.BeginIndention(Self.ClassType);
- a$139 = Self.Interfaces;
- var $temp8;
- for(a$136=0,$temp8=a$139.length;a$136<$temp8;a$136++) {
- Interface$1 = a$139[a$136];
- Result = Result+TCustomDeclaration.GetAsCode$(Interface$1);
- }
- TCustomDeclaration.EndIndention(Self.ClassType);
- }
- if (Self.Variables.length>0) {
- var a$140 = [];
- Result+="var"+"\r\n";
- TCustomDeclaration.BeginIndention(Self.ClassType);
- a$140 = Self.Variables;
- var $temp9;
- for(a$137=0,$temp9=a$140.length;a$137<$temp9;a$137++) {
- Variable = a$140[a$137];
- Result = Result+TCustomDeclaration.GetAsCode$(Variable);
- }
- TCustomDeclaration.EndIndention(Self.ClassType);
- }
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TCustomTypeMember = {
- $ClassName:"TCustomTypeMember",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Visibility = 0;
- $.IsStatic = false;
- }
- ,Create$4:function(Self, Owner$2) {
- TCustomDeclaration.Create$4(Self,Owner$2);
- Self.Visibility = 0;
- return Self
- }
- ,Destroy:TObject.Destroy
- ,Create$4$:function($){return $.ClassType.Create$4.apply($.ClassType, arguments)}
- ,GetAsCode:TCustomDeclaration.GetAsCode
-};
-var TMethodDeclaration = {
- $ClassName:"TMethodDeclaration",$Parent:TCustomTypeMember
- ,$Init:function ($) {
- TCustomTypeMember.$Init($);
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = TCustomDeclaration.GetIndentionString(Self.ClassType)+"function "+Self.Name;
- if (Self.Type) {
- Result+=TCustomDeclaration.GetAsCode$(Self.Type);
- }
- Result+=";"+"\r\n";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomTypeMember.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TInterfaceDeclaration = {
- $ClassName:"TInterfaceDeclaration",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Members = [];
- $.Name = "";
- $.Extends = [];
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TIndexDeclaration = {
- $ClassName:"TIndexDeclaration",$Parent:TCustomTypeMember
- ,$Init:function ($) {
- TCustomTypeMember.$Init($);
- $.IsStringIndex = false;
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomTypeMember.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TImportDeclaration = {
- $ClassName:"TImportDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TFunctionType = {
- $ClassName:"TFunctionType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- $.ResultType = null;
- $.Parameters = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- var Index = 0;
- if (Self.Parameters.length>0) {
- Result = "("+TCustomDeclaration.GetAsCode$(Self.Parameters[0]);
- var $temp10;
- for(Index=0+1,$temp10=Self.Parameters.length;Index<$temp10;Index++) {
- Result+="; "+TCustomDeclaration.GetAsCode$(Self.Parameters[Index]);
- }
- Result+=")";
- }
- if (Self.ResultType) {
- Result+=": "+TCustomDeclaration.GetAsCode$(Self.ResultType);
- }
- return Result
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = "function";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TFunctionParameter = {
- $ClassName:"TFunctionParameter",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Type = null;
- $.Nullable = false;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = Self.Name+": ";
- if (Self.Type) {
- Result+=TCustomDeclaration.GetAsCode$(Self.Type);
- } else {
- Result+="Variant";
- }
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TFunctionDeclaration = {
- $ClassName:"TFunctionDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = TCustomDeclaration.GetAsCode$(Self.Type);
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TFloatType = {
- $ClassName:"TFloatType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = "Float";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomNamedType.GetAsCode
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TFieldDeclaration = {
- $ClassName:"TFieldDeclaration",$Parent:TCustomTypeMember
- ,$Init:function ($) {
- TCustomTypeMember.$Init($);
- $.Nullable = false;
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = TCustomDeclaration.GetIndentionString(Self.ClassType)+Self.Name+": "+TCustomDeclaration.GetAsCode$(Self.Type)+";";
- if (Self.Nullable) {
- Result+=" \/\/ nullable";
- }
- Result+="\r\n";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomTypeMember.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TExportDeclaration = {
- $ClassName:"TExportDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.FDefault = false;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TEnumerationItem = {
- $ClassName:"TEnumerationItem",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Name = $.Value = "";
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TEnumerationDeclaration = {
- $ClassName:"TEnumerationDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Items = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TEnumDeclaration = {
- $ClassName:"TEnumDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomDeclaration.GetAsCode
-};
-var TDefinitionDeclaration = {
- $ClassName:"TDefinitionDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TConstructorDeclaration = {
- $ClassName:"TConstructorDeclaration",$Parent:TCustomTypeMember
- ,$Init:function ($) {
- TCustomTypeMember.$Init($);
- $.TypeParameters = "";
- $.ParameterList = [];
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = TCustomDeclaration.GetIndentionString(Self.ClassType)+"constructor Create";
- if (Self.Type) {
- Result+=TCustomDeclaration.GetAsCode$(Self.Type);
- }
- Result+=";"+"\r\n";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomTypeMember.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TClassDeclaration = {
- $ClassName:"TClassDeclaration",$Parent:TInterfaceDeclaration
- ,$Init:function ($) {
- TInterfaceDeclaration.$Init($);
- $.Implements = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TCallSignature = {
- $ClassName:"TCallSignature",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.TypeParameters = "";
- $.ParameterList = [];
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TCallbackDeclaration = {
- $ClassName:"TCallbackDeclaration",$Parent:TCustomTypeMember
- ,$Init:function ($) {
- TCustomTypeMember.$Init($);
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = TCustomDeclaration.GetIndentionString(Self.ClassType)+"callback "+Self.Name;
- if (Self.Type) {
- Result+=TCustomDeclaration.GetAsCode$(Self.Type);
- }
- Result+=";"+"\r\n";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomTypeMember.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TBooleanType = {
- $ClassName:"TBooleanType",$Parent:TCustomNamedType
- ,$Init:function ($) {
- TCustomNamedType.$Init($);
- }
- ,GetName:function(Self) {
- var Result = "";
- Result = "Boolean";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TCustomNamedType.GetAsCode
- ,GetName$:function($){return $.ClassType.GetName($)}
-};
-var TArrayType = {
- $ClassName:"TArrayType",$Parent:TCustomType
- ,$Init:function ($) {
- TCustomType.$Init($);
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- Result = "array of "+TCustomDeclaration.GetAsCode$(Self.Type);
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TAmbientVariableDeclaration = {
- $ClassName:"TAmbientVariableDeclaration",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.IsConst = false;
- $.AmbientBindingList = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- var a$141 = 0;
- var AmbientBinding = null;
- var a$142 = [];
- Result = (Self.IsConst)?"const ":"var ";
- a$142 = Self.AmbientBindingList;
- var $temp11;
- for(a$141=0,$temp11=a$142.length;a$141<$temp11;a$141++) {
- AmbientBinding = a$142[a$141];
- Result+=TCustomDeclaration.GetAsCode$(AmbientBinding);
- }
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TAmbientModuleDeclaration = {
- $ClassName:"TAmbientModuleDeclaration",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.Interfaces = [];
- $.Modules = [];
- $.Classes = [];
- $.Functions = [];
- $.Variables = [];
- $.IdentifierPath = "";
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TAmbientFunctionDeclaration = {
- $ClassName:"TAmbientFunctionDeclaration",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.BindingIdentifier = "";
- $.CallSignature = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TAmbientDeclaration = {
- $ClassName:"TAmbientDeclaration",$Parent:TNamedDeclaration
- ,$Init:function ($) {
- TNamedDeclaration.$Init($);
- $.Variables = [];
- $.Namespaces = [];
- $.Modules = [];
- $.Classes = [];
- $.Functions = [];
- $.Enums = [];
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- var a$143 = 0;
- var Function$2 = null,
- a$144 = 0;
- var Module$2 = null,
- a$145 = 0;
- var Class$1 = null,
- a$146 = 0;
- var Variable$1 = null;
- var a$147 = [],
- a$148 = [];
- a$148 = Self.Functions;
- var $temp12;
- for(a$143=0,$temp12=a$148.length;a$143<$temp12;a$143++) {
- Function$2 = a$148[a$143];
- Result+=TCustomDeclaration.GetAsCode$(Function$2);
- }
- a$147 = Self.Modules;
- var $temp13;
- for(a$144=0,$temp13=a$147.length;a$144<$temp13;a$144++) {
- Module$2 = a$147[a$144];
- Result+=TCustomDeclaration.GetAsCode$(Module$2);
- }
- if (Self.Classes.length>0) {
- var a$149 = [];
- Result+="type"+"\r\n";
- TCustomDeclaration.BeginIndention(Self.ClassType);
- a$149 = Self.Classes;
- var $temp14;
- for(a$145=0,$temp14=a$149.length;a$145<$temp14;a$145++) {
- Class$1 = a$149[a$145];
- Result = Result+TCustomDeclaration.GetAsCode$(Class$1);
- }
- TCustomDeclaration.EndIndention(Self.ClassType);
- }
- if (Self.Variables.length>0) {
- var a$150 = [];
- Result+="var"+"\r\n";
- TCustomDeclaration.BeginIndention(Self.ClassType);
- a$150 = Self.Variables;
- var $temp15;
- for(a$146=0,$temp15=a$150.length;a$146<$temp15;a$146++) {
- Variable$1 = a$150[a$146];
- Result = Result+TCustomDeclaration.GetAsCode$(Variable$1);
- }
- TCustomDeclaration.EndIndention(Self.ClassType);
- }
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TAmbientClassDeclaration = {
- $ClassName:"TAmbientClassDeclaration",$Parent:TClassDeclaration
- ,$Init:function ($) {
- TClassDeclaration.$Init($);
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode:TClassDeclaration.GetAsCode
-};
-var TAmbientBinding = {
- $ClassName:"TAmbientBinding",$Parent:TCustomDeclaration
- ,$Init:function ($) {
- TCustomDeclaration.$Init($);
- $.BindingIdentifier = "";
- $.Type = null;
- }
- ,GetAsCode:function(Self) {
- var Result = "";
- return Result
- }
- ,Destroy:TObject.Destroy
- ,Create$4:TCustomDeclaration.Create$4
- ,GetAsCode$:function($){return $.ClassType.GetAsCode($)}
-};
-var TAccessibilityModifier = [ "amPublic", "amPrivate", "amProtected" ];
-function ConvertFile(InputFile, OutputFile) {
- if (InputFile==(InputFile).split(".")[0]) {
- InputFile+=".d.ts";
- }
- FileSystem.readFile(InputFile,function (err, data) {
- var InputText = "",
- Translator = null,
- OutputText = "";
- InputText = data.toString("utf8");
- Translator = TTranslator.Create$3($New(TTranslator));
- Translator.Name = (InputFile).split(".")[0];
- OutputText = TTranslator.Translate(Translator,InputText);
- FileSystem.writeFile(OutputFile,OutputText,function (err$1) {
- });
- Translator = null;
- });
-};
-
-var TypeScriptExport = require("typescript");
-var IndentionLevel = 0;
-var FileSystem = fs();
-
-var userArgs = process.argv.slice(2);
-if (userArgs.length == 0) {
- return 'Usage: ts2pas inputfile [outputfile]';
-}
-var inputFile = userArgs[0];
-var outputfile = userArgs[0]+".pas";
-if (userArgs.length == 2)
- outputfile = userArgs[1];
-
-ConvertFile(inputFile, outputfile);
\ No newline at end of file
+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(){var FMessage=""},Create:function(s,Msg){s.FMessage=Msg;return s}}
+function stringRepeat(s,n){if(n<1)return'';var r='';while(n>0){if(n&1)r+=s;n>>=1,s+=s};return r};function DupeString(s,n){return stringRepeat(s,n)}
+function $W(e){return e.ClassType?e:Exception.Create($New(Exception),e.constructor.name+", "+e.message)}
+function $New(c){var i={ClassType:c};c.$Init(i);return i}
+function $Is(o,c){if(o===null)return false;return $Inh(o.ClassType,c)};function $Inh(s,c){if(s===null)return false;while((s)&&(s!==c))s=s.$Parent;return(s)?true:false};function $Extend(base,sub,props){function F(){};F.prototype=base.prototype;sub.prototype=new F();sub.prototype.constructor=sub;for(var n in props){if(props.hasOwnProperty(n)){sub.prototype[n]=props[n]}}}
+function $AsIntf(o,i){if(o===null)return null;var r=o.ClassType.$Intf[i].map(function(e){return function(){var arg=Array.prototype.slice.call(arguments);arg.splice(0,0,o);return e.apply(o,arg)}});r.O=o;return r};function $As(o,c){if((o===null)||$Is(o,c))return o;throw Exception.Create($New(Exception),"Cannot cast instance of type \""+o.ClassType.$ClassName+"\" to class \""+c.$ClassName+"\"")}
+function JError(){}
+$Extend(Object,JError,{});function LW(q6){bF(q6,(q6).split(".")[0]+".pas")};function bF(De,AJ){if(De==(De).split(".")[0])De+=".d.ts";BK.readFile(De,function(h9,We){var rJ="",uC=null,N8="";rJ=We.toString("utf8");uC=F.Y($New(F));uC.Name=(De).split(".")[0];N8=F.t(uC,rJ);BK.writeFile(AJ,N8,function(jn){});uC=null})};function Copy$ih(s,d){d.encoding=s.encoding;d.mode=s.mode;d.flag=s.flag;return d}
+function Clone$ih($){return{encoding:$.encoding,mode:$.mode,flag:$.flag}}
+function Copy$dh(s,d){d.encoding=s.encoding;d.mode=s.mode;d.flag=s.flag;return d}
+function Clone$dh($){return{encoding:$.encoding,mode:$.mode,flag:$.flag}}
+function Copy$X5(s,d){d.persistent=s.persistent;return d}
+function Clone$X5($){return{persistent:$.persistent}}
+function Copy$Ob(s,d){d.curr=s.curr;d.prev=s.prev;return d}
+function Clone$Ob($){return{curr:$.curr,prev:$.prev}}
+function Copy$Wn(s,d){d.curr=s.curr;d.prev=s.prev;return d}
+function Clone$Wn($){return{curr:$.curr,prev:$.prev}}
+function Copy$zU(s,d){d.persistent=s.persistent;d.interval=s.interval;return d}
+function Clone$zU($){return{persistent:$.persistent,interval:$.interval}}
+function Copy$Rj(s,d){d.encoding=s.encoding;d.flag=s.flag;return d}
+function Clone$Rj($){return{encoding:$.encoding,flag:$.flag}}
+function Copy$e2(s,d){d.encoding=s.encoding;d.flag=s.flag;return d}
+function Clone$e2($){return{encoding:$.encoding,flag:$.flag}}
+function Copy$gd(s,d){d.flags=s.flags;d.encoding=s.encoding;d.string_=s.string_;return d}
+function Clone$gd($){return{flags:$.flags,encoding:$.encoding,string_:$.string_}}
+function Copy$Kf(s,d){d.bufferSize=s.bufferSize;d.encoding=s.encoding;d.fd=s.fd;d.mode=s.mode;d.flags=s.flags;return d}
+function Clone$Kf($){return{bufferSize:$.bufferSize,encoding:$.encoding,fd:$.fd,mode:$.mode,flags:$.flags}}
+function Copy$P7(s,d){d.encoding=s.encoding;d.mode=s.mode;d.flag=s.flag;return d}
+function Clone$P7($){return{encoding:$.encoding,mode:$.mode,flag:$.flag}}
+function Copy$wy(s,d){d.encoding=s.encoding;d.mode=s.mode;d.flag=s.flag;return d}
+function Clone$wy($){return{encoding:$.encoding,mode:$.mode,flag:$.flag}}
+function TV(){var R=null;R=require("fs");return R};function l3(){var R=null;R=require("stream");return R};function Bk(){var R=null;R=require("events");return R};var F={$ClassName:"TTranslator",$Parent:TObject,$Init:function($){TObject.$Init($);$.NeedsSemicolon=false;$.Name="";$.HT=[];$.SI=[];$.Nj=[];$.gS=$.T9=null},mC:function(S){return S.gS.getTokenText()},BS:function(S){return S.gS.getToken()},Q:function(S,kX){if(!(S.gS.isIdentifier()||kX.indexOf(F.BS(S))>=0))F.i(S,0)},n9:function(S,ia){if(!(ia.indexOf(F.BS(S))>=0))F.i(S,0)},yO:function(S,GY){if(F.BS(S)!=GY)F.i(S,GY)},Vj:function(S){var R="";var rk=0;var Df=null,Ak=0;var dT=null,Wz=0;var a3=null;var jr=[],kP=[],pY=[];R="unit "+S.Name+";"+"\r\n"+"\r\n";R+="interface"+"\r\n"+"\r\n";pY=S.Nj;var $t1;for(rk=0,$t1=pY.length;rk<$t1;rk++){Df=pY[rk];R=R+Vm.nK$(Df)}
+kP=S.SI;var $t2;for(Ak=0,$t2=kP.length;Ak<$t2;Ak++){dT=kP[Ak];R=R+Vm.nK$(dT)}
+jr=S.HT;var $t3;for(Wz=0,$t3=jr.length;Wz<$t3;Wz++){a3=jr[Wz];R=R+Vm.nK$(a3)}
+return R},Y:function(S){S.NeedsSemicolon=false;return S},i:function(S,Wx){var vD=null,QJ="";vD=Hf.getLineAndCharacterOfPosition(S.T9,S.gS.getTokenPos());QJ=("Unknown token \""+F.mC(S).toString()+"\" in this context ("+(vD.line+1).toString()+":"+(vD.character+1).toString()+")");if(Wx>0)QJ+=("; Expected ("+Wx.toString()+")");console.trace("");throw Exception.Create($New(Exception),QJ)},cJ:function(S){var R=null;F.W(S,true);R=Vm.ee$($New(B5),$AsIntf(S,"NB"));R.Name=F.mC(S);if(F.v(S,54,false))R.Type=F.h(S);if(S.NeedsSemicolon)F.n9(S,[23,24].slice());return R},K:function(S){var R=null;var R9=[],yL=0,TP=false,UB=null;F.yO(S,73);R=Vm.ee$($New(UM),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);F.b(S,[83,106,15].slice(),true);if(F.BS(S)==83){F.W(S,true);R.Extends.push(F.f(S))}
+if(F.BS(S)==106){F.W(S,true);R.Implements.push(F.V(S));while(F.BS(S)==24){F.W(S,true);R.Implements.push(F.V(S))}}
+F.yO(S,15);R9.push(92,9,82,16,23);F.I(S,R9,false);while(F.BS(S)!=16){yL=0;switch(F.BS(S)){case 112:yL=0;F.I(S,[92].slice(),true);break;case 111:yL=1;F.I(S,[92].slice(),true);break;case 110:yL=2;F.I(S,[92].slice(),true);break}
+TP=F.BS(S)==113;if(TP)F.I(S,[92,17].slice(),true);UB=F.n(S);UB.Visibility=yL;UB.IsStatic=TP;R.Members.push(UB);if(F.BS(S)==23)F.I(S,R9,false)}
+F.yO(S,16);return R},n:function(S){var R=null;var B2="",OJ=false;F.Q(S,[92,17,9,82].slice());if(F.BS(S)==17){R=F.J(S)}else{B2=S.gS.getTokenValue();F.b(S,[25,53,54,17].slice(),true);if(F.BS(S)==25){F.z(S);F.b(S,[53,54,17].slice(),true)}
+OJ=F.BS(S)==53;if(OJ)F.v(S,54,true);switch(F.BS(S)){case 54:R=F.j(S);$As(R,db).Nullable=OJ;break;case 17:if((B2).toLowerCase()=="constructor"){R=F.c(S)}else R=F.L(S);break}
+R.Name=B2}
+if(S.NeedsSemicolon)F.n9(S,[23,24,16].slice());return R},p:function(S){var R=null;F.yO(S,122);R=Vm.ee$($New(Yb),$AsIntf(S,"NB"));F.b(S,[102,108,74,87,73,81,125,126].slice(),true);switch(F.BS(S)){case 102:case 108:case 74:R.Variables.push(F.O(S));break;case 87:R.Functions.push(F.ch(S));break;case 73:R.Classes.push(F.K(S));break;case 81:R.Enums.push(F.G(S));break;case 125:R.Modules.push(F.U(S));break;case 126:R.Namespaces.push(F.v7(S));break}
+return R},G:function(S){var R=null;return R},ch:function(S){var R=null;F.yO(S,87);R=Vm.ee$($New(Qu),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);R.CallSignature=F.D(S);if(S.NeedsSemicolon)F.n9(S,[23].slice());return R},U:function(S){var R=null;var Dm=[],Dm=[82,102,87,73,107,81,125,89,16,23].slice();var UQ=false;F.yO(S,125);R=Vm.ee$($New(tB),$AsIntf(S,"NB"));F.I(S,[9].slice(),true);R.IdentifierPath=F.V(S);F.yO(S,15);F.b(S,Dm,true);while(F.BS(S)!=16){UQ=F.BS(S)==82;if(UQ){F.b(S,Dm.concat([77,56]),true);if(F.BS(S)==77){UQ=false;F.W(S,false);F.v(S,23,false);F.b(S,Dm,true)}
+if(F.BS(S)==56){UQ=false;F.W(S,false);F.v(S,23,false);F.b(S,Dm,true)}}
+switch(F.BS(S)){case 102:R.Variables.push(F.O(S));break;case 87:R.Functions.push(F.ch(S));break;case 73:R.Classes.push(F.K(S));F.b(S,Dm,true);break;case 125:R.Modules.push(F.U(S));F.b(S,Dm,true);break;case 107:R.Interfaces.push(F.l(S));F.b(S,Dm,true);break;case 89:F.y(S);if(!S.NeedsSemicolon)F.b(S,Dm,true);break}
+if(F.BS(S)==23)F.b(S,Dm,true)}
+F.yO(S,16);return R},v7:function(S){var R=null;return R},O:function(S){var R=null;F.n9(S,[102,108,74].slice());R=Vm.ee$($New(cM),$AsIntf(S,"NB"));R.IsConst=F.BS(S)==74;do{R.AmbientBindingList.push(F.cJ(S))}while(!(F.BS(S)==23||(!S.NeedsSemicolon)&&(!S.gS.isIdentifier())));return R},J:function(S){var R=null;R=Vm.ee$($New(yE),$AsIntf(S,"NB"));R.Type=F.r(S);F.n9(S,[23,16].slice());return R},D:function(S){var R=null;R=Vm.ee$($New(SS),$AsIntf(S,"NB"));F.b(S,[17,25].slice(),true);if(F.BS(S)==25){F.z(S);F.v(S,17,true)}
+F.yO(S,17);F.I(S,[112,110,111,22,18].slice(),true);while(F.BS(S)!=18){R.ParameterList.push(F.B(S));if(F.BS(S)==24)F.I(S,[22].slice(),false)}
+F.n9(S,[18].slice());F.b(S,[54,23].slice(),true);if(F.BS(S)==54)R.Type=F.M(S);return R},ri:function(S){var R=null;var ts=[],SL=0,ns=false,c1=null;F.yO(S,73);R=Vm.ee$($New(wV),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);console.log("Read class: "+R.Name);F.b(S,[83,106,15].slice(),true);if(F.BS(S)==83){F.W(S,true);R.Extends.push(F.f(S))}
+if(F.BS(S)==106){F.W(S,true);R.Implements.push(F.V(S));while(F.BS(S)==24){F.W(S,true);R.Implements.push(F.V(S))}}
+F.yO(S,15);F.yO(S,15);ts.push(92,9,82,16,23);F.I(S,ts,false);while(F.BS(S)!=16){SL=0;switch(F.BS(S)){case 112:SL=0;F.I(S,[92].slice(),true);break;case 111:SL=1;F.I(S,[92].slice(),true);break;case 110:SL=2;F.I(S,[92].slice(),true);break}
+ns=F.BS(S)==113;if(ns)F.I(S,[92,17].slice(),true);c1=F.n(S);c1.Visibility=SL;c1.IsStatic=ns;R.Members.push(c1);if(F.BS(S)==23)F.I(S,ts,false)}
+return R},m:function(S){var R=null;var N9="",eV=false;F.Q(S,[92,17,9,82].slice());if(F.BS(S)==17){R=F.J(S)}else{N9=F.mC(S);F.b(S,[25,53,54,17].slice(),true);if(F.BS(S)==25){F.z(S);F.b(S,[53,54,17].slice(),true)}
+eV=F.BS(S)==53;if(eV)F.v(S,54,true);switch(F.BS(S)){case 54:R=F.j(S);$As(R,db).Nullable=eV;break;case 17:if((N9).toLowerCase()=="constructor"){R=F.c(S)}else R=F.L(S);break}
+R.Name=N9}
+if(S.NeedsSemicolon)F.n9(S,[23,24,16].slice());return R},c:function(S){var R=null;R=Vm.ee$($New(pX),$AsIntf(S,"NB"));R.Type=F.r(S);if(S.NeedsSemicolon)F.n9(S,[23,16].slice());return R},dJ:function(S){var R=null;F.yO(S,92);R=Vm.ee$($New(pX),$AsIntf(S,"NB"));if(F.W(S,false)){F.v(S,17,false)}
+F.yO(S,17);F.I(S,[112,110,111,22,18].slice(),true);while(F.BS(S)!=18){R.ParameterList.push(F.B(S));if(F.BS(S)==24)F.I(S,[22].slice(),false)}
+F.yO(S,18);F.v(S,54,true);R.Type=F.h(S);return R},E:function(S){while(F.b(S,[82,122,107,125,89,1].slice(),true)){{var $t4=F.BS(S);if($t4==82){continue}
+else if($t4==122){S.HT.push(F.p(S))}
+else if($t4==107){S.SI.push(F.l(S))}
+else if($t4==125){S.Nj.push(F.a(S))}
+else if($t4==89){F.y(S)}
+else if($t4==1){break}}}},w:function(S){var R=null;F.yO(S,81);R=Vm.ee$($New(p8),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);F.v(S,15,true);F.W(S,true);do{R.Items.push(F.Z(S))}while(!(!F.W(S,false)));F.yO(S,16);return R},Z:function(S){var R=null;F.Q(S,[]);R=Vm.ee$($New(PR),$AsIntf(S,"NB"));R.Name=F.mC(S);if(F.v(S,56,false)){F.v(S,8,true);R.Value=F.mC(S);F.s(S)}
+F.yO(S,24);return R},e:function(S){var R=null;F.yO(S,82);R=Vm.ee$($New(fs),$AsIntf(S,"NB"));F.I(S,[77].slice(),true);R.fU=F.BS(S)==82||(F.mC(S)).toLowerCase()=="default";if(R.fU)F.W(S,true);R.Name=F.mC(S);F.v(S,23,true);return R},j:function(S){var R=null;R=Vm.ee$($New(db),$AsIntf(S,"NB"));R.Type=F.M(S);if(S.NeedsSemicolon)F.Q(S,[23,16,24].slice());return R},x:function(S){var R=null;F.yO(S,87);R=Vm.ee$($New(TY),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);F.v(S,17,true);R.Type=F.r(S);return R},g:function(S){var R=null;var TW=false;F.Q(S,[22].slice());TW=F.BS(S)==22;if(TW)F.W(S,true);R=Vm.ee$($New(V2),$AsIntf(S,"NB"));R.Name=F.mC(S);F.b(S,[53,54,18].slice(),true);R.Nullable=F.BS(S)==53;if(R.Nullable)F.b(S,[54].slice(),true);if(F.BS(S)==54)R.Type=F.M(S);return R},r:function(S){var R=null;F.yO(S,17);R=Vm.ee$($New(Fq),$AsIntf(S,"NB"));while(F.I(S,[22].slice(),false)){R.Parameters.push(F.g(S));F.n9(S,[24,18,23].slice());if(F.BS(S)==18)break}
+F.n9(S,[18,23].slice());if(F.b(S,[54,34].slice(),false))R.ResultType=F.M(S);return R},I:function(S,gL,l2){var R=false;F.s(S);R=S.gS.isIdentifier()||gL.indexOf(F.BS(S))>=0;if((!R)&&l2)F.i(S,0);return R},W:function(S,OK){var R=false;F.s(S);R=S.gS.isIdentifier();if((!R)&&OK)F.i(S,69);return R},V:function(S){var R="";F.Q(S,[9].slice());R=F.mC(S);while(F.v(S,21,false)){F.W(S,true);R+="."+F.mC(S)}
+return R},y:function(S){var R=null;F.yO(S,89);R=Vm.ee$($New(DI),$AsIntf(S,"NB"));F.I(S,[37].slice(),true);if(F.BS(S)==37){F.v(S,116,true);F.W(S,true);F.v(S,133,true);F.v(S,9,true)}else{F.v(S,56,true);F.W(S,true)}
+if(S.NeedsSemicolon)F.v(S,23,true);return R},k:function(S){var R=null;F.yO(S,19);R=Vm.ee$($New(dw),$AsIntf(S,"NB"));F.W(S,true);F.v(S,54,true);F.b(S,[130,128].slice(),true);R.IsStringIndex=F.BS(S)==130;F.v(S,20,true);F.v(S,54,true);R.Type=F.h(S);return R},l:function(S){var R=null;F.yO(S,107);R=Vm.ee$($New(Fw),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);F.b(S,[25,83,15].slice(),true);if(F.BS(S)==25){F.z(S);F.b(S,[83,15].slice(),true)}
+while(F.BS(S)==83){F.W(S,true);R.Extends.push(F.f(S));while(F.BS(S)==24){F.W(S,true);R.Extends.push(F.f(S))}}
+F.yO(S,15);R.Type=F.X(S);F.yO(S,16);return R},L:function(S){var R=null;R=Vm.ee$($New(NV),$AsIntf(S,"NB"));R.Type=F.r(S);if(S.NeedsSemicolon)F.n9(S,[23,16].slice());return R},a:function(S){var R=null;var P4=[],P4=[73,82,81,89,125,87,107,102,23].slice();F.yO(S,125);R=Vm.ee$($New(vS),$AsIntf(S,"NB"));F.I(S,[9].slice(),true);R.Name=F.V(S);F.yO(S,15);F.b(S,P4,true);while(F.BS(S)!=16){switch(F.BS(S)){case 73:R.Classes.push(F.K(S));break;case 82:R.Exports.push(F.e(S));break;case 81:F.w(S);break;case 87:R.Functions.push(F.x(S));break;case 89:F.y(S);break;case 125:R.Modules.push(F.a(S));break;case 107:R.Interfaces.push(F.l(S));break;case 102:R.Variables.push(F.N(S));break}
+F.b(S,P4,true)}
+F.yO(S,16);return R},X:function(S){var R=null;var sz=[],sz=[9,8,92,17,78,19,16].slice();F.yO(S,15);R=Vm.ee$($New(ms),$AsIntf(S,"NB"));F.I(S,sz,true);while(F.BS(S)!=16){R.Members.push(F.u(S));if(([23,24].indexOf(F.BS(S))>=0))F.I(S,sz,true)}
+F.yO(S,16);return R},B:function(S){var R=null;F.Q(S,[112,110,111,22].slice());R=Vm.ee$($New(Dt),$AsIntf(S,"NB"));R.Name=F.mC(S);R.IsRest=F.BS(S)==22;if(R.IsRest){F.W(S,true);R.Name=F.mC(S);if(F.v(S,54,false))R.Type=F.h(S);F.yO(S,18);return R}
+F.Q(S,[112,110,111].slice());switch(F.BS(S)){case 112:R.AccessibilityModifier=0;F.W(S,false);break;case 110:R.AccessibilityModifier=1;F.W(S,false);break;case 111:R.AccessibilityModifier=2;F.W(S,false);break}
+F.Q(S,[]);F.b(S,[53,54,56,24,18].slice(),true);R.IsOptional=F.BS(S)==53;if(R.IsOptional)F.b(S,[54,56,24,18].slice(),true);if(F.BS(S)==54)R.Type=F.M(S);F.n9(S,[56,24,18].slice());if(F.BS(S)==56){F.W(S,true);R.DefaultValue=F.mC(S)}
+F.n9(S,[24,18].slice());return R},C:function(S){var R=null;var dn=[],dn=[69,9,117,15,128,130,120,103,101,17].slice();var ii=null;F.n9(S,dn);switch(F.BS(S)){case 17:R=F.M(S);F.yO(S,18);F.s(S);break;case 69:R=Te.Qm($New(Te),$AsIntf(S,"NB"),F.V(S));if(F.BS(S)==25){$As(R,Te).Arguments.push(F.H(S));F.s(S)}
+break;case 9:R=Te.Qm($New(Te),$AsIntf(S,"NB"),S.gS.getTokenValue());F.s(S);break;case 117:R=Vm.ee$($New(zv),$AsIntf(S,"NB"));F.s(S);break;case 128:R=Vm.ee$($New(v4),$AsIntf(S,"NB"));F.s(S);break;case 103:R=null;F.s(S);break;case 101:R=Vm.ee$($New(wh),$AsIntf(S,"NB"));$As(R,wh).Type=F.M(S);break;case 130:R=Vm.ee$($New(dU),$AsIntf(S,"NB"));F.s(S);break;case 120:R=Vm.ee$($New(pB),$AsIntf(S,"NB"));F.s(S);break;case 15:R=F.X(S);F.s(S);break}
+while(F.BS(S)==19){ii=R;R=Vm.ee$($New(Ep),$AsIntf(S,"NB"));$As(R,Ep).Type=ii;F.v(S,20,true);F.s(S)}
+return R},b:function(S,b4,sy){var R=false;R=b4.indexOf(F.s(S))>=0;if((!R)&&sy)F.i(S,0);return R},v:function(S,Jt,aQ){var R=false;R=F.s(S)==Jt;if((!R)&&aQ)F.i(S,Jt);return R},s:function(S){var R=0;R=S.gS.scan();return R},M:function(S){var R=null;var Wp=[],XX=null;Wp.push(69,9,117,15,128,130,120,103,101,17);F.b(S,Wp,true);if(F.BS(S)==17)return F.r(S);R=F.C(S);while(F.BS(S)==47){if(!$Is(R,Hl)){XX=R;R=Vm.ee$($New(Hl),$AsIntf(S,"NB"));$As(R,Hl).Types.push(XX)}
+F.b(S,Wp,true);$As(R,Hl).Types.push(F.C(S))}
+return R},h:function(S){var R=null;F.yO(S,54);R=F.M(S);return R},H:function(S){var R=null;F.yO(S,25);R=Vm.ee$($New(fY),$AsIntf(S,"NB"));R.Type=F.M(S);F.yO(S,27);return R},u:function(S){var R=null;var IN="",YS=false;F.Q(S,[9,8,110,92,78,17,19].slice());if(F.BS(S)==92)return F.dJ(S);if(F.BS(S)==17)return F.J(S);if(F.BS(S)==19)return F.k(S);if(S.gS.isIdentifier()||([9,8,78].indexOf(S.gS.getToken())>=0)){IN=F.mC(S);F.b(S,[53,54,17].slice(),true);YS=F.BS(S)==53;if(YS)F.v(S,54,true);switch(F.BS(S)){case 54:R=F.j(S);$As(R,db).Nullable=YS;break;case 17:R=F.L(S);break}
+R.Name=IN}
+return R},z:function(S){var R=null;F.yO(S,25);R=Vm.ee$($New(Ne),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);F.b(S,[83,27].slice(),true);if(F.BS(S)==83){R.ExtendsType=F.M(S);F.yO(S,27)}
+return R},f:function(S){var R=null;F.Q(S,[]);R=Vm.ee$($New(nQ),$AsIntf(S,"NB"));R.Name=F.V(S);return R},N:function(S){var R=null;F.yO(S,102);R=Vm.ee$($New(jX),$AsIntf(S,"NB"));F.W(S,true);R.Name=F.mC(S);F.v(S,54,true);R.Type=F.M(S);return R},t:function(S,QV){var R="";S.gS=Hf.createScanner(0,true,0,QV);S.T9=Hf.createSourceFile("main",QV,0);try{F.E$(S)}catch($e){var yB=$W($e);console.error(yB.FMessage)}
+R=F.Vj$(S);return R},Destroy:TObject.Destroy,Vj$:function($){return $.ClassType.Vj($)},E$:function($){return $.ClassType.E($)}};F.$Intf={NB:[]}
+var bG={1:"Export",2:"Ambient",4:"Public",8:"Private",16:"Protected",32:"Static",64:"Abstract",128:"Async",256:"Default",512:"MultiLine",1024:"Synthetic",2048:"DeclarationFile",4096:"Let",8192:"Const",16384:"OctalLiteral",32768:"Namespace",65536:"ExportContext",131072:"ContainsThis"};var nY={1:"None",2:"IntrinsicNamedElement",4:"IntrinsicIndexedElement",8:"ClassElement",16:"UnknownElement"};var fr=["Warning","Error","Message"];var Ib=["vPublic","vProtected","vPrivate"];var Vm={$ClassName:"TCustomDeclaration",$Parent:TObject,$Init:function($){TObject.$Init($);$.US=null},CS:function(S){++d},ee:function(S,aR){S.US=aR;return S},sb:function(S){--d},qe:function(S){var R="";R=DupeString(" ",d);return R},Destroy:TObject.Destroy,ee$:function($){return $.ClassType.ee.apply($.ClassType,arguments)},nK$:function($){return $.ClassType.nK($)}};var Y9={$ClassName:"TCustomType",$Parent:Vm,$Init:function($){Vm.$Init($)},Destroy:TObject.Destroy,ee:Vm.ee,nK:Vm.nK};var i6={$ClassName:"TCustomNamedType",$Parent:Y9,$Init:function($){Y9.$Init($)},nK:function(S){var R="";R="J"+i6.xk$(S);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)},xk$:function($){return $.ClassType.xk($)}};var Nc={$ClassName:"TPredefinedType",$Parent:i6,$Init:function($){i6.$Init($)},nK:function(S){var R="";R=i6.xk$(S);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)},xk:i6.xk};var zv={$ClassName:"TVariantType",$Parent:Nc,$Init:function($){Nc.$Init($)},xk:function(S){var R="";R="Variant";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK:Nc.nK,xk$:function($){return $.ClassType.xk($)}};var Se={$ClassName:"TNamedDeclaration",$Parent:Vm,$Init:function($){Vm.$Init($);$.Name=""},Destroy:TObject.Destroy,ee:Vm.ee,nK:Vm.nK};var jX={$ClassName:"TVariableDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.Type=null},nK:function(S){var R="";console.log("not implemented: TVariableDeclaration.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var Hl={$ClassName:"TUnionType",$Parent:Y9,$Init:function($){Y9.$Init($);$.Types=[]},nK:function(S){var R="";var iU=0;var L5=null;var R1=[];R="Variant {";R1=S.Types;var $t5;for(iU=0,$t5=R1.length;iU<$t5;iU++){L5=R1[iU];R+=Vm.nK$(L5)}
+return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var nQ={$ClassName:"TTypeReference",$Parent:Vm,$Init:function($){Vm.$Init($);$.Name="";$.Arguments=[]},nK:function(S){var R="";var tP=0;R=S.Name;if(S.Arguments.length>0){R+=" {"+Vm.nK$(S.Arguments[0]);var $t6;for(tP=0+1,$t6=S.Arguments.length;tP<$t6;tP++){R+=", "+Vm.nK$(S.Arguments[tP])}
+R+="} "}
+return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var Ne={$ClassName:"TTypeParameter",$Parent:Vm,$Init:function($){Vm.$Init($);$.Name="";$.ExtendsType=null},nK:function(S){var R="";console.log("not implemented: TTypeParameter.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var wh={$ClassName:"TTypeOfType",$Parent:i6,$Init:function($){i6.$Init($);$.Type=null},xk:function(S){var R="";R="type of";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK:i6.nK,xk$:function($){return $.ClassType.xk($)}};var fY={$ClassName:"TTypeArgument",$Parent:Vm,$Init:function($){Vm.$Init($);$.Name="";$.Type=null},nK:function(S){var R="";console.log("not implemented: TTypeArgument.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var dU={$ClassName:"TStringType",$Parent:Nc,$Init:function($){Nc.$Init($)},xk:function(S){var R="";R="String";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK:Nc.nK,xk$:function($){return $.ClassType.xk($)}};var Dt={$ClassName:"TParameter",$Parent:Se,$Init:function($){Se.$Init($);$.DefaultValue="";$.IsRest=$.IsOptional=false;$.Type=null;$.AccessibilityModifier=0},nK:function(S){var R="";R=S.Name+": "+Vm.nK$(S.Type);if(S.DefaultValue!="")R+=" = "+S.DefaultValue;return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var ms={$ClassName:"TObjectType",$Parent:Y9,$Init:function($){Y9.$Init($);$.Members=[]},nK:function(S){var R="";var ad=0;var y1=null;var fm=[];Vm.CS(S.ClassType);fm=S.Members;var $t7;for(ad=0,$t7=fm.length;ad<$t7;ad++){y1=fm[ad];R+=Vm.nK$(y1)}
+Vm.sb(S.ClassType);R+=Vm.qe(S.ClassType)+"end;";R+="\r\n"+"\r\n";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var Ct={$ClassName:"TNamespaceDeclaration",$Parent:Se,$Init:function($){Se.$Init($)},Destroy:TObject.Destroy,ee:Vm.ee,nK:Vm.nK};var Te={$ClassName:"TNamedType",$Parent:i6,$Init:function($){i6.$Init($);$.Fh="";$.Arguments=[]},xk:function(S){var R="";R=S.Fh;return R},Qm:function(S,ot,OL){Vm.ee(S,ot);S.Fh=OL;return S},Destroy:TObject.Destroy,ee:Vm.ee,nK:i6.nK,xk$:function($){return $.ClassType.xk($)}};var vS={$ClassName:"TModuleDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.Modules=[];$.Variables=[];$.Exports=[];$.Functions=[];$.Interfaces=[];$.Classes=[]},nK:function(S){var R="";var Go=0;var LG=null,AC=0;var sf=null,FV=0;var u1=null;if(S.Classes.length>0){var DQ=[];R+="type"+"\r\n";Vm.CS(S.ClassType);DQ=S.Classes;var $t8;for(Go=0,$t8=DQ.length;Go<$t8;Go++){LG=DQ[Go];R=R+Vm.nK$(LG)}
+Vm.sb(S.ClassType)}
+if(S.Interfaces.length>0){var Yp=[];R+="type"+"\r\n";Vm.CS(S.ClassType);Yp=S.Interfaces;var $t9;for(AC=0,$t9=Yp.length;AC<$t9;AC++){sf=Yp[AC];R=R+Vm.nK$(sf)}
+Vm.sb(S.ClassType)}
+if(S.Variables.length>0){var i7=[];R+="var"+"\r\n";Vm.CS(S.ClassType);i7=S.Variables;var $tA;for(FV=0,$tA=i7.length;FV<$tA;FV++){u1=i7[FV];R=R+Vm.nK$(u1)}
+Vm.sb(S.ClassType)}
+return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var jO={$ClassName:"TCustomTypeMember",$Parent:Se,$Init:function($){Se.$Init($);$.Visibility=0;$.IsStatic=false},ee:function(S,Ox){Vm.ee(S,Ox);S.Visibility=0;return S},Destroy:TObject.Destroy,ee$:function($){return $.ClassType.ee.apply($.ClassType,arguments)},nK:Vm.nK};var NV={$ClassName:"TMethodDeclaration",$Parent:jO,$Init:function($){jO.$Init($);$.Type=null},nK:function(S){var R="";R=Vm.qe(S.ClassType)+"function "+S.Name;if(S.Type)R+=Vm.nK$(S.Type);R+=";"+"\r\n";return R},Destroy:TObject.Destroy,ee:jO.ee,nK$:function($){return $.ClassType.nK($)}};var Fw={$ClassName:"TInterfaceDeclaration",$Parent:Vm,$Init:function($){Vm.$Init($);$.Name="";$.Extends=[];$.Type=null},nK:function(S){var R="";var zN=0;R="type"+"\r\n";Vm.CS(S.ClassType);R+=Vm.qe(S.ClassType)+S.Name+" = class external";if(S.Extends.length>0){R+="(";R+=Vm.nK$(S.Extends[0]);var $tB;for(zN=0+1,$tB=S.Extends.length;zN<$tB;zN++){R+=", "+Vm.nK$(S.Extends[zN])}
+R+=")"}
+R+="\r\n";R+=Vm.nK$(S.Type);Vm.sb(S.ClassType);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var dw={$ClassName:"TIndexDeclaration",$Parent:jO,$Init:function($){jO.$Init($);$.IsStringIndex=false;$.Type=null},nK:function(S){var R="";console.log("not implemented: TIndexDeclaration.GetAsCode");return R},Destroy:TObject.Destroy,ee:jO.ee,nK$:function($){return $.ClassType.nK($)}};var DI={$ClassName:"TImportDeclaration",$Parent:Se,$Init:function($){Se.$Init($)},nK:function(S){var R="";console.log("not implemented: TImportDeclaration.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var Fq={$ClassName:"TFunctionType",$Parent:i6,$Init:function($){i6.$Init($);$.ResultType=null;$.Parameters=[]},nK:function(S){var R="";var B7=0;if(S.Parameters.length>0){R="("+Vm.nK$(S.Parameters[0]);var $tC;for(B7=0+1,$tC=S.Parameters.length;B7<$tC;B7++){R+="; "+Vm.nK$(S.Parameters[B7])}
+R+=")"}
+if(S.ResultType)R+=": "+Vm.nK$(S.ResultType);return R},xk:function(S){var R="";R="function";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)},xk$:function($){return $.ClassType.xk($)}};var V2={$ClassName:"TFunctionParameter",$Parent:Se,$Init:function($){Se.$Init($);$.Type=null;$.Nullable=false},nK:function(S){var R="";R=Wm(S.Name)+": ";if(S.Type){R+=Vm.nK$(S.Type)}else R+="Variant";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var TY={$ClassName:"TFunctionDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.Type=null},nK:function(S){var R="";R=Vm.nK$(S.Type);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var v4={$ClassName:"TFloatType",$Parent:Nc,$Init:function($){Nc.$Init($)},xk:function(S){var R="";R="Float";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK:Nc.nK,xk$:function($){return $.ClassType.xk($)}};var db={$ClassName:"TFieldDeclaration",$Parent:jO,$Init:function($){jO.$Init($);$.Nullable=false;$.Type=null},nK:function(S){var R="";R=Vm.qe(S.ClassType)+Wm(S.Name)+": "+Vm.nK$(S.Type)+";";if(S.Nullable)R+=" \/\/ nullable";R+="\r\n";return R},Destroy:TObject.Destroy,ee:jO.ee,nK$:function($){return $.ClassType.nK($)}};var fs={$ClassName:"TExportDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.fU=false},nK:function(S){var R="";R="";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var PR={$ClassName:"TEnumerationItem",$Parent:Vm,$Init:function($){Vm.$Init($);$.Name=$.Value=""},nK:function(S){var R="";console.log("not implemented: TEnumerationItem.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var p8={$ClassName:"TEnumerationDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.Items=[]},nK:function(S){var R="";console.log("not implemented: TEnumerationDeclaration.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var OC={$ClassName:"TEnumDeclaration",$Parent:Se,$Init:function($){Se.$Init($)},Destroy:TObject.Destroy,ee:Vm.ee,nK:Vm.nK};var ji={$ClassName:"TDefinitionDeclaration",$Parent:Se,$Init:function($){Se.$Init($)},nK:function(S){var R="";console.log("not implemented: TDefinitionDeclaration.GetAsCode");return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var pX={$ClassName:"TConstructorDeclaration",$Parent:jO,$Init:function($){jO.$Init($);$.TypeParameters="";$.ParameterList=[];$.Type=null},nK:function(S){var R="";R=Vm.qe(S.ClassType)+"constructor Create";if(S.Type)R+=Vm.nK$(S.Type);R+=";"+"\r\n";return R},Destroy:TObject.Destroy,ee:jO.ee,nK$:function($){return $.ClassType.nK($)}};var wV={$ClassName:"TClassDeclaration",$Parent:Fw,$Init:function($){Fw.$Init($);$.Implements=[];$.Members=[]},nK:function(S){var R="";var UW=0;var Kd=0;var u7=null;var Y6=[];R="type"+"\r\n";Vm.CS(S.ClassType);R+=Vm.qe(S.ClassType)+"J"+S.Name+" = class external '"+S.Name+"'";if(S.Extends.length>0){R+="(";R+=Vm.nK$(S.Extends[0]);var $tD;for(UW=0+1,$tD=S.Extends.length;UW<$tD;UW++){R+=", "+Vm.nK$(S.Extends[UW])}
+R+=")"}
+R+="\r\n";Vm.CS(S.ClassType);Y6=S.Members;var $tE;for(Kd=0,$tE=Y6.length;Kd<$tE;Kd++){u7=Y6[Kd];R+=Vm.nK$(u7)}
+Vm.sb(S.ClassType);R+=Vm.qe(S.ClassType)+"end;"+"\r\n"+"\r\n";Vm.sb(S.ClassType);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var SS={$ClassName:"TCallSignature",$Parent:Vm,$Init:function($){Vm.$Init($);$.TypeParameters="";$.ParameterList=[];$.Type=null},nK:function(S){var R="";var vf=0;var cx=null;var EE=[];R="(";EE=S.ParameterList;var $tF;for(vf=0,$tF=EE.length;vf<$tF;vf++){cx=EE[vf];R+=Vm.nK$(cx)}
+R+=")";if(S.Type)R+=": "+Vm.nK$(S.Type);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var yE={$ClassName:"TCallbackDeclaration",$Parent:jO,$Init:function($){jO.$Init($);$.Type=null},nK:function(S){var R="";R=Vm.qe(S.ClassType)+"callback "+S.Name;if(S.Type)R+=Vm.nK$(S.Type);R+=";"+"\r\n";return R},Destroy:TObject.Destroy,ee:jO.ee,nK$:function($){return $.ClassType.nK($)}};var pB={$ClassName:"TBooleanType",$Parent:Nc,$Init:function($){Nc.$Init($)},xk:function(S){var R="";R="Boolean";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK:Nc.nK,xk$:function($){return $.ClassType.xk($)}};var Ep={$ClassName:"TArrayType",$Parent:Y9,$Init:function($){Y9.$Init($);$.Type=null},nK:function(S){var R="";R="array of "+Vm.nK$(S.Type);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var cM={$ClassName:"TAmbientVariableDeclaration",$Parent:Vm,$Init:function($){Vm.$Init($);$.IsConst=false;$.AmbientBindingList=[]},nK:function(S){var R="";var mv=0;var b7=null;var Yr=[];R=(S.IsConst)?"const":"var";R+=" ";Yr=S.AmbientBindingList;var $tG;for(mv=0,$tG=Yr.length;mv<$tG;mv++){b7=Yr[mv];R+=Vm.nK$(b7)}
+R+=";"+"\r\n";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var tB={$ClassName:"TAmbientModuleDeclaration",$Parent:Vm,$Init:function($){Vm.$Init($);$.Interfaces=[];$.Modules=[];$.Classes=[];$.Functions=[];$.Variables=[];$.IdentifierPath=""},nK:function(S){var R="";var tU=0;var KN=null,h5=0;var Wy=null,nc=0;var oq=null,Cg=0;var aV=null,Dk=0;var k7=null;var wi=[],hc=[],r7=[],uA=[],DN=[];R="\/\/"+S.IdentifierPath+"\r\n"+"\r\n";hc=S.Variables;var $tH;for(tU=0,$tH=hc.length;tU<$tH;tU++){KN=hc[tU];R+=Vm.nK$(KN)}
+wi=S.Functions;var $tI;for(h5=0,$tI=wi.length;h5<$tI;h5++){Wy=wi[h5];R+=Vm.nK$(Wy)}
+uA=S.Classes;var $tJ;for(nc=0,$tJ=uA.length;nc<$tJ;nc++){oq=uA[nc];R+=Vm.nK$(oq)}
+r7=S.Modules;var $tK;for(Cg=0,$tK=r7.length;Cg<$tK;Cg++){aV=r7[Cg];R+=Vm.nK$(aV)}
+DN=S.Interfaces;var $tL;for(Dk=0,$tL=DN.length;Dk<$tL;Dk++){k7=DN[Dk];R+=String(module.AsCode)}
+return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var Qu={$ClassName:"TAmbientFunctionDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.CallSignature=null},nK:function(S){var R="";R=(S.CallSignature.Type)?"function":"procedure";R+=" "+S.Name+Vm.nK$(S.CallSignature);R+=";"+"\r\n";return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var Yb={$ClassName:"TAmbientDeclaration",$Parent:Se,$Init:function($){Se.$Init($);$.Variables=[];$.Namespaces=[];$.Modules=[];$.Classes=[];$.Functions=[];$.Enums=[]},nK:function(S){var R="";var gw=0;var xo=null,GM=0;var bQ=null,Vr=0;var S1=null,r4=0;var CN=null;var n7=[],Ef=[],al=[];al=S.Functions;var $tM;for(gw=0,$tM=al.length;gw<$tM;gw++){xo=al[gw];R+=Vm.nK$(xo)}
+Ef=S.Modules;var $tN;for(GM=0,$tN=Ef.length;GM<$tN;GM++){bQ=Ef[GM];R+=Vm.nK$(bQ)}
+if(S.Classes.length>0){var rg=[];R+="type"+"\r\n";Vm.CS(S.ClassType);rg=S.Classes;var $tO;for(Vr=0,$tO=rg.length;Vr<$tO;Vr++){S1=rg[Vr];R=R+Vm.nK$(S1)}
+Vm.sb(S.ClassType)}
+if(S.Variables.length>0){n7=S.Variables;var $tP;for(r4=0,$tP=n7.length;r4<$tP;r4++){CN=n7[r4];R=R+Vm.nK$(CN)}}
+return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var UM={$ClassName:"TAmbientClassDeclaration",$Parent:wV,$Init:function($){wV.$Init($)},Destroy:TObject.Destroy,ee:Vm.ee,nK:wV.nK};var B5={$ClassName:"TAmbientBinding",$Parent:Se,$Init:function($){Se.$Init($);$.Type=null},nK:function(S){var R="";R=S.Name+": "+Vm.nK$(S.Type);return R},Destroy:TObject.Destroy,ee:Vm.ee,nK$:function($){return $.ClassType.nK($)}};var jB=["amPublic","amPrivate","amProtected"];function Wm(YF){var R="";switch((YF).toLowerCase()){case"type":R="&type";break;case"export":R="&export";break;case"label":R="&label";break;default:R=YF}
+return R};var Hf=null;var Hf=require("typescript");var d=0;var P=[],Fn="",i9="",BK=null;var BK=TV();P=process.argv;P.splice(0,2);if(P.length==0){return"Usage: ts2pas inputfile [outputfile]"}
+Fn=P[0];i9=P[0]+".pas";if(P.length==2)i9=P[1];bF(Fn,i9);