├── .gitignore ├── LICENSE ├── README.md ├── jsxbin_to_jsx.Tests ├── JsxJsxbinPair.cs ├── JsxbinToJsxTests.cs ├── Properties │ └── AssemblyInfo.cs ├── Testdata.cs └── jsxbin_to_jsx.Tests.csproj ├── jsxbin_to_jsx.sln ├── jsxbin_to_jsx ├── App.config ├── JsxbinDecoding │ ├── AbstractNode.cs │ ├── ArgumentList.cs │ ├── ArrayExpr.cs │ ├── ArrayIndexingExpr.cs │ ├── AssignmentExpr.cs │ ├── BinaryExpr.cs │ ├── ConditionalExpr.cs │ ├── ConstDeclaration.cs │ ├── ConstDeclarationInfo.cs │ ├── Constants.cs │ ├── DebuggerStatement.cs │ ├── DeleteExpr.cs │ ├── DoWhileExpr.cs │ ├── ExprNode.cs │ ├── ForInStatementVersion1.cs │ ├── ForInStatementVersion2.cs │ ├── ForStatement.cs │ ├── ForStatement2.cs │ ├── FunctionCallExpr.cs │ ├── FunctionDeclaration.cs │ ├── FunctionExpr.cs │ ├── FunctionSignature.cs │ ├── INode.cs │ ├── IReferenceDecoder.cs │ ├── IStatement.cs │ ├── IdNodeVersion1.cs │ ├── IdNodeVersion2.cs │ ├── IdRefExpr.cs │ ├── IfStatement.cs │ ├── IncrementExpr.cs │ ├── IndexingIncrementExpr.cs │ ├── JumpStatement.cs │ ├── LineInfo.cs │ ├── LogicalExp.cs │ ├── LogicalExpInfo.cs │ ├── MemberAssignmentExpr.cs │ ├── MemberExpr.cs │ ├── Nesting.cs │ ├── NodeType.cs │ ├── ObjectExpr.cs │ ├── ReferenceDecoderVersion1.cs │ ├── ReferenceDecoderVersion2.cs │ ├── RegExpLiteral.cs │ ├── ReturnStatement.cs │ ├── RootNode.cs │ ├── ScanState.cs │ ├── SetDefaultXMLNamespaceExpr.cs │ ├── StatementList.cs │ ├── SwitchStatement.cs │ ├── SymbolTable.cs │ ├── ThisExpr.cs │ ├── ThrowStatement.cs │ ├── TryStatement.cs │ ├── UnaryExpr.cs │ ├── UnknownNode2.cs │ ├── ValueNode.cs │ ├── WhileStatement.cs │ ├── WithStatement.cs │ ├── XMLAccessorExpr.cs │ ├── XMLAssignmentExpr.cs │ ├── XMLDoubleDotDescendantsExpr.cs │ └── XMLNamespaceExpr.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── jsxbin_to_jsx.csproj ├── libs └── Jsbeautifier.dll └── testfiles ├── v1.0 ├── arrays.jsx ├── arrays.jsxbin ├── assignment_operators.jsx ├── assignment_operators.jsxbin ├── binary_bitwise_operators.jsx ├── binary_bitwise_operators.jsxbin ├── comparison_operators.jsx ├── comparison_operators.jsxbin ├── conditional_operator.jsx ├── conditional_operator.jsxbin ├── do_while_loop.jsx ├── do_while_loop.jsxbin ├── exceptions.jsx ├── exceptions.jsxbin ├── for_in_loop.jsx ├── for_in_loop.jsxbin ├── for_loop.jsx ├── for_loop.jsxbin ├── functions.jsx ├── functions.jsxbin ├── if_statement.jsx ├── if_statement.jsxbin ├── labels.jsx ├── labels.jsxbin ├── logical_operators.jsx ├── logical_operators.jsxbin ├── methods.jsx ├── methods.jsxbin ├── objects.jsx ├── objects.jsxbin ├── regex.jsx ├── regex.jsxbin ├── strings.jsx ├── strings.jsxbin ├── switch_statement.jsx ├── switch_statement.jsxbin ├── unary_arithmetic_operators.jsx ├── unary_arithmetic_operators.jsxbin ├── unary_bitwise_operators.jsx ├── unary_bitwise_operators.jsxbin ├── unicode_string.jsx ├── unicode_string.jsxbin ├── variables.jsx ├── variables.jsxbin ├── while_loop.jsx ├── while_loop.jsxbin ├── with_statement.jsx ├── with_statement.jsxbin ├── xml.jsx └── xml.jsxbin └── v2.0 ├── arrays.jsx ├── arrays.jsxbin ├── assignment_operators.jsx ├── assignment_operators.jsxbin ├── binary_arithmetic_operators.tempJsx ├── binary_arithmetic_operators.tempJsxbin ├── binary_bitwise_operators.jsx ├── binary_bitwise_operators.jsxbin ├── comparison_operators.jsx ├── comparison_operators.jsxbin ├── conditional_operator.jsx ├── conditional_operator.jsxbin ├── do_while_loop.jsx ├── do_while_loop.jsxbin ├── exceptions.jsx ├── exceptions.jsxbin ├── for_in_loop.jsx ├── for_in_loop.jsxbin ├── for_loop.jsx ├── for_loop.jsxbin ├── functions.jsx ├── functions.jsxbin ├── if_statement.jsx ├── if_statement.jsxbin ├── labels.jsx ├── labels.jsxbin ├── logical_operators.jsx ├── logical_operators.jsxbin ├── methods.jsx ├── methods.jsxbin ├── number_systems.tempJsx ├── number_systems.tempJsxbin ├── objects.jsx ├── objects.jsxbin ├── regex.jsx ├── regex.jsxbin ├── strings.jsx ├── strings.jsxbin ├── switch_statement.jsx ├── switch_statement.jsxbin ├── unary_arithmetic_operators.jsx ├── unary_arithmetic_operators.jsxbin ├── unary_bitwise_operators.jsx ├── unary_bitwise_operators.jsxbin ├── unicode_string.jsx ├── unicode_string.jsxbin ├── variables.jsx ├── variables.jsxbin ├── while_loop.jsx ├── while_loop.jsxbin ├── with_statement.jsx ├── with_statement.jsxbin ├── xml.jsx └── xml.jsxbin /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 autoboosh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction to JSXBIN to JSX Converter 2 | JSXBIN is a binary format of JSX, which is a superset of JavaScript made by Adobe for automating certain tasks in Adobe products such as Photoshop. Sometimes it's useful to decode and read JSXBIN files but since there's no official decoder available, here is an alternative instead. 3 | 4 | # Usage 5 | 1. Download the [latest version from the releases page](https://github.com/autoboosh/jsxbin-to-jsx-converter/releases) 6 | 2. Extract the converter 7 | 2. Run jsxbin_to_jsx on your command line using the following syntax: 8 | 9 | ``` 10 | jsxbin_to_jsx [-v] JSXBIN JSX 11 | Flags: 12 | -v print tree structure to stdout 13 | ``` 14 | 15 | Example: 16 | 17 | ``` 18 | jsxbin_to_jsx encoded.jsxbin decoded.jsx 19 | ``` 20 | 21 | The converter automatically formats the code using [JsBeautifier](https://github.com/ghost6991/Jsbeautifier). 22 | 23 | # Debugging 24 | To view the parse tree created by the decoder use the -v flag: 25 | 26 | ``` 27 | jsxbin_to_jsx -v encoded.jsxbin decoded.jsx > debug.txt 28 | ``` 29 | 30 | Decoding the following code: 31 | 32 | ```javascript 33 | var test = 5; 34 | if (test > 5) { 35 | doSomething(); 36 | } 37 | ``` 38 | 39 | translates into the following parse tree: 40 | 41 | ``` 42 | StatementList 43 | ExprNode 44 | AssignmentExpr 45 | IfStatement 46 | StatementList 47 | ExprNode 48 | FunctionCallExpr 49 | IdNode 50 | BinaryExpr 51 | IdRefExpr 52 | ``` 53 | 54 | # Tests 55 | The Tests-Project contains one single test. This test decodes all jsxbin-Files found in the testfiles folder comparing them with their jsx-File equivalent, also found in the same folder. 56 | 57 | # Feedback 58 | If you encounter any problems or have any feedback, please open an issue. -------------------------------------------------------------------------------- /jsxbin_to_jsx.Tests/JsxJsxbinPair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace jsxbin_to_jsx.Tests 8 | { 9 | public sealed class JsxJsxbinPair 10 | { 11 | public string Jsx { get; set; } 12 | public string JsxFilename { get; set; } 13 | public string Jsxbin { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jsxbin_to_jsx.Tests/JsxbinToJsxTests.cs: -------------------------------------------------------------------------------- 1 | using jsxbin_to_jsx.JsxbinDecoding; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace jsxbin_to_jsx.Tests 5 | { 6 | [TestClass] 7 | public class JsxbinToJsxTests 8 | { 9 | [TestMethod] 10 | public void TestVersion1() 11 | { 12 | ExecuteTests("v1.0"); 13 | } 14 | 15 | [TestMethod] 16 | public void TestVersion2() 17 | { 18 | ExecuteTests("v2.0"); 19 | } 20 | 21 | private void ExecuteTests(string version) 22 | { 23 | foreach (var p in new Testdata().ReadTestfiles(version)) 24 | { 25 | string actualJsx = AbstractNode.Decode(p.Jsxbin, false); 26 | Assert.AreEqual(p.Jsx, actualJsx, string.Format("Decoding JSXBIN {0} does not match expected output in {1}.", version, p.JsxFilename)); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jsxbin_to_jsx.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über folgende 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die einer Assembly zugeordnet sind. 8 | [assembly: AssemblyTitle("UnitTestProject1")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UnitTestProject1")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Wenn ComVisible auf "false" festgelegt wird, sind die Typen innerhalb dieser Assembly 18 | // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("40ce5b7d-7a83-4ebf-a73e-5f5e92999900")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [Assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /jsxbin_to_jsx.Tests/Testdata.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | 7 | namespace jsxbin_to_jsx.Tests 8 | { 9 | public class Testdata 10 | { 11 | 12 | public IEnumerable ReadTestfiles(string versionFolder) 13 | { 14 | string basePath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; 15 | string TestfilesDirectory = Path.Combine(basePath, "testfiles", versionFolder); 16 | // *.jsx matches .jsxbin files as well, which is not what we want. 17 | // http://www.codeproject.com/Questions/152289/Directory-Get-Files-search-pattern-problem 18 | var jsxfiles = Directory.EnumerateFiles(TestfilesDirectory, "*.jsx").Where(f => f.EndsWith(".jsx")).Select(f => new FileInfo(f)); 19 | var jsxJsxbinFilepaths = jsxfiles.Select(f => Tuple.Create(f.FullName, f.Name, CreateJsxbinFilepath(f))); 20 | var jsxJsxbinPairs = jsxJsxbinFilepaths.Select(p => new JsxJsxbinPair() 21 | { 22 | Jsx = ReadFile(p.Item1), 23 | JsxFilename = p.Item2, 24 | Jsxbin = ReadFile(p.Item3) 25 | }); 26 | return jsxJsxbinPairs.ToList(); 27 | } 28 | 29 | private string CreateJsxbinFilepath(FileInfo jsxFilepath) 30 | { 31 | return Path.Combine(jsxFilepath.DirectoryName, Path.GetFileNameWithoutExtension(jsxFilepath.FullName) + ".jsxbin"); 32 | } 33 | 34 | private string ReadFile(string filepath) 35 | { 36 | return File.ReadAllText(filepath, System.Text.Encoding.UTF8); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jsxbin_to_jsx.Tests/jsxbin_to_jsx.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {40CE5B7D-7A83-4EBF-A73E-5F5E92999900} 7 | Library 8 | Properties 9 | jsxbin_to_jsx.Tests 10 | jsxbin_to_jsx.Tests 11 | v4.5.2 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 10.0 15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 17 | False 18 | UnitTest 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | {7ad7c7b3-32f0-4426-a1a5-a647fdb523c1} 61 | jsxbin_to_jsx 62 | 63 | 64 | 65 | 66 | 67 | 68 | False 69 | 70 | 71 | False 72 | 73 | 74 | False 75 | 76 | 77 | False 78 | 79 | 80 | 81 | 82 | 83 | 84 | 91 | -------------------------------------------------------------------------------- /jsxbin_to_jsx.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsxbin_to_jsx", "jsxbin_to_jsx\jsxbin_to_jsx.csproj", "{7AD7C7B3-32F0-4426-A1A5-A647FDB523C1}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "jsxbin_to_jsx.Tests", "jsxbin_to_jsx.Tests\jsxbin_to_jsx.Tests.csproj", "{40CE5B7D-7A83-4EBF-A73E-5F5E92999900}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7AD7C7B3-32F0-4426-A1A5-A647FDB523C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {7AD7C7B3-32F0-4426-A1A5-A647FDB523C1}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {7AD7C7B3-32F0-4426-A1A5-A647FDB523C1}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {7AD7C7B3-32F0-4426-A1A5-A647FDB523C1}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {40CE5B7D-7A83-4EBF-A73E-5F5E92999900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {40CE5B7D-7A83-4EBF-A73E-5F5E92999900}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {40CE5B7D-7A83-4EBF-A73E-5F5E92999900}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {40CE5B7D-7A83-4EBF-A73E-5F5E92999900}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/AbstractNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace jsxbin_to_jsx.JsxbinDecoding 8 | { 9 | public abstract class AbstractNode : INode 10 | { 11 | public const double ALL_VERSIONS = 0; 12 | private const string alphabet_lower = "ghijklmn"; 13 | private const string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"; 14 | private static readonly Dictionary decoders = new Dictionary(); 15 | private static ScanState scanState; 16 | private static readonly Regex ValidIdentifier = new Regex("^[a-zA-Z_$][0-9a-zA-Z_$]*$", RegexOptions.Compiled); 17 | private static IReferenceDecoder referenceDecoder; 18 | 19 | public abstract string Marker { get; } 20 | public abstract NodeType NodeType { get; } 21 | public abstract void Decode(); 22 | public abstract string PrettyPrint(); 23 | public bool PrintStructure { get; set; } 24 | public int IndentLevel { get; set; } 25 | 26 | public virtual double JsxbinVersion 27 | { 28 | get 29 | { 30 | return ALL_VERSIONS; 31 | } 32 | } 33 | 34 | protected ScanState ScanState 35 | { 36 | get 37 | { 38 | return scanState; 39 | } 40 | } 41 | 42 | protected bool IsValidIdentifier(string identifier) 43 | { 44 | return ValidIdentifier.IsMatch(identifier); 45 | } 46 | 47 | public static string Decode(string jsxbin, bool printStructure) 48 | { 49 | string normalized = jsxbin.Replace("\n", "").Replace("\r", "").Replace("\\", ""); 50 | Match versionMatch = Regex.Match(normalized, "^@JSXBIN@ES@([\\d.]+)@"); 51 | double version = ALL_VERSIONS; 52 | if (versionMatch.Success) 53 | version = double.Parse(versionMatch.Groups[1].Value); 54 | string noheader = Regex.Replace(normalized, "^@JSXBIN@ES@[\\d.]+@", ""); 55 | scanState = new ScanState(noheader); 56 | InitializeDecoders(scanState, version); 57 | var root = new RootNode(); 58 | root.PrintStructure = printStructure; 59 | root.Decode(); 60 | var jsx = root.PrettyPrint(); 61 | return string.Join(Environment.NewLine, jsx); 62 | } 63 | 64 | public string DecodeNumber() 65 | { 66 | var chr = GetCurrentAndAdvanceCore(scanState.Clone()); 67 | string number = ""; 68 | if (IsHex(chr, Constants.MARKER_NUMBER_8_BYTES)) 69 | { 70 | var val = GetCurrentAndAdvanceCore(scanState); 71 | number = DecodeNumberCore(8, false); 72 | } 73 | else 74 | { 75 | number = DecodeLiteral(true, false); 76 | } 77 | return number ?? "0"; 78 | } 79 | 80 | public bool DecodeBool() 81 | { 82 | var str = GetCurrentAndAdvanceCore(scanState); 83 | if (str == Constants.BOOL_FALSE) 84 | { 85 | return false; 86 | } 87 | else if (str == Constants.BOOL_TRUE) 88 | { 89 | return true; 90 | } 91 | else 92 | { 93 | throw new Exception("unexpected bool value " + str); 94 | } 95 | } 96 | 97 | private static void InitializeDecoders(ScanState scanState, double version) 98 | { 99 | decoders.Clear(); 100 | var type = typeof(INode); 101 | var types = AppDomain.CurrentDomain.GetAssemblies() 102 | .SelectMany(s => s.GetTypes()) 103 | .Where(p => p.IsClass && !p.IsAbstract && p.IsSubclassOf(typeof(AbstractNode))); 104 | foreach (var t in types) 105 | { 106 | INode n = (INode)Activator.CreateInstance(t); 107 | if (n.JsxbinVersion == ALL_VERSIONS || n.JsxbinVersion == version) 108 | decoders.Add(n.Marker, t); 109 | } 110 | if (version == 1.0) 111 | referenceDecoder = new ReferenceDecoderVersion1(); 112 | else 113 | referenceDecoder = new ReferenceDecoderVersion2(); 114 | } 115 | 116 | public INode DecodeNode() 117 | { 118 | char marker = GetCurrentAndAdvance(scanState); 119 | if (IsHex(marker, Constants.MARKER_HAS_NO_VARIANT)) 120 | { 121 | return null; 122 | } 123 | else if (decoders.ContainsKey(marker.ToString())) 124 | { 125 | var type = decoders[marker.ToString()]; 126 | INode node = (INode)Activator.CreateInstance(type); 127 | bool ignoreHeaderFunction = this.NodeType == NodeType.Root; 128 | if (PrintStructure && !ignoreHeaderFunction) 129 | { 130 | Console.WriteLine(new string(' ', 4 * IndentLevel) + node.NodeType.ToString()); 131 | node.IndentLevel = IndentLevel + 1; 132 | } 133 | node.PrintStructure = PrintStructure; 134 | node.Decode(); 135 | return node; 136 | } 137 | else 138 | { 139 | throw new Exception("No decoder found for marker " + marker); 140 | } 141 | } 142 | 143 | public char GetCurrentAndAdvance(ScanState scanState) 144 | { 145 | return GetCurrentAndAdvanceCore(scanState); 146 | } 147 | 148 | public char GetCurrentAndAdvanceCore(ScanState scanState) 149 | { 150 | char cur = scanState.getCur(); 151 | scanState.Inc(); 152 | return cur; 153 | } 154 | 155 | public bool IsNested() 156 | { 157 | return scanState.GetNestingLevels() > 0; 158 | } 159 | 160 | public void DecrementNesting() 161 | { 162 | scanState.DecrementNestingLevels(); 163 | } 164 | 165 | public LogicalExpInfo DecodeLogicalExp() 166 | { 167 | var info = new LogicalExpInfo(); 168 | info.OpName = DecodeId(); 169 | info.LeftExpr = DecodeNode(); 170 | info.RightExpr = DecodeNode(); 171 | info.LeftLiteral = DecodeVariant(); 172 | info.RightLiteral = DecodeVariant(); 173 | return info; 174 | } 175 | 176 | public string DecodeVariant() 177 | { 178 | var chr = GetCurrentAndAdvance(scanState.Clone()); 179 | if (IsHex(chr, Constants.MARKER_HAS_NO_VARIANT)) 180 | { 181 | GetCurrentAndAdvance(scanState); 182 | return null; 183 | } 184 | else 185 | { 186 | return DecodeVariantCore(); 187 | } 188 | } 189 | 190 | public bool IsHex(char src, int num) 191 | { 192 | return src == Convert.ToChar(num); 193 | } 194 | 195 | public string DecodeId() 196 | { 197 | char marker = GetCurrentAndAdvanceCore(scanState.Clone()); 198 | if (!IsHex(marker, Constants.MARKER_ID_REFERENCE)) 199 | { 200 | var id = DecodeLength().ToString(); 201 | return scanState.GetSymbol(id); 202 | } 203 | else 204 | { 205 | var type = GetCurrentAndAdvanceCore(scanState); 206 | var name = DecodeString(); 207 | var id = DecodeLength().ToString(); 208 | scanState.AddSymbol(id, name); 209 | return name; 210 | } 211 | } 212 | 213 | public string DecodeVariantCore() 214 | { 215 | char str = GetCurrentAndAdvanceCore(scanState); 216 | int typ = str - 0x61; 217 | string val = ""; 218 | switch (typ) 219 | { 220 | case 2: 221 | val = DecodeBool().ToString(); 222 | val = val.ToLower(); 223 | break; 224 | case 3: 225 | val = DecodeNumber(); 226 | break; 227 | case 4: 228 | val = DecodeString(); 229 | val = val.Replace("\\", "\\\\"); 230 | val = val.Replace("\"", "\\\""); 231 | val = "\"" + val + "\""; 232 | val = val.Replace("\n", "\\n").Replace("\t", "\\t").Replace("\r", "\\r"); 233 | break; 234 | case 0: 235 | case 1: 236 | val = "null"; 237 | break; 238 | default: 239 | throw new Exception("Unexpected Variant type: " + typ.ToString()); 240 | } 241 | return val.ToString(); 242 | } 243 | 244 | public string DecodeString() 245 | { 246 | string str = DecodeLiteral(true, false); 247 | int length = str == null ? 0 : Int32.Parse(str); 248 | if (length == 0) 249 | { 250 | return ""; 251 | } 252 | string res = ""; 253 | int i = length; 254 | while (i > 0) 255 | { 256 | res += DecodeLiteral(false, true); 257 | i--; 258 | } 259 | return res; 260 | } 261 | 262 | public string DecodeNumberCore(int numberLength, bool twosComplement) 263 | { 264 | List bytes = new List(); 265 | int i = numberLength; 266 | while (i > 0) 267 | { 268 | byte decr = DecodeByte(); 269 | bytes.Add(decr); 270 | i--; 271 | } 272 | string decryptedNumber = ""; 273 | if (numberLength == 4) 274 | { 275 | uint number = BitConverter.ToUInt32(bytes.ToArray(), 0); 276 | decryptedNumber = number.ToString(); 277 | } 278 | else if (numberLength == 2) 279 | { 280 | ushort number = BitConverter.ToUInt16(bytes.ToArray(), 0); 281 | decryptedNumber = number.ToString(); 282 | } 283 | else if (numberLength == 8) 284 | { 285 | double number = BitConverter.ToDouble(bytes.ToArray(), 0); 286 | decryptedNumber = number.ToString(); 287 | } 288 | else 289 | { 290 | throw new Exception("Unknown number length found: " + numberLength); 291 | } 292 | if (twosComplement) 293 | { 294 | decryptedNumber = "-" + decryptedNumber; 295 | return decryptedNumber; 296 | } 297 | else 298 | { 299 | return decryptedNumber; 300 | } 301 | } 302 | 303 | public string ConvertToUnicodeString(string codePoint) 304 | { 305 | int code = int.Parse(codePoint); 306 | return char.ConvertFromUtf32(code).ToString(); 307 | } 308 | 309 | public string DecodeLiteral(bool isNumber, bool isUnicodeString) 310 | { 311 | if (IsNested()) 312 | { 313 | DecrementNesting(); 314 | return null; 315 | } 316 | bool twosComplement = false; 317 | if (scanState.IsHex(Constants.MARKER_NEGATIVE_NUMBER)) 318 | { 319 | twosComplement = true; 320 | GetCurrentAndAdvanceCore(scanState); 321 | } 322 | if (scanState.IsHex(Constants.MARKER_NUMBER_4_BYTES)) 323 | { 324 | GetCurrentAndAdvanceCore(scanState); 325 | string nr = DecodeNumberCore(4, twosComplement); 326 | if (isUnicodeString) 327 | { 328 | nr = ConvertToUnicodeString(nr); 329 | } 330 | return nr; 331 | } 332 | else if (scanState.IsHex(Constants.MARKER_NUMBER_2_BYTES)) 333 | { 334 | GetCurrentAndAdvanceCore(scanState); 335 | string nr = DecodeNumberCore(2, twosComplement); 336 | if (isUnicodeString) 337 | { 338 | nr = ConvertToUnicodeString(nr); 339 | } 340 | return nr; 341 | } 342 | else 343 | { 344 | byte bz = DecodeByte(); 345 | string str = ""; 346 | if (twosComplement) 347 | { 348 | int nr = -1 * (int)bz; 349 | str = nr.ToString(); 350 | } 351 | else 352 | { 353 | if (isNumber) 354 | { 355 | str = bz.ToString(); 356 | } 357 | else 358 | { 359 | str = Encoding.GetEncoding("iso-8859-1").GetString(new byte[] { bz }); 360 | } 361 | } 362 | return str; 363 | } 364 | } 365 | 366 | public byte DecodeByte() 367 | { 368 | if (IsNested()) 369 | { 370 | DecrementNesting(); 371 | return 0; 372 | } 373 | int[] res = new int[2]; 374 | var first = GetCurrentAndAdvanceCore(scanState); 375 | byte decrypt = 0; 376 | int minus41 = first - 0x41; 377 | if (minus41 <= 0x19) 378 | { 379 | decrypt = (byte)minus41; 380 | } 381 | else 382 | { 383 | int n = alphabet_lower.IndexOf(first); 384 | char second = GetCurrentAndAdvanceCore(scanState); 385 | int rest = alphabet_upper.IndexOf(second); 386 | decrypt = (byte)(n * 32 + rest); 387 | } 388 | return decrypt; 389 | } 390 | 391 | public ConstDeclarationInfo DecodeConstDeclaration() 392 | { 393 | ConstDeclarationInfo info = new ConstDeclarationInfo(); 394 | List res = new List(); 395 | info.Name = DecodeId(); 396 | info.Length = DecodeLength(); 397 | info.Expr = DecodeNode(); 398 | info.Literal = DecodeVariant(); 399 | info.BoolVal1 = DecodeBool(); 400 | info.BoolVal2 = DecodeBool(); 401 | return info; 402 | } 403 | 404 | public int DecodeLength() 405 | { 406 | var length = DecodeLiteral(true, false); 407 | return length == null ? 0 : Math.Abs(Int32.Parse(length)); 408 | } 409 | 410 | public LineInfo DecodeLineInfo() 411 | { 412 | var info = new LineInfo(); 413 | List res = new List(); 414 | var lineNumber = DecodeLength(); 415 | var child = DecodeNode(); 416 | int length = DecodeLength(); 417 | info.LineNumber = lineNumber; 418 | info.Child = child; 419 | int i = length; 420 | while (i > 0) 421 | { 422 | info.Labels.Add(DecodeId()); 423 | i--; 424 | } 425 | return info; 426 | } 427 | 428 | public Tuple DecodeReference() 429 | { 430 | return referenceDecoder.Decode(this); 431 | } 432 | 433 | public LineInfo DecodeBody() 434 | { 435 | return DecodeLineInfo(); 436 | } 437 | 438 | public List DecodeChildren() 439 | { 440 | int length = DecodeLength(); 441 | if (length == 0) 442 | { 443 | return new List(); 444 | } 445 | int i = length; 446 | List res = new List(); 447 | while (i > 0) 448 | { 449 | var child = DecodeNode(); 450 | if (child != null) 451 | { 452 | res.Add(child); 453 | } 454 | i--; 455 | } 456 | return res; 457 | } 458 | 459 | public void ForEachChild(Action action) 460 | { 461 | int length = DecodeLength(); 462 | if (length == 0) 463 | { 464 | return; 465 | } 466 | int i = length; 467 | while (i > 0) 468 | { 469 | action(); 470 | i--; 471 | } 472 | } 473 | 474 | public FunctionSignature DecodeSignature() 475 | { 476 | var sig = new FunctionSignature(); 477 | int length = DecodeLength(); 478 | if (length > 0) 479 | { 480 | int i = length; 481 | while (i > 0) 482 | { 483 | var paramName = DecodeId(); 484 | // does not contain anything worthwile, only nesting 485 | var paramLength = DecodeLength(); 486 | sig.Parameter.Add(Tuple.Create(paramName, paramLength)); 487 | i--; 488 | } 489 | } 490 | sig.Header1 = DecodeLength(); 491 | sig.Type = DecodeLength(); 492 | sig.Header3 = DecodeLength(); 493 | sig.Name = DecodeId(); 494 | sig.Header5 = DecodeLiteralNumber2(); 495 | return sig; 496 | } 497 | 498 | public int DecodeLiteralNumber2() 499 | { 500 | string number = DecodeLiteral(true, false); 501 | return number == null ? 0 : Int32.Parse(number); 502 | } 503 | 504 | public Tuple, INode> DecodeRefAndNode() 505 | { 506 | List res = new List(); 507 | var refa = DecodeReference(); 508 | var node = DecodeNode(); 509 | return Tuple.Create(refa, node); 510 | } 511 | 512 | public Tuple DecodeIdAndNode() 513 | { 514 | List res = new List(); 515 | string id = DecodeId(); 516 | var node = DecodeNode(); 517 | return Tuple.Create(id, node); 518 | } 519 | 520 | public override string ToString() 521 | { 522 | throw new Exception("Call PrettyPrint() instead."); 523 | } 524 | } 525 | } 526 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ArgumentList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class ArgumentList : AbstractNode 8 | { 9 | bool boolVal; 10 | 11 | public override string Marker 12 | { 13 | get { return Convert.ToChar(0x52).ToString(); } 14 | } 15 | 16 | public override NodeType NodeType 17 | { 18 | get 19 | { 20 | return NodeType.ArgumentList; 21 | } 22 | } 23 | 24 | public List Arguments { get; set; } 25 | 26 | public override void Decode() 27 | { 28 | Arguments = DecodeChildren(); 29 | boolVal = DecodeBool(); 30 | } 31 | 32 | public override string PrettyPrint() 33 | { 34 | return string.Join(", ", Arguments.Select(a => a.PrettyPrint())); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ArrayExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class ArrayExpr : AbstractNode 7 | { 8 | INode arguments; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x41).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.ArrayExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | arguments = DecodeNode(); 26 | } 27 | 28 | public override string PrettyPrint() 29 | { 30 | ArgumentList args = (ArgumentList)arguments; 31 | if (args == null) 32 | { 33 | return "[]"; 34 | } 35 | return "[" + string.Join(", ", args.Arguments.Select(a => a.PrettyPrint())) + "]"; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ArrayIndexingExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ArrayIndexingExpr : AbstractNode 6 | { 7 | string arrayName; 8 | string expr; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x51).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.ArrayIndexingExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | var array = DecodeRefAndNode(); 26 | var exprInfo = DecodeNode(); 27 | arrayName = array.Item2.PrettyPrint(); 28 | expr = exprInfo.PrettyPrint(); 29 | } 30 | 31 | public override string PrettyPrint() 32 | { 33 | return string.Format("{0}[{1}]", arrayName, expr); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/AssignmentExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class AssignmentExpr : AbstractNode 7 | { 8 | string varName; 9 | bool isDeclaration; 10 | bool isShorthand; 11 | INode expr; 12 | string literal; 13 | 14 | public override string Marker 15 | { 16 | get { return Convert.ToChar(0x53).ToString(); } 17 | } 18 | 19 | public override NodeType NodeType 20 | { 21 | get 22 | { 23 | return NodeType.AssignmentExpr; 24 | } 25 | } 26 | 27 | public override void Decode() 28 | { 29 | varName = DecodeId(); 30 | var type = DecodeLength(); 31 | expr = DecodeNode(); 32 | literal = DecodeVariant(); 33 | isShorthand = DecodeBool(); 34 | isDeclaration = DecodeBool(); 35 | } 36 | 37 | public override string PrettyPrint() 38 | { 39 | string varKeyword = isDeclaration ? "var " : ""; 40 | string result = ""; 41 | if (isShorthand) 42 | { 43 | BinaryExpr binaryExpr = (BinaryExpr)expr; 44 | string assignExpr = literal == null ? binaryExpr.Op : literal; 45 | string opName = binaryExpr.OpName; 46 | result = string.Format("{0}{1} {2}= {3}", varKeyword, varName, opName, assignExpr); 47 | } 48 | else 49 | { 50 | string assignExpr = literal == null ? expr.PrettyPrint() : literal; 51 | result = string.Format("{0}{1} = {2}", varKeyword, varName, assignExpr); 52 | } 53 | return result; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/BinaryExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class BinaryExpr : AbstractNode 7 | { 8 | string opName; 9 | INode left; 10 | INode right; 11 | string literalLeft; 12 | string literalRight; 13 | 14 | public override string Marker 15 | { 16 | get { return Convert.ToChar(0x43).ToString(); } 17 | } 18 | 19 | public override NodeType NodeType 20 | { 21 | get 22 | { 23 | return NodeType.BinaryExpr; 24 | } 25 | } 26 | 27 | public string OpName { get; set; } 28 | public string Op { get; set; } 29 | 30 | public override void Decode() 31 | { 32 | opName = DecodeId(); 33 | left = DecodeNode(); 34 | right = DecodeNode(); 35 | literalLeft = DecodeVariant(); 36 | literalRight = DecodeVariant(); 37 | var leftExpr = CreateExpr(literalLeft, left); 38 | var rightExpr = CreateExpr(literalRight, right); 39 | bool isUpdateExpr = (leftExpr != null && rightExpr == null) || (leftExpr == null && rightExpr != null); 40 | if (isUpdateExpr) 41 | { 42 | string op = leftExpr + rightExpr; 43 | OpName = opName; 44 | Op = op; 45 | } 46 | else 47 | { 48 | Op = string.Format("{0} {1} {2}", leftExpr, opName, rightExpr); 49 | } 50 | } 51 | 52 | public override string PrettyPrint() 53 | { 54 | return Op; 55 | } 56 | 57 | string CreateExpr(string literal, INode expr) 58 | { 59 | bool requiresParens = false; 60 | string actualExpr; 61 | if (expr != null && expr.NodeType == NodeType.BinaryExpr) 62 | { 63 | var binaryExpr = (BinaryExpr)expr; 64 | actualExpr = binaryExpr.Op; 65 | requiresParens = true; 66 | bool isAssociativeOp = (binaryExpr.opName == "*" && opName == "*") || (binaryExpr.opName == "+" && opName == "+"); 67 | if (isAssociativeOp) 68 | { 69 | requiresParens = false; 70 | } 71 | } 72 | else 73 | { 74 | actualExpr = expr == null ? literal : expr.PrettyPrint(); 75 | } 76 | return requiresParens ? "(" + actualExpr + ")" : actualExpr; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ConditionalExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class ConditionalExpr : AbstractNode 7 | { 8 | INode condition; 9 | INode ifTrue; 10 | INode ifFalse; 11 | 12 | public override string Marker 13 | { 14 | get { return Convert.ToChar(0x64).ToString(); } 15 | } 16 | 17 | public override NodeType NodeType 18 | { 19 | get 20 | { 21 | return NodeType.ConditionalExpr; 22 | } 23 | } 24 | 25 | public override void Decode() 26 | { 27 | condition = DecodeNode(); 28 | ifTrue = DecodeNode(); 29 | ifFalse = DecodeNode(); 30 | } 31 | 32 | public override string PrettyPrint() 33 | { 34 | string printed = string.Format("{0} ? {1} : {2}", condition.PrettyPrint(), 35 | RequiresParens(ifTrue) ? "(" + ifTrue.PrettyPrint() + ")" : ifTrue.PrettyPrint(), 36 | RequiresParens(ifFalse) ? "(" + ifFalse.PrettyPrint() + ")" : ifFalse.PrettyPrint()); 37 | return printed; 38 | } 39 | 40 | bool RequiresParens(INode node) 41 | { 42 | return node.NodeType == NodeType.ConditionalExpr || node.NodeType == NodeType.ArgumentList; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ConstDeclaration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public sealed class ConstDeclaration : AbstractNode 6 | { 7 | ConstDeclarationInfo info; 8 | 9 | public override string Marker 10 | { 11 | get 12 | { 13 | return Convert.ToChar(0x47).ToString(); 14 | } 15 | } 16 | 17 | public override NodeType NodeType 18 | { 19 | get 20 | { 21 | return NodeType.ConstDeclaration; 22 | } 23 | } 24 | 25 | public override void Decode() 26 | { 27 | info = DecodeConstDeclaration(); 28 | } 29 | 30 | public override string PrettyPrint() 31 | { 32 | string name = info.Name; 33 | string value = info.GetValue(); 34 | return string.Format("const {0} = {1}", name, value); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ConstDeclarationInfo.cs: -------------------------------------------------------------------------------- 1 | namespace jsxbin_to_jsx.JsxbinDecoding 2 | { 3 | public sealed class ConstDeclarationInfo 4 | { 5 | 6 | public string Name { get; set; } 7 | public int Length { get; set; } 8 | public INode Expr { get; set; } 9 | public string Literal { get; set; } 10 | public bool BoolVal1 { get; set; } 11 | public bool BoolVal2 { get; set; } 12 | 13 | public string GetValue() 14 | { 15 | return Expr == null ? Literal : Expr.PrettyPrint(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace jsxbin_to_jsx.JsxbinDecoding 2 | { 3 | public static class Constants 4 | { 5 | public const int MARKER_HAS_NO_VARIANT = 0x6E; 6 | public const int MARKER_ID_REFERENCE = 0x7A; 7 | public const int MARKER_NEGATIVE_NUMBER = 0x79; 8 | public const int MARKER_NUMBER_8_BYTES = 0x38; 9 | public const int MARKER_NUMBER_4_BYTES = 0x34; 10 | public const int MARKER_NUMBER_2_BYTES = 0x32; 11 | public const int BOOL_TRUE = 0x74; 12 | public const int BOOL_FALSE = 0x66; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/DebuggerStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class DebuggerStatement : AbstractNode, IStatement 6 | { 7 | LineInfo lineInfo; 8 | 9 | public int LineNumber 10 | { 11 | get 12 | { 13 | return lineInfo.LineNumber; 14 | } 15 | } 16 | 17 | public override string Marker 18 | { 19 | get 20 | { 21 | return Convert.ToChar(0x48).ToString(); 22 | } 23 | } 24 | 25 | public override NodeType NodeType 26 | { 27 | get 28 | { 29 | return NodeType.DebuggerStatement; 30 | } 31 | } 32 | 33 | public override void Decode() 34 | { 35 | lineInfo = DecodeLineInfo(); 36 | } 37 | 38 | public override string PrettyPrint() 39 | { 40 | string label = lineInfo.CreateLabelStmt(); 41 | string name = "debugger"; 42 | return label + name; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/DeleteExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class DeleteExpr : AbstractNode 7 | { 8 | Tuple idAndNode; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x69).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.DeleteExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | idAndNode = DecodeIdAndNode(); 26 | } 27 | 28 | public override string PrettyPrint() 29 | { 30 | string name = idAndNode.Item1; 31 | string arg = idAndNode.Item2.PrettyPrint(); 32 | return name + " " + arg; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/DoWhileExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class DoWhileExpr : AbstractNode, IStatement 8 | { 9 | LineInfo body; 10 | string test; 11 | 12 | public int LineNumber 13 | { 14 | get 15 | { 16 | return body.LineNumber; 17 | } 18 | } 19 | 20 | public override string Marker 21 | { 22 | get { return Convert.ToChar(0x49).ToString(); } 23 | } 24 | 25 | public override NodeType NodeType 26 | { 27 | get 28 | { 29 | return NodeType.DoWhileExpr; 30 | } 31 | } 32 | 33 | public override void Decode() 34 | { 35 | body = DecodeBody(); 36 | test = DecodeNode().PrettyPrint(); 37 | } 38 | 39 | public override string PrettyPrint() 40 | { 41 | var label = body.CreateLabelStmt(); 42 | var bodyExpr = body.CreateBody(); 43 | StringBuilder b = new StringBuilder(); 44 | b.AppendLine(label + "do {"); 45 | b.AppendLine(" " + bodyExpr); 46 | b.Append("} while (" + test + ")"); 47 | return b.ToString(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ExprNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ExprNode : AbstractNode, IStatement 6 | { 7 | LineInfo lineInfo; 8 | INode expr; 9 | 10 | public int LineNumber 11 | { 12 | get 13 | { 14 | return lineInfo.LineNumber; 15 | } 16 | } 17 | 18 | public override string Marker 19 | { 20 | get { return Convert.ToChar(0x4A).ToString(); } 21 | } 22 | 23 | public override NodeType NodeType 24 | { 25 | get 26 | { 27 | return NodeType.ExprNode; 28 | } 29 | } 30 | 31 | public INode Expr 32 | { 33 | get 34 | { 35 | return expr; 36 | } 37 | } 38 | 39 | public override void Decode() 40 | { 41 | lineInfo = DecodeLineInfo(); 42 | expr = DecodeNode(); 43 | } 44 | 45 | public override string PrettyPrint() 46 | { 47 | string labels = lineInfo.CreateLabelStmt(); 48 | return labels + expr.PrettyPrint(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ForInStatementVersion1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class ForInStatementVersion1 : AbstractNode, IStatement 7 | { 8 | LineInfo bodyInfo; 9 | string loopVarName; 10 | string objExpr; 11 | int part25; 12 | string part3; 13 | 14 | public int LineNumber 15 | { 16 | get 17 | { 18 | return bodyInfo.LineNumber; 19 | } 20 | } 21 | 22 | public override string Marker 23 | { 24 | get { return Convert.ToChar(0x4C).ToString(); } 25 | } 26 | 27 | public override NodeType NodeType 28 | { 29 | get 30 | { 31 | return NodeType.ForInStatement; 32 | } 33 | } 34 | 35 | public override double JsxbinVersion 36 | { 37 | get 38 | { 39 | return 1.0; 40 | } 41 | } 42 | 43 | public override void Decode() 44 | { 45 | bodyInfo = DecodeBody(); 46 | loopVarName = DecodeNode().PrettyPrint(); 47 | objExpr = DecodeNode().PrettyPrint(); 48 | part25 = DecodeLength(); 49 | part3 = DecodeId(); 50 | // Doesn't seem to exist in version 1.0 51 | // isForEachLoop = DecodeBool(); 52 | } 53 | 54 | public override string PrettyPrint() 55 | { 56 | string label = bodyInfo.CreateLabelStmt(); 57 | string body = bodyInfo.CreateBody(); 58 | StringBuilder b = new StringBuilder(); 59 | b.AppendLine(string.Format("{0}for (var {1} in {2}) {{", label, loopVarName, objExpr)); 60 | b.AppendLine(body); 61 | b.Append("}"); 62 | return b.ToString(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ForInStatementVersion2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class ForInStatementVersion2 : AbstractNode, IStatement 7 | { 8 | LineInfo bodyInfo; 9 | string loopVarName; 10 | string objExpr; 11 | int part25; 12 | string part3; 13 | bool isForEachLoop; 14 | 15 | public int LineNumber 16 | { 17 | get 18 | { 19 | return bodyInfo.LineNumber; 20 | } 21 | } 22 | 23 | public override string Marker 24 | { 25 | get { return Convert.ToChar(0x4C).ToString(); } 26 | } 27 | 28 | public override NodeType NodeType 29 | { 30 | get 31 | { 32 | return NodeType.ForInStatement; 33 | } 34 | } 35 | 36 | public override double JsxbinVersion 37 | { 38 | get 39 | { 40 | return 2.0; 41 | } 42 | } 43 | 44 | public override void Decode() 45 | { 46 | bodyInfo = DecodeBody(); 47 | loopVarName = DecodeNode().PrettyPrint(); 48 | objExpr = DecodeNode().PrettyPrint(); 49 | part25 = DecodeLength(); 50 | part3 = DecodeId(); 51 | isForEachLoop = DecodeBool(); 52 | } 53 | 54 | public override string PrettyPrint() 55 | { 56 | string label = bodyInfo.CreateLabelStmt(); 57 | string body = bodyInfo.CreateBody(); 58 | string loopName = isForEachLoop ? "for each" : "for"; 59 | StringBuilder b = new StringBuilder(); 60 | b.AppendLine(string.Format("{0}{1} (var {2} in {3}) {{", label, loopName, loopVarName, objExpr)); 61 | b.AppendLine(body); 62 | b.Append("}"); 63 | return b.ToString(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ForStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class ForStatement : AbstractNode, IStatement 8 | { 9 | LineInfo bodyInfo; 10 | INode loopVarInfo; 11 | string initExpr; 12 | INode upperBoundInfo; 13 | string stepSize; 14 | int part6; 15 | string compOp; 16 | 17 | public int LineNumber 18 | { 19 | get 20 | { 21 | return bodyInfo.LineNumber; 22 | } 23 | } 24 | 25 | public override string Marker 26 | { 27 | get { return Convert.ToChar(0x61).ToString(); } 28 | } 29 | 30 | public override NodeType NodeType 31 | { 32 | get 33 | { 34 | return NodeType.ForStatement; 35 | } 36 | } 37 | 38 | public override void Decode() 39 | { 40 | bodyInfo = DecodeBody(); 41 | loopVarInfo = DecodeNode(); 42 | initExpr = DecodeNumber(); 43 | upperBoundInfo = DecodeNode(); 44 | stepSize = DecodeNumber(); 45 | part6 = DecodeLength(); 46 | compOp = DecodeId(); 47 | } 48 | 49 | public override string PrettyPrint() 50 | { 51 | string label = bodyInfo.CreateLabelStmt(); 52 | string body = bodyInfo.CreateBody(); 53 | string loopVarName = loopVarInfo == null ? null : loopVarInfo.PrettyPrint(); 54 | string upperBound = upperBoundInfo == null ? null : upperBoundInfo.PrettyPrint(); 55 | StringBuilder b = new StringBuilder(); 56 | b.AppendLine(string.Format("{0}for (var {1} = {2};{1} {3} {4}; {1} += {5}) {{", label, loopVarName, initExpr, compOp, upperBound, stepSize)); 57 | b.AppendLine(body); 58 | b.Append("}"); 59 | return b.ToString(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ForStatement2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class ForStatement2 : AbstractNode, IStatement 7 | { 8 | LineInfo bodyInfo; 9 | INode initInfo; 10 | INode testInfo; 11 | INode updateInfo; 12 | 13 | public int LineNumber 14 | { 15 | get 16 | { 17 | return bodyInfo.LineNumber; 18 | } 19 | } 20 | 21 | public override string Marker 22 | { 23 | get { return Convert.ToChar(0x4B).ToString(); } 24 | } 25 | 26 | public override NodeType NodeType 27 | { 28 | get 29 | { 30 | return NodeType.ForStatement2; 31 | } 32 | } 33 | 34 | public override void Decode() 35 | { 36 | bodyInfo = DecodeBody(); 37 | initInfo = DecodeNode(); 38 | testInfo = DecodeNode(); 39 | updateInfo = DecodeNode(); 40 | } 41 | 42 | public override string PrettyPrint() 43 | { 44 | var label = bodyInfo.CreateLabelStmt(); 45 | string body = bodyInfo.CreateBody(); 46 | StringBuilder b = new StringBuilder(); 47 | b.AppendLine(string.Format("{0}for ({1}; {2}; {3}) {{", 48 | label, 49 | initInfo == null ? "" : initInfo.PrettyPrint(), 50 | testInfo == null ? "" : testInfo.PrettyPrint(), 51 | updateInfo == null ? "" : updateInfo.PrettyPrint())); 52 | b.AppendLine(body); 53 | b.Append("}"); 54 | return b.ToString(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/FunctionCallExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class FunctionCallExpr : AbstractNode 8 | { 9 | INode functionName; 10 | INode argsInfo; 11 | bool isConstructorCall; 12 | 13 | public override string Marker 14 | { 15 | get { return Convert.ToChar(0x45).ToString(); } 16 | } 17 | 18 | public override NodeType NodeType 19 | { 20 | get 21 | { 22 | return NodeType.FunctionCallExpr; 23 | } 24 | } 25 | 26 | public override void Decode() 27 | { 28 | functionName = DecodeNode(); 29 | argsInfo = DecodeNode(); 30 | isConstructorCall = DecodeBool(); 31 | } 32 | 33 | public override string PrettyPrint() 34 | { 35 | ArgumentList args = (ArgumentList)argsInfo; 36 | string ctor = isConstructorCall ? "new " : ""; 37 | string callExpr = string.Format("{0}{1}({2})", ctor, functionName.PrettyPrint(), args == null ? "" : string.Join(", ", args.Arguments.Select(a => a.PrettyPrint()))); 38 | return callExpr; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/FunctionDeclaration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class FunctionDeclaration : AbstractNode, IStatement 8 | { 9 | LineInfo bodyInfo; 10 | FunctionSignature signature; 11 | int type; 12 | 13 | public int LineNumber 14 | { 15 | get 16 | { 17 | return bodyInfo.LineNumber; 18 | } 19 | } 20 | 21 | public override string Marker 22 | { 23 | get { return Convert.ToChar(0x4D).ToString(); } 24 | } 25 | 26 | public override NodeType NodeType 27 | { 28 | get 29 | { 30 | return NodeType.FunctionDeclaration; 31 | } 32 | } 33 | 34 | public override void Decode() 35 | { 36 | bodyInfo = DecodeLineInfo(); 37 | signature = DecodeSignature(); 38 | type = DecodeLength(); 39 | } 40 | 41 | public override string PrettyPrint() 42 | { 43 | bool isHeader = signature.Header5 == 1; 44 | string body = bodyInfo.CreateBody(); 45 | // Header seems to imply an automatically added "wrapper" function which is not really needed. 46 | if (isHeader) 47 | { 48 | return body; 49 | } 50 | // Filter out parameters that are actually local variables which for some reason count as parameters. 51 | var paramList = signature.Parameter.OrderBy(p => p.Item2).Where(p => p.Item2 > 536870000 && p.Item2 < 540000000).Select(p => p.Item1).ToList(); 52 | var paramNames = string.Join(", ", paramList); 53 | StringBuilder b = new StringBuilder(); 54 | b.AppendLine(string.Format("function {0}({1}) {{", signature.Name, paramNames)); 55 | b.AppendLine(body); 56 | b.Append("}"); 57 | return b.ToString(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/FunctionExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class FunctionExpr : AbstractNode, IStatement 7 | { 8 | LineInfo lineInfo; 9 | INode expr; 10 | 11 | public int LineNumber 12 | { 13 | get 14 | { 15 | return lineInfo.LineNumber; 16 | } 17 | } 18 | 19 | public override string Marker 20 | { 21 | get { return Convert.ToChar(0x4E).ToString(); } 22 | } 23 | 24 | public override NodeType NodeType 25 | { 26 | get 27 | { 28 | return NodeType.FunctionExpr; 29 | } 30 | } 31 | 32 | public override void Decode() 33 | { 34 | lineInfo = DecodeLineInfo(); 35 | expr = DecodeNode(); 36 | } 37 | 38 | public override string PrettyPrint() 39 | { 40 | string resultingExpr = expr.PrettyPrint(); 41 | return resultingExpr; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/FunctionSignature.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class FunctionSignature 7 | { 8 | public FunctionSignature() 9 | { 10 | Parameter = new List>(); 11 | } 12 | 13 | public int Header1 { get; set; } 14 | public int Type { get; set; } 15 | public int Header3 { get; set; } 16 | public string Name { get; set; } 17 | public int Header5 { get; set; } 18 | public List> Parameter { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/INode.cs: -------------------------------------------------------------------------------- 1 | namespace jsxbin_to_jsx.JsxbinDecoding 2 | { 3 | public interface INode 4 | { 5 | NodeType NodeType { get; } 6 | string Marker { get; } 7 | void Decode(); 8 | string PrettyPrint(); 9 | bool PrintStructure { get; set; } 10 | int IndentLevel { get; set; } 11 | double JsxbinVersion { get; } 12 | string DecodeId(); 13 | bool DecodeBool(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IReferenceDecoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public interface IReferenceDecoder 6 | { 7 | double JsxbinVersion { get; } 8 | Tuple Decode(INode node); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace jsxbin_to_jsx.JsxbinDecoding 8 | { 9 | public interface IStatement 10 | { 11 | int LineNumber { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IdNodeVersion1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class IdNodeVersion1 : AbstractNode 6 | { 7 | string id; 8 | 9 | public override string Marker 10 | { 11 | get { return Convert.ToChar(0x6A).ToString(); } 12 | } 13 | 14 | public override NodeType NodeType 15 | { 16 | get 17 | { 18 | return NodeType.IdNode; 19 | } 20 | } 21 | 22 | public override double JsxbinVersion 23 | { 24 | get 25 | { 26 | return 1.0; 27 | } 28 | } 29 | 30 | public override void Decode() 31 | { 32 | id = DecodeId(); 33 | // Version 1.0 doesn't seem to have this field. 34 | // boolVal = DecodeBool(); 35 | } 36 | 37 | public override string PrettyPrint() 38 | { 39 | return id; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IdNodeVersion2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class IdNodeVersion2 : AbstractNode 6 | { 7 | string id; 8 | bool boolVal; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x6A).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.IdNode; 20 | } 21 | } 22 | 23 | public override double JsxbinVersion 24 | { 25 | get 26 | { 27 | return 2.0; 28 | } 29 | } 30 | 31 | public override void Decode() 32 | { 33 | id = DecodeId(); 34 | boolVal = DecodeBool(); 35 | } 36 | 37 | public override string PrettyPrint() 38 | { 39 | return id; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IdRefExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class IdRefExpr : AbstractNode 6 | { 7 | Tuple val; 8 | int type; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x56).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.IdRefExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | val = DecodeReference(); 26 | type = DecodeLength(); 27 | } 28 | 29 | public override string PrettyPrint() 30 | { 31 | string idName = val.Item1; 32 | return idName; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IfStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class IfStatement : AbstractNode, IStatement 8 | { 9 | LineInfo body; 10 | INode test; 11 | INode tail; 12 | 13 | public int LineNumber 14 | { 15 | get 16 | { 17 | return body.LineNumber; 18 | } 19 | } 20 | 21 | public override string Marker 22 | { 23 | get { return Convert.ToChar(0x4F).ToString(); } 24 | } 25 | 26 | public override NodeType NodeType 27 | { 28 | get 29 | { 30 | return NodeType.IfStatement; 31 | } 32 | } 33 | 34 | public INode Tail 35 | { 36 | get 37 | { 38 | return tail; 39 | } 40 | 41 | set 42 | { 43 | tail = value; 44 | } 45 | } 46 | 47 | public INode Test 48 | { 49 | get 50 | { 51 | return test; 52 | } 53 | 54 | set 55 | { 56 | test = value; 57 | } 58 | } 59 | 60 | public LineInfo Body 61 | { 62 | get 63 | { 64 | return body; 65 | } 66 | 67 | set 68 | { 69 | body = value; 70 | } 71 | } 72 | 73 | public override void Decode() 74 | { 75 | body = DecodeLineInfo(); 76 | test = DecodeNode(); 77 | tail = DecodeNode(); 78 | } 79 | 80 | public override string PrettyPrint() 81 | { 82 | StringBuilder output = new StringBuilder(); 83 | BuildIf(output); 84 | if (!HasElse()) 85 | { 86 | return output.ToString(); 87 | } 88 | BuildTail(output); 89 | return output.ToString(); 90 | } 91 | 92 | void BuildIf(StringBuilder output) 93 | { 94 | string label = body.CreateLabelStmt(); 95 | string bodyExpr = body.CreateBody(); 96 | string testExpr = test.PrettyPrint(); 97 | output.AppendLine(string.Format("{0}if ({1}) {{", label, testExpr)); 98 | output.AppendLine(bodyExpr); 99 | output.Append("}"); 100 | } 101 | 102 | void BuildTail(StringBuilder output) 103 | { 104 | INode currentTail = tail; 105 | while (IsElseIf(currentTail)) 106 | { 107 | var elseIf = (IfStatement)currentTail; 108 | BuildElseIf(elseIf, output); 109 | currentTail = elseIf.Tail; 110 | } 111 | BuildElse(currentTail, output); 112 | } 113 | 114 | void BuildElseIf(IfStatement node, StringBuilder output) 115 | { 116 | output.AppendLine(string.Format(" {0}else if ({1}) {{", node.Body.CreateLabelStmt(), node.Test.PrettyPrint())); 117 | output.AppendLine(node.Body.CreateBody()); 118 | output.Append("}"); 119 | } 120 | 121 | void BuildElse(INode node, StringBuilder output) 122 | { 123 | output.AppendLine(" else {"); 124 | output.AppendLine(node.PrettyPrint()); 125 | output.Append("}"); 126 | } 127 | 128 | bool IsElseIf(INode node) 129 | { 130 | return node.NodeType == NodeType.IfStatement && ((IfStatement)node).Tail != null; 131 | } 132 | 133 | bool HasElse() 134 | { 135 | return Tail != null; 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IncrementExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class IncrementExpr : AbstractNode 6 | { 7 | string id; 8 | int p2; 9 | string addOrSubtract; 10 | bool isPostFix; 11 | 12 | public override string Marker 13 | { 14 | get { return Convert.ToChar(0x54).ToString(); } 15 | } 16 | 17 | public override NodeType NodeType 18 | { 19 | get 20 | { 21 | return NodeType.IncrementExpr; 22 | } 23 | } 24 | 25 | public override void Decode() 26 | { 27 | id = DecodeId(); 28 | p2 = DecodeLength(); 29 | addOrSubtract = DecodeNumber(); 30 | isPostFix = DecodeBool(); 31 | } 32 | 33 | public override string PrettyPrint() 34 | { 35 | string op = ""; 36 | if (addOrSubtract == "1") 37 | { 38 | op = "++"; 39 | } 40 | else 41 | { 42 | op = "--"; 43 | } 44 | if (isPostFix) 45 | { 46 | return id + op; 47 | } 48 | else 49 | { 50 | return op + id; 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/IndexingIncrementExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class IndexingIncrementExpr : AbstractNode 6 | { 7 | string varName; 8 | int addOrSubtract; 9 | bool isPostfix; 10 | 11 | public override string Marker 12 | { 13 | get { return Convert.ToChar(0x50).ToString(); } 14 | } 15 | 16 | public override NodeType NodeType 17 | { 18 | get 19 | { 20 | return NodeType.IndexingIncrementExpr; 21 | } 22 | } 23 | 24 | public override void Decode() 25 | { 26 | varName = DecodeNode().PrettyPrint(); 27 | addOrSubtract = DecodeLiteralNumber2(); 28 | isPostfix = DecodeBool(); 29 | } 30 | 31 | public override string PrettyPrint() 32 | { 33 | string op = addOrSubtract == 1 ? "++" : "--"; 34 | var result = isPostfix ? varName + op : op + varName; 35 | return result; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/JumpStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class JumpStatement : AbstractNode, IStatement 6 | { 7 | LineInfo labelInfo; 8 | string jmpLocation; 9 | bool isBreakStatement; 10 | 11 | public int LineNumber 12 | { 13 | get 14 | { 15 | return labelInfo.LineNumber; 16 | } 17 | } 18 | 19 | public override string Marker 20 | { 21 | get { return Convert.ToChar(0x44).ToString(); } 22 | } 23 | 24 | public override NodeType NodeType 25 | { 26 | get 27 | { 28 | return NodeType.JumpStatement; 29 | } 30 | } 31 | 32 | public override void Decode() 33 | { 34 | labelInfo = DecodeLineInfo(); 35 | jmpLocation = DecodeId(); 36 | isBreakStatement = DecodeBool(); 37 | } 38 | 39 | public override string PrettyPrint() 40 | { 41 | string jmp = labelInfo.CreateLabelStmt(); 42 | if (isBreakStatement) 43 | { 44 | jmp += "break " + jmpLocation; 45 | } 46 | else 47 | { 48 | jmp += "continue " + jmpLocation; 49 | } 50 | jmp += ";"; 51 | return jmp; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/LineInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public sealed class LineInfo 8 | { 9 | public LineInfo() 10 | { 11 | Labels = new List(); 12 | } 13 | public int LineNumber { get; set; } 14 | public INode Child { get; set; } 15 | public List Labels { get; set; } 16 | 17 | public string CreateLabelStmt() 18 | { 19 | return string.Join(Environment.NewLine, Labels.Select(s => s + ": ")); 20 | } 21 | 22 | public string CreateBody() 23 | { 24 | return Child == null ? string.Empty : Child.PrettyPrint(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/LogicalExp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public sealed class LogicalExp : AbstractNode 7 | { 8 | LogicalExpInfo info; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x55).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.LogicalExp; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | info = DecodeLogicalExp(); 26 | } 27 | 28 | public override string PrettyPrint() 29 | { 30 | return string.Format("{0} {1} {2}", info.GetLeftExp(), info.OpName, info.GetRightExp()); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/LogicalExpInfo.cs: -------------------------------------------------------------------------------- 1 | namespace jsxbin_to_jsx.JsxbinDecoding 2 | { 3 | public sealed class LogicalExpInfo 4 | { 5 | public string OpName { get; set; } 6 | public INode LeftExpr { get; set; } 7 | public string LeftLiteral { get; set; } 8 | public INode RightExpr { get; set; } 9 | public string RightLiteral { get; set; } 10 | 11 | 12 | public string GetLeftExp() 13 | { 14 | return GetExpr(LeftExpr, LeftLiteral); 15 | } 16 | 17 | public string GetRightExp() 18 | { 19 | return GetExpr(RightExpr, RightLiteral); 20 | } 21 | 22 | public string GetExpr(INode expr, string literal) 23 | { 24 | return expr == null ? literal : expr.PrettyPrint(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/MemberAssignmentExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class MemberAssignmentExpr : AbstractNode 7 | { 8 | INode varNode; 9 | INode expr; 10 | string literal; 11 | bool isShorthand; 12 | 13 | public override string Marker 14 | { 15 | get { return Convert.ToChar(0x42).ToString(); } 16 | } 17 | 18 | public override NodeType NodeType 19 | { 20 | get 21 | { 22 | return NodeType.MemberAssignmentExpr; 23 | } 24 | } 25 | 26 | public override void Decode() 27 | { 28 | varNode = DecodeNode(); 29 | expr = DecodeNode(); 30 | literal = DecodeVariant(); 31 | isShorthand = DecodeBool(); 32 | } 33 | 34 | public override string PrettyPrint() 35 | { 36 | if (isShorthand) 37 | { 38 | BinaryExpr binaryExpr = (BinaryExpr)expr; 39 | string assignExpr = literal == null ? binaryExpr.Op : literal; 40 | string opName = binaryExpr.OpName; 41 | return string.Format("{0} {1}= {2}", varNode.PrettyPrint(), opName, assignExpr); 42 | } 43 | else 44 | { 45 | string assignExpr = literal == null ? expr.PrettyPrint() : literal; 46 | return string.Format("{0} = {1}", varNode.PrettyPrint(), assignExpr); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/MemberExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class MemberExpr : AbstractNode 7 | { 8 | Tuple memberInfo; 9 | INode objInfo; 10 | 11 | public override string Marker 12 | { 13 | get { return Convert.ToChar(0x58).ToString(); } 14 | } 15 | 16 | public override NodeType NodeType 17 | { 18 | get 19 | { 20 | return NodeType.MemberExpr; 21 | } 22 | } 23 | 24 | public override void Decode() 25 | { 26 | memberInfo = DecodeReference(); 27 | objInfo = DecodeNode(); 28 | } 29 | 30 | public override string PrettyPrint() 31 | { 32 | string obj = objInfo == null ? "" : objInfo.PrettyPrint(); 33 | string member = ""; 34 | if (IsValidIdentifier(memberInfo.Item1)) 35 | { 36 | member = "." + memberInfo.Item1; 37 | } 38 | else 39 | { 40 | // Prettier format for array indexing. ["1"] becomes [1]. 41 | // http://stackoverflow.com/questions/27537677/is-javascript-array-index-a-string-or-integer 42 | int numericalIndex; 43 | if (Int32.TryParse(memberInfo.Item1, out numericalIndex)) 44 | { 45 | member = "[" + memberInfo.Item1 + "]"; 46 | } 47 | else 48 | { 49 | member = "[\"" + memberInfo.Item1 + "\"]"; 50 | } 51 | } 52 | return obj + member; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/Nesting.cs: -------------------------------------------------------------------------------- 1 | namespace jsxbin_to_jsx.JsxbinDecoding 2 | { 3 | public sealed class Nesting 4 | { 5 | readonly ScanState _scanState; 6 | public Nesting(ScanState scanState) 7 | { 8 | Levels = 0; 9 | _scanState = scanState; 10 | } 11 | 12 | public int Levels { get; set; } 13 | 14 | public void DecrementLevel() 15 | { 16 | Levels--; 17 | } 18 | 19 | public void ParseLevels() 20 | { 21 | Levels = ParseLevelsCore(); 22 | } 23 | 24 | private int ParseLevelsCore() 25 | { 26 | if (_scanState.IsHex(0x41)) 27 | { 28 | _scanState.Inc(); 29 | return 1; 30 | } 31 | if (_scanState.IsHex(0x30)) 32 | { 33 | _scanState.Inc(); 34 | int lvlsCrypted = _scanState.getCur(); 35 | int lvls = lvlsCrypted - 0x3F; 36 | _scanState.Inc(); 37 | if (lvls > 0x1B) 38 | { 39 | return lvls + ParseLevelsCore(); 40 | } 41 | else 42 | { 43 | return lvls; 44 | } 45 | } 46 | return 0; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/NodeType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace jsxbin_to_jsx.JsxbinDecoding 8 | { 9 | public enum NodeType 10 | { 11 | ArgumentList, 12 | ArrayExpr, 13 | ArrayIndexingExpr, 14 | AssignmentExpr, 15 | BinaryExpr, 16 | ConditionalExpr, 17 | ConstDeclaration, 18 | DebuggerStatement, 19 | DeleteExpr, 20 | DoWhileExpr, 21 | ExprNode, 22 | ForInStatement, 23 | ForStatement, 24 | ForStatement2, 25 | FunctionCallExpr, 26 | FunctionDeclaration, 27 | FunctionExpr, 28 | IdNode, 29 | IdRefExpr, 30 | IfStatement, 31 | IncrementExpr, 32 | IndexingIncrementExpr, 33 | JumpStatement, 34 | LogicalExp, 35 | MemberAssignmentExpr, 36 | MemberExpr, 37 | ObjectExpr, 38 | RegExpLiteral, 39 | ReturnStatement, 40 | Root, 41 | SetDefaultXMLNamespaceExpr, 42 | StatementList, 43 | SwitchStatement, 44 | ThisExpr, 45 | ThrowStatement, 46 | TryStatement, 47 | UnaryExpr, 48 | UnknownNode2, 49 | ValueNode, 50 | WhileStatement, 51 | WithStatement, 52 | XMLAccessorExpr, 53 | XMLAssignmentExpr, 54 | XMLDoubleDotDescendantsExpr, 55 | XMLNamespaceExpr 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ObjectExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace jsxbin_to_jsx.JsxbinDecoding 7 | { 8 | public class ObjectExpr : AbstractNode 9 | { 10 | string objId; 11 | List> props; 12 | 13 | public override string Marker 14 | { 15 | get { return Convert.ToChar(0x57).ToString(); } 16 | } 17 | 18 | public override NodeType NodeType 19 | { 20 | get 21 | { 22 | return NodeType.ObjectExpr; 23 | } 24 | } 25 | 26 | public override void Decode() 27 | { 28 | objId = DecodeId(); 29 | props = new List>(); 30 | ForEachChild(() => 31 | { 32 | var id = DecodeId(); 33 | var val = DecodeNode(); 34 | var t = Tuple.Create(id, val); 35 | props.Add(t); 36 | }); 37 | } 38 | 39 | public override string PrettyPrint() 40 | { 41 | StringBuilder b = new StringBuilder(); 42 | if (props.Count == 0) 43 | { 44 | b.Append("{}"); 45 | } 46 | else 47 | { 48 | var propValuesCombined = props.Select(t => { 49 | string objExpr = t.Item1; 50 | if (!IsValidIdentifier(t.Item1)) 51 | { 52 | objExpr = "\"" + objExpr + "\""; 53 | } 54 | return objExpr + ": " + t.Item2.PrettyPrint(); 55 | }); 56 | string init = string.Join("," + Environment.NewLine, propValuesCombined); 57 | b.AppendLine("{"); 58 | b.AppendLine(init); 59 | b.Append("}"); 60 | } 61 | return b.ToString(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ReferenceDecoderVersion1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public sealed class ReferenceDecoderVersion1 : IReferenceDecoder 6 | { 7 | public double JsxbinVersion 8 | { 9 | get 10 | { 11 | return 1.0; 12 | } 13 | } 14 | 15 | public Tuple Decode(INode node) 16 | { 17 | var id = node.DecodeId(); 18 | return Tuple.Create(id, false); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ReferenceDecoderVersion2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public sealed class ReferenceDecoderVersion2 : IReferenceDecoder 6 | { 7 | public double JsxbinVersion 8 | { 9 | get 10 | { 11 | return 2.0; 12 | } 13 | } 14 | 15 | public Tuple Decode(INode node) 16 | { 17 | var id = node.DecodeId(); 18 | var flag = node.DecodeBool(); 19 | return Tuple.Create(id, flag); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/RegExpLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class RegExpLiteral : AbstractNode 6 | { 7 | string regex; 8 | string flags; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x59).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.RegExpLiteral; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | regex = DecodeString(); 26 | flags = DecodeString(); 27 | } 28 | 29 | public override string PrettyPrint() 30 | { 31 | return string.Format("/{0}/{1}", regex, flags); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ReturnStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ReturnStatement : AbstractNode, IStatement 6 | { 7 | LineInfo lineInfo; 8 | INode exprInfo; 9 | 10 | public int LineNumber 11 | { 12 | get 13 | { 14 | return lineInfo.LineNumber; 15 | } 16 | } 17 | 18 | public override string Marker 19 | { 20 | get { return Convert.ToChar(0x5A).ToString(); } 21 | } 22 | 23 | public override NodeType NodeType 24 | { 25 | get 26 | { 27 | return NodeType.ReturnStatement; 28 | } 29 | } 30 | 31 | public override void Decode() 32 | { 33 | lineInfo = DecodeLineInfo(); 34 | exprInfo = DecodeNode(); 35 | } 36 | 37 | public override string PrettyPrint() 38 | { 39 | string returnExpr = exprInfo == null ? "" : " " + exprInfo.PrettyPrint(); 40 | string label = lineInfo.CreateLabelStmt(); 41 | string stmt = label + "return" + returnExpr; 42 | stmt += ";"; 43 | return stmt; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/RootNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class RootNode : AbstractNode 7 | { 8 | INode child; 9 | public const string ROOT_MARKER = "ROOT"; 10 | 11 | public override string Marker 12 | { 13 | get { return ROOT_MARKER; } 14 | } 15 | 16 | public override NodeType NodeType 17 | { 18 | get 19 | { 20 | return NodeType.Root; 21 | } 22 | } 23 | 24 | public override void Decode() 25 | { 26 | child = DecodeNode(); 27 | } 28 | 29 | public override string PrettyPrint() 30 | { 31 | return child.PrettyPrint(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ScanState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ScanState 6 | { 7 | int _index = 0; 8 | string _input; 9 | Nesting nesting; 10 | SymbolTable table = new SymbolTable(); 11 | public ScanState(string input) 12 | { 13 | _input = input; 14 | nesting = new Nesting(this); 15 | } 16 | 17 | public ScanState(string input, int index) 18 | { 19 | _input = input; 20 | _index = index; 21 | } 22 | 23 | public void AddSymbol(string key, string value) 24 | { 25 | table.Add(key, value); 26 | } 27 | 28 | public string GetSymbol(string key) 29 | { 30 | return table.Get(key); 31 | } 32 | 33 | public void Inc() 34 | { 35 | _index++; 36 | } 37 | 38 | public char getCur() 39 | { 40 | return _input[_index]; 41 | } 42 | 43 | public bool IsHex(int num) 44 | { 45 | return getCur() == Convert.ToChar(num); 46 | } 47 | 48 | public ScanState Clone() 49 | { 50 | return new ScanState(_input, _index); 51 | } 52 | 53 | public int GetNestingLevels() 54 | { 55 | if (nesting.Levels == 0) 56 | { 57 | nesting.ParseLevels(); 58 | } 59 | return nesting.Levels; 60 | } 61 | 62 | public void DecrementNestingLevels() 63 | { 64 | if (nesting.Levels == 0) 65 | { 66 | return; 67 | } 68 | nesting.DecrementLevel(); 69 | } 70 | 71 | public string Progress 72 | { 73 | get 74 | { 75 | string m = "****"; 76 | string copy = _input; 77 | copy = copy.Insert(_index, m); 78 | copy = copy.Insert(_index + m.Length + 1, m); 79 | return copy; 80 | } 81 | } 82 | 83 | public string GetAndOrAddId(List id) 84 | { 85 | string propName = ""; 86 | if (id.Count == 3) 87 | { 88 | propName = id[1]; 89 | AddSymbol(id[2], propName); 90 | } 91 | else 92 | { 93 | propName = GetSymbol(id[0]); 94 | } 95 | return propName; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/SetDefaultXMLNamespaceExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class SetDefaultXMLNamespaceExpr : AbstractNode 6 | { 7 | INode setDefaultNamespaceFunctionCall; 8 | 9 | public override string Marker 10 | { 11 | get { return Convert.ToChar(0x6B).ToString(); } 12 | } 13 | 14 | public override NodeType NodeType 15 | { 16 | get 17 | { 18 | return NodeType.SetDefaultXMLNamespaceExpr; 19 | } 20 | } 21 | 22 | public override void Decode() 23 | { 24 | setDefaultNamespaceFunctionCall = DecodeNode(); 25 | } 26 | 27 | public override string PrettyPrint() 28 | { 29 | return setDefaultNamespaceFunctionCall.PrettyPrint(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/StatementList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace jsxbin_to_jsx.JsxbinDecoding 6 | { 7 | public class StatementList : AbstractNode, IStatement 8 | { 9 | LineInfo lineInfo; 10 | int length; 11 | List statements; 12 | 13 | public int LineNumber 14 | { 15 | get 16 | { 17 | return lineInfo.LineNumber; 18 | } 19 | } 20 | 21 | public override string Marker 22 | { 23 | get 24 | { 25 | return Convert.ToChar(0x62).ToString(); 26 | } 27 | } 28 | 29 | public override NodeType NodeType 30 | { 31 | get 32 | { 33 | return NodeType.StatementList; 34 | } 35 | } 36 | 37 | public override void Decode() 38 | { 39 | lineInfo = DecodeBody(); 40 | length = DecodeLength(); 41 | statements = new List(); 42 | int i = length; 43 | while (i > 0) 44 | { 45 | statements.Add(DecodeNode()); 46 | i--; 47 | } 48 | statements.AddRange(DecodeChildren()); 49 | } 50 | 51 | public override string PrettyPrint() 52 | { 53 | string labels = lineInfo.CreateLabelStmt(); 54 | var statementsOrdered = statements.OrderBy(s => ((IStatement)s).LineNumber); 55 | var statementsPretty = statementsOrdered.Select(f => 56 | { 57 | bool requiresSemicolon = f.NodeType == NodeType.ExprNode; 58 | string expr = f.PrettyPrint(); 59 | if (requiresSemicolon) 60 | { 61 | expr = expr + ";"; 62 | } 63 | return expr; 64 | }).ToList(); 65 | string block = string.Join(Environment.NewLine, statementsPretty); 66 | return labels + block; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/SwitchStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace jsxbin_to_jsx.JsxbinDecoding 7 | { 8 | public class SwitchStatement : AbstractNode, IStatement 9 | { 10 | LineInfo labelInfo; 11 | INode test; 12 | List cases; 13 | List bodies; 14 | 15 | public int LineNumber 16 | { 17 | get 18 | { 19 | return labelInfo.LineNumber; 20 | } 21 | } 22 | 23 | public override string Marker 24 | { 25 | get { return Convert.ToChar(0x63).ToString(); } 26 | } 27 | 28 | public override NodeType NodeType 29 | { 30 | get 31 | { 32 | return NodeType.SwitchStatement; 33 | } 34 | } 35 | 36 | public override void Decode() 37 | { 38 | labelInfo = DecodeBody(); 39 | test = DecodeNode(); 40 | cases = new List(); 41 | ForEachChild(() => 42 | { 43 | var r = DecodeNode(); 44 | if (r != null) 45 | { 46 | cases.Add(r); 47 | } 48 | }); 49 | bodies = new List(); 50 | ForEachChild(() => 51 | { 52 | var q = DecodeNode(); 53 | if (q != null) 54 | { 55 | bodies.Add(q); 56 | } 57 | }); 58 | } 59 | 60 | public override string PrettyPrint() 61 | { 62 | StringBuilder b = new StringBuilder(); 63 | b.AppendLine(string.Format("switch({0}) {{", test.PrettyPrint())); 64 | for (int i = 0; i < cases.Count; i++) 65 | { 66 | var caseArgs = ((ArgumentList)cases[i]).Arguments; 67 | string caseStmt = ""; 68 | if (caseArgs.Count > 0) 69 | { 70 | caseStmt = string.Join(Environment.NewLine, caseArgs.Select(c => string.Format("case {0}:", c.PrettyPrint()))); 71 | } 72 | else 73 | { 74 | caseStmt = "default:"; 75 | } 76 | b.AppendLine(caseStmt); 77 | string bodyStmt = ""; 78 | if (i < bodies.Count) 79 | { 80 | bodyStmt = bodies[i].PrettyPrint(); 81 | } 82 | b.AppendLine(bodyStmt); 83 | } 84 | b.Append("}"); 85 | return b.ToString(); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/SymbolTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace jsxbin_to_jsx.JsxbinDecoding 8 | { 9 | public sealed class SymbolTable 10 | { 11 | Dictionary table = new Dictionary(); 12 | 13 | public void Add(string key, string value) 14 | { 15 | table[key] = value; 16 | } 17 | 18 | public string Get(string key) 19 | { 20 | return table[key]; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ThisExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ThisExpr : AbstractNode 6 | { 7 | Tuple info; 8 | 9 | public override string Marker 10 | { 11 | get { return Convert.ToChar(0x65).ToString(); } 12 | } 13 | 14 | public override NodeType NodeType 15 | { 16 | get 17 | { 18 | return NodeType.ThisExpr; 19 | } 20 | } 21 | 22 | public override void Decode() 23 | { 24 | info = DecodeReference(); 25 | } 26 | 27 | public override string PrettyPrint() 28 | { 29 | return info.Item1; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ThrowStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ThrowStatement : AbstractNode, IStatement 6 | { 7 | LineInfo lineInfo; 8 | INode exprInfo; 9 | 10 | public int LineNumber 11 | { 12 | get 13 | { 14 | return lineInfo.LineNumber; 15 | } 16 | } 17 | 18 | public override string Marker 19 | { 20 | get { return Convert.ToChar(0x66).ToString(); } 21 | } 22 | 23 | public override NodeType NodeType 24 | { 25 | get 26 | { 27 | return NodeType.ThrowStatement; 28 | } 29 | } 30 | 31 | public override void Decode() 32 | { 33 | lineInfo = DecodeLineInfo(); 34 | exprInfo = DecodeNode(); 35 | } 36 | 37 | public override string PrettyPrint() 38 | { 39 | var body = exprInfo.PrettyPrint(); 40 | var expr = "throw " + body; 41 | return expr; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/TryStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class TryStatement : AbstractNode, IStatement 7 | { 8 | LineInfo tryBlock; 9 | string expr; 10 | 11 | public int LineNumber 12 | { 13 | get 14 | { 15 | return tryBlock.LineNumber; 16 | } 17 | } 18 | 19 | public override string Marker 20 | { 21 | get { return Convert.ToChar(0x67).ToString(); } 22 | } 23 | 24 | public override NodeType NodeType 25 | { 26 | get 27 | { 28 | return NodeType.TryStatement; 29 | } 30 | } 31 | 32 | public override void Decode() 33 | { 34 | tryBlock = DecodeLineInfo(); 35 | int length = DecodeLength(); 36 | var finallyBlock = DecodeNode(); 37 | StringBuilder b = new StringBuilder(); 38 | string label = tryBlock.CreateLabelStmt(); 39 | string body = tryBlock.CreateBody(); 40 | b.AppendLine(label + "try {"); 41 | b.AppendLine(body); 42 | int i = length; 43 | while (i > 0) 44 | { 45 | var arg = DecodeId(); 46 | var exceptionFilter = DecodeNode(); 47 | var catchBlock = DecodeNode(); 48 | b.Append("} catch (" + arg); 49 | if (exceptionFilter != null) 50 | { 51 | b.Append(" if " + exceptionFilter.PrettyPrint()); 52 | } 53 | b.AppendLine(") {"); 54 | b.Append(catchBlock == null ? string.Empty : catchBlock.PrettyPrint()); 55 | b.AppendLine(""); 56 | i--; 57 | } 58 | if (finallyBlock != null) 59 | { 60 | b.AppendLine("} finally {"); 61 | b.Append(finallyBlock.PrettyPrint()); 62 | b.AppendLine(""); 63 | } 64 | b.Append("}"); 65 | expr = b.ToString(); 66 | } 67 | 68 | public override string PrettyPrint() 69 | { 70 | return expr; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/UnaryExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class UnaryExpr : AbstractNode 6 | { 7 | string op; 8 | INode expr; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x68).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.UnaryExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | op = DecodeId(); 26 | expr = DecodeNode(); 27 | } 28 | 29 | public override string PrettyPrint() 30 | { 31 | bool requiresParens = expr.NodeType != NodeType.IdNode 32 | && expr.NodeType != NodeType.IdRefExpr 33 | && expr.NodeType != NodeType.FunctionCallExpr 34 | && expr.NodeType != NodeType.MemberExpr 35 | && expr.NodeType != NodeType.ArrayIndexingExpr; 36 | string exprParens = requiresParens ? "(" + expr.PrettyPrint() + ")" : expr.PrettyPrint(); 37 | var unaryExpr = op + exprParens; 38 | return unaryExpr; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/UnknownNode2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class UnknownNode2 : AbstractNode 6 | { 7 | Tuple idAndNode; 8 | 9 | public override string Marker 10 | { 11 | get { return Convert.ToChar(0x73).ToString(); } 12 | } 13 | 14 | public override NodeType NodeType 15 | { 16 | get 17 | { 18 | return NodeType.UnknownNode2; 19 | } 20 | } 21 | 22 | public override void Decode() 23 | { 24 | idAndNode = DecodeIdAndNode(); 25 | } 26 | 27 | public override string PrettyPrint() 28 | { 29 | throw new Exception("Not defined"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/ValueNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class ValueNode : AbstractNode 6 | { 7 | string value; 8 | 9 | public override string Marker 10 | { 11 | get { return Convert.ToChar(0x46).ToString(); } 12 | } 13 | 14 | public override NodeType NodeType 15 | { 16 | get 17 | { 18 | return NodeType.ValueNode; 19 | } 20 | } 21 | 22 | public override void Decode() 23 | { 24 | value = DecodeVariantCore(); 25 | } 26 | 27 | public override string PrettyPrint() 28 | { 29 | return value; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/WhileStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class WhileStatement : AbstractNode, IStatement 7 | { 8 | LineInfo bodyInfo; 9 | INode condInfo; 10 | 11 | public int LineNumber 12 | { 13 | get 14 | { 15 | return bodyInfo.LineNumber; 16 | } 17 | } 18 | 19 | public override string Marker 20 | { 21 | get { return Convert.ToChar(0x6C).ToString(); } 22 | } 23 | 24 | public override NodeType NodeType 25 | { 26 | get 27 | { 28 | return NodeType.WhileStatement; 29 | } 30 | } 31 | 32 | public override void Decode() 33 | { 34 | bodyInfo = DecodeBody(); 35 | condInfo = DecodeNode(); 36 | } 37 | 38 | public override string PrettyPrint() 39 | { 40 | var cond = condInfo == null ? "true" : condInfo.PrettyPrint(); 41 | string label = bodyInfo.CreateLabelStmt(); 42 | var body = bodyInfo.CreateBody(); 43 | StringBuilder b = new StringBuilder(); 44 | b.AppendLine(string.Format("{0}while ({1}) {{", label, cond)); 45 | b.AppendLine(body); 46 | b.Append("}"); 47 | return b.ToString(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/WithStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class WithStatement : AbstractNode, IStatement 7 | { 8 | LineInfo bodyInfo; 9 | string objName; 10 | 11 | public int LineNumber 12 | { 13 | get 14 | { 15 | return bodyInfo.LineNumber; 16 | } 17 | } 18 | 19 | public override string Marker 20 | { 21 | get { return Convert.ToChar(0x6D).ToString(); } 22 | } 23 | 24 | public override NodeType NodeType 25 | { 26 | get 27 | { 28 | return NodeType.WithStatement; 29 | } 30 | } 31 | 32 | public override void Decode() 33 | { 34 | bodyInfo = DecodeLineInfo(); 35 | objName = DecodeNode().PrettyPrint(); 36 | } 37 | 38 | public override string PrettyPrint() 39 | { 40 | string label = bodyInfo.CreateLabelStmt(); 41 | string body = bodyInfo.CreateBody(); 42 | StringBuilder b = new StringBuilder(); 43 | b.AppendLine(string.Format("{0}with ({1}) {{", label, objName)); 44 | b.AppendLine(body); 45 | b.Append("}"); 46 | return b.ToString(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/XMLAccessorExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class XMLAccessorExpr : AbstractNode 7 | { 8 | Tuple reference; 9 | INode obj; 10 | INode member; 11 | 12 | public override string Marker 13 | { 14 | get 15 | { 16 | return Convert.ToChar(0x72).ToString(); 17 | } 18 | } 19 | 20 | public override NodeType NodeType 21 | { 22 | get 23 | { 24 | return NodeType.XMLAccessorExpr; 25 | } 26 | } 27 | 28 | public override void Decode() 29 | { 30 | reference = DecodeReference(); 31 | obj = DecodeNode(); 32 | member = DecodeNode(); 33 | } 34 | 35 | public override string PrettyPrint() 36 | { 37 | return obj.PrettyPrint() + "." + member.PrettyPrint(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/XMLAssignmentExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace jsxbin_to_jsx.JsxbinDecoding 5 | { 6 | public class XMLAssignmentExpr : AbstractNode 7 | { 8 | string expr; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x6F).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.XMLAssignmentExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | const int TYPE_NORMAL = 0; 26 | const int TYPE_ELEMENTPLACEHOLDER = 1; 27 | const int TYPE_ATTR_PLACEHOLDER = 2; 28 | const int TYPE_VALUE_PLACEHOLDER = 3; 29 | 30 | StringBuilder res = new StringBuilder(); 31 | ForEachChild(() => 32 | { 33 | var child = DecodeNode(); 34 | var type = DecodeLength(); 35 | if (type == TYPE_NORMAL) 36 | { 37 | res.Append(child.PrettyPrint()); 38 | } 39 | else 40 | { 41 | res.Append(" + " + child.PrettyPrint() + " + "); 42 | } 43 | }); 44 | expr = res.ToString(); 45 | } 46 | 47 | public override string PrettyPrint() 48 | { 49 | return expr; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/XMLDoubleDotDescendantsExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class XMLDoubleDotDescendantsExpr : AbstractNode 6 | { 7 | Tuple descendants; 8 | INode obj; 9 | 10 | public override string Marker 11 | { 12 | get { return Convert.ToChar(0x71).ToString(); } 13 | } 14 | 15 | public override NodeType NodeType 16 | { 17 | get 18 | { 19 | return NodeType.XMLDoubleDotDescendantsExpr; 20 | } 21 | } 22 | 23 | public override void Decode() 24 | { 25 | descendants = DecodeReference(); 26 | obj = DecodeNode(); 27 | DecodeNode(); 28 | DecodeNode(); 29 | } 30 | 31 | public override string PrettyPrint() 32 | { 33 | return obj.PrettyPrint() + ".." + descendants.Item1; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/JsxbinDecoding/XMLNamespaceExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace jsxbin_to_jsx.JsxbinDecoding 4 | { 5 | public class XMLNamespaceExpr : AbstractNode 6 | { 7 | Tuple namespaceObj; 8 | INode obj; 9 | string xmlId; 10 | 11 | public override string Marker 12 | { 13 | get { return Convert.ToChar(0x70).ToString(); } 14 | } 15 | 16 | public override NodeType NodeType 17 | { 18 | get 19 | { 20 | return NodeType.XMLNamespaceExpr; 21 | } 22 | } 23 | 24 | public override void Decode() 25 | { 26 | namespaceObj = DecodeReference(); 27 | obj = DecodeNode(); 28 | DecodeNode(); 29 | DecodeNode(); 30 | xmlId = DecodeId(); 31 | } 32 | 33 | public override string PrettyPrint() 34 | { 35 | var isQualifiedOrSomething = namespaceObj.Item2; 36 | string ns = isQualifiedOrSomething ? "@" + namespaceObj.Item1 : namespaceObj.Item1; 37 | return obj.PrettyPrint() + "." + ns + "::" + xmlId; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/Program.cs: -------------------------------------------------------------------------------- 1 | using Jsbeautifier; 2 | using jsxbin_to_jsx.JsxbinDecoding; 3 | using System; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace jsxbin_to_jsx 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | if (args.Length < 2) 14 | { 15 | PrintHelp(); 16 | return; 17 | } 18 | DecodeArgs parsedArgs = null; 19 | try 20 | { 21 | parsedArgs = ParseCommandLine(args); 22 | } 23 | catch (Exception ex) 24 | { 25 | Console.WriteLine(ex.Message); 26 | PrintHelp(); 27 | return; 28 | } 29 | Decode(parsedArgs); 30 | } 31 | 32 | static void PrintHelp() 33 | { 34 | Console.WriteLine("Usage: [-v] jsxbin_to_jsx JSXBIN JSX"); 35 | Console.WriteLine("Example: -v jsxbin_to_jsx encoded.jsxbin decoded.jsx"); 36 | Console.WriteLine("Flags:"); 37 | Console.WriteLine("-v print tree structure to stdout"); 38 | } 39 | 40 | static void Decode(DecodeArgs decoderArgs) 41 | { 42 | try 43 | { 44 | Console.WriteLine("Decoding {0}", decoderArgs.JsxbinFilepath); 45 | string jsxbin = File.ReadAllText(decoderArgs.JsxbinFilepath, Encoding.ASCII); 46 | string jsx = AbstractNode.Decode(jsxbin, decoderArgs.PrintStructure); 47 | jsx = new Beautifier().Beautify(jsx); 48 | File.WriteAllText(decoderArgs.JsxFilepath, jsx, Encoding.UTF8); 49 | Console.WriteLine("Jsxbin successfully decoded to {0}", decoderArgs.JsxFilepath); 50 | } 51 | catch (Exception ex) 52 | { 53 | Console.WriteLine("Decoding failed. If this problem persists, please raise an issue on github. Error message: {0}. Stacktrace: {1}.", ex.Message, ex.StackTrace); 54 | } 55 | } 56 | 57 | static DecodeArgs ParseCommandLine(string[] args) 58 | { 59 | var decoderArgs = new DecodeArgs(); 60 | int flagOffset = 0; 61 | if (args.Length > 2) 62 | { 63 | if (args[0] == "-v") 64 | { 65 | flagOffset++; 66 | decoderArgs.PrintStructure = true; 67 | } 68 | else 69 | { 70 | throw new Exception(string.Format("Flag {0} is not valid.", args[0])); 71 | } 72 | } 73 | decoderArgs.JsxbinFilepath = args[flagOffset]; 74 | decoderArgs.JsxFilepath = args[flagOffset + 1]; 75 | return decoderArgs; 76 | } 77 | 78 | private class DecodeArgs 79 | { 80 | public string JsxFilepath { get; set; } 81 | public string JsxbinFilepath { get; set; } 82 | public bool PrintStructure { get; set; } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("jsxbin_to_jsx")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("jsxbin_to_jsx")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("9552b139-d2a9-496d-b673-843622d16793")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /jsxbin_to_jsx/jsxbin_to_jsx.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7AD7C7B3-32F0-4426-A1A5-A647FDB523C1} 8 | Exe 9 | Properties 10 | jsxbin_to_jsx 11 | jsxbin_to_jsx 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\libs\Jsbeautifier.dll 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /libs/Jsbeautifier.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecopy/jsxbin-to-jsx-converter/a7a225f676f4cb1f9bbe9b737dba5b717fc37145/libs/Jsbeautifier.dll -------------------------------------------------------------------------------- /testfiles/v1.0/arrays.jsx: -------------------------------------------------------------------------------- 1 | var emptyArray = []; 2 | var filledArray = [78, 452, "yes"]; 3 | var ctorArray = new Array("bbb", "ccc"); 4 | emptyArray.push("testvalue"); 5 | var indexingNumber = filledArray[0]; 6 | var indexingString = filledArray[1]; -------------------------------------------------------------------------------- /testfiles/v1.0/arrays.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AGJAnASzKjFjNjQjUjZiBjSjSjBjZByBAnnftJBnASzLjGjJjMjMjFjEiB 2 | jSjSjBjZCyBARDFdiOFd2mEBFeDjZjFjTfnftJCnASzJjDjUjPjSiBjSjSjBjZDyBEjzFiBjSjSjBjZ 3 | ERCFeDjCjCjCFeDjDjDjDftnftJDnAEXzEjQjVjTjIFVByBRBFeJjUjFjTjUjWjBjMjVjFffJEnASzO 4 | jJjOjEjFjYjJjOjHiOjVjNjCjFjSGyBXzBhQHVCyBnftJFnASzOjJjOjEjFjYjJjOjHiTjUjSjJjOjH 5 | IyBXzBhRJVCyBnftAFB40BiAC4B0AiAD4C0AiAG4D0AiAI4E0AiAAFAzAKByB -------------------------------------------------------------------------------- /testfiles/v1.0/assignment_operators.jsx: -------------------------------------------------------------------------------- 1 | var x = 9; 2 | x += 657; 3 | x += ((4923 * MyMethod(5)) / AnotherMethod("valvalval")); 4 | x *= 30; 5 | x /= 6; 6 | x -= 3; 7 | x %= 7; 8 | var obj1 = { 9 | a: 1 10 | }; 11 | var obj2 = { 12 | b: 1 13 | }; 14 | obj1.a = 99; 15 | obj1 = obj2; -------------------------------------------------------------------------------- /testfiles/v1.0/assignment_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ALJAnASzBjYByBndJftJBnASByBCzBhLCnnnd2kRCntfJCnASByBCCnCzB 2 | hPDCzBhKEnEjzIiNjZiNjFjUjIjPjEFRBFdFffd2hbTnEjzNiBjOjPjUjIjFjSiNjFjUjIjPjEGRBFe 3 | JjWjBjMjWjBjMjWjBjMffnnnnntfJDnASByBCEnnndgentfJEnASByBCDnnndGntfJFnASByBCzBhNH 4 | nnndDntfJGnASByBCzBhFInnndHntfJHnASzEjPjCjKhRJyBWzGiPjCjKjFjDjUKBzBjBLFdBnftJKn 5 | ASzEjPjCjKhSMyBWKBzBjCNFdBnftJNnABXLVJyBndjDfJOnASJyBVMyBnffADB40BiAJ4B0AiAM4C0 6 | AiAADAzAOByB -------------------------------------------------------------------------------- /testfiles/v1.0/binary_bitwise_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = 0; 2 | a & 2; 3 | a | 3; 4 | a ^ 4; 5 | a << 10; 6 | a >> 20; 7 | a >>> 50; -------------------------------------------------------------------------------- /testfiles/v1.0/binary_bitwise_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AHJAnASzBjBByBndAftJBnACzBhGCVByBnndCJCnACzBjcDVByBnndDJDn 2 | ACzBieEVByBnndEJEnACzChchcFVByBnndKJFnACzCheheGVByBnndUJGnACzDheheheHVByBnndhSA 3 | BB40BiAABAzAIByB -------------------------------------------------------------------------------- /testfiles/v1.0/comparison_operators.jsx: -------------------------------------------------------------------------------- 1 | x = a == 2; 2 | x = c != 3; 3 | x = d > 5; 4 | x = f >= 7; 5 | x = g < 9; 6 | x = q <= 11; 7 | x = 12 === 13; 8 | x = 14 !== 15; -------------------------------------------------------------------------------- /testfiles/v1.0/comparison_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AIJAnABjzBjYBCzChdhdCjzBjBDnndCnfJBnABjBCzChBhdEjzBjDFnndD 2 | nfJCnABjBCzBheGjzBjEHnndFnfJDnABjBCzChehdIjzBjGJnndHnfJEnABjBCzBhcKjzBjHLnndJnf 3 | JFnABjBCzChchdMjzBjRNnndLnfJGnABjBCzDhdhdhdOnFdNdMnnfJHnABjBCzDhBhdhdPnFdPdOnnf 4 | 0DzAQByB -------------------------------------------------------------------------------- /testfiles/v1.0/conditional_operator.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | var a = true; 3 | var b = a === "b" ? 2 : 5; 4 | var c = BRIL.appVersion < 11 ? (eventObject = {}, eventObject.target = this) : 0; 5 | } -------------------------------------------------------------------------------- /testfiles/v1.0/conditional_operator.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MyBbyBnABMAbyBn0ADJBnASzBjBBAnctftJCnASzBjCCBdCzDhdhdhdDVBAnneBjC 2 | FdCFdFnftJDnASzBjDECdCzBhcFXzKjBjQjQiWjFjSjTjJjPjOGjzEiCiSiJiMHnndLRCBjzLjFjWjF 3 | jOjUiPjCjKjFjDjUIWzGiPjCjKjFjDjUJAnfBXzGjUjBjSjHjFjUKjIezEjUjIjJjTLnftFdAnftADB 4 | 40BiAC4B0AiAE4C0AiAADAzAMAE0EMByB -------------------------------------------------------------------------------- /testfiles/v1.0/do_while_loop.jsx: -------------------------------------------------------------------------------- 1 | var cond = "50"; 2 | var test1 = "test"; 3 | do { 4 | test1 = "nothing"; 5 | } while (cond) -------------------------------------------------------------------------------- /testfiles/v1.0/do_while_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ADJAnASzEjDjPjOjEByBneChVhQftJBnASzFjUjFjTjUhRCyBneEjUjFjT 2 | jUftICbyDn0ABJDnASCyBneHjOjPjUjIjJjOjHffAVByBACC4B0AiAB40BiAACAzADByB -------------------------------------------------------------------------------- /testfiles/v1.0/exceptions.jsx: -------------------------------------------------------------------------------- 1 | throw new Error("test error throw") 2 | throw new CustomErr("custom err throw") 3 | try { 4 | var x = "trytrytrytry"; 5 | } catch (e if e == "InvalidNameException") { 6 | var x = "special catch"; 7 | } catch (e) { 8 | var x = "all catch"; 9 | } finally { 10 | var x = "finallyblock"; 11 | } -------------------------------------------------------------------------------- /testfiles/v1.0/exceptions.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ADfAnAEjzFiFjSjSjPjSBRBFeQjUjFjTjUhAjFjSjSjPjShAjUjIjSjPjX 2 | ftfBnAEjzJiDjVjTjUjPjNiFjSjSCRBFeQjDjVjTjUjPjNhAjFjSjShAjUjIjSjPjXftgCbyBn0ABJD 3 | nASzBjYDyBneMjUjSjZjUjSjZjUjSjZjUjSjZftACbyBn0ABJJnASDyBneMjGjJjOjBjMjMjZjCjMjP 4 | jDjLftzBjFECzChdhdFjEnneUiJjOjWjBjMjJjEiOjBjNjFiFjYjDjFjQjUjJjPjObyBn0ABJFnASDy 5 | BneNjTjQjFjDjJjBjMhAjDjBjUjDjIftEnbyBn0ABJHnASDyBneJjBjMjMhAjDjBjUjDjIftABD40Bi 6 | AABAzAGByB -------------------------------------------------------------------------------- /testfiles/v1.0/for_in_loop.jsx: -------------------------------------------------------------------------------- 1 | var result = { 2 | a: 1 3 | }; 4 | for (var propertyName in result) { 5 | result.a = "fifty"; 6 | } -------------------------------------------------------------------------------- /testfiles/v1.0/for_in_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ACJAnASzGjSjFjTjVjMjUByBWzGiPjCjKjFjDjUCBzBjBDFdBnftLDbyEn 2 | 0ABJEnABXDVByBneFjGjJjGjUjZfAVzMjQjSjPjQjFjSjUjZiOjBjNjFEyBVByByBzAFACB40BiAE4B 3 | 0AiAACAFByB -------------------------------------------------------------------------------- /testfiles/v1.0/for_loop.jsx: -------------------------------------------------------------------------------- 1 | var result = ""; 2 | for (var index = 52342;index < testMethod("noway"); index += -40239) { 3 | result += "b"; 4 | } 5 | for (var index = 52342; index < testMethod("noway"); index *= 40239) { 6 | result += "b"; 7 | } 8 | for (var index = 52342; index < testMethod("noway"); index /= 40239) { 9 | result += "b"; 10 | } 11 | for (; index < testMethod("noway"); index /= 40239) { 12 | result += "b"; 13 | } 14 | for (; ; index /= 40239) { 15 | result += "b"; 16 | } -------------------------------------------------------------------------------- /testfiles/v1.0/for_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AGJAnASzGjSjFjTjVjMjUByBneAftaBbyCn0ABJCnASByBCzBhLCnnneBj 2 | CntfAVzFjJjOjEjFjYDyB2jWmMEjzKjUjFjTjUiNjFjUjIjPjEERBFeFjOjPjXjBjZffy2hPkdyBzBh 3 | cFKEbyFn0ABJFnASByBCCnnneBjCntfASDyBnd2jWmMftCFVDyBEjERBFeFjOjPjXjBjZffnnSDyBCz 4 | BhKGnnnd2hPkdntfKHbyIn0ABJInASByBCCnnneBjCntfASDyBnd2jWmMftCFVDyBEjERBFeFjOjPjX 5 | jBjZffnnSDyBCzBhPHnnnd2hPkdntfKKbyLn0ABJLnASByBCCnnneBjCntfAnCFVDyBEjERBFeFjOjP 6 | jXjBjZffnnSDyBCHnnnd2hPkdntfKNbyOn0ABJOnASByBCCnnneBjCntfAnnSDyBCHnnnd2hPkdntfA 7 | CD4B0AiAB40BiAACAzAIByB -------------------------------------------------------------------------------- /testfiles/v1.0/functions.jsx: -------------------------------------------------------------------------------- 1 | var addCtor = new Function("firstFuncX", "firstFuncY", "return firstFuncX + firstFuncY"); 2 | var tCtor = addCtor(5656, 123124); 3 | var addFuncExpr = function (sndFuncX, sndFuncY) { 4 | return sndFuncX + sndFuncY; 5 | }; 6 | var tFuncExpr = addFuncExpr(23123, 5345); 7 | function addShorthand(thirdFuncX, thirdFuncY) { 8 | return thirdFuncX + thirdFuncY; 9 | } 10 | var tShorthand = addShorthand(1, 2); 11 | function subtract(fourthFuncX, fourthFuncY) { 12 | return fourthFuncX - fourthFuncY; 13 | } 14 | var testo = subtract.length; 15 | var test2 = subtract.getName(5); -------------------------------------------------------------------------------- /testfiles/v1.0/functions.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBnACMGbyBn0ABZHnACzBhLBVzKjUjIjJjSjEiGjVjOjDiYCAVzKjUjIjJjSjE 2 | iGjVjOjDiZDBnnACC40BhAD4B0AhAC0AzMjBjEjEiTjIjPjSjUjIjBjOjEEAIMKbyBn0ABZLnACzBhN 3 | FVzLjGjPjVjSjUjIiGjVjOjDiYGAVzLjGjPjVjSjUjIiGjVjOjDiZHBnnACG40BhAH4B0AhAC0AzIjT 4 | jVjCjUjSjBjDjUIAMHJAnASzHjBjEjEiDjUjPjSJyBEjzIiGjVjOjDjUjJjPjOKRDFeKjGjJjSjTjUi 5 | GjVjOjDiYFeKjGjJjSjTjUiGjVjOjDiZFegejSjFjUjVjSjOhAjGjJjSjTjUiGjVjOjDiYhAhLhAjGj 6 | JjSjTjUiGjVjOjDiZftnftJBnASzFjUiDjUjPjSLyBEVJyBRCFd2YWFd4nUnABAffnftJCnASzLjBjE 7 | jEiGjVjOjDiFjYjQjSMyBNyBnAMCbyBn0ABZDnACBVzIjTjOjEiGjVjOjDiYNAVzIjTjOjEiGjVjOjD 8 | iZOBnnACO4B0AhAN40BhAC0AzAPCEnftJFnASzJjUiGjVjOjDiFjYjQjSQyBEVMyBRCFd2iTiaFd2nB 9 | UffnftJJnASzKjUiTjIjPjSjUjIjBjOjERyBEjERCFdBFdCffnftJNnASzFjUjFjTjUjPSyBXzGjMjF 10 | jOjHjUjITjInftJOnASzFjUjFjTjUhSUyBEXzHjHjFjUiOjBjNjFVjIRBFdFffnftAHQ4D0AiAR4E0A 11 | iAS4F0AiAU4G0AiAJ40BiAL4B0AiAM4C0AiAAHAPByB -------------------------------------------------------------------------------- /testfiles/v1.0/if_statement.jsx: -------------------------------------------------------------------------------- 1 | var a = true; 2 | if (a) { 3 | a = "if stmt"; 4 | } else if (a == "anotherOne") { 5 | a = "another stmt"; 6 | } else if (a == "ifelse") { 7 | a = "elseif stmt"; 8 | } else { 9 | a = "else stmt"; 10 | } 11 | if (b) { 12 | b = "a"; 13 | } else { 14 | b = "c"; 15 | } 16 | if (c) { 17 | c = "c"; 18 | } -------------------------------------------------------------------------------- /testfiles/v1.0/if_statement.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AEJAnASzBjBByBnctftOBbyCn0ABJCnASByBneHjJjGhAjTjUjNjUffAVB 2 | yBODbyEn0ABJEnASByBneMjBjOjPjUjIjFjShAjTjUjNjUffACzChdhdCVByBnneKjBjOjPjUjIjFjS 3 | iPjOjFOFbyGn0ABJGnASByBneLjFjMjTjFjJjGhAjTjUjNjUffACCVByBnneGjJjGjFjMjTjFbyIn0A 4 | BJInASByBneJjFjMjTjFhAjTjUjNjUffOKbyLn0ABJLnABjzBjCDneBjBfAjDbyNn0ABJNnABjDneBj 5 | DfOPbyQn0ABJQnABjzBjDEneBjDfAjEnABB40BiAABAzAFByB -------------------------------------------------------------------------------- /testfiles/v1.0/labels.jsx: -------------------------------------------------------------------------------- 1 | loop1: for (var a = 0;a < 10; a += 1) { 2 | if (a == 4) { 3 | break loop1; 4 | } 5 | alert("a = " + a); 6 | loop2: for (var b = 0;b < 10; b += 1) { 7 | if (b == 3) { 8 | continue loop2; 9 | } 10 | if (b == 6) { 11 | continue loop1; 12 | } 13 | alert("b = " + b); 14 | } 15 | alert("finished"); 16 | } 17 | block1: alert("Hello"); 18 | alert("World"); 19 | for (var a = 0;a < 10; a += 1) { 20 | alert("a = " + a); 21 | } -------------------------------------------------------------------------------- /testfiles/v1.0/labels.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AEaAbBn0AEOBbyCn0ABDCnAzFjMjPjPjQhRBtACzChdhdCVzBjBDyBnndE 2 | nJEnAEjzFjBjMjFjSjUERBCzBhLFnVDyBeEjBhAhdhAnffayFbGn0ADOGbyHn0ABDHnAzFjMjPjPjQh 3 | SGfACCVzBjCHyBnndDnOJbyKn0ABDKnABfACCVHyBnndGnJMnAEjERBCFnVHyBeEjChAhdhAnffBGVH 4 | yBAFdKByBzBhcIJOnAEjERBFeIjGjJjOjJjTjIjFjEffBBVDyBAFdKByBIJyQnBzGjCjMjPjDjLhRJE 5 | jERBFeFiIjFjMjMjPffJRnAEjERBFeFiXjPjSjMjEffaSbyTn0ABJTnAEjERBCFnVDyBeEjBhAhdhAn 6 | ffAVDyBAFdKByBIACD40BiAH4B0AiAACAzAKByB -------------------------------------------------------------------------------- /testfiles/v1.0/logical_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = true; 2 | var b = false; 3 | !a; 4 | !(!a); 5 | a || b; 6 | a || b; 7 | callme(2) || !(!b); 8 | a && b; 9 | 1 == 2 ? a : b; -------------------------------------------------------------------------------- /testfiles/v1.0/logical_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AJJAnASzBjBByBnctftJBnASzBjCCyBncfftJCnAhzBhBDVByBJDnAhDhD 2 | VByBJEnAUzCjcjcEVByBVCyBnnJFnAUEVByBVCyBnnJGnAUEEjzGjDjBjMjMjNjFFRBFdCffhDhDVCy 3 | BnnJHnAUzChGhGGVByBVCyBnnJInAdCzChdhdHnFdCdBnVByBVCyBACB40BiAC4B0AiAACAzAIByB -------------------------------------------------------------------------------- /testfiles/v1.0/methods.jsx: -------------------------------------------------------------------------------- 1 | function px() { 2 | return this.prefix + "X"; 3 | } 4 | function Foo(yz) { 5 | this.prefix = "a-"; 6 | if (yz > 0) { 7 | this.pyz = function () { 8 | return this.prefix + "Y"; 9 | }; 10 | } else { 11 | this.pyz = function () { 12 | return this.prefix + "Z"; 13 | }; 14 | } 15 | this.m1 = px; 16 | } 17 | var foo1 = new Foo(1); 18 | var foo2 = new Foo(0); 19 | foo2.prefix = "b-"; 20 | alert("foo1/2 " + foo1.pyz() + foo2.pyz()); 21 | foo1.m3 = px; 22 | var baz = { 23 | prefix: "c-" 24 | }; 25 | baz.m4 = px; 26 | alert("m1/m3/m4 " + foo1.m1() + foo1.m3() + baz.m4()); 27 | foo1.m2(); -------------------------------------------------------------------------------- /testfiles/v1.0/methods.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MQbyBnACMAbyBn0ABZBnACzBhLBXzGjQjSjFjGjJjYCezEjUjIjJjTDnneBiY0DzC 2 | jQjYEACMDbyBn0ADJEnABXCeDneCjBhNfOFbyGn0ABJGnABXzDjQjZjaFeDNyBnAMGbyBn0ABZHnACB 3 | XCeDnneBiZ0DzAGCInfACzBheHVzCjZjaIAnndAbyKn0ABJKnABXFeDNyBnAMKbyBn0ABZLnACBXCeD 4 | nneBia0DGCMnfJOnABXzCjNhRJeDjEnfABI40BhAB0AzDiGjPjPKAPJJQnASzEjGjPjPhRLyBEjKRBF 5 | dBftnftJRnASzEjGjPjPhSMyBEjKRBFdAftnftJSnABXCVMyBneCjChNfJTnAEjzFjBjMjFjSjUNRBC 6 | BCBnEXFVLyBnfeHjGjPjPhRhPhShAnEXFVMyBnfnnffJUnABXzCjNhTOVLyBjEnfJVnASzDjCjBjaPy 7 | BWzGiPjCjKjFjDjUQBCFeCjDhNnftJYnABXzCjNhURVPyBjEnfJZnAEjNRBCBCBCBnEXJVLyBnfeJjN 8 | hRhPjNhThPjNhUhAnEXOVLyBnfnnEXRVPyBnfnnffJganAEXzCjNhSSVLyBnfADL40BiAM4B0AiAP4C 9 | 0AiAADAGByB -------------------------------------------------------------------------------- /testfiles/v1.0/objects.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | dog = { 3 | color: "brown", 4 | size: "large" 5 | }; 6 | var anObject = new Object(); 7 | var emptyLiteralObj = {}; 8 | var myStructure = { 9 | name: { 10 | first: "Mel", 11 | last: "Smith" 12 | }, 13 | age: 33, 14 | hobbies: ["chess", "jogging"] 15 | }; 16 | dog instanceof anObject; 17 | } -------------------------------------------------------------------------------- /testfiles/v1.0/objects.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MyBbyBnABMAbyBn0AFJBnABjzDjEjPjHBWzGiPjCjKjFjDjUCCzFjDjPjMjPjSDFe 2 | FjCjSjPjXjOzEjTjJjajFEFeFjMjBjSjHjFnfJFnASzIjBjOiPjCjKjFjDjUFAEjCntnftJGnASzPjF 3 | jNjQjUjZiMjJjUjFjSjBjMiPjCjKGBWCAnftJHnASzLjNjZiTjUjSjVjDjUjVjSjFHCWCDzEjOjBjNj 4 | FIWCCzFjGjJjSjTjUJFeDiNjFjMzEjMjBjTjUKFeFiTjNjJjUjIzDjBjHjFLFdhBzHjIjPjCjCjJjFj 5 | TMARCFeFjDjIjFjTjTFeHjKjPjHjHjJjOjHfnftJPnACzKjJjOjTjUjBjOjDjFjPjGNjBVFAnnADG4B 6 | 0AiAH4C0AiAF40BiAADAzAOAQ0EOByB -------------------------------------------------------------------------------- /testfiles/v1.0/regex.jsx: -------------------------------------------------------------------------------- 1 | /testregex/.test("testestest"); 2 | "ratatam".replace(/ta/g, "tu"); -------------------------------------------------------------------------------- /testfiles/v1.0/regex.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ACJAnAEXzEjUjFjTjUBYJjUjFjTjUjSjFjHjFjYARBFeKjUjFjTjUjFjTj 2 | UjFjTjUffJBnAEXzHjSjFjQjMjBjDjFCFeHjSjBjUjBjUjBjNRCYCjUjBBjHFeCjUjVff0DzADByB -------------------------------------------------------------------------------- /testfiles/v1.0/strings.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | var escapedQuotes = "\"Hello, World!\" he said."; 3 | str += "e"; 4 | } -------------------------------------------------------------------------------- /testfiles/v1.0/strings.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MyBbyBnABMAbyBn0ACJBnASzNjFjTjDjBjQjFjEiRjVjPjUjFjTBAneYhCiIjFjMj 2 | MjPhMhAiXjPjSjMjEhBhChAjIjFhAjTjBjJjEhOftJCnABjzDjTjUjSCCzBhLDnnneBjFntABB40BiA 3 | ABAzAEAD0EEByB -------------------------------------------------------------------------------- /testfiles/v1.0/switch_statement.jsx: -------------------------------------------------------------------------------- 1 | var a = true; 2 | switch(a) { 3 | case "test1": 4 | a = 5; 5 | break ; 6 | case "test2": 7 | a = 10; 8 | break ; 9 | default: 10 | a = 15; 11 | break ; 12 | } 13 | switch(a) { 14 | case "test3": 15 | a = 33; 16 | break ; 17 | case "test4": 18 | a = 55; 19 | break ; 20 | } 21 | switch(a) { 22 | case "test3": 23 | case "test4": 24 | a = 55; 25 | break ; 26 | case "test6": 27 | case "test7": 28 | a = 66; 29 | break ; 30 | } 31 | switch(a) { 32 | case "test3": 33 | case "test4": 34 | a = 55; 35 | break ; 36 | default: 37 | 38 | } -------------------------------------------------------------------------------- /testfiles/v1.0/switch_statement.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AFJAnASzBjBByBnctftcBnAVByBDRBFeFjUjFjTjUhRfRBFeFjUjFjTjUh 2 | SfRBnfDbDn0ACJDnASByBndFffDEnAzACtbGn0ACJGnASByBndKffDHnACtbJn0ACJJnASByBndPffD 3 | KnACtcMnAVByBCRBFeFjUjFjTjUhTfRBFeFjUjFjTjUhUfCbOn0ACJOnASByBndhBffDPnACtbRn0AC 4 | JRnASByBndhXffDSnACtcUnAVByBCRCFeFjUjFjTjUhTFeFjUjFjTjUhUfRCFeFjUjFjTjUhWFeFjUj 5 | FjTjUhXfCbXn0ACJXnASByBndhXffDYnACtbgbn0ACJgbnASByBndiCffDgcnACtcgenAVByBCRCFeF 6 | jUjFjTjUhTFeFjUjFjTjUhUfRBnfCbhBn0ACJhBnASByBndhXffDhCnACtnABB40BiAABACByB -------------------------------------------------------------------------------- /testfiles/v1.0/unary_arithmetic_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = 100; 2 | a = +a; 3 | a = -a; 4 | a = a++; 5 | a = ++b; 6 | a = a--; 7 | a = --a; -------------------------------------------------------------------------------- /testfiles/v1.0/unary_arithmetic_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0AHJAnASzBjBByBndjEftJBnASByBhzBhLCVByBnffJCnASByBhzBhNDVBy 2 | BnffJDnASByBTByBBtnffJEnASByBPjzBjCEBfnffJFnASByBTByByBtnffJGnASByBTByByBfnffAB 3 | B40BiAABAzAFByB -------------------------------------------------------------------------------- /testfiles/v1.0/unary_bitwise_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = 0; 2 | ~a; -------------------------------------------------------------------------------- /testfiles/v1.0/unary_bitwise_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ACJAnASzBjBByBndAftJBnAhzBjeCVByBABB40BiAABAzADByB -------------------------------------------------------------------------------- /testfiles/v1.0/unicode_string.jsx: -------------------------------------------------------------------------------- 1 | var unicodetest = "雷電"; -------------------------------------------------------------------------------- /testfiles/v1.0/unicode_string.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ABJAnASzLjVjOjJjDjPjEjFjUjFjTjUByBneC2nXkW2nbkWftABB40BiAA 2 | BAzACByB -------------------------------------------------------------------------------- /testfiles/v1.0/variables.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | var integertest = 482; 3 | integertest = -238481283123; 4 | integertest = -323.423; 5 | integertest = -40023; 6 | integertest = -5; 7 | var floatingtest = 34.5; 8 | var stringtest = "onetwothree"; 9 | globalVarTest = "globglobglob"; 10 | globalVarTest = "globglobglob2"; 11 | var nullVar = null; 12 | var undefinedVar = undefined; 13 | var infinityVar = Infinity; 14 | var notANumberVar = NaN; 15 | var boolVarTrue = true; 16 | var boolVarFalse = false; 17 | } -------------------------------------------------------------------------------- /testfiles/v1.0/variables.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MyBbyBnABMAbyBn0APJBnASzLjJjOjUjFjHjFjSjUjFjTjUBAnd2nCBftJCnASBAn 2 | d8AkAZmMiLmDiLmCffJDnASBAnd8iUnDlFkbmEhWjUmAffJEnASBAndy2iXkcffJFnASBAndyFffJGn 3 | ASzMjGjMjPjBjUjJjOjHjUjFjTjUCBnd80DiAiBiAftJHnASzKjTjUjSjJjOjHjUjFjTjUDCneLjPjO 4 | jFjUjXjPjUjIjSjFjFftJInABjzNjHjMjPjCjBjMiWjBjSiUjFjTjUEneMjHjMjPjCjHjMjPjCjHjMj 5 | PjCfJJnABjEneNjHjMjPjCjHjMjPjCjHjMjPjChSfJKnASzHjOjVjMjMiWjBjSFDnbftJLnASzMjVjO 6 | jEjFjGjJjOjFjEiWjBjSGEjzJjVjOjEjFjGjJjOjFjEHnftJMnASzLjJjOjGjJjOjJjUjZiWjBjSIFj 7 | zIiJjOjGjJjOjJjUjZJnftJNnASzNjOjPjUiBiOjVjNjCjFjSiWjBjSKGjzDiOjBiOLnftJOnASzLjC 8 | jPjPjMiWjBjSiUjSjVjFMHnctftJPnASzMjCjPjPjMiWjBjSiGjBjMjTjFNIncfftAJB40BiAC4B0Ai 9 | AD4C0AiAF4D0AiAG4E0AiAI4F0AiAK4G0AiAM4H0AiAN4I0AiAAJAzAOAQ0EOByB -------------------------------------------------------------------------------- /testfiles/v1.0/while_loop.jsx: -------------------------------------------------------------------------------- 1 | var cond = 5923; 2 | var test1 = "test"; 3 | while (cond > 0) { 4 | test1 += cond; 5 | cond--; 6 | } -------------------------------------------------------------------------------- /testfiles/v1.0/while_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ADJAnASzEjDjPjOjEByBnd2hDXftJBnASzFjUjFjTjUhRCyBneEjUjFjTj 2 | UftlCbDn0ACJDnASCyBCzBhLDnVByBnnntfJEnATByByBtACzBheEVByBnnd0ACC4B0AiAB40BiAACA 3 | zAFByB -------------------------------------------------------------------------------- /testfiles/v1.0/with_statement.jsx: -------------------------------------------------------------------------------- 1 | with (document) { 2 | var a = getElementById("a"); 3 | var b = getElementById("b"); 4 | var c = getElementById("c"); 5 | } -------------------------------------------------------------------------------- /testfiles/v1.0/with_statement.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ABmAbBn0ADJBnASzBjBByBEjzOjHjFjUiFjMjFjNjFjOjUiCjZiJjECRBF 2 | eBjBffnftJCnASzBjCDyBEjCRBFeBjCffnftJDnASzBjDEyBEjCRBFeBjDffnftAjzIjEjPjDjVjNjF 3 | jOjUFADB40BiAD4B0AiAE4C0AiAADAzAGByB -------------------------------------------------------------------------------- /testfiles/v1.0/xml.jsx: -------------------------------------------------------------------------------- 1 | var result = bookstoreXML.book["@category"] == "CHILDREN"; -------------------------------------------------------------------------------- /testfiles/v1.0/xml.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@1.0@MAbyBn0ABJAnASzGjSjFjTjVjMjUByBCzChdhdCXzJiAjDjBjUjFjHjPjSjZDXzEj 2 | CjPjPjLEjzMjCjPjPjLjTjUjPjSjFiYiNiMFnneIiDiIiJiMiEiSiFiOnftABB40BiAABAzAGByB -------------------------------------------------------------------------------- /testfiles/v2.0/arrays.jsx: -------------------------------------------------------------------------------- 1 | var emptyArray = []; 2 | var filledArray = [78, 452, "yes"]; 3 | var ctorArray = new Array("bbb", "ccc"); 4 | emptyArray.push("testvalue"); 5 | var indexingNumber = filledArray[0]; 6 | var indexingString = filledArray[1]; -------------------------------------------------------------------------------- /testfiles/v2.0/arrays.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AGJAnASzKjFjNjQjUjZiBjSjSjBjZByBAnnftJBnASzLjGjJjMjMjFjEi 2 | BjSjSjBjZCyBARDFdiOFd2mEBFeDjZjFjTfnftJCnASzJjDjUjPjSiBjSjSjBjZDyBEjzFiBjSjSjBj 3 | ZEfRCFeDjCjCjCFeDjDjDjDftnftJDnAEXzEjQjVjTjIFfVBfyBRBFeJjUjFjTjUjWjBjMjVjFffJEn 4 | ASzOjJjOjEjFjYjJjOjHiOjVjNjCjFjSGyBXzBhQHfVCfyBnftJFnASzOjJjOjEjFjYjJjOjHiTjUjS 5 | jJjOjHIyBXzBhRJfVCfyBnftAFB40BiAC4B0AiAD4C0AiAG4D0AiAI4E0AiAAFAzAKByB -------------------------------------------------------------------------------- /testfiles/v2.0/assignment_operators.jsx: -------------------------------------------------------------------------------- 1 | var x = 9; 2 | x += 657; 3 | x += ((4923 * MyMethod(5)) / AnotherMethod("valvalval")); 4 | x *= 30; 5 | x /= 6; 6 | x -= 3; 7 | x %= 7; 8 | var obj1 = { 9 | a: 1 10 | }; 11 | var obj2 = { 12 | b: 1 13 | }; 14 | obj1.a = 99; 15 | obj1 = obj2; -------------------------------------------------------------------------------- /testfiles/v2.0/assignment_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ALJAnASzBjYByBndJftJBnASByBCzBhLCnnnd2kRCntfJCnASByBCCnCz 2 | BhPDCzBhKEnEjzIiNjZiNjFjUjIjPjEFfRBFdFffd2hbTnEjzNiBjOjPjUjIjFjSiNjFjUjIjPjEGfR 3 | BFeJjWjBjMjWjBjMjWjBjMffnnnnntfJDnASByBCEnnndgentfJEnASByBCDnnndGntfJFnASByBCzB 4 | hNHnnndDntfJGnASByBCzBhFInnndHntfJHnASzEjPjCjKhRJyBWzGiPjCjKjFjDjUKBzBjBLFdBnft 5 | JInASzEjPjCjKhSMyBWKBzBjCNFdBnftJJnABXLfVJfyBndjDfJKnASJyBVMfyBnffADB40BiAJ4B0A 6 | iAM4C0AiAADAzAOByB -------------------------------------------------------------------------------- /testfiles/v2.0/binary_arithmetic_operators.tempJsx: -------------------------------------------------------------------------------- 1 | "He" + "llo"; 2 | 2 + 6; 3 | 2 + "555"; 4 | 10 - 5 5 | 3 * 50 6 | 99 / 4 7 | 232 % 7676 8 | -------------------------------------------------------------------------------- /testfiles/v2.0/binary_arithmetic_operators.tempJsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AHJAnAFeFiIjFjMjMjPJBnAFdIJCnAFeEhShVhVhVJDnAFdFJEnAFdkWJ 2 | FnAFd80DmAhYiAJGnAFdnI0DzABByB -------------------------------------------------------------------------------- /testfiles/v2.0/binary_bitwise_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = 0; 2 | a & 2; 3 | a | 3; 4 | a ^ 4; 5 | a << 10; 6 | a >> 20; 7 | a >>> 50; -------------------------------------------------------------------------------- /testfiles/v2.0/binary_bitwise_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AHJAnASzBjBByBndAftJBnACzBhGCVBfyBnndCJCnACzBjcDVBfyBnndD 2 | JDnACzBieEVBfyBnndEJEnACzChchcFVBfyBnndKJFnACzCheheGVBfyBnndUJGnACzDheheheHVBfy 3 | BnndhSABB40BiAABAzAIByB -------------------------------------------------------------------------------- /testfiles/v2.0/comparison_operators.jsx: -------------------------------------------------------------------------------- 1 | x = a == 2; 2 | x = c != 3; 3 | x = d > 5; 4 | x = f >= 7; 5 | x = g < 9; 6 | x = q <= 11; 7 | x = 12 === 13; 8 | x = 14 !== 15; -------------------------------------------------------------------------------- /testfiles/v2.0/comparison_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AIJAnABjzBjYBfCzChdhdCjzBjBDfnndCnfJBnABjBfCzChBhdEjzBjDF 2 | fnndDnfJCnABjBfCzBheGjzBjEHfnndFnfJDnABjBfCzChehdIjzBjGJfnndHnfJEnABjBfCzBhcKjz 3 | BjHLfnndJnfJFnABjBfCzChchdMjzBjRNfnndLnfJGnABjBfCzDhdhdhdOnFdNdMnnfJHnABjBfCzDh 4 | BhdhdPnFdPdOnnf0DzAQByB -------------------------------------------------------------------------------- /testfiles/v2.0/conditional_operator.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | var a = true; 3 | var b = a === "b" ? 2 : 5; 4 | var c = BRIL.appVersion < 11 ? (eventObject = {}, eventObject.target = this) : 0; 5 | } -------------------------------------------------------------------------------- /testfiles/v2.0/conditional_operator.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBnABMAbyBn0ADJBnASzBjBBAnctftJCnASzBjCCBdCzDhdhdhdDVBfAnneBj 2 | CFdCFdFnftJDnASzBjDECdCzBhcFXzKjBjQjQiWjFjSjTjJjPjOGfjzEiCiSiJiMHfnndLRCBjzLjFj 3 | WjFjOjUiPjCjKjFjDjUIfWzGiPjCjKjFjDjUJAnfBXzGjUjBjSjHjFjUKfjIfezEjUjIjJjTLfnftFd 4 | AnftADB40BiAC4B0AiAE4C0AiAADAzAMAE0EMByB -------------------------------------------------------------------------------- /testfiles/v2.0/do_while_loop.jsx: -------------------------------------------------------------------------------- 1 | var cond = "50"; 2 | var test1 = "test"; 3 | do { 4 | test1 = "nothing"; 5 | } while (cond) -------------------------------------------------------------------------------- /testfiles/v2.0/do_while_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ADJAnASzEjDjPjOjEByBneChVhQftJBnASzFjUjFjTjUhRCyBneEjUjFj 2 | TjUftICbyDn0ABJDnASCyBneHjOjPjUjIjJjOjHffAVBfyBACC4B0AiAB40BiAACAzADByB -------------------------------------------------------------------------------- /testfiles/v2.0/exceptions.jsx: -------------------------------------------------------------------------------- 1 | throw new Error("test error throw") 2 | throw new CustomErr("custom err throw") 3 | try { 4 | var x = "trytrytrytry"; 5 | } catch (e if e == "InvalidNameException") { 6 | var x = "special catch"; 7 | } catch (e) { 8 | var x = "all catch"; 9 | } finally { 10 | var x = "finallyblock"; 11 | } -------------------------------------------------------------------------------- /testfiles/v2.0/exceptions.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ADfAnAEjzFiFjSjSjPjSBfRBFeQjUjFjTjUhAjFjSjSjPjShAjUjIjSjP 2 | jXftfBnAEjzJiDjVjTjUjPjNiFjSjSCfRBFeQjDjVjTjUjPjNhAjFjSjShAjUjIjSjPjXftgCbyBn0A 3 | BJDnASzBjYDyBneMjUjSjZjUjSjZjUjSjZjUjSjZftACbyBn0ABJKnASDyBneMjGjJjOjBjMjMjZjCj 4 | MjPjDjLftzBjFECzChdhdFjEfnneUiJjOjWjBjMjJjEiOjBjNjFiFjYjDjFjQjUjJjPjObyBn0ABJFn 5 | ASDyBneNjTjQjFjDjJjBjMhAjDjBjUjDjIftEnbyBn0ABJInASDyBneJjBjMjMhAjDjBjUjDjIftABD 6 | 40BiAABAzAGByB -------------------------------------------------------------------------------- /testfiles/v2.0/for_in_loop.jsx: -------------------------------------------------------------------------------- 1 | var result = { 2 | a: 1 3 | }; 4 | for (var propertyName in result) { 5 | result.a = "fifty"; 6 | } -------------------------------------------------------------------------------- /testfiles/v2.0/for_in_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ACJAnASzGjSjFjTjVjMjUByBWzGiPjCjKjFjDjUCBzBjBDFdBnftLBbyC 2 | n0ABJCnABXDfVBfyBneFjGjJjGjUjZfAVzMjQjSjPjQjFjSjUjZiOjBjNjFEfyBVBfyByBzAFfACB40 3 | BiAE4B0AiAACAFByB -------------------------------------------------------------------------------- /testfiles/v2.0/for_loop.jsx: -------------------------------------------------------------------------------- 1 | var result = ""; 2 | for (var index = 52342;index < testMethod("noway"); index += -40239) { 3 | result += "b"; 4 | } 5 | for (var index = 52342; index < testMethod("noway"); index *= 40239) { 6 | result += "b"; 7 | } 8 | for (var index = 52342; index < testMethod("noway"); index /= 40239) { 9 | result += "b"; 10 | } 11 | for (; index < testMethod("noway"); index /= 40239) { 12 | result += "b"; 13 | } 14 | for (; ; index /= 40239) { 15 | result += "b"; 16 | } -------------------------------------------------------------------------------- /testfiles/v2.0/for_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AGJAnASzGjSjFjTjVjMjUByBneAftaBbyCn0ABJCnASByBCzBhLCnnneB 2 | jCntfAVzFjJjOjEjFjYDfyB2jWmMEjzKjUjFjTjUiNjFjUjIjPjEEfRBFeFjOjPjXjBjZffy2hPkdyB 3 | zBhcFKEbyFn0ABJFnASByBCCnnneBjCntfASDyBnd2jWmMftCFVDfyBEjEfRBFeFjOjPjXjBjZffnnS 4 | DyBCzBhKGnnnd2hPkdntfKHbyIn0ABJInASByBCCnnneBjCntfASDyBnd2jWmMftCFVDfyBEjEfRBFe 5 | FjOjPjXjBjZffnnSDyBCzBhPHnnnd2hPkdntfKKbyLn0ABJLnASByBCCnnneBjCntfAnCFVDfyBEjEf 6 | RBFeFjOjPjXjBjZffnnSDyBCHnnnd2hPkdntfKNbyOn0ABJOnASByBCCnnneBjCntfAnnSDyBCHnnnd 7 | 2hPkdntfACD4B0AiAB40BiAACAzAIByB -------------------------------------------------------------------------------- /testfiles/v2.0/functions.jsx: -------------------------------------------------------------------------------- 1 | var addCtor = new Function("firstFuncX", "firstFuncY", "return firstFuncX + firstFuncY"); 2 | var tCtor = addCtor(5656, 123124); 3 | var addFuncExpr = function (sndFuncX, sndFuncY) { 4 | return sndFuncX + sndFuncY; 5 | }; 6 | var tFuncExpr = addFuncExpr(23123, 5345); 7 | function addShorthand(thirdFuncX, thirdFuncY) { 8 | return thirdFuncX + thirdFuncY; 9 | } 10 | var tShorthand = addShorthand(1, 2); 11 | function subtract(fourthFuncX, fourthFuncY) { 12 | return fourthFuncX - fourthFuncY; 13 | } 14 | var testo = subtract.length; 15 | var test2 = subtract.getName(5); -------------------------------------------------------------------------------- /testfiles/v2.0/functions.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBnACMGbyBn0ABZHnACzBhLBVzKjUjIjJjSjEiGjVjOjDiYCfAVzKjUjIjJjS 2 | jEiGjVjOjDiZDfBnnACC40BhAD4B0AhAC0AzMjBjEjEiTjIjPjSjUjIjBjOjEEAIMKbyBn0ABZLnACz 3 | BhNFVzLjGjPjVjSjUjIiGjVjOjDiYGfAVzLjGjPjVjSjUjIiGjVjOjDiZHfBnnACG40BhAH4B0AhAC0 4 | AzIjTjVjCjUjSjBjDjUIAMHJAnASzHjBjEjEiDjUjPjSJyBEjzIiGjVjOjDjUjJjPjOKfRDFeKjGjJj 5 | SjTjUiGjVjOjDiYFeKjGjJjSjTjUiGjVjOjDiZFegejSjFjUjVjSjOhAjGjJjSjTjUiGjVjOjDiYhAh 6 | LhAjGjJjSjTjUiGjVjOjDiZftnftJBnASzFjUiDjUjPjSLyBEVJfyBRCFd2YWFd4nUnABAffnftJCnA 7 | SzLjBjEjEiGjVjOjDiFjYjQjSMyBNyBnAMCbyBn0ABZDnACBVzIjTjOjEiGjVjOjDiYNfAVzIjTjOjE 8 | iGjVjOjDiZOfBnnACN40BhAO4B0AhAC0AzAPCEnftJFnASzJjUiGjVjOjDiFjYjQjSQyBEVMfyBRCFd 9 | 2iTiaFd2nBUffnftJJnASzKjUiTjIjPjSjUjIjBjOjERyBEjEfRCFdBFdCffnftJNnASzFjUjFjTjUj 10 | PSyBXzGjMjFjOjHjUjITfjIfnftJOnASzFjUjFjTjUhSUyBEXzHjHjFjUiOjBjNjFVfjIfRBFdFffnf 11 | tAHJ40BiAL4B0AiAM4C0AiAQ4D0AiAR4E0AiAS4F0AiAU4G0AiAAHAPByB -------------------------------------------------------------------------------- /testfiles/v2.0/if_statement.jsx: -------------------------------------------------------------------------------- 1 | var a = true; 2 | if (a) { 3 | a = "if stmt"; 4 | } else if (a == "anotherOne") { 5 | a = "another stmt"; 6 | } else if (a == "ifelse") { 7 | a = "elseif stmt"; 8 | } else { 9 | a = "else stmt"; 10 | } 11 | if (b) { 12 | b = "a"; 13 | } else { 14 | b = "c"; 15 | } 16 | if (c) { 17 | c = "c"; 18 | } -------------------------------------------------------------------------------- /testfiles/v2.0/if_statement.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AEJAnASzBjBByBnctftOBbyCn0ABJCnASByBneHjJjGhAjTjUjNjUffAV 2 | BfyBODbyEn0ABJEnASByBneMjBjOjPjUjIjFjShAjTjUjNjUffACzChdhdCVBfyBnneKjBjOjPjUjIj 3 | FjSiPjOjFOFbyGn0ABJGnASByBneLjFjMjTjFjJjGhAjTjUjNjUffACCVBfyBnneGjJjGjFjMjTjFby 4 | In0ABJInASByBneJjFjMjTjFhAjTjUjNjUffOKbyLn0ABJLnABjzBjCDfneBjBfAjDfbyNn0ABJNnAB 5 | jDfneBjDfOPbyQn0ABJQnABjzBjDEfneBjDfAjEfnABB40BiAABAzAFByB -------------------------------------------------------------------------------- /testfiles/v2.0/labels.jsx: -------------------------------------------------------------------------------- 1 | loop1: for (var a = 0;a < 10; a += 1) { 2 | if (a == 4) { 3 | break loop1; 4 | } 5 | alert("a = " + a); 6 | loop2: for (var b = 0;b < 10; b += 1) { 7 | if (b == 3) { 8 | continue loop2; 9 | } 10 | if (b == 6) { 11 | continue loop1; 12 | } 13 | alert("b = " + b); 14 | } 15 | alert("finished"); 16 | } 17 | block1: alert("Hello"); 18 | alert("World"); 19 | for (var a = 0;a < 10; a += 1) { 20 | alert("a = " + a); 21 | } -------------------------------------------------------------------------------- /testfiles/v2.0/labels.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AEaAbBn0AEOBbyCn0ABDCnAzFjMjPjPjQhRBtACzChdhdCVzBjBDfyBnn 2 | dEnJEnAEjzFjBjMjFjSjUEfRBCzBhLFnVDfyBeEjBhAhdhAnffayFbGn0ADOGbyHn0ABDHnAzFjMjPj 3 | PjQhSGfACCVzBjCHfyBnndDnOJbyKn0ABDKnABfACCVHfyBnndGnJMnAEjEfRBCFnVHfyBeEjChAhdh 4 | AnffBGVHfyBAFdKByBzBhcIJOnAEjEfRBFeIjGjJjOjJjTjIjFjEffBBVDfyBAFdKByBIJyQnBzGjCj 5 | MjPjDjLhRJEjEfRBFeFiIjFjMjMjPffJRnAEjEfRBFeFiXjPjSjMjEffaSbyTn0ABJTnAEjEfRBCFnV 6 | DfyBeEjBhAhdhAnffAVDfyBAFdKByBIACD40BiAH4B0AiAACAzAKByB -------------------------------------------------------------------------------- /testfiles/v2.0/logical_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = true; 2 | var b = false; 3 | !a; 4 | !(!a); 5 | a || b; 6 | a || b; 7 | callme(2) || !(!b); 8 | a && b; 9 | 1 == 2 ? a : b; -------------------------------------------------------------------------------- /testfiles/v2.0/logical_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AJJAnASzBjBByBnctftJBnASzBjCCyBncfftJCnAhzBhBDVBfyBJDnAhD 2 | hDVBfyBJEnAUzCjcjcEVBfyBVCfyBnnJFnAUEVBfyBVCfyBnnJGnAUEEjzGjDjBjMjMjNjFFfRBFdCf 3 | fhDhDVCfyBnnJHnAUzChGhGGVBfyBVCfyBnnJInAdCzChdhdHnFdCdBnVBfyBVCfyBACB40BiAC4B0A 4 | iAACAzAIByB -------------------------------------------------------------------------------- /testfiles/v2.0/methods.jsx: -------------------------------------------------------------------------------- 1 | function px() { 2 | return this.prefix + "X"; 3 | } 4 | function Foo(yz) { 5 | this.prefix = "a-"; 6 | if (yz > 0) { 7 | this.pyz = function () { 8 | return this.prefix + "Y"; 9 | }; 10 | } else { 11 | this.pyz = function () { 12 | return this.prefix + "Z"; 13 | }; 14 | } 15 | this.m1 = px; 16 | } 17 | var foo1 = new Foo(1); 18 | var foo2 = new Foo(0); 19 | foo2.prefix = "b-"; 20 | alert("foo1/2 " + foo1.pyz() + foo2.pyz()); 21 | foo1.m3 = px; 22 | var baz = { 23 | prefix: "c-" 24 | }; 25 | baz.m4 = px; 26 | alert("m1/m3/m4 " + foo1.m1() + foo1.m3() + baz.m4()); 27 | foo1.m2(); -------------------------------------------------------------------------------- /testfiles/v2.0/methods.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBnACMAbyBn0ABZAnACzBhLBXzGjQjSjFjGjJjYCfezEjUjIjJjTDfnneBiY0 2 | DzCjQjYE0AMBbyBn0ADJCnABXCfeDfneCjBhNfODbyEn0ABJEnABXzDjQjZjaFfeDfNyBnAMEbyBn0A 3 | BZEnACBXCfeDfnneBiZ0DzAGCEnfACzBheHVzCjZjaIfAnndAbyGn0ABJGnABXFfeDfNyBnAMGbyBn0 4 | ABZGnACBXCfeDfnneBia0DGCGnfJInABXzCjNhRJfeDfjEfnfABI40BhAB0AzDiGjPjPKAJJJKnASzE 5 | jGjPjPhRLyBEjKfRBFdBftnftJLnASzEjGjPjPhSMyBEjKfRBFdAftnftJMnABXCfVMfyBneCjChNfJ 6 | NnAEjzFjBjMjFjSjUNfRBCBCBnEXFfVLfyBnfeHjGjPjPhRhPhShAnEXFfVMfyBnfnnffJOnABXzCjN 7 | hTOfVLfyBjEfnfJPnASzDjCjBjaPyBWzGiPjCjKjFjDjUQBCFeCjDhNnftJQnABXzCjNhURfVPfyBjE 8 | fnfJRnAEjNfRBCBCBCBnEXJfVLfyBnfeJjNhRhPjNhThPjNhUhAnEXOfVLfyBnfnnEXRfVPfyBnfnnf 9 | fJSnAEXzCjNhSSfVLfyBnfADL40BiAM4B0AiAP4C0AiAADAGByB -------------------------------------------------------------------------------- /testfiles/v2.0/number_systems.tempJsx: -------------------------------------------------------------------------------- 1 | var octalTest = 0337; 2 | var hexTest = 0xFF; -------------------------------------------------------------------------------- /testfiles/v2.0/number_systems.tempJsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ACJAnASzJjPjDjUjBjMiUjFjTjUByBndmfftJBnASzHjIjFjYiUjFjTjU 2 | CyBndnfftACB40BiAC4B0AiAACAzADByB -------------------------------------------------------------------------------- /testfiles/v2.0/objects.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | dog = { 3 | color: "brown", 4 | size: "large" 5 | }; 6 | var anObject = new Object(); 7 | var emptyLiteralObj = {}; 8 | var myStructure = { 9 | name: { 10 | first: "Mel", 11 | last: "Smith" 12 | }, 13 | age: 33, 14 | hobbies: ["chess", "jogging"] 15 | }; 16 | dog instanceof anObject; 17 | } -------------------------------------------------------------------------------- /testfiles/v2.0/objects.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBnABMAbyBn0AFJBnABjzDjEjPjHBfWzGiPjCjKjFjDjUCCzFjDjPjMjPjSDF 2 | eFjCjSjPjXjOzEjTjJjajFEFeFjMjBjSjHjFnfJFnASzIjBjOiPjCjKjFjDjUFAEjCfntnftJGnASzP 3 | jFjNjQjUjZiMjJjUjFjSjBjMiPjCjKGBWCAnftJHnASzLjNjZiTjUjSjVjDjUjVjSjFHCWCDzEjOjBj 4 | NjFIWCCzFjGjJjSjTjUJFeDiNjFjMzEjMjBjTjUKFeFiTjNjJjUjIzDjBjHjFLFdhBzHjIjPjCjCjJj 5 | FjTMARCFeFjDjIjFjTjTFeHjKjPjHjHjJjOjHfnftJPnACzKjJjOjTjUjBjOjDjFjPjGNjBfVFfAnnA 6 | DF40BiAG4B0AiAH4C0AiAADAzAOAQ0EOByB -------------------------------------------------------------------------------- /testfiles/v2.0/regex.jsx: -------------------------------------------------------------------------------- 1 | /testregex/.test("testestest"); 2 | "ratatam".replace(/ta/g, "tu"); -------------------------------------------------------------------------------- /testfiles/v2.0/regex.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ACJAnAEXzEjUjFjTjUBfYJjUjFjTjUjSjFjHjFjYARBFeKjUjFjTjUjFj 2 | TjUjFjTjUffJBnAEXzHjSjFjQjMjBjDjFCfFeHjSjBjUjBjUjBjNRCYCjUjBBjHFeCjUjVff0DzADBy 3 | B -------------------------------------------------------------------------------- /testfiles/v2.0/strings.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | var escapedQuotes = "\"Hello, World!\" he said."; 3 | str += "e"; 4 | } -------------------------------------------------------------------------------- /testfiles/v2.0/strings.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBnABMAbyBn0ACJBnASzNjFjTjDjBjQjFjEiRjVjPjUjFjTBAneYhCiIjFjMj 2 | MjPhMhAiXjPjSjMjEhBhChAjIjFhAjTjBjJjEhOftJCnABjzDjTjUjSCfCzBhLDnnneBjFntABB40Bi 3 | AABAzAEAD0EEByB -------------------------------------------------------------------------------- /testfiles/v2.0/switch_statement.jsx: -------------------------------------------------------------------------------- 1 | var a = true; 2 | switch(a) { 3 | case "test1": 4 | a = 5; 5 | break ; 6 | case "test2": 7 | a = 10; 8 | break ; 9 | default: 10 | a = 15; 11 | break ; 12 | } 13 | switch(a) { 14 | case "test3": 15 | a = 33; 16 | break ; 17 | case "test4": 18 | a = 55; 19 | break ; 20 | } 21 | switch(a) { 22 | case "test3": 23 | case "test4": 24 | a = 55; 25 | break ; 26 | case "test6": 27 | case "test7": 28 | a = 66; 29 | break ; 30 | } 31 | switch(a) { 32 | case "test3": 33 | case "test4": 34 | a = 55; 35 | break ; 36 | default: 37 | 38 | } -------------------------------------------------------------------------------- /testfiles/v2.0/switch_statement.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AFJAnASzBjBByBnctftcBnAVBfyBDRBFeFjUjFjTjUhRfRBFeFjUjFjTj 2 | UhSfRBnfDbDn0ACJDnASByBndFffDEnAzACtbGn0ACJGnASByBndKffDHnACtbJn0ACJJnASByBndPf 3 | fDKnACtcMnAVBfyBCRBFeFjUjFjTjUhTfRBFeFjUjFjTjUhUfCbOn0ACJOnASByBndhBffDPnACtbRn 4 | 0ACJRnASByBndhXffDSnACtcUnAVBfyBCRCFeFjUjFjTjUhTFeFjUjFjTjUhUfRCFeFjUjFjTjUhWFe 5 | FjUjFjTjUhXfCbXn0ACJXnASByBndhXffDYnACtbgbn0ACJgbnASByBndiCffDgcnACtcgenAVBfyBC 6 | RCFeFjUjFjTjUhTFeFjUjFjTjUhUfRBnfCbhBn0ACJhBnASByBndhXffDhCnACtnABB40BiAABACByB -------------------------------------------------------------------------------- /testfiles/v2.0/unary_arithmetic_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = 100; 2 | a = +a; 3 | a = -a; 4 | a = a++; 5 | a = ++b; 6 | a = a--; 7 | a = --a; -------------------------------------------------------------------------------- /testfiles/v2.0/unary_arithmetic_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AHJAnASzBjBByBndjEftJBnASByBhzBhLCVBfyBnffJCnASByBhzBhNDV 2 | BfyBnffJDnASByBTByBBtnffJEnASByBPjzBjCEfBfnffJFnASByBTByByBtnffJGnASByBTByByBfn 3 | ffABB40BiAABAzAFByB -------------------------------------------------------------------------------- /testfiles/v2.0/unary_bitwise_operators.jsx: -------------------------------------------------------------------------------- 1 | var a = 0; 2 | ~a; -------------------------------------------------------------------------------- /testfiles/v2.0/unary_bitwise_operators.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ACJAnASzBjBByBndAftJBnAhzBjeCVBfyBABB40BiAABAzADByB -------------------------------------------------------------------------------- /testfiles/v2.0/unicode_string.jsx: -------------------------------------------------------------------------------- 1 | var unicodetest = "雷電"; -------------------------------------------------------------------------------- /testfiles/v2.0/unicode_string.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ABJAnASzLjVjOjJjDjPjEjFjUjFjTjUByBneC2nXkW2nbkWftABB40BiA 2 | ABAzACByB -------------------------------------------------------------------------------- /testfiles/v2.0/variables.jsx: -------------------------------------------------------------------------------- 1 | function () { 2 | var integertest = 482; 3 | integertest = -238481283123; 4 | integertest = -323.423; 5 | integertest = -40023; 6 | integertest = -5; 7 | var floatingtest = 34.5; 8 | var stringtest = "onetwothree"; 9 | globalVarTest = "globglobglob"; 10 | globalVarTest = "globglobglob2"; 11 | var nullVar = null; 12 | var undefinedVar = undefined; 13 | var infinityVar = Infinity; 14 | var notANumberVar = NaN; 15 | var boolVarTrue = true; 16 | var boolVarFalse = false; 17 | } -------------------------------------------------------------------------------- /testfiles/v2.0/variables.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBnABMAbyBn0APJBnASzLjJjOjUjFjHjFjSjUjFjTjUBAnd2nCBftJCnASBAn 2 | d8AkAZmMiLmDiLmCffJDnASBAnd8iUnDlFkbmEhWjUmAffJEnASBAndy2iXkcffJFnASBAndyFffJGn 3 | ASzMjGjMjPjBjUjJjOjHjUjFjTjUCBnd80DiAiBiAftJHnASzKjTjUjSjJjOjHjUjFjTjUDCneLjPjO 4 | jFjUjXjPjUjIjSjFjFftJInABjzNjHjMjPjCjBjMiWjBjSiUjFjTjUEfneMjHjMjPjCjHjMjPjCjHjM 5 | jPjCfJJnABjEfneNjHjMjPjCjHjMjPjCjHjMjPjChSfJKnASzHjOjVjMjMiWjBjSFDnbftJLnASzMjV 6 | jOjEjFjGjJjOjFjEiWjBjSGEjzJjVjOjEjFjGjJjOjFjEHfnftJMnASzLjJjOjGjJjOjJjUjZiWjBjS 7 | IFjzIiJjOjGjJjOjJjUjZJfnftJNnASzNjOjPjUiBiOjVjNjCjFjSiWjBjSKGjzDiOjBiOLfnftJOnA 8 | SzLjCjPjPjMiWjBjSiUjSjVjFMHnctftJPnASzMjCjPjPjMiWjBjSiGjBjMjTjFNIncfftAJB40BiAC 9 | 4B0AiAD4C0AiAF4D0AiAG4E0AiAI4F0AiAK4G0AiAM4H0AiAN4I0AiAAJAzAOAQ0EOByB -------------------------------------------------------------------------------- /testfiles/v2.0/while_loop.jsx: -------------------------------------------------------------------------------- 1 | var cond = 5923; 2 | var test1 = "test"; 3 | while (cond > 0) { 4 | test1 += cond; 5 | cond--; 6 | } -------------------------------------------------------------------------------- /testfiles/v2.0/while_loop.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ADJAnASzEjDjPjOjEByBnd2hDXftJBnASzFjUjFjTjUhRCyBneEjUjFjT 2 | jUftlCbDn0ACJDnASCyBCzBhLDnVBfyBnnntfJEnATByByBtACzBheEVBfyBnnd0ACC4B0AiAB40BiA 3 | ACAzAFByB -------------------------------------------------------------------------------- /testfiles/v2.0/with_statement.jsx: -------------------------------------------------------------------------------- 1 | with (document) { 2 | var a = getElementById("a"); 3 | var b = getElementById("b"); 4 | var c = getElementById("c"); 5 | } -------------------------------------------------------------------------------- /testfiles/v2.0/with_statement.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0ABmAbBn0ADJBnASzBjBByBEjzOjHjFjUiFjMjFjNjFjOjUiCjZiJjECfR 2 | BFeBjBffnftJCnASzBjCDyBEjCfRBFeBjCffnftJDnASzBjDEyBEjCfRBFeBjDffnftAjzIjEjPjDjV 3 | jNjFjOjUFfADB40BiAD4B0AiAE4C0AiAADAzAGByB -------------------------------------------------------------------------------- /testfiles/v2.0/xml.jsx: -------------------------------------------------------------------------------- 1 | var result = bookstoreXML.book.@category == "CHILDREN"; 2 | var k = xml..title; 3 | bookstoreXML.ns::book; 4 | bookstoreXML.*::book; -------------------------------------------------------------------------------- /testfiles/v2.0/xml.jsxbin: -------------------------------------------------------------------------------- 1 | @JSXBIN@ES@2.0@MyBbyBn0AEJAnASzGjSjFjTjVjMjUByBrzACfXzEjCjPjPjLDfjzMjCjPjPjLjTjU 2 | jPjSjFiYiNiMEfCzChdhdFjzJiAjDjBjUjFjHjPjSjZGfnneIiDiIiJiMiEiSiFiOnftJBnASzBjLHy 3 | BqzFjUjJjUjMjFIfjzDjYjNjMJfnnnftJCnApzCjOjTKfjEfnnDJDnApzBhKLfjEfnnDACH4B0AiAB4 4 | 0BiAACACByB --------------------------------------------------------------------------------