From a8b7aaa8bf49dbc851fb371a6a99b7d2d842dea0 Mon Sep 17 00:00:00 2001 From: nilproject Date: Thu, 10 Dec 2015 00:29:20 +0600 Subject: [PATCH] Fix portable version. Fix few minor bugs. Naming --- NiL.JS.Portable.sln | 10 +- NiL.JS.Portable/Core/Backward.cs | 72 ++++ NiL.JS.Portable/NiL.JS.Portable.csproj | 395 ++++++++++-------- NiL.JS.Test/Program.cs | 11 +- NiL.JS.Test/Translator.cs | 8 +- NiL.JS/BaseLibrary/Array.cs | 24 +- NiL.JS/BaseLibrary/Function.cs | 30 +- NiL.JS/BaseLibrary/GeneratorFunction.cs | 18 +- NiL.JS/Core/Context.cs | 116 ++--- NiL.JS/Core/Functions/ExternalFunction.cs | 4 +- NiL.JS/Core/Functions/ProxyConstructor.cs | 3 + NiL.JS/Core/Interop/NativeList.cs | 4 + NiL.JS/Core/Interop/TypeProxy.cs | 149 +++---- NiL.JS/Core/JIT/JITHelpers.cs | 56 --- NiL.JS/Core/JSObject.cs | 2 +- NiL.JS/Core/JSValue.cs | 40 +- NiL.JS/Core/Parser.cs | 49 +-- NiL.JS/Core/StringMap.cs | 2 + NiL.JS/Core/Tools.cs | 22 +- NiL.JS/Core/Visitor.cs | 140 +++---- .../{AdditionOperator.cs => Addition.cs} | 22 +- NiL.JS/Expressions/ArrayDefinition.cs | 4 +- .../{AssignmentOperator.cs => Assignment.cs} | 16 +- NiL.JS/Expressions/AssignmentOperatorCache.cs | 4 +- NiL.JS/Expressions/AssignmentOverReplace.cs | 2 +- ...ctionOperator.cs => BitwiseConjunction.cs} | 4 +- ...ctionOperator.cs => BitwiseDisjunction.cs} | 8 +- ...ator.cs => BitwiseExclusiveDisjunction.cs} | 4 +- ...NegationOperator.cs => BitwiseNegation.cs} | 4 +- .../Expressions/{CallOperator.cs => Call.cs} | 10 +- NiL.JS/Expressions/ClassDefinition.cs | 26 +- .../{CommaOperator.cs => Comma.cs} | 4 +- ...{ConditionalOperator.cs => Conditional.cs} | 14 +- .../{ConstantDefinition.cs => Constant.cs} | 4 +- ...BooleanOperator.cs => ConvertToBoolean.cs} | 4 +- ...IntegerOperator.cs => ConvertToInteger.cs} | 4 +- ...ToNumberOperator.cs => ConvertToNumber.cs} | 4 +- ...StringExpression.cs => ConvertToString.cs} | 4 +- ...ression.cs => ConvertToUnsignedInteger.cs} | 4 +- .../{DecrementOperator.cs => Decrement.cs} | 4 +- .../{DeleteOperator.cs => Delete.cs} | 12 +- ...ePropertyOperator.cs => DeleteProperty.cs} | 10 +- .../{DivisionOperator.cs => Division.cs} | 4 +- .../{EmptyExpression.cs => Empty.cs} | 10 +- .../{EqualOperator.cs => Equal.cs} | 6 +- NiL.JS/Expressions/Expression.cs | 16 +- NiL.JS/Expressions/ExpressionTree.cs | 201 ++++----- NiL.JS/Expressions/FunctionDefinition.cs | 15 +- ...airExpression.cs => GetSetPropertyPair.cs} | 4 +- ...etVariableExpression.cs => GetVariable.cs} | 10 +- NiL.JS/Expressions/{InOperator.cs => In.cs} | 4 +- .../{IncrementOperator.cs => Increment.cs} | 4 +- .../{InstanceOfOperator.cs => InstanceOf.cs} | 6 +- .../Expressions/{LessOperator.cs => Less.cs} | 8 +- ...{LessOrEqualOperator.cs => LessOrEqual.cs} | 6 +- ...ctionOperator.cs => LogicalConjunction.cs} | 4 +- ...ctionOperator.cs => LogicalDisjunction.cs} | 4 +- ...NegationOperator.cs => LogicalNegation.cs} | 4 +- .../{ModuloOperator.cs => Modulo.cs} | 4 +- .../Expressions/{MoreOperator.cs => More.cs} | 8 +- ...{MoreOrEqualOperator.cs => MoreOrEqual.cs} | 6 +- ...plicationOperator.cs => Multiplication.cs} | 18 +- .../{NegationOperator.cs => Negation.cs} | 4 +- NiL.JS/Expressions/{NewOperator.cs => New.cs} | 12 +- .../{GetNewTarget.cs => NewTarget.cs} | 4 +- .../{NotEqualOperator.cs => NotEqual.cs} | 4 +- ...rAdditionOperator.cs => NumberAddition.cs} | 10 +- .../{NumberLessOperator.cs => NumberLess.cs} | 10 +- ...rEqualOperator.cs => NumberLessOrEqual.cs} | 10 +- .../{NumberMoreOpeartor.cs => NumberMore.cs} | 10 +- ...rEqualOperator.cs => NumberMoreOrEqual.cs} | 10 +- NiL.JS/Expressions/ObjectDefinition.cs | 24 +- .../{GetPropertyOperator.cs => Property.cs} | 16 +- ...ExpCreateExpression.cs => RegExpCreate.cs} | 7 +- ...etPropertyExpression.cs => SetProperty.cs} | 10 +- ...hiftLeftOperator.cs => SignedShiftLeft.cs} | 8 +- ...ftRightOperator.cs => SignedShiftRight.cs} | 8 +- .../{SpreadOperator.cs => Spread.cs} | 4 +- ...{StrictEqualOperator.cs => StrictEqual.cs} | 4 +- ...tNotEqualOperator.cs => StrictNotEqual.cs} | 4 +- ...onExpression.cs => StringConcatenation.cs} | 6 +- .../{SubstractOperator.cs => Substract.cs} | 8 +- NiL.JS/Expressions/{GetSuper.cs => Super.cs} | 4 +- NiL.JS/Expressions/{GetThis.cs => This.cs} | 6 +- .../{TypeOfOperator.cs => TypeOf.cs} | 8 +- ...RightOperator.cs => UnsignedShiftRight.cs} | 8 +- .../{YieldOperator.cs => Yield.cs} | 8 +- .../Extensions/IterationProtocolExtensions.cs | 2 +- NiL.JS/Extensions/JSValueExtensions.cs | 14 +- NiL.JS/NiL.JS.csproj | 152 +++---- .../{BreakStatement.cs => Break.cs} | 4 +- NiL.JS/Statements/CodeBlock.cs | 21 +- .../{ContinueStatement.cs => Continue.cs} | 4 +- .../{DebuggerStatement.cs => Debugger.cs} | 4 +- .../{DoWhileStatement.cs => DoWhile.cs} | 12 +- NiL.JS/Statements/{ForStatement.cs => For.cs} | 60 +-- .../{ForInStatement.cs => ForIn.cs} | 41 +- .../{ForOfStatement.cs => ForOf.cs} | 52 ++- .../{IfElseStatement.cs => IfElse.cs} | 12 +- ...finityLoopStatement.cs => InfinityLoop.cs} | 6 +- .../{ReturnStatement.cs => Return.cs} | 60 +-- .../{StoreValueStatement.cs => StoreValue.cs} | 4 +- .../{SwitchStatement.cs => Switch.cs} | 11 +- .../{ThrowStatement.cs => Throw.cs} | 12 +- .../{TryCatchStatement.cs => TryCatch.cs} | 10 +- ...tionStatement.cs => VariableDefinition.cs} | 34 +- .../{WhileStatement.cs => While.cs} | 18 +- .../Statements/{WithStatement.cs => With.cs} | 13 +- NiL.JS/Strings.Designer.cs | 16 +- NiL.JS/Strings.resx | 3 + NiL.JS/Strings1.Designer.cs | 109 ----- Portable.Test.Phone.Windows/MainPage.xaml.cs | 5 +- Portable.Test.Phone/MainPage.xaml.cs | 5 +- README.md | 4 +- Tests/ftest.js | Bin 202 -> 2 bytes Tests/tests/custom/regression.js | 13 +- Tests/uglifyjs.js | 3 +- portable.test/portable.test.csproj | 22 +- 118 files changed, 1340 insertions(+), 1262 deletions(-) rename NiL.JS/Expressions/{AdditionOperator.cs => Addition.cs} (95%) rename NiL.JS/Expressions/{AssignmentOperator.cs => Assignment.cs} (94%) rename NiL.JS/Expressions/{BitwiseConjunctionOperator.cs => BitwiseConjunction.cs} (87%) rename NiL.JS/Expressions/{BitwiseDisjunctionOperator.cs => BitwiseDisjunction.cs} (87%) rename NiL.JS/Expressions/{BitwiseExclusiveDisjunctionOperator.cs => BitwiseExclusiveDisjunction.cs} (86%) rename NiL.JS/Expressions/{BitwiseNegationOperator.cs => BitwiseNegation.cs} (88%) rename NiL.JS/Expressions/{CallOperator.cs => Call.cs} (97%) rename NiL.JS/Expressions/{CommaOperator.cs => Comma.cs} (95%) rename NiL.JS/Expressions/{ConditionalOperator.cs => Conditional.cs} (87%) rename NiL.JS/Expressions/{ConstantDefinition.cs => Constant.cs} (97%) rename NiL.JS/Expressions/{ToBooleanOperator.cs => ConvertToBoolean.cs} (88%) rename NiL.JS/Expressions/{ToIntegerOperator.cs => ConvertToInteger.cs} (94%) rename NiL.JS/Expressions/{ToNumberOperator.cs => ConvertToNumber.cs} (88%) rename NiL.JS/Expressions/{ToStringExpression.cs => ConvertToString.cs} (90%) rename NiL.JS/Expressions/{ToUnsignedIntegerExpression.cs => ConvertToUnsignedInteger.cs} (90%) rename NiL.JS/Expressions/{DecrementOperator.cs => Decrement.cs} (98%) rename NiL.JS/Expressions/{DeleteOperator.cs => Delete.cs} (90%) rename NiL.JS/Expressions/{DeletePropertyOperator.cs => DeleteProperty.cs} (88%) rename NiL.JS/Expressions/{DivisionOperator.cs => Division.cs} (94%) rename NiL.JS/Expressions/{EmptyExpression.cs => Empty.cs} (83%) rename NiL.JS/Expressions/{EqualOperator.cs => Equal.cs} (98%) rename NiL.JS/Expressions/{GsPropertyPairExpression.cs => GetSetPropertyPair.cs} (90%) rename NiL.JS/Expressions/{GetVariableExpression.cs => GetVariable.cs} (96%) rename NiL.JS/Expressions/{InOperator.cs => In.cs} (94%) rename NiL.JS/Expressions/{IncrementOperator.cs => Increment.cs} (98%) rename NiL.JS/Expressions/{InstanceOfOperator.cs => InstanceOf.cs} (92%) rename NiL.JS/Expressions/{LessOperator.cs => Less.cs} (98%) rename NiL.JS/Expressions/{LessOrEqualOperator.cs => LessOrEqual.cs} (84%) rename NiL.JS/Expressions/{LogicalConjunctionOperator.cs => LogicalConjunction.cs} (91%) rename NiL.JS/Expressions/{LogicalDisjunctionOperator.cs => LogicalDisjunction.cs} (91%) rename NiL.JS/Expressions/{LogicalNegationOperator.cs => LogicalNegation.cs} (87%) rename NiL.JS/Expressions/{ModuloOperator.cs => Modulo.cs} (93%) rename NiL.JS/Expressions/{MoreOperator.cs => More.cs} (98%) rename NiL.JS/Expressions/{MoreOrEqualOperator.cs => MoreOrEqual.cs} (84%) rename NiL.JS/Expressions/{MultiplicationOperator.cs => Multiplication.cs} (87%) rename NiL.JS/Expressions/{NegationOperator.cs => Negation.cs} (94%) rename NiL.JS/Expressions/{NewOperator.cs => New.cs} (83%) rename NiL.JS/Expressions/{GetNewTarget.cs => NewTarget.cs} (95%) rename NiL.JS/Expressions/{NotEqualOperator.cs => NotEqual.cs} (85%) rename NiL.JS/Expressions/{NumberAdditionOperator.cs => NumberAddition.cs} (92%) rename NiL.JS/Expressions/{NumberLessOperator.cs => NumberLess.cs} (89%) rename NiL.JS/Expressions/{NumberLessOrEqualOperator.cs => NumberLessOrEqual.cs} (88%) rename NiL.JS/Expressions/{NumberMoreOpeartor.cs => NumberMore.cs} (89%) rename NiL.JS/Expressions/{NumberMoreOrEqualOperator.cs => NumberMoreOrEqual.cs} (88%) rename NiL.JS/Expressions/{GetPropertyOperator.cs => Property.cs} (87%) rename NiL.JS/Expressions/{RegExpCreateExpression.cs => RegExpCreate.cs} (94%) rename NiL.JS/Expressions/{SetPropertyExpression.cs => SetProperty.cs} (92%) rename NiL.JS/Expressions/{SignedShiftLeftOperator.cs => SignedShiftLeft.cs} (87%) rename NiL.JS/Expressions/{SignedShiftRightOperator.cs => SignedShiftRight.cs} (87%) rename NiL.JS/Expressions/{SpreadOperator.cs => Spread.cs} (94%) rename NiL.JS/Expressions/{StrictEqualOperator.cs => StrictEqual.cs} (96%) rename NiL.JS/Expressions/{StrictNotEqualOperator.cs => StrictNotEqual.cs} (79%) rename NiL.JS/Expressions/{StringConcatenationExpression.cs => StringConcatenation.cs} (95%) rename NiL.JS/Expressions/{SubstractOperator.cs => Substract.cs} (91%) rename NiL.JS/Expressions/{GetSuper.cs => Super.cs} (96%) rename NiL.JS/Expressions/{GetThis.cs => This.cs} (91%) rename NiL.JS/Expressions/{TypeOfOperator.cs => TypeOf.cs} (93%) rename NiL.JS/Expressions/{UnsignedShiftRightOperator.cs => UnsignedShiftRight.cs} (88%) rename NiL.JS/Expressions/{YieldOperator.cs => Yield.cs} (94%) rename NiL.JS/Statements/{BreakStatement.cs => Break.cs} (96%) rename NiL.JS/Statements/{ContinueStatement.cs => Continue.cs} (95%) rename NiL.JS/Statements/{DebuggerStatement.cs => Debugger.cs} (95%) rename NiL.JS/Statements/{DoWhileStatement.cs => DoWhile.cs} (95%) rename NiL.JS/Statements/{ForStatement.cs => For.cs} (89%) rename NiL.JS/Statements/{ForInStatement.cs => ForIn.cs} (90%) rename NiL.JS/Statements/{ForOfStatement.cs => ForOf.cs} (87%) rename NiL.JS/Statements/{IfElseStatement.cs => IfElse.cs} (96%) rename NiL.JS/Statements/{InfinityLoopStatement.cs => InfinityLoop.cs} (94%) rename NiL.JS/Statements/{ReturnStatement.cs => Return.cs} (61%) rename NiL.JS/Statements/{StoreValueStatement.cs => StoreValue.cs} (94%) rename NiL.JS/Statements/{SwitchStatement.cs => Switch.cs} (97%) rename NiL.JS/Statements/{ThrowStatement.cs => Throw.cs} (91%) rename NiL.JS/Statements/{TryCatchStatement.cs => TryCatch.cs} (98%) rename NiL.JS/Statements/{VariableDefinitionStatement.cs => VariableDefinition.cs} (90%) rename NiL.JS/Statements/{WhileStatement.cs => While.cs} (92%) rename NiL.JS/Statements/{WithStatement.cs => With.cs} (92%) delete mode 100644 NiL.JS/Strings1.Designer.cs diff --git a/NiL.JS.Portable.sln b/NiL.JS.Portable.sln index 5ae6e226b..29321eaaa 100644 --- a/NiL.JS.Portable.sln +++ b/NiL.JS.Portable.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NiL.JS.Portable", "NiL.JS.Portable\NiL.JS.Portable.csproj", "{DEB5F360-2822-4852-95A3-964E37C802AF}" EndProject @@ -45,12 +45,14 @@ Global {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|ARM.ActiveCfg = Debug|Any CPU {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x64.ActiveCfg = Debug|Any CPU - {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x86.ActiveCfg = Debug|Any CPU + {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x86.ActiveCfg = Debug|x86 + {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x86.Build.0 = Debug|x86 {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|Any CPU.Build.0 = Release|Any CPU {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|ARM.ActiveCfg = Release|Any CPU {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x64.ActiveCfg = Release|Any CPU - {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x86.ActiveCfg = Release|Any CPU + {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x86.ActiveCfg = Release|x86 + {BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x86.Build.0 = Release|x86 {2D0B76DE-95A0-4263-A35D-5856F04F17BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D0B76DE-95A0-4263-A35D-5856F04F17BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D0B76DE-95A0-4263-A35D-5856F04F17BA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU diff --git a/NiL.JS.Portable/Core/Backward.cs b/NiL.JS.Portable/Core/Backward.cs index 9bdfb00bb..4eed31b01 100644 --- a/NiL.JS.Portable/Core/Backward.cs +++ b/NiL.JS.Portable/Core/Backward.cs @@ -6,9 +6,33 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace System { + [ComVisible(true)] + public enum TypeCode + { + Empty = 0, // Null reference + Object = 1, // Instance that isn't a value + DBNull = 2, // Database null value + Boolean = 3, // Boolean + Char = 4, // Unicode character + SByte = 5, // Signed 8-bit integer + Byte = 6, // Unsigned 8-bit integer + Int16 = 7, // Signed 16-bit integer + UInt16 = 8, // Unsigned 16-bit integer + Int32 = 9, // Signed 32-bit integer + UInt32 = 10, // Unsigned 32-bit integer + Int64 = 11, // Signed 64-bit integer + UInt64 = 12, // Unsigned 64-bit integer + Single = 13, // IEEE 32-bit float + Double = 14, // IEEE 64-bit double + Decimal = 15, // Decimal + DateTime = 16, // DateTime + String = 18, // Unicode character string + } + namespace Reflection { public enum MemberTypes @@ -96,5 +120,53 @@ public static MethodInfo GetAddMethod(this EventInfo self) { return self.AddMethod; } + + private static readonly Type[] _Types = + { + null, + typeof(object), + Type.GetType("System.DBNull"), + typeof(bool), + typeof(char), + typeof(sbyte), + typeof(byte), + typeof(short), + typeof(ushort), + typeof(int), + typeof(uint), + typeof(long), + typeof(ulong), + typeof(float), + typeof(double), + typeof(decimal), + typeof(DateTime), + null, + typeof(string) + }; + + public static TypeCode GetTypeCode(this Type type) + { + if (type == null) + return TypeCode.Empty; + + if (type.GetTypeInfo().IsClass) + { + if (type == _Types[2]) + return TypeCode.DBNull; + + if (type == typeof(string)) + return TypeCode.String; + + return TypeCode.Object; + } + + for (var i = 3; i < _Types.Length; i++) + { + if (_Types[i] == type) + return (TypeCode)i; + } + + return TypeCode.Object; + } } } diff --git a/NiL.JS.Portable/NiL.JS.Portable.csproj b/NiL.JS.Portable/NiL.JS.Portable.csproj index 6ef1257f7..dad0e46a3 100644 --- a/NiL.JS.Portable/NiL.JS.Portable.csproj +++ b/NiL.JS.Portable/NiL.JS.Portable.csproj @@ -8,7 +8,7 @@ {DEB5F360-2822-4852-95A3-964E37C802AF} Library Properties - NiL.JS.Portable + NiL.JS NiL.JS.Portable ru-RU 512 @@ -37,8 +37,7 @@ true - - + NiL.JS.Keys.pfx @@ -71,6 +70,9 @@ BaseLibrary\Function.cs + + BaseLibrary\GeneratorFunction.cs + BaseLibrary\Int16Array.cs @@ -146,6 +148,9 @@ Core\Context.cs + + Core\CustomCodeFragment.cs + Core\Delegates.cs @@ -176,6 +181,15 @@ Core\GlobalObject.cs + + Core\IIterable.cs + + + Core\IIterator.cs + + + Core\IIteratorResult.cs + Core\Interop\AllowNullArgumentsAttribute.cs @@ -242,18 +256,15 @@ Core\JSValue.cs - - Core\ObjectContainer.cs + + Core\ObjectWrapper.cs + + + Core\ParseInfo.cs Core\Parser.cs - - Core\ParseResult.cs - - - Core\ParsingState.cs - Core\PropertyPair.cs @@ -263,8 +274,8 @@ Core\SparseArray.cs - - Core\StringMap2.cs + + Core\StringMap.cs Core\Tools.cs @@ -284,65 +295,83 @@ ExceptionsHelper.cs - - Expressions\AdditionOperator.cs + + Expressions\Addition.cs + + + Expressions\ArrayDefinition.cs + + + Expressions\Assignment.cs + + + Expressions\AssignmentOperatorCache.cs + + + Expressions\AssignmentOverReplace.cs + + + Expressions\BitwiseConjunction.cs - - Expressions\ArrayNotation.cs + + Expressions\BitwiseDisjunction.cs - - Expressions\AssignmentOperator.cs + + Expressions\BitwiseExclusiveDisjunction.cs - - Expressions\AssignOverReplace.cs + + Expressions\BitwiseNegation.cs - - Expressions\BitwiseConjunctionOperator.cs + + Expressions\Call.cs - - Expressions\BitwiseDisjunctionOperator.cs + + Expressions\ClassDefinition.cs - - Expressions\BitwiseExclusiveDisjunctionOperator.cs + + Expressions\Comma.cs - - Expressions\BitwiseNegationOperator.cs + + Expressions\Conditional.cs - - Expressions\CallOperator.cs + + Expressions\Constant.cs - - Expressions\ClassNotation.cs + + Expressions\ConvertToBoolean.cs - - Expressions\CommaOperator.cs + + Expressions\ConvertToInteger.cs - - Expressions\ConditionalOperator.cs + + Expressions\ConvertToNumber.cs - - Expressions\ConstantNotation.cs + + Expressions\ConvertToString.cs - - Expressions\DecrementOperator.cs + + Expressions\ConvertToUnsignedInteger.cs - - Expressions\DeleteMemberExpression.cs + + Expressions\Decrement.cs - - Expressions\DeleteOperator.cs + + Expressions\Delete.cs - - Expressions\DivisionOperator.cs + + Expressions\DeleteProperty.cs - - Expressions\EmptyExpression.cs + + Expressions\Division.cs - - Expressions\EntityNotation.cs + + Expressions\Empty.cs - - Expressions\EqualOperator.cs + + Expressions\EntityDefinition.cs + + + Expressions\Equal.cs Expressions\Expression.cs @@ -353,208 +382,220 @@ Expressions\ExpressionWrapper.cs - - Expressions\FunctionNotation.cs + + Expressions\ExtractStoredValue.cs + + + Expressions\FunctionDefinition.cs + + + Expressions\GetSetPropertyPair.cs + + + Expressions\GetVariable.cs + + + Expressions\In.cs + + + Expressions\Increment.cs - - Expressions\GetMemberOperator.cs + + Expressions\InstanceOf.cs - - Expressions\GetValueForAssignmentOperator.cs + + Expressions\Less.cs - - Expressions\GetVariableExpression.cs + + Expressions\LessOrEqual.cs - - Expressions\IncrementOperator.cs + + Expressions\LogicalConjunction.cs - - Expressions\InOperator.cs + + Expressions\LogicalDisjunction.cs - - Expressions\InstanceOfOperator.cs + + Expressions\LogicalNegation.cs - - Expressions\LessOperator.cs + + Expressions\Modulo.cs - - Expressions\LessOrEqualOperator.cs + + Expressions\More.cs - - Expressions\LogicalConjunctionOperator.cs + + Expressions\MoreOrEqual.cs - - Expressions\LogicalDisjunctionOperator.cs + + Expressions\Multiplication.cs - - Expressions\LogicalNegationOperator.cs + + Expressions\Negation.cs - - Expressions\ModuloOperator.cs + + Expressions\New.cs - - Expressions\MoreOperator.cs + + Expressions\NewTarget.cs - - Expressions\MoreOrEqualOperator.cs + + Expressions\NotEqual.cs - - Expressions\MultiplicationOperator.cs + + Expressions\NumberAddition.cs - - Expressions\NegationOperator.cs + + Expressions\NumberLess.cs - - Expressions\NewOperator.cs + + Expressions\NumberLessOrEqual.cs - - Expressions\NotEqualOperator.cs + + Expressions\NumberMore.cs - - Expressions\NumberAdditionOperator.cs + + Expressions\NumberMoreOrEqual.cs - - Expressions\NumberLessOperator.cs + + Expressions\ObjectDefinition.cs - - Expressions\NumberLessOrEqualOperator.cs + + Expressions\Property.cs - - Expressions\NumberMoreOpeartor.cs + + Expressions\RegExpCreate.cs - - Expressions\NumberMoreOrEqualOperator.cs + + Expressions\SetProperty.cs - - Expressions\ObjectNotation.cs + + Expressions\SignedShiftLeft.cs - - Expressions\RegExpCreateExpression.cs + + Expressions\SignedShiftRight.cs - - Expressions\SetMemberExpression.cs + + Expressions\Spread.cs - - Expressions\SignedShiftLeftOperator.cs + + Expressions\StrictEqual.cs - - Expressions\SignedShiftRightOperator.cs + + Expressions\StrictNotEqual.cs - - Expressions\StrictEqualOperator.cs + + Expressions\StringConcatenation.cs - - Expressions\StrictNotEqualOperator.cs + + Expressions\Substract.cs - - Expressions\StringConcatenationExpression.cs + + Expressions\Super.cs - - Expressions\SubstractOperator.cs + + Expressions\SuspendableExpression.cs - - Expressions\ToBooleanOperator.cs + + Expressions\This.cs - - Expressions\ToIntegerOperator.cs + + Expressions\TypeOf.cs - - Expressions\ToNumberOperator.cs + + Expressions\UnsignedShiftRight.cs - - Expressions\ToStringExpression.cs + + Expressions\Yield.cs - - Expressions\ToUnsignedIntegerExpression.cs + + Extensions\IterationProtocolExtensions.cs - - Expressions\TypeOfOperator.cs + + Extensions\JSValueExtensions.cs - - Expressions\UnsignedShiftRightOperator.cs + + Extensions\ObjectExtensions.cs + + + Module.cs Properties\AssemblyInfo.cs - - Script.cs - - - Statements\BreakStatement.cs + + Statements\Break.cs Statements\CodeBlock.cs - - Statements\ContinueStatement.cs + + Statements\Continue.cs - - Statements\DebuggerStatement.cs + + Statements\Debugger.cs - - Statements\DoWhileStatement.cs + + Statements\DoWhile.cs - - Statements\ForInStatement.cs + + Statements\For.cs - - Statements\ForOfStatement.cs + + Statements\ForIn.cs - - Statements\ForStatement.cs + + Statements\ForOf.cs - - Statements\IfElseStatement.cs + + Statements\IfElse.cs - - Statements\InfinityLoopStatement.cs + + Statements\InfinityLoop.cs Statements\LabeledStatement.cs - - Statements\MultilineComment.cs - - - Statements\ReturnStatement.cs + + Statements\Return.cs - - Statements\SinglelineComment.cs + + Statements\StoreValue.cs - - Statements\SwitchStatement.cs + + Statements\Switch.cs - - Statements\ThrowStatement.cs + + Statements\Throw.cs - - Statements\TryCatchStatement.cs + + Statements\TryCatch.cs - - Statements\VariableDefineStatement.cs + + Statements\VariableDefinition.cs - - Statements\WhileStatement.cs + + Statements\While.cs - - Statements\WithStatement.cs + + Statements\With.cs Strings.Designer.cs - - - Strings1.Designer.cs True True Strings.resx + + + Strings.resx ResXFileCodeGenerator - Strings1.Designer.cs + Strings.Designer.cs diff --git a/NiL.JS.Test/Program.cs b/NiL.JS.Test/Program.cs index 7dcda7049..ab5f7faf1 100644 --- a/NiL.JS.Test/Program.cs +++ b/NiL.JS.Test/Program.cs @@ -41,7 +41,7 @@ static void Main(string[] args) })); #if PORTABLE - Context.GlobalContext.DefineVariable("console").Assign(TypeProxy.Proxy(new + Context.GlobalContext.DefineVariable("console").Assign(new { log = new Action(arguments => { @@ -54,10 +54,10 @@ static void Main(string[] args) } System.Console.WriteLine(); }) - })); + }.WrapToJSValue()); #endif - int mode = 101 + int mode = 103 ; switch (mode) { @@ -169,9 +169,10 @@ static void Main(string[] args) var context = new Context(); context.Eval(new StreamReader(file).ReadToEnd()); - context.DefineVariable("code").Assign(new NiL.JS.BaseLibrary.String(myString)); + context.DefineVariable("code").Assign(new BaseLibrary.String(myString)); - var result = context.Eval(@"var ast = UglifyJS.parse(code); + var result = context.Eval( +@"var ast = UglifyJS.parse(code); ast.figure_out_scope(); compressor = UglifyJS.Compressor(); ast = ast.transform(compressor); diff --git a/NiL.JS.Test/Translator.cs b/NiL.JS.Test/Translator.cs index aaadcab1a..4623974ac 100644 --- a/NiL.JS.Test/Translator.cs +++ b/NiL.JS.Test/Translator.cs @@ -50,7 +50,7 @@ protected override Visitor Visit(JS.Statements.CodeBlock node) return this; } - protected override Visitor Visit(JS.Statements.VariableDefinitionStatement node) + protected override Visitor Visit(JS.Statements.VariableDefinition node) { for (var i = 0; i < node.Initializers.Length; i++) node.Initializers[i].Visit(this); @@ -77,13 +77,13 @@ protected override Visitor Visit(JS.Expressions.FunctionDefinition node) return this; } - protected override Visitor Visit(JS.Statements.ReturnStatement node) + protected override Visitor Visit(JS.Statements.Return node) { result.Append("return"); - if (node.Body != null) + if (node.Value != null) { result.Append(" "); - node.Body.Visit(this); + node.Value.Visit(this); } return this; } diff --git a/NiL.JS/BaseLibrary/Array.cs b/NiL.JS/BaseLibrary/Array.cs index 7ab0a042a..3cd748191 100644 --- a/NiL.JS/BaseLibrary/Array.cs +++ b/NiL.JS/BaseLibrary/Array.cs @@ -586,7 +586,7 @@ public static JSValue indexOf(JSValue self, Arguments args) continue; if (value.valueType == JSValueType.Property) value = (value.oValue as GsPropertyPair).get == null ? undefined : (value.oValue as GsPropertyPair).get.Call(self, null); - if (Expressions.StrictEqualOperator.Check(value, image)) + if (Expressions.StrictEqual.Check(value, image)) return key; } while (alter); @@ -730,7 +730,7 @@ public static JSValue lastIndexOf(JSValue self, Arguments args) continue; if (value.valueType == JSValueType.Property) value = (value.oValue as GsPropertyPair).get == null ? undefined : (value.oValue as GsPropertyPair).get.Call(self, null); - if (Expressions.StrictEqualOperator.Check(value, image)) + if (Expressions.StrictEqual.Check(value, image)) return key; } while (alter); @@ -822,7 +822,7 @@ public static JSValue reverse(JSValue self) var selfa = self as Array; if (selfa != null) { - for (var i = selfa.data.Length >> 1; i-- > 0; ) + for (var i = selfa.data.Length >> 1; i-- > 0;) { var item0 = selfa.data[(int)(selfa.data.Length - 1 - i)]; var item1 = selfa.data[(int)(i)]; @@ -979,7 +979,7 @@ private static JSValue reduceImpl(bool right, JSValue self, Arguments args) bool called = false; var length = src.data.Length; long prewIndex = right ? length - 1 : 0; - for (var e = (right ? src.data.ReversOrder : src.data.DirectOrder).GetEnumerator(); ; ) + for (var e = (right ? src.data.ReversOrder : src.data.DirectOrder).GetEnumerator(); ;) { KeyValuePair element; if (e.MoveNext()) @@ -1072,7 +1072,7 @@ public static JSValue shift(JSValue self) JSValue prw = res; var length = src.data.Length; long prewIndex = 0; - for (var e = src.data.DirectOrder.GetEnumerator(); ; ) + for (var e = src.data.DirectOrder.GetEnumerator(); ;) { KeyValuePair element; if (e.MoveNext()) @@ -1235,7 +1235,7 @@ public static JSValue slice(JSValue self, Arguments args) ExceptionsHelper.Throw(new TypeError("Can not call Array.prototype.slice for null or undefined")); HashSet processedKeys = new HashSet(); Array res = new Array(); - for (; ; ) + for (;;) { var selfa = self as Array; if (selfa != null) @@ -1499,7 +1499,7 @@ private static JSValue spliceImpl(JSValue self, Arguments args, bool needResult) var tjo = new JSValue(); if (delta > 0) { - for (var i = _length; i-- > pos1; ) + for (var i = _length; i-- > pos1;) { if (i <= int.MaxValue) { @@ -1727,7 +1727,7 @@ public static JSValue sort(JSValue self, Arguments args) } } var tjo = new JSValue() { valueType = JSValueType.String }; - for (var i = keysToRemove.Count; i-- > 0; ) + for (var i = keysToRemove.Count; i-- > 0;) { tjo.oValue = keysToRemove[i]; var t = self.GetProperty(tjo, true, PropertyScope.Сommon); @@ -1740,7 +1740,7 @@ public static JSValue sort(JSValue self, Arguments args) var index = 0u; foreach (var node in tt.Nodes) { - for (var i = node.value.Count; i-- > 0; ) + for (var i = node.value.Count; i-- > 0;) self[(index++).ToString()] = node.value[i]; } } @@ -1768,12 +1768,12 @@ public static JSValue sort(JSValue self, Arguments args) } } } - for (var i = keysToRemove.Count; i-- > 0; ) + for (var i = keysToRemove.Count; i-- > 0;) self[keysToRemove[i]].valueType = JSValueType.NotExists; var index = 0u; foreach (var node in tt.Nodes) { - for (var i = node.value.Count; i-- > 0; ) + for (var i = node.value.Count; i-- > 0;) self[(index++).ToString()] = node.value[i]; } } @@ -1786,7 +1786,7 @@ public static JSValue sort(JSValue self, Arguments args) [ArgumentsLength(1)] public static JSValue unshift(JSValue self, Arguments args) { - for (var i = args.length; i-- > 0; ) + for (var i = args.length; i-- > 0;) args[i + 2] = args[i]; args.length += 2; args.a0 = 0; diff --git a/NiL.JS/BaseLibrary/Function.cs b/NiL.JS/BaseLibrary/Function.cs index 9eb13d55b..f2ac9384e 100644 --- a/NiL.JS/BaseLibrary/Function.cs +++ b/NiL.JS/BaseLibrary/Function.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Text; using NiL.JS.Core; using NiL.JS.Core.Functions; using NiL.JS.Core.Interop; -using NiL.JS.Core.JIT; using NiL.JS.Expressions; using NiL.JS.Statements; using linqEx = System.Linq.Expressions; @@ -289,7 +289,7 @@ internal Function(Context context, FunctionDefinition creator) [Hidden] public JSValue Construct(Arguments arguments) { - if (RequireNewKeywordLevel == BaseLibrary.RequireNewKeywordLevel.WithoutNewOnly) + if (RequireNewKeywordLevel == RequireNewKeywordLevel.WithoutNewOnly) { ExceptionsHelper.ThrowTypeError(string.Format(Strings.InvalidTryToCreateWithNew, name)); } @@ -304,7 +304,7 @@ public JSValue Construct(Arguments arguments) [Hidden] internal JSValue Construct(JSValue targetObject, Arguments arguments, Function newTarget) { - if (RequireNewKeywordLevel == BaseLibrary.RequireNewKeywordLevel.WithoutNewOnly) + if (RequireNewKeywordLevel == RequireNewKeywordLevel.WithoutNewOnly) { ExceptionsHelper.ThrowTypeError(string.Format(Strings.InvalidTryToCreateWithNew, name)); } @@ -337,13 +337,13 @@ internal virtual JSValue InternalInvoke(JSValue targetObject, Expression[] argum { if (body.lines.Length == 1) { - var ret = body.lines[0] as ReturnStatement; + var ret = body.lines[0] as Return; if (ret != null) { - if (ret.Body != null) + if (ret.Value != null) { - if (ret.Body.ContextIndependent) - result = ret.Body.Evaluate(null); + if (ret.Value.ContextIndependent) + result = ret.Value.Evaluate(null); else break; } @@ -513,7 +513,7 @@ public JSValue Call(Arguments args) [Hidden] public JSValue Call(JSValue targetObject, Arguments arguments) { - if (RequireNewKeywordLevel == BaseLibrary.RequireNewKeywordLevel.WithNewOnly) + if (RequireNewKeywordLevel == RequireNewKeywordLevel.WithNewOnly) { ExceptionsHelper.ThrowTypeError(string.Format(Strings.InvalidTryToCreateWithoutNew, name)); } @@ -524,7 +524,6 @@ public JSValue Call(JSValue targetObject, Arguments arguments) protected internal virtual JSValue Invoke(bool construct, JSValue targetObject, Arguments arguments, Function newTarget) { - #if DEBUG && !PORTABLE if (creator.trace) System.Console.WriteLine("DEBUG: Run \"" + creator.Reference.Name + "\""); @@ -536,6 +535,7 @@ protected internal virtual JSValue Invoke(bool construct, JSValue targetObject, notExists.valueType = JSValueType.NotExists; return notExists; } + var ceocw = creator._functionInfo.ContainsEval || creator._functionInfo.ContainsWith || creator._functionInfo.ContainsYield; if (creator.recursionDepth > creator.parametersStored) // рекурсивный вызов. { @@ -543,10 +543,10 @@ protected internal virtual JSValue Invoke(bool construct, JSValue targetObject, storeParameters(); creator.parametersStored = creator.recursionDepth; } + if (arguments == null) - { arguments = new Arguments(Context.CurrentContext); - } + for (;;) // tail recursion catcher { var internalContext = new Context(parentContext, ceocw, this); @@ -1046,7 +1046,13 @@ public virtual Delegate MakeDelegate(Type delegateType) return cachedDelegate; } - var @delegate = Tools.BuildJsCallTree("" + name, linqEx.Expression.Constant(this), null, delegateType.GetMethod("Invoke"), delegateType).Compile(); + MethodInfo invokeMethod = null; +#if PORTABLE + invokeMethod = System.Linq.Enumerable.First(delegateType.GetRuntimeMethods(), x => x.Name == "Invoke"); +#else + invokeMethod = delegateType.GetMethod("Invoke"); +#endif + var @delegate = Tools.BuildJsCallTree("" + name, linqEx.Expression.Constant(this), null, invokeMethod, delegateType).Compile(); if (delegateCache == null) delegateCache = new Dictionary(); diff --git a/NiL.JS/BaseLibrary/GeneratorFunction.cs b/NiL.JS/BaseLibrary/GeneratorFunction.cs index 08e0db76d..eeacccb01 100644 --- a/NiL.JS/BaseLibrary/GeneratorFunction.cs +++ b/NiL.JS/BaseLibrary/GeneratorFunction.cs @@ -1,5 +1,6 @@ using NiL.JS.Core; using NiL.JS.Core.Interop; +using NiL.JS.Expressions; namespace NiL.JS.BaseLibrary { @@ -17,13 +18,11 @@ public override JSValue prototype } } - private Function generator; - [Hidden] - public GeneratorFunction(Function generator) + public GeneratorFunction(Context context, FunctionDefinition generator) + : base(context, generator) { - this.generator = generator; - RequireNewKeywordLevel = BaseLibrary.RequireNewKeywordLevel.WithoutNewOnly; + RequireNewKeywordLevel = RequireNewKeywordLevel.WithoutNewOnly; } protected internal override JSValue Invoke(bool construct, JSValue targetObject, Arguments arguments, Function newTarget) @@ -31,12 +30,7 @@ protected internal override JSValue Invoke(bool construct, JSValue targetObject, if (construct) ExceptionsHelper.ThrowTypeError("Generators cannot be invoked as a constructor"); - return TypeProxy.Marshal(new GeneratorIterator(generator, targetObject, arguments)); - } - - internal void Resume() - { - + return TypeProxy.Marshal(new GeneratorIterator(this, targetObject, arguments)); } internal override JSObject GetDefaultPrototype() @@ -56,7 +50,7 @@ internal sealed class GeneratorIterator : IIterator, IIterable private JSValue targetObject; [Hidden] - public GeneratorIterator(Function generator, JSValue self, Arguments args) + public GeneratorIterator(GeneratorFunction generator, JSValue self, Arguments args) { this.initialContext = Context.CurrentContext; this.generator = generator; diff --git a/NiL.JS/Core/Context.cs b/NiL.JS/Core/Context.cs index 835340a66..5d01bbcb1 100644 --- a/NiL.JS/Core/Context.cs +++ b/NiL.JS/Core/Context.cs @@ -561,56 +561,73 @@ public JSValue Eval(string code, bool inplace) throw new InvalidOperationException("Cannot execute script in global context"); if (string.IsNullOrEmpty(code)) return JSValue.undefined; + + // чистить кэш тут не достаточно. + // Мы не знаем, где объявлена одноимённая переменная + // и в тех случаях, когда она пришла из функции выше + // или даже глобального контекста, её кэш может быть + // не сброшен вовремя и значение будет браться из контекста + // eval'а, а не того контекста, в котором её позовут. + /* + * function a(){ + * var c = 1; + * function b(){ + * eval("var c = 2"); + * // переменная объявлена в контексте b, значит и значение должно быть из + * // контекста b, но если по выходу из b кэш этой переменной сброшен не будет, + * // то в a её значение будет 2 + * } + * } + */ + + var mainContext = this; + while (mainContext.oldContext != null && mainContext.oldContext == mainContext.parent && mainContext.owner == mainContext.oldContext.owner) + { + mainContext = mainContext.oldContext; + } + + int index = 0; + string c = Tools.RemoveComments(code, 0); + var ps = new ParseInfo(c, code, null) + { + strict = strict, + AllowDirectives = true, + CodeContext = CodeContext.InEval + }; + + var body = CodeBlock.Parse(ps, ref index) as CodeBlock; + if (index < c.Length) + throw new System.ArgumentException("Invalid char"); + var variables = new Dictionary(); + var stats = new FunctionInfo(); + + CodeNode cb = body; + Parser.Build(ref cb, 0, variables, (strict ? CodeContext.Strict : CodeContext.None) | CodeContext.InEval, null, stats, Options.None); + + var tv = stats.WithLexicalEnvironment ? null : new Dictionary(); + body.RebuildScope(stats, tv, body._variables.Length == 0 || !stats.WithLexicalEnvironment ? 1 : 0); + if (tv != null) + body._variables = new List(tv.Values).ToArray(); + + body.Optimize(ref cb, null, null, Options.SuppressUselessExpressionsElimination | Options.SuppressConstantPropogation, null); + body = cb as CodeBlock ?? body; + + if (stats.ContainsYield) + body.Decompose(ref cb); + + body.suppressScopeIsolation = true; + #if DEV var debugging = this.debugging; this.debugging = false; #endif + var runned = this.Activate(); try { - // чистить кэш тут не достаточно. - // Мы не знаем, где объявлена одноимённая переменная - // и в тех случаях, когда она пришла из функции выше - // или даже глобального контекста, её кэш может быть - // не сброшен вовремя и значение будет браться из контекста - // eval'а, а не того контекста, в котором её позовут. - /* - * function a(){ - * var c = 1; - * function b(){ - * eval("var c = 2"); - * // переменная объявлена в контексте b, значит и значение должно быть из - * // контекста b, но если по выходу из b кэш этой переменной сброшен не будет, - * // то в a её значение будет 2 - * } - * } - */ - - var mainContext = this; - while (mainContext.oldContext != null && mainContext.oldContext == mainContext.parent && mainContext.owner == mainContext.oldContext.owner) - { - mainContext = mainContext.oldContext; - } - - int index = 0; - string c = Tools.RemoveComments(code, 0); - var ps = new ParseInfo(c, code, null) - { - strict = strict, - AllowDirectives = true - }; - var body = CodeBlock.Parse(ps, ref index) as CodeBlock; - if (index < c.Length) - throw new System.ArgumentException("Invalid char"); - var variables = new Dictionary(); - var stats = new FunctionInfo(); - var context = new Context(this, false, owner) + var context = inplace && !body.strict && !strict ? this : new Context(this, false, owner) { strict = strict || body.strict }; - CodeNode cb = body; - Parser.Build(ref cb, 0, variables, (strict ? CodeContext.Strict : CodeContext.None) | CodeContext.InEval, null, stats, Options.None); - - body.suppressScopeIsolation = true; if (!strict && !body.strict) { @@ -649,33 +666,24 @@ public JSValue Eval(string code, bool inplace) } } - var tv = stats.WithLexicalEnvironment ? null : new Dictionary(); - body.RebuildScope(stats, tv, body._variables.Length == 0 || !stats.WithLexicalEnvironment ? 1 : 0); - if (tv != null) - body._variables = new List(tv.Values).ToArray(); - - body.Optimize(ref cb, null, null, Options.SuppressUselessExpressionsElimination | Options.SuppressConstantPropogation, null); - body = cb as CodeBlock ?? body; - - if (stats.ContainsYield) - body.Decompose(ref cb); - if (body.lines.Length == 0) return JSValue.undefined; - var run = context.Activate(); + var runContextOfEval = context.Activate(); try { return body.Evaluate(context) ?? context.lastResult ?? JSValue.notExists; } finally { - if (run) + if (runContextOfEval) context.Deactivate(); } } finally { + if (runned) + this.Deactivate(); #if DEV this.debugging = debugging; #endif diff --git a/NiL.JS/Core/Functions/ExternalFunction.cs b/NiL.JS/Core/Functions/ExternalFunction.cs index 94f58e9f1..e8e93dbe9 100644 --- a/NiL.JS/Core/Functions/ExternalFunction.cs +++ b/NiL.JS/Core/Functions/ExternalFunction.cs @@ -1,4 +1,6 @@ using System; +using System.Linq; +using System.Reflection; using NiL.JS.BaseLibrary; using NiL.JS.Core.Interop; @@ -20,7 +22,7 @@ public override string name get { #if PORTABLE - return del.GetMethodInfo().Name; + return System.Reflection.RuntimeReflectionExtensions.GetMethodInfo(del).Name; #else return del.Method.Name; #endif diff --git a/NiL.JS/Core/Functions/ProxyConstructor.cs b/NiL.JS/Core/Functions/ProxyConstructor.cs index 97a1fe477..011585f70 100644 --- a/NiL.JS/Core/Functions/ProxyConstructor.cs +++ b/NiL.JS/Core/Functions/ProxyConstructor.cs @@ -84,6 +84,9 @@ public ProxyConstructor(TypeProxy typeProxy) #endif for (int i = 0; i < ctors.Length; i++) { + if (ctors[i].IsStatic) + continue; + if (!ctors[i].IsDefined(typeof(HiddenAttribute), false) || ctors[i].IsDefined(typeof(ForceUseAttribute), true)) { ctorsL.Add(new MethodProxy(ctors[i])); diff --git a/NiL.JS/Core/Interop/NativeList.cs b/NiL.JS/Core/Interop/NativeList.cs index 686c1e116..680d507e3 100644 --- a/NiL.JS/Core/Interop/NativeList.cs +++ b/NiL.JS/Core/Interop/NativeList.cs @@ -29,7 +29,11 @@ public Element(NativeList owner, int index) base.Assign(value as JSValue); else { +#if PORTABLE + switch (value.GetType().GetTypeCode()) +#else switch (Type.GetTypeCode(value.GetType())) +#endif { case TypeCode.Boolean: { diff --git a/NiL.JS/Core/Interop/TypeProxy.cs b/NiL.JS/Core/Interop/TypeProxy.cs index e95939738..0811103ca 100644 --- a/NiL.JS/Core/Interop/TypeProxy.cs +++ b/NiL.JS/Core/Interop/TypeProxy.cs @@ -82,7 +82,6 @@ internal JSObject prototypeInstance internal bool InstanceMode = false; private TypeProxy() - : base() { valueType = JSValueType.Object; oValue = this; @@ -164,7 +163,11 @@ public static JSValue Marshal(object value) if (res != null) return res; } +#if PORTABLE + switch (value.GetType().GetTypeCode()) +#else switch (Type.GetTypeCode(value.GetType())) +#endif { case TypeCode.Boolean: { @@ -177,18 +180,18 @@ public static JSValue Marshal(object value) case TypeCode.Byte: { return new JSValue - { - iValue = (byte)value, - valueType = JSValueType.Int - }; + { + iValue = (byte)value, + valueType = JSValueType.Int + }; } case TypeCode.Char: { return new JSValue - { - oValue = ((char)value).ToString(), - valueType = JSValueType.String - }; + { + oValue = ((char)value).ToString(), + valueType = JSValueType.String + }; } case TypeCode.DateTime: { @@ -198,74 +201,74 @@ public static JSValue Marshal(object value) case TypeCode.Decimal: { return new JSValue - { - dValue = (double)(decimal)value, - valueType = JSValueType.Double - }; + { + dValue = (double)(decimal)value, + valueType = JSValueType.Double + }; } case TypeCode.Double: { return new JSValue - { - dValue = (double)value, - valueType = JSValueType.Double - }; + { + dValue = (double)value, + valueType = JSValueType.Double + }; } case TypeCode.Int16: { return new JSValue - { - iValue = (short)value, - valueType = JSValueType.Int - }; + { + iValue = (short)value, + valueType = JSValueType.Int + }; } case TypeCode.Int32: { return new JSValue - { - iValue = (int)value, - valueType = JSValueType.Int - }; + { + iValue = (int)value, + valueType = JSValueType.Int + }; } case TypeCode.Int64: { return new JSValue - { - dValue = (long)value, - valueType = JSValueType.Double - }; + { + dValue = (long)value, + valueType = JSValueType.Double + }; } case TypeCode.SByte: { return new JSValue - { - iValue = (sbyte)value, - valueType = JSValueType.Int - }; + { + iValue = (sbyte)value, + valueType = JSValueType.Int + }; } case TypeCode.Single: { return new JSValue - { - dValue = (float)value, - valueType = JSValueType.Double - }; + { + dValue = (float)value, + valueType = JSValueType.Double + }; } case TypeCode.String: { return new JSValue - { - oValue = value, - valueType = JSValueType.String - }; + { + oValue = value, + valueType = JSValueType.String + }; } case TypeCode.UInt16: { return new JSValue - { - iValue = (ushort)value, - valueType = JSValueType.Int - }; + { + iValue = (ushort)value, + valueType = JSValueType.Int + }; } case TypeCode.UInt32: { @@ -273,18 +276,18 @@ public static JSValue Marshal(object value) if (v > int.MaxValue) { return new JSValue - { - dValue = v, - valueType = JSValueType.Double - }; + { + dValue = v, + valueType = JSValueType.Double + }; } else { return new JSValue - { - iValue = (int)v, - valueType = JSValueType.Int - }; + { + iValue = (int)v, + valueType = JSValueType.Int + }; } } case TypeCode.UInt64: @@ -293,18 +296,18 @@ public static JSValue Marshal(object value) if (v > int.MaxValue) { return new JSValue - { - dValue = v, - valueType = JSValueType.Double - }; + { + dValue = v, + valueType = JSValueType.Double + }; } else { return new JSValue - { - iValue = (int)v, - valueType = JSValueType.Int - }; + { + iValue = (int)v, + valueType = JSValueType.Int + }; } } default: @@ -312,22 +315,22 @@ public static JSValue Marshal(object value) if (value is Delegate) { return new JSValue - { + { #if PORTABLE oValue = new MethodProxy(((Delegate)value).GetMethodInfo(), ((Delegate)value).Target), #else - oValue = new MethodProxy(((Delegate)value).Method, ((Delegate)value).Target), + oValue = new MethodProxy(((Delegate)value).Method, ((Delegate)value).Target), #endif - valueType = JSValueType.Function - }; + valueType = JSValueType.Function + }; } else if (value is IList) { return new JSValue - { - oValue = new NativeList(value as IList), - valueType = JSValueType.Object - }; + { + oValue = new NativeList(value as IList), + valueType = JSValueType.Object + }; } else { @@ -673,7 +676,7 @@ private JSValue proxyMember(bool forWrite, IList m) if (forWrite && (r.attributes & (JSValueAttributesInternal.ReadOnly | JSValueAttributesInternal.SystemObject)) == JSValueAttributesInternal.SystemObject) r = r.CloneImpl(false); - for (var i = m.Count; i-- > 0; ) + for (var i = m.Count; i-- > 0;) { if (!m[i].IsDefined(typeof(DoNotEnumerateAttribute), false)) { @@ -709,7 +712,7 @@ protected internal override bool DeleteProperty(JSValue name) IList m = null; if (members.TryGetValue(tname.ToString(), out m)) { - for (var i = m.Count; i-- > 0; ) + for (var i = m.Count; i-- > 0;) { if (m[i].IsDefined(typeof(DoNotDeleteAttribute), false)) return false; @@ -732,7 +735,7 @@ public override JSValue propertyIsEnumerable(Arguments args) IList m = null; if (members.TryGetValue(name, out m)) { - for (var i = m.Count; i-- > 0; ) + for (var i = m.Count; i-- > 0;) if (!m[i].IsDefined(typeof(DoNotEnumerateAttribute), false)) return true; return false; @@ -762,7 +765,7 @@ protected internal override IEnumerator> GetEnumer { if (fields.ContainsKey(item.Key)) continue; - for (var i = item.Value.Count; i-- > 0; ) + for (var i = item.Value.Count; i-- > 0;) { if (!hideNonEnumerable || !item.Value[i].IsDefined(typeof(DoNotEnumerateAttribute), false)) { diff --git a/NiL.JS/Core/JIT/JITHelpers.cs b/NiL.JS/Core/JIT/JITHelpers.cs index f39e890ae..2ea253f55 100644 --- a/NiL.JS/Core/JIT/JITHelpers.cs +++ b/NiL.JS/Core/JIT/JITHelpers.cs @@ -7,7 +7,6 @@ namespace NiL.JS.Core.JIT { #if !NET35 - internal static class JITHelpers { public static readonly FieldInfo _items = typeof(List).GetField("_items", BindingFlags.Instance | BindingFlags.NonPublic); @@ -162,61 +161,6 @@ internal static JSValue wrap(T source, JSValue dest) } return dest; } - - internal static MethodInfo methodof(Action method) - { - return method.Method; - } - - internal static MethodInfo methodof(Func method) - { - return method.Method; - } - - internal static MethodInfo methodof(Func method) - { - return method.Method; - } - - internal static MethodInfo methodof(Func method) - { - return method.Method; - } - - internal static MethodInfo methodof(Func func) - { - return func.Method; - } - - internal static MethodInfo methodof(Func func) - { - return func.Method; - } - - internal static MethodInfo methodof(Func func) - { - return func.Method; - } - - internal static MethodInfo methodof(Action method) - { - return method.Method; - } - - internal static MethodInfo methodof(Func method) - { - return method.Method; - } - - internal static MethodInfo methodof(Action method) - { - return method.Method; - } - - internal static MethodInfo methodof(Action method) - { - return method.Method; - } } #endif } \ No newline at end of file diff --git a/NiL.JS/Core/JSObject.cs b/NiL.JS/Core/JSObject.cs index be7ed6934..fa38fc729 100644 --- a/NiL.JS/Core/JSObject.cs +++ b/NiL.JS/Core/JSObject.cs @@ -581,7 +581,7 @@ private static JSObject definePropertyImpl(JSObject target, JSObject desc, strin { if (!config && (obj.attributes & JSValueAttributesInternal.ReadOnly) != 0 - && !((StrictEqualOperator.Check(obj, value) && ((obj.valueType == JSValueType.Undefined && value.valueType == JSValueType.Undefined) || !obj.IsNumber || !value.IsNumber || (1.0 / Tools.JSObjectToDouble(obj) == 1.0 / Tools.JSObjectToDouble(value)))) + && !((StrictEqual.Check(obj, value) && ((obj.valueType == JSValueType.Undefined && value.valueType == JSValueType.Undefined) || !obj.IsNumber || !value.IsNumber || (1.0 / Tools.JSObjectToDouble(obj) == 1.0 / Tools.JSObjectToDouble(value)))) || (obj.valueType == JSValueType.Double && value.valueType == JSValueType.Double && double.IsNaN(obj.dValue) && double.IsNaN(value.dValue)))) ExceptionsHelper.Throw(new TypeError("Cannot change value of not configurable not writable peoperty.")); //if ((obj.attributes & JSObjectAttributesInternal.ReadOnly) == 0 || obj.valueType == JSObjectType.Property) diff --git a/NiL.JS/Core/JSValue.cs b/NiL.JS/Core/JSValue.cs index 18c2ab47e..c34afce7d 100644 --- a/NiL.JS/Core/JSValue.cs +++ b/NiL.JS/Core/JSValue.cs @@ -119,7 +119,7 @@ public class JSValue : IEnumerable>, IComparable= JSValueType.Undefined; } + get + { return valueType >= JSValueType.Undefined; } } [Hidden] @@ -311,7 +312,8 @@ public bool Defined #if INLINE [MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] #endif - get { return valueType > JSValueType.Undefined; } + get + { return valueType > JSValueType.Undefined; } } [Hidden] @@ -321,7 +323,8 @@ public bool IsNull #if INLINE [MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] #endif - get { return valueType >= JSValueType.Object && oValue == null; } + get + { return valueType >= JSValueType.Object && oValue == null; } } [Hidden] @@ -331,7 +334,8 @@ public bool IsNumber #if INLINE [MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] #endif - get { return valueType == JSValueType.Int || valueType == JSValueType.Double; } + get + { return valueType == JSValueType.Int || valueType == JSValueType.Double; } } internal bool NeedClone @@ -531,7 +535,7 @@ internal protected virtual JSValue GetProperty(JSValue key, bool forWrite, Prope break; } } - ExceptionsHelper.Throw(new ApplicationException("Method GetProperty(...) of custom types must be overriden")); + ExceptionsHelper.Throw(new InvalidOperationException("Method GetProperty(...) of custom types must be overriden")); return null; } @@ -567,11 +571,11 @@ internal protected virtual void SetProperty(JSValue name, JSValue value, Propert if (valueType >= JSValueType.Object) { if (oValue == null) - ExceptionsHelper.ThrowTypeError("Can not get property \"" + name + "\" of \"null\""); + ExceptionsHelper.ThrowTypeError(string.Format(Strings.TryingToSetProperty, name, "null")); if (oValue == this) { - System.Diagnostics.Debug.Write(typeof(JSValue).Name + "." + JIT.JITHelpers.methodof(SetProperty).Name + " must be overridden for objects"); + System.Diagnostics.Debug.WriteLine(typeof(JSValue).Name + "." + nameof(SetProperty) + " must be overridden for objects"); GetProperty(name, true, propertyScope).Assign(value); } @@ -583,6 +587,10 @@ internal protected virtual void SetProperty(JSValue name, JSValue value, Propert return; } } + else if (valueType <= JSValueType.Undefined) + { + ExceptionsHelper.ThrowTypeError(string.Format(Strings.TryingToSetProperty, name, "undefined")); + } } internal protected virtual bool DeleteProperty(JSValue name) @@ -607,7 +615,7 @@ public override bool Equals(object obj) return false; if (object.ReferenceEquals(obj, this)) return true; - return Expressions.StrictEqualOperator.Check(this, obj as JSValue); + return Expressions.StrictEqual.Check(this, obj as JSValue); } #region Do not remove @@ -659,25 +667,25 @@ public static implicit operator JSValue(string value) } [Hidden] - public static explicit operator int(JSValue obj) + public static explicit operator int (JSValue obj) { return Tools.JSObjectToInt32(obj); } [Hidden] - public static explicit operator long(JSValue obj) + public static explicit operator long (JSValue obj) { return Tools.JSObjectToInt64(obj); } [Hidden] - public static explicit operator double(JSValue obj) + public static explicit operator double (JSValue obj) { return Tools.JSObjectToDouble(obj); } [Hidden] - public static explicit operator bool(JSValue obj) + public static explicit operator bool (JSValue obj) { switch (obj.valueType) { @@ -695,7 +703,7 @@ public static explicit operator bool(JSValue obj) } return false; } - + [Hidden] public object Clone() { @@ -891,7 +899,7 @@ private IEnumerator> GetEnumeratorImpl(bool hideNo else if (valueType == JSValueType.Object) { if (oValue == this) - throw new ApplicationException("Internal error. #VaO"); + throw new InvalidOperationException("Internal error. #VaO"); } } diff --git a/NiL.JS/Core/Parser.cs b/NiL.JS/Core/Parser.cs index 1eafb94e7..2e20c2af2 100644 --- a/NiL.JS/Core/Parser.cs +++ b/NiL.JS/Core/Parser.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; using System.Collections.Generic; using NiL.JS.BaseLibrary; using NiL.JS.Expressions; @@ -40,20 +41,20 @@ public static class Parser { new Rule("[", ExpressionTree.Parse), new Rule("{", CodeBlock.Parse), - new Rule("var ", VariableDefinitionStatement.Parse), - new Rule("let ", VariableDefinitionStatement.Parse), - new Rule("const ", VariableDefinitionStatement.Parse), - new Rule("if", IfElseStatement.Parse), - new Rule("for", ForOfStatement.Parse), - new Rule("for", ForInStatement.Parse), - new Rule("for", ForStatement.Parse), - new Rule("while", WhileStatement.Parse), - new Rule("return", ReturnStatement.Parse), + new Rule("var ", VariableDefinition.Parse), + new Rule("let ", VariableDefinition.Parse), + new Rule("const ", VariableDefinition.Parse), + new Rule("if", IfElse.Parse), + new Rule("for", ForOf.Parse), + new Rule("for", ForIn.Parse), + new Rule("for", For.Parse), + new Rule("while", While.Parse), + new Rule("return", Return.Parse), new Rule("function", FunctionDefinition.ParseFunction), new Rule("class", ClassDefinition.Parse), - new Rule("switch", SwitchStatement.Parse), - new Rule("with", WithStatement.Parse), - new Rule("do", DoWhileStatement.Parse), + new Rule("switch", Switch.Parse), + new Rule("with", With.Parse), + new Rule("do", DoWhile.Parse), new Rule(ValidateArrow, FunctionDefinition.ParseArrow), new Rule("(", ExpressionTree.Parse), new Rule("+", ExpressionTree.Parse), @@ -66,18 +67,18 @@ public static class Parser new Rule("this", ExpressionTree.Parse), new Rule("super", ExpressionTree.Parse), new Rule("typeof", ExpressionTree.Parse), - new Rule("try", TryCatchStatement.Parse), + new Rule("try", TryCatch.Parse), new Rule("new", ExpressionTree.Parse), new Rule("delete", ExpressionTree.Parse), new Rule("void", ExpressionTree.Parse), - new Rule("yield", YieldOperator.Parse), - new Rule("break", BreakStatement.Parse), - new Rule("continue", ContinueStatement.Parse), - new Rule("throw", ThrowStatement.Parse), + new Rule("yield", Yield.Parse), + new Rule("break", Break.Parse), + new Rule("continue", Continue.Parse), + new Rule("throw", Throw.Parse), new Rule(ValidateName, LabeledStatement.Parse), new Rule(ValidateName, ExpressionTree.Parse), new Rule(ValidateValue, ExpressionTree.Parse), - new Rule("debugger", DebuggerStatement.Parse) + new Rule("debugger", Debugger.Parse) }, // 1 new List // Начало выражения @@ -100,7 +101,7 @@ public static class Parser new Rule("new", ExpressionTree.Parse), new Rule("delete", ExpressionTree.Parse), new Rule("void", ExpressionTree.Parse), - new Rule("yield", YieldOperator.Parse), + new Rule("yield", Yield.Parse), new Rule(ValidateName, ExpressionTree.Parse), new Rule(ValidateValue, ExpressionTree.Parse), }, @@ -108,11 +109,11 @@ public static class Parser new List // Сущности внутри выражения { new Rule("[", ArrayDefinition.Parse), - new Rule("{", ObjectDefinition.Parse), + new Rule("{", Expressions.ObjectDefinition.Parse), new Rule("function", FunctionDefinition.ParseFunction), new Rule("class", ClassDefinition.Parse), - new Rule("new", NewOperator.Parse), - new Rule("yield", YieldOperator.Parse), + new Rule("new", New.Parse), + new Rule("yield", Yield.Parse), new Rule(ValidateArrow, FunctionDefinition.ParseArrow), new Rule(ValidateRegex, RegExpExpression.Parse), } @@ -632,11 +633,11 @@ public static void DefineCustomCodeFragment(Type type) else throw new ArgumentException(); - var validateMethod = type.GetMethod("Validate", new[] { typeof(string), typeof(int) }); + var validateMethod = type.GetRuntimeMethod("Validate", new[] { typeof(string), typeof(int) }); if (validateMethod == null || validateMethod.ReturnType != typeof(bool)) throw new ArgumentException("type must contain static method \"Validate\" which get String and Int32 and returns Boolean"); - var parserMethod = type.GetMethod("Parse", new[] { typeof(ParseInfo), typeof(int).MakeByRefType() }); + var parserMethod = type.GetRuntimeMethod("Parse", new[] { typeof(ParseInfo), typeof(int).MakeByRefType() }); if (parserMethod == null || parserMethod.ReturnType != typeof(CodeNode)) throw new ArgumentException("type must contain static method \"Parse\" which get " + typeof(ParseInfo).Name + " and Int32 by reference and returns " + typeof(CodeNode).Name); diff --git a/NiL.JS/Core/StringMap.cs b/NiL.JS/Core/StringMap.cs index a5d05cd1b..a211287c3 100644 --- a/NiL.JS/Core/StringMap.cs +++ b/NiL.JS/Core/StringMap.cs @@ -26,7 +26,9 @@ public KeyValuePair[] Items } } +#if !PORTABLE [Serializable] +#endif [DebuggerDisplay("Count = {Count}")] [DebuggerTypeProxy(typeof(StringMapDebugView<>))] public sealed class StringMap2 : IDictionary diff --git a/NiL.JS/Core/Tools.cs b/NiL.JS/Core/Tools.cs index 5e825503d..82a31ce3e 100644 --- a/NiL.JS/Core/Tools.cs +++ b/NiL.JS/Core/Tools.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Text; using NiL.JS.BaseLibrary; using NiL.JS.Core.Interop; -using NiL.JS.Core.JIT; using NiL.JS.Extensions; namespace NiL.JS.Core @@ -1517,19 +1517,21 @@ internal static LambdaExpression BuildJsCallTree(string name, Expression functio expressions.Add(Expression.Assign(argumentsParameter, Expression.New(typeof(Arguments)))); for (var i = 0; i < handlerArgumentsParameters.Length; i++) { - expressions.Add(Expression.Call(argumentsParameter, typeof(Arguments).GetMethod("Add"), - Expression.Call(JITHelpers.methodof(TypeProxy.Marshal), handlerArgumentsParameters[i]))); + expressions.Add(Expression.Call( + argumentsParameter, + typeof(Arguments).GetRuntimeMethod("Add", new[] { typeof(JSValue) }), + Expression.Call(Tools.methodof(TypeProxy.Marshal), handlerArgumentsParameters[i]))); } } - var callTree = Expression.Call(functionGetter, typeof(Function).GetMethod(nameof(Function.Call), new[] { typeof(Arguments) }), argumentsParameter); + var callTree = Expression.Call(functionGetter, typeof(Function).GetRuntimeMethod(nameof(Function.Call), new[] { typeof(Arguments) }), argumentsParameter); expressions.Add(callTree); if (method.ReturnParameter.ParameterType != typeof(void) && method.ReturnParameter.ParameterType != typeof(object) && !typeof(JSValue).IsAssignableFrom(method.ReturnParameter.ParameterType)) { - var asMethod = typeof(JSValueExtensions).GetMethod("As").MakeGenericMethod(method.ReturnParameter.ParameterType); + var asMethod = typeof(JSValueExtensions).GetRuntimeMethods().First(x => x.Name == "As").MakeGenericMethod(method.ReturnParameter.ParameterType); expressions[expressions.Count - 1] = Expression.Call(asMethod, callTree); } @@ -1540,5 +1542,15 @@ internal static LambdaExpression BuildJsCallTree(string name, Expression functio else return Expression.Lambda(result, name, handlerArgumentsParameters); } + + internal static MethodInfo methodof(Action method) + { + return method.GetMethodInfo(); + } + + internal static MethodInfo methodof(Func method) + { + return method.GetMethodInfo(); + } } } diff --git a/NiL.JS/Core/Visitor.cs b/NiL.JS/Core/Visitor.cs index f16a6a057..873191c14 100644 --- a/NiL.JS/Core/Visitor.cs +++ b/NiL.JS/Core/Visitor.cs @@ -15,12 +15,12 @@ public abstract class Visitor { internal protected abstract T Visit(CodeNode node); - internal protected virtual T Visit(AdditionOperator node) + internal protected virtual T Visit(Addition node) { return Visit(node as Expression); } - internal protected virtual T Visit(BitwiseConjunctionOperator node) + internal protected virtual T Visit(BitwiseConjunction node) { return Visit(node as Expression); } @@ -30,12 +30,12 @@ internal protected virtual T Visit(ArrayDefinition node) return Visit(node as Expression); } - internal protected virtual T Visit(AssignmentOperator node) + internal protected virtual T Visit(Assignment node) { return Visit(node as Expression); } - internal protected virtual T Visit(CallOperator node) + internal protected virtual T Visit(Call node) { return Visit(node as Expression); } @@ -45,32 +45,32 @@ internal protected virtual T Visit(ClassDefinition node) return Visit(node as Expression); } - internal protected virtual T Visit(ConstantDefinition node) + internal protected virtual T Visit(Constant node) { return Visit(node as Expression); } - internal protected virtual T Visit(DecrementOperator node) + internal protected virtual T Visit(Decrement node) { return Visit(node as Expression); } - internal protected virtual T Visit(DeleteOperator node) + internal protected virtual T Visit(Delete node) { return Visit(node as Expression); } - internal protected virtual T Visit(DeletePropertyOperator node) + internal protected virtual T Visit(DeleteProperty node) { return Visit(node as Expression); } - internal protected virtual T Visit(DivisionOperator node) + internal protected virtual T Visit(Division node) { return Visit(node as Expression); } - internal protected virtual T Visit(EqualOperator node) + internal protected virtual T Visit(Equal node) { return Visit(node as Expression); } @@ -85,12 +85,12 @@ internal protected virtual T Visit(FunctionDefinition node) return Visit(node as Expression); } - internal protected virtual T Visit(GetPropertyOperator node) + internal protected virtual T Visit(Property node) { return Visit(node as Expression); } - internal protected virtual T Visit(GetVariableExpression node) + internal protected virtual T Visit(GetVariable node) { return Visit(node as VariableReference); } @@ -100,122 +100,122 @@ internal protected virtual T Visit(VariableReference node) return Visit(node as Expression); } - internal protected virtual T Visit(InOperator node) + internal protected virtual T Visit(In node) { return Visit(node as Expression); } - internal protected virtual T Visit(IncrementOperator node) + internal protected virtual T Visit(Increment node) { return Visit(node as Expression); } - internal protected virtual T Visit(InstanceOfOperator node) + internal protected virtual T Visit(InstanceOf node) { return Visit(node as Expression); } - internal protected virtual T Visit(ObjectDefinition node) + internal protected virtual T Visit(Expressions.ObjectDefinition node) { return Visit(node as Expression); } - internal protected virtual T Visit(LessOperator node) + internal protected virtual T Visit(Less node) { return Visit(node as Expression); } - internal protected virtual T Visit(LessOrEqualOperator node) + internal protected virtual T Visit(LessOrEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(LogicalConjunctionOperator node) + internal protected virtual T Visit(LogicalConjunction node) { return Visit(node as Expression); } - internal protected virtual T Visit(LogicalNegationOperator node) + internal protected virtual T Visit(LogicalNegation node) { return Visit(node as Expression); } - internal protected virtual T Visit(LogicalDisjunctionOperator node) + internal protected virtual T Visit(LogicalDisjunction node) { return Visit(node as Expression); } - internal protected virtual T Visit(ModuloOperator node) + internal protected virtual T Visit(Modulo node) { return Visit(node as Expression); } - internal protected virtual T Visit(MoreOperator node) + internal protected virtual T Visit(More node) { return Visit(node as Expression); } - internal protected virtual T Visit(MoreOrEqualOperator node) + internal protected virtual T Visit(MoreOrEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(MultiplicationOperator node) + internal protected virtual T Visit(Multiplication node) { return Visit(node as Expression); } - internal protected virtual T Visit(NegationOperator node) + internal protected virtual T Visit(Negation node) { return Visit(node as Expression); } - internal protected virtual T Visit(NewOperator node) + internal protected virtual T Visit(New node) { return Visit(node as Expression); } - internal protected virtual T Visit(CommaOperator node) + internal protected virtual T Visit(Comma node) { return Visit(node as Expression); } - internal protected virtual T Visit(BitwiseNegationOperator node) + internal protected virtual T Visit(BitwiseNegation node) { return Visit(node as Expression); } - internal protected virtual T Visit(NotEqualOperator node) + internal protected virtual T Visit(NotEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(NumberAdditionOperator node) + internal protected virtual T Visit(NumberAddition node) { return Visit(node as Expression); } - internal protected virtual T Visit(NumberLessOperator node) + internal protected virtual T Visit(NumberLess node) { return Visit(node as Expression); } - internal protected virtual T Visit(NumberLessOrEqualOperator node) + internal protected virtual T Visit(NumberLessOrEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(NumberMoreOpeartor node) + internal protected virtual T Visit(NumberMore node) { return Visit(node as Expression); } - internal protected virtual T Visit(NumberMoreOrEqualOperator node) + internal protected virtual T Visit(NumberMoreOrEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(BitwiseDisjunctionOperator node) + internal protected virtual T Visit(BitwiseDisjunction node) { return Visit(node as Expression); } @@ -225,92 +225,92 @@ internal protected virtual T Visit(RegExpExpression node) return Visit(node as Expression); } - internal protected virtual T Visit(SetPropertyExpression node) + internal protected virtual T Visit(SetProperty node) { return Visit(node as Expression); } - internal protected virtual T Visit(SignedShiftLeftOperator node) + internal protected virtual T Visit(SignedShiftLeft node) { return Visit(node as Expression); } - internal protected virtual T Visit(SignedShiftRightOperator node) + internal protected virtual T Visit(SignedShiftRight node) { return Visit(node as Expression); } - internal protected virtual T Visit(StrictEqualOperator node) + internal protected virtual T Visit(StrictEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(StrictNotEqualOperator node) + internal protected virtual T Visit(StrictNotEqual node) { return Visit(node as Expression); } - internal protected virtual T Visit(StringConcatenationExpression node) + internal protected virtual T Visit(StringConcatenation node) { return Visit(node as Expression); } - internal protected virtual T Visit(SubstractOperator node) + internal protected virtual T Visit(Substract node) { return Visit(node as Expression); } - internal protected virtual T Visit(ConditionalOperator node) + internal protected virtual T Visit(Conditional node) { return Visit(node as Expression); } - internal protected virtual T Visit(ToBooleanOperator node) + internal protected virtual T Visit(ConvertToBoolean node) { return Visit(node as Expression); } - internal protected virtual T Visit(ToIntegerOperator node) + internal protected virtual T Visit(ConvertToInteger node) { return Visit(node as Expression); } - internal protected virtual T Visit(ToNumberOperator node) + internal protected virtual T Visit(ConvertToNumber node) { return Visit(node as Expression); } - internal protected virtual T Visit(ToStringExpression node) + internal protected virtual T Visit(ConvertToString node) { return Visit(node as Expression); } - internal protected virtual T Visit(ToUnsignedIntegerExpression node) + internal protected virtual T Visit(ConvertToUnsignedInteger node) { return Visit(node as Expression); } - internal protected virtual T Visit(TypeOfOperator node) + internal protected virtual T Visit(TypeOf node) { return Visit(node as Expression); } - internal protected virtual T Visit(UnsignedShiftRightOperator node) + internal protected virtual T Visit(UnsignedShiftRight node) { return Visit(node as Expression); } - internal protected virtual T Visit(BitwiseExclusiveDisjunctionOperator node) + internal protected virtual T Visit(BitwiseExclusiveDisjunction node) { return Visit(node as Expression); } #if !PORTABLE - internal protected virtual T Visit(YieldOperator node) + internal protected virtual T Visit(Yield node) { return Visit(node as Expression); } #endif - internal protected virtual T Visit(BreakStatement node) + internal protected virtual T Visit(Break node) { return Visit(node as CodeNode); } @@ -320,47 +320,47 @@ internal protected virtual T Visit(CodeBlock node) return Visit(node as CodeNode); } - internal protected virtual T Visit(ContinueStatement node) + internal protected virtual T Visit(Continue node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(DebuggerStatement node) + internal protected virtual T Visit(Debugger node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(DoWhileStatement node) + internal protected virtual T Visit(DoWhile node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(EmptyExpression node) + internal protected virtual T Visit(Empty node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(ForInStatement node) + internal protected virtual T Visit(ForIn node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(ForOfStatement node) + internal protected virtual T Visit(ForOf node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(ForStatement node) + internal protected virtual T Visit(For node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(IfElseStatement node) + internal protected virtual T Visit(IfElse node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(InfinityLoopStatement node) + internal protected virtual T Visit(InfinityLoop node) { return Visit(node as CodeNode); } @@ -370,37 +370,37 @@ internal protected virtual T Visit(LabeledStatement node) return Visit(node as CodeNode); } - internal protected virtual T Visit(ReturnStatement node) + internal protected virtual T Visit(Return node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(SwitchStatement node) + internal protected virtual T Visit(Switch node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(ThrowStatement node) + internal protected virtual T Visit(Throw node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(TryCatchStatement node) + internal protected virtual T Visit(TryCatch node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(VariableDefinitionStatement node) + internal protected virtual T Visit(VariableDefinition node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(WhileStatement node) + internal protected virtual T Visit(While node) { return Visit(node as CodeNode); } - internal protected virtual T Visit(WithStatement node) + internal protected virtual T Visit(With node) { return Visit(node as CodeNode); } diff --git a/NiL.JS/Expressions/AdditionOperator.cs b/NiL.JS/Expressions/Addition.cs similarity index 95% rename from NiL.JS/Expressions/AdditionOperator.cs rename to NiL.JS/Expressions/Addition.cs index e18215b70..f610f8c7f 100644 --- a/NiL.JS/Expressions/AdditionOperator.cs +++ b/NiL.JS/Expressions/Addition.cs @@ -11,7 +11,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class AdditionOperator : Expression + public sealed class Addition : Expression { protected internal override PredictedType ResultType { @@ -55,7 +55,7 @@ internal override bool ResultInTempContainer get { return false; } } - public AdditionOperator(Expression first, Expression second) + public Addition(Expression first, Expression second) : base(first, second, true) { @@ -289,31 +289,31 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary() { first, second }); + _this = new StringConcatenation(new List() { first, second }); } else if (second.ContextIndependent && second.Evaluate(null).valueType == JSValueType.String) { if (second.Evaluate(null).ToString().Length == 0) - _this = new ToStringExpression(first); + _this = new ConvertToString(first); else - _this = new StringConcatenationExpression(new List() { first, second }); + _this = new StringConcatenation(new List() { first, second }); } } } @@ -327,7 +327,7 @@ public override void Optimize(ref CodeNode _this, FunctionDefinition owner, Comp if (Tools.IsEqual(first.ResultType, PredictedType.Number, PredictedType.Group) && Tools.IsEqual(second.ResultType, PredictedType.Number, PredictedType.Group)) { - _this = new NumberAdditionOperator(first, second); + _this = new NumberAddition(first, second); return; } } diff --git a/NiL.JS/Expressions/ArrayDefinition.cs b/NiL.JS/Expressions/ArrayDefinition.cs index fa931bcc0..a94009a58 100644 --- a/NiL.JS/Expressions/ArrayDefinition.cs +++ b/NiL.JS/Expressions/ArrayDefinition.cs @@ -69,7 +69,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) else elms.Add((Expression)ExpressionTree.Parse(state, ref i, false, false)); if (spread) - elms[elms.Count - 1] = new SpreadOperator(elms[elms.Count - 1]) { Position = start, Length = i - start }; + elms[elms.Count - 1] = new Spread(elms[elms.Count - 1]) { Position = start, Length = i - start }; while (Tools.IsWhiteSpace(state.Code[i])) i++; if (state.Code[i] == ',') @@ -186,7 +186,7 @@ public override void Decompose(ref Expression self, IList result) { if (!(elements[i] is ExtractStoredValue)) { - result.Add(new StoreValueStatement(elements[i], false)); + result.Add(new StoreValue(elements[i], false)); elements[i] = new ExtractStoredValue(elements[i]); } } diff --git a/NiL.JS/Expressions/AssignmentOperator.cs b/NiL.JS/Expressions/Assignment.cs similarity index 94% rename from NiL.JS/Expressions/AssignmentOperator.cs rename to NiL.JS/Expressions/Assignment.cs index f6f1e71ac..686061a19 100644 --- a/NiL.JS/Expressions/AssignmentOperator.cs +++ b/NiL.JS/Expressions/Assignment.cs @@ -9,7 +9,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - internal sealed class ForceAssignmentOperator:AssignmentOperator + internal sealed class ForceAssignmentOperator:Assignment { public ForceAssignmentOperator(Expression first, Expression second) : base(first, second) @@ -41,7 +41,7 @@ public override JSValue Evaluate(Context context) #if !PORTABLE [Serializable] #endif - public class AssignmentOperator : Expression + public class Assignment : Expression { private Arguments setterArgs; private bool saveResult; @@ -67,7 +67,7 @@ protected internal override bool LValueModifier } } - public AssignmentOperator(Expression first, Expression second) + public Assignment(Expression first, Expression second) : base(first, second, false) { } @@ -144,7 +144,7 @@ public override bool Build(ref CodeNode _this, int expressionDepth, System.Colle var assigns = (f.Descriptor.assignments ?? (f.Descriptor.assignments = new List())); if (assigns.IndexOf(this) == -1) assigns.Add(this); - if (second is ConstantDefinition) + if (second is Constant) { var pt = second.ResultType; if (f._descriptor.lastPredictedType == PredictedType.Unknown) @@ -155,9 +155,9 @@ public override bool Build(ref CodeNode _this, int expressionDepth, System.Colle if (repeat) System.Diagnostics.Debugger.Break(); #endif - var gme = first as GetPropertyOperator; + var gme = first as Property; if (gme != null) - _this = new SetPropertyExpression(gme.first, gme.second, second) { Position = Position, Length = Length }; + _this = new SetProperty(gme.first, gme.second, second) { Position = Position, Length = Length }; if ((codeContext & (CodeContext.InExpression | CodeContext.InEval)) != 0) saveResult = true; @@ -192,7 +192,7 @@ public override void Optimize(ref CodeNode _this, FunctionDefinition owner, Comp message(MessageLevel.CriticalWarning, new CodeCoordinates(0, Position, Length), "Assign to undefined variable \"" + vr.Name + "\". It will declare a global variable."); } - var gve = first as GetVariableExpression; + var gve = first as GetVariable; if (gve != null && gve._descriptor.IsDefined && (_codeContext & CodeContext.InWith) == 0) { if (owner != null // не будем это применять в корневом узле. Только в функциях. Иначе это может задумываться как настройка контекста для последующего использования в Eval @@ -214,7 +214,7 @@ public override void Optimize(ref CodeNode _this, FunctionDefinition owner, Comp if (second.ContextIndependent) { _this.Eliminated = true; - _this = EmptyExpression.Instance; + _this = Empty.Instance; } else { diff --git a/NiL.JS/Expressions/AssignmentOperatorCache.cs b/NiL.JS/Expressions/AssignmentOperatorCache.cs index 26c6333ab..035732aae 100644 --- a/NiL.JS/Expressions/AssignmentOperatorCache.cs +++ b/NiL.JS/Expressions/AssignmentOperatorCache.cs @@ -108,8 +108,8 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary result) { if (!(_arguments[i] is ExtractStoredValue)) { - result.Add(new StoreValueStatement(_arguments[i], false)); + result.Add(new StoreValue(_arguments[i], false)); _arguments[i] = new ExtractStoredValue(_arguments[i]); } } diff --git a/NiL.JS/Expressions/ClassDefinition.cs b/NiL.JS/Expressions/ClassDefinition.cs index c95bfd07b..604e58946 100644 --- a/NiL.JS/Expressions/ClassDefinition.cs +++ b/NiL.JS/Expressions/ClassDefinition.cs @@ -155,9 +155,9 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var baseClassName = code.Substring(n, i - n); if (baseClassName == "null") - baseType = new ConstantDefinition(JSValue.@null); + baseType = new Constant(JSValue.@null); else - baseType = new GetVariableExpression(baseClassName, 1); + baseType = new GetVariable(baseClassName, 1); baseType.Position = n; baseType.Length = i - n; @@ -233,12 +233,12 @@ internal static CodeNode Parse(ParseInfo state, ref int index) { case 'g': { - computedProperties.Add(new MemberDescriptor((Expression)propertyName, new GsPropertyPairExpression((Expression)initializer, null), @static)); + computedProperties.Add(new MemberDescriptor((Expression)propertyName, new GetSetPropertyPair((Expression)initializer, null), @static)); break; } case 's': { - computedProperties.Add(new MemberDescriptor((Expression)propertyName, new GsPropertyPairExpression(null, (Expression)initializer), @static)); + computedProperties.Add(new MemberDescriptor((Expression)propertyName, new GetSetPropertyPair(null, (Expression)initializer), @static)); break; } default: @@ -256,16 +256,16 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var accessorName = (@static ? "static " : "") + propertyAccessor._name; if (!flds.ContainsKey(accessorName)) { - var propertyPair = new GsPropertyPairExpression + var propertyPair = new GetSetPropertyPair ( mode == FunctionKind.Getter ? propertyAccessor : null, mode == FunctionKind.Setter ? propertyAccessor : null ); - flds.Add(accessorName, new MemberDescriptor(new ConstantDefinition(propertyAccessor._name), propertyPair, @static)); + flds.Add(accessorName, new MemberDescriptor(new Constant(propertyAccessor._name), propertyPair, @static)); } else { - var vle = flds[accessorName].Value as GsPropertyPairExpression; + var vle = flds[accessorName].Value as GetSetPropertyPair; if (vle == null) ExceptionsHelper.Throw((new SyntaxError("Try to define " + mode.ToString().ToLowerInvariant() + " for defined field at " + CodeCoordinates.FromTextPosition(state.Code, s, 0)))); @@ -353,7 +353,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) } else { - flds[fieldName] = new MemberDescriptor(new ConstantDefinition(method._name), method, @static); + flds[fieldName] = new MemberDescriptor(new Constant(method._name), method, @static); } if (method == null) ExceptionsHelper.Throw(new SyntaxError()); @@ -363,7 +363,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) { string ctorCode; int ctorIndex = 0; - if (baseType != null && !(baseType is ConstantDefinition)) + if (baseType != null && !(baseType is Constant)) ctorCode = "constructor(...args) { super(...args); }"; else ctorCode = "constructor(...args) { }"; @@ -376,7 +376,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) ref ctorIndex, FunctionKind.Method); } - + result = new ClassDefinition(name, baseType, new List(flds.Values).ToArray(), ctor as FunctionDefinition, computedProperties.ToArray()); if ((oldCodeContext & CodeContext.InExpression) == 0) @@ -617,8 +617,7 @@ public override void Decompose(ref Expression self, IList result) { _members[i]._value.Decompose(ref _members[i]._value, result); // results will be empty at each iterations #if DEBUG - if (result.Count != 0) - System.Diagnostics.Debug.Fail("Decompose: results not empty"); + System.Diagnostics.Debug.Assert(result.Count == 0, "Decompose: results not empty"); #endif } @@ -629,8 +628,7 @@ public override void Decompose(ref Expression self, IList result) computedProperties[i]._value.Decompose(ref computedProperties[i]._value, result); #if DEBUG - if (result.Count != 0) - System.Diagnostics.Debug.Fail("Decompose: results not empty"); + System.Diagnostics.Debug.Assert(result.Count == 0, "Decompose: results not empty"); #endif } } diff --git a/NiL.JS/Expressions/CommaOperator.cs b/NiL.JS/Expressions/Comma.cs similarity index 95% rename from NiL.JS/Expressions/CommaOperator.cs rename to NiL.JS/Expressions/Comma.cs index d597e3218..cc37e5d4a 100644 --- a/NiL.JS/Expressions/CommaOperator.cs +++ b/NiL.JS/Expressions/Comma.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class CommaOperator : Expression + public sealed class Comma : Expression { protected internal override PredictedType ResultType { @@ -22,7 +22,7 @@ internal override bool ResultInTempContainer get { return false; } } - public CommaOperator(Expression first, Expression second) + public Comma(Expression first, Expression second) : base(first, second, false) { diff --git a/NiL.JS/Expressions/ConditionalOperator.cs b/NiL.JS/Expressions/Conditional.cs similarity index 87% rename from NiL.JS/Expressions/ConditionalOperator.cs rename to NiL.JS/Expressions/Conditional.cs index d2ad8ff1a..3ecd8369a 100644 --- a/NiL.JS/Expressions/ConditionalOperator.cs +++ b/NiL.JS/Expressions/Conditional.cs @@ -8,7 +8,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class ConditionalOperator : Expression + public sealed class Conditional : Expression { private Expression[] threads; @@ -43,7 +43,7 @@ internal override bool ResultInTempContainer public IList Threads { get { return new ReadOnlyCollection(threads); } } - public ConditionalOperator(Expression first, Expression[] threads) + public Conditional(Expression first, Expression[] threads) : base(first, null, false) { this.threads = threads; @@ -71,17 +71,17 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary 0 && (Parser.ValidateName(cn.value.ToString(), ref i, true))) res += "." + cn.value; diff --git a/NiL.JS/Expressions/DivisionOperator.cs b/NiL.JS/Expressions/Division.cs similarity index 94% rename from NiL.JS/Expressions/DivisionOperator.cs rename to NiL.JS/Expressions/Division.cs index eb90e2d4b..0d9ea6679 100644 --- a/NiL.JS/Expressions/DivisionOperator.cs +++ b/NiL.JS/Expressions/Division.cs @@ -6,7 +6,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class DivisionOperator : Expression + public sealed class Division : Expression { protected internal override PredictedType ResultType { @@ -21,7 +21,7 @@ internal override bool ResultInTempContainer get { return true; } } - public DivisionOperator(Expression first, Expression second) + public Division(Expression first, Expression second) : base(first, second, true) { diff --git a/NiL.JS/Expressions/EmptyExpression.cs b/NiL.JS/Expressions/Empty.cs similarity index 83% rename from NiL.JS/Expressions/EmptyExpression.cs rename to NiL.JS/Expressions/Empty.cs index b3c99f301..56f07116f 100644 --- a/NiL.JS/Expressions/EmptyExpression.cs +++ b/NiL.JS/Expressions/Empty.cs @@ -7,10 +7,10 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class EmptyExpression : Expression + public sealed class Empty : Expression { - private static readonly EmptyExpression _instance = new EmptyExpression(); - public static EmptyExpression Instance { get { return _instance; } } + private static readonly Empty _instance = new Empty(); + public static Empty Instance { get { return _instance; } } internal override bool ResultInTempContainer { @@ -25,12 +25,12 @@ protected internal override PredictedType ResultType } } - public EmptyExpression() + public Empty() : base(null, null, false) { } - public EmptyExpression(int position) + public Empty(int position) : base(null, null, false) { Position = position; diff --git a/NiL.JS/Expressions/EqualOperator.cs b/NiL.JS/Expressions/Equal.cs similarity index 98% rename from NiL.JS/Expressions/EqualOperator.cs rename to NiL.JS/Expressions/Equal.cs index b22ee54a3..59357a320 100644 --- a/NiL.JS/Expressions/EqualOperator.cs +++ b/NiL.JS/Expressions/Equal.cs @@ -6,7 +6,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public class EqualOperator : Expression + public class Equal : Expression { protected internal override PredictedType ResultType { @@ -21,7 +21,7 @@ internal override bool ResultInTempContainer get { return false; } } - public EqualOperator(Expression first, Expression second) + public Equal(Expression first, Expression second) : base(first, second, false) { @@ -279,7 +279,7 @@ public override void Optimize(ref CodeNode _this, FunctionDefinition owner, Comp base.Optimize(ref _this, owner, message, opts, stats); if (message != null) { - var fc = first as ConstantDefinition ?? second as ConstantDefinition; + var fc = first as Constant ?? second as Constant; if (fc != null) { switch (fc.value.valueType) diff --git a/NiL.JS/Expressions/Expression.cs b/NiL.JS/Expressions/Expression.cs index c37949ca0..44fa18aed 100644 --- a/NiL.JS/Expressions/Expression.cs +++ b/NiL.JS/Expressions/Expression.cs @@ -101,18 +101,18 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary result) { if (second.NeedDecompose && !(first is ExtractStoredValue)) { - result.Add(new StoreValueStatement(first, LValueModifier)); + result.Add(new StoreValue(first, LValueModifier)); first = new ExtractStoredValue(first); } diff --git a/NiL.JS/Expressions/ExpressionTree.cs b/NiL.JS/Expressions/ExpressionTree.cs index a6593cd69..b3b14fe46 100644 --- a/NiL.JS/Expressions/ExpressionTree.cs +++ b/NiL.JS/Expressions/ExpressionTree.cs @@ -113,23 +113,23 @@ private Expression getFastImpl() { case OperationType.Multiply: { - return new MultiplicationOperator(first, second); + return new Multiplication(first, second); } case OperationType.None: { - return new CommaOperator(first, second); + return new Comma(first, second); } case OperationType.Assignment: { - return new AssignmentOperator(first, second); + return new Assignment(first, second); } case OperationType.Less: { - return new LessOperator(first, second); + return new Less(first, second); } case OperationType.Incriment: { - return new IncrementOperator(first ?? second, first == null ? IncrimentType.Postincriment : IncrimentType.Preincriment); + return new Increment(first ?? second, first == null ? IncrimentType.Postincriment : IncrimentType.Preincriment); } case OperationType.Call: { @@ -137,91 +137,91 @@ private Expression getFastImpl() } case OperationType.Decriment: { - return new DecrementOperator(first ?? second, first == null ? DecrimentType.Postdecriment : DecrimentType.Postdecriment); + return new Decrement(first ?? second, first == null ? DecrimentType.Postdecriment : DecrimentType.Postdecriment); } case OperationType.LessOrEqual: { - return new LessOrEqualOperator(first, second); + return new LessOrEqual(first, second); } case OperationType.Addition: { - return new AdditionOperator(first, second); + return new Addition(first, second); } case OperationType.StrictNotEqual: { - return new StrictNotEqualOperator(first, second); + return new StrictNotEqual(first, second); } case OperationType.More: { - return new MoreOperator(first, second); + return new More(first, second); } case OperationType.MoreOrEqual: { - return new MoreOrEqualOperator(first, second); + return new MoreOrEqual(first, second); } case OperationType.Division: { - return new DivisionOperator(first, second); + return new Division(first, second); } case OperationType.Equal: { - return new EqualOperator(first, second); + return new Equal(first, second); } case OperationType.Substract: { - return new SubstractOperator(first, second); + return new Substract(first, second); } case OperationType.StrictEqual: { - return new StrictEqualOperator(first, second); + return new StrictEqual(first, second); } case OperationType.LogicalOr: { - return new LogicalDisjunctionOperator(first, second); + return new LogicalDisjunction(first, second); } case OperationType.LogicalAnd: { - return new LogicalConjunctionOperator(first, second); + return new LogicalConjunction(first, second); } case OperationType.NotEqual: { - return new NotEqualOperator(first, second); + return new NotEqual(first, second); } case OperationType.UnsignedShiftRight: { - return new UnsignedShiftRightOperator(first, second); + return new UnsignedShiftRight(first, second); } case OperationType.SignedShiftLeft: { - return new SignedShiftLeftOperator(first, second); + return new SignedShiftLeft(first, second); } case OperationType.SignedShiftRight: { - return new SignedShiftRightOperator(first, second); + return new SignedShiftRight(first, second); } case OperationType.Module: { - return new ModuloOperator(first, second); + return new Modulo(first, second); } case OperationType.LogicalNot: { - return new LogicalNegationOperator(first); + return new LogicalNegation(first); } case OperationType.Not: { - return new BitwiseNegationOperator(first); + return new BitwiseNegation(first); } case OperationType.Xor: { - return new BitwiseExclusiveDisjunctionOperator(first, second); + return new BitwiseExclusiveDisjunction(first, second); } case OperationType.Or: { - return new BitwiseDisjunctionOperator(first, second); + return new BitwiseDisjunction(first, second); } case OperationType.And: { - return new BitwiseConjunctionOperator(first, second); + return new BitwiseConjunction(first, second); } case OperationType.Conditional: { @@ -229,11 +229,11 @@ private Expression getFastImpl() && (second as ExpressionTree)._operationKind == OperationType.None && (second as ExpressionTree).second == null) second = (second as ExpressionTree).first; - return new ConditionalOperator(first, (Expression[])second.Evaluate(null).oValue); + return new Conditional(first, (Expression[])second.Evaluate(null).oValue); } case OperationType.TypeOf: { - return new TypeOfOperator(first); + return new TypeOf(first); } case OperationType.New: { @@ -241,15 +241,15 @@ private Expression getFastImpl() } case OperationType.Delete: { - return new DeleteOperator(first); + return new Delete(first); } case OperationType.InstanceOf: { - return new InstanceOfOperator(first, second); + return new InstanceOf(first, second); } case OperationType.In: { - return new InOperator(first, second); + return new In(first, second); } default: throw new ArgumentException("invalid operation type"); @@ -462,11 +462,11 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i goto default; if (state.strict) { - if ((first is GetVariableExpression) - && ((first as GetVariableExpression).Name == "arguments" || (first as GetVariableExpression).Name == "eval")) - ExceptionsHelper.ThrowSyntaxError("Cannot incriment \"" + (first as GetVariableExpression).Name + "\" in strict mode.", state.Code, i); + if ((first is GetVariable) + && ((first as GetVariable).Name == "arguments" || (first as GetVariable).Name == "eval")) + ExceptionsHelper.ThrowSyntaxError("Cannot incriment \"" + (first as GetVariable).Name + "\" in strict mode.", state.Code, i); } - first = new IncrementOperator(first, IncrimentType.Postincriment) { Position = first.Position, Length = i + 2 - first.Position }; + first = new Increment(first, IncrimentType.Postincriment) { Position = first.Position, Length = i + 2 - first.Position }; repeat = true; i += 2; } @@ -498,11 +498,11 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i goto default; if (state.strict) { - if ((first is GetVariableExpression) - && ((first as GetVariableExpression).Name == "arguments" || (first as GetVariableExpression).Name == "eval")) - ExceptionsHelper.Throw(new SyntaxError("Can not decriment \"" + (first as GetVariableExpression).Name + "\" in strict mode.")); + if ((first is GetVariable) + && ((first as GetVariable).Name == "arguments" || (first as GetVariable).Name == "eval")) + ExceptionsHelper.Throw(new SyntaxError("Can not decriment \"" + (first as GetVariable).Name + "\" in strict mode.")); } - first = new DecrementOperator(first, DecrimentType.Postdecriment) { Position = first.Position, Length = i + 2 - first.Position }; + first = new Decrement(first, DecrimentType.Postdecriment) { Position = first.Position, Length = i + 2 - first.Position }; repeat = true; i += 2; } @@ -739,7 +739,7 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i JSValue jsname = null; if (!state.stringConstants.TryGetValue(name, out jsname)) state.stringConstants[name] = jsname = name; - first = new GetPropertyOperator(first, new ConstantDefinition(name) + first = new Property(first, new Constant(name) { Position = s, Length = i - s @@ -766,7 +766,7 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i i++; if (state.Code[i] != ']') ExceptionsHelper.Throw((new SyntaxError("Expected \"]\" at " + CodeCoordinates.FromTextPosition(state.Code, startPos, 0)))); - first = new GetPropertyOperator(first, mname) { Position = first.Position, Length = i + 1 - first.Position }; + first = new Property(first, mname) { Position = first.Position, Length = i + 1 - first.Position }; i++; repeat = true; canAsign = true; @@ -774,7 +774,7 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i if (state.message != null) { startPos = 0; - var cname = mname as ConstantDefinition; + var cname = mname as Constant; if (cname != null && cname.value.valueType == JSValueType.String && Parser.ValidateName(cname.value.oValue.ToString(), ref startPos, false) @@ -795,27 +795,40 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i i++; if (state.Code[i] == ')') break; - else if (state.Code[i] == ',') + else { - if (args.Count == 0) - ExceptionsHelper.ThrowSyntaxError("Empty argument of function call", state.Code, i); - do - i++; - while (Tools.IsWhiteSpace(state.Code[i])); + bool commaExists = args.Count == 0; + for (;;) + { + if (state.Code[i] == ',') + { + if (commaExists) + ExceptionsHelper.ThrowSyntaxError("Missing argument of function call", state.Code, i); + do + i++; + while (Tools.IsWhiteSpace(state.Code[i])); + commaExists = true; + } + else + break; + } + if (!commaExists) + ExceptionsHelper.ThrowSyntaxError("Expected ','", state.Code, i); } if (i + 1 == state.Code.Length) ExceptionsHelper.ThrowSyntaxError("Unexpected end of source", state.Code, i); + var spread = Parser.Validate(state.Code, "...", ref i); args.Add((Expression)ExpressionTree.Parse(state, ref i, false, false)); if (spread) { - args[args.Count - 1] = new SpreadOperator(args[args.Count - 1]); + args[args.Count - 1] = new Spread(args[args.Count - 1]); withSpread = true; } if (args[args.Count - 1] == null) ExceptionsHelper.ThrowSyntaxError("Expected \")\"", state.Code, startPos); } - first = new CallOperator(first, args.ToArray()) + first = new Call(first, args.ToArray()) { Position = first.Position, Length = i - first.Position + 1, @@ -875,7 +888,7 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i } } while (repeat); if (state.strict - && (first is GetVariableExpression) && ((first as GetVariableExpression).Name == "arguments" || (first as GetVariableExpression).Name == "eval")) + && (first is GetVariable) && ((first as GetVariable).Name == "arguments" || (first as GetVariable).Name == "eval")) { if (assign || kind == OperationType.Assignment) ExceptionsHelper.ThrowSyntaxError("Assignment to eval or arguments is not allowed in strict mode", state.Code, i); @@ -911,7 +924,7 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i var opassigncache = new AssignmentOperatorCache(first); if (second is ExpressionTree && (second as ExpressionTree)._operationKind == OperationType.None) { - second.first = new AssignmentOperator(opassigncache, new ExpressionTree() + second.first = new Assignment(opassigncache, new ExpressionTree() { first = opassigncache, second = second.first, @@ -927,7 +940,7 @@ private static Expression parseContinuation(ParseInfo state, Expression first, i } else { - res = new AssignmentOperator(opassigncache, new ExpressionTree() + res = new Assignment(opassigncache, new ExpressionTree() { first = opassigncache, second = second, @@ -986,22 +999,22 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, && (state.Code[i] != '(' || (state.CodeContext & CodeContext.InClassConstructor) == 0))) // вызов конструктора ExceptionsHelper.ThrowSyntaxError("super keyword unexpected in this coontext", state.Code, i); - operand = new GetSuper(); + operand = new Super(); break; } case "new.target": { - operand = new GetNewTarget(); + operand = new NewTarget(); break; } case "this": { - operand = new GetThis(); + operand = new This(); break; } default: { - operand = new GetVariableExpression(name, state.lexicalScopeLevel); + operand = new GetVariable(name, state.lexicalScopeLevel); break; } } @@ -1027,11 +1040,11 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, var name = Tools.Unescape(state.Code.Substring(start, i - start), state.strict); if (name == "undefined") { - operand = new ConstantDefinition(JSValue.undefined); + operand = new Constant(JSValue.undefined); } else { - operand = new GetVariableExpression(name, state.lexicalScopeLevel); + operand = new GetVariable(name, state.lexicalScopeLevel); } } else if (Parser.ValidateValue(state.Code, ref i)) @@ -1041,17 +1054,17 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, { value = Tools.Unescape(value.Substring(1, value.Length - 2), state.strict); if (state.stringConstants.ContainsKey(value)) - operand = new ConstantDefinition(state.stringConstants[value]) { Position = start, Length = i - start }; + operand = new Constant(state.stringConstants[value]) { Position = start, Length = i - start }; else - operand = new ConstantDefinition(state.stringConstants[value] = value) { Position = start, Length = i - start }; + operand = new Constant(state.stringConstants[value] = value) { Position = start, Length = i - start }; } else { bool b = false; if (value == "null") - operand = new ConstantDefinition(JSValue.@null) { Position = start, Length = i - start }; + operand = new Constant(JSValue.@null) { Position = start, Length = i - start }; else if (bool.TryParse(value, out b)) - operand = new ConstantDefinition(b ? NiL.JS.BaseLibrary.Boolean.True : NiL.JS.BaseLibrary.Boolean.False) { Position = start, Length = i - start }; + operand = new Constant(b ? NiL.JS.BaseLibrary.Boolean.True : NiL.JS.BaseLibrary.Boolean.False) { Position = start, Length = i - start }; else { int n = 0; @@ -1061,20 +1074,20 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, if ((n = (int)d) == d && !double.IsNegativeInfinity(1.0 / d)) { if (state.intConstants.ContainsKey(n)) - operand = new ConstantDefinition(state.intConstants[n]) { Position = start, Length = i - start }; + operand = new Constant(state.intConstants[n]) { Position = start, Length = i - start }; else - operand = new ConstantDefinition(state.intConstants[n] = n) { Position = start, Length = i - start }; + operand = new Constant(state.intConstants[n] = n) { Position = start, Length = i - start }; } else { if (state.doubleConstants.ContainsKey(d)) - operand = new ConstantDefinition(state.doubleConstants[d]) { Position = start, Length = i - start }; + operand = new Constant(state.doubleConstants[d]) { Position = start, Length = i - start }; else - operand = new ConstantDefinition(state.doubleConstants[d] = d) { Position = start, Length = i - start }; + operand = new Constant(state.doubleConstants[d] = d) { Position = start, Length = i - start }; } } else if (Parser.ValidateRegex(state.Code, ref start, true)) - throw new ApplicationException("This case was moved"); + throw new InvalidOperationException("This case was moved"); else throw new ArgumentException("Unable to process value (" + value + ")"); } @@ -1103,26 +1116,26 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, operand = (Expression)Parse(state, ref i, true, true, false, true, forForLoop); - if (((operand as GetPropertyOperator) as object ?? (operand as GetVariableExpression)) == null) + if (((operand as Property) as object ?? (operand as GetVariable)) == null) { ExceptionsHelper.ThrowSyntaxError("Invalid prefix operation. ", state.Code, i); } if (state.strict - && (operand is GetVariableExpression) - && ((operand as GetVariableExpression).Name == "arguments" || (operand as GetVariableExpression).Name == "eval")) + && (operand is GetVariable) + && ((operand as GetVariable).Name == "arguments" || (operand as GetVariable).Name == "eval")) { - ExceptionsHelper.ThrowSyntaxError("Can not incriment \"" + (operand as GetVariableExpression).Name + "\" in strict mode.", state.Code, i); + ExceptionsHelper.ThrowSyntaxError("Can not incriment \"" + (operand as GetVariable).Name + "\" in strict mode.", state.Code, i); } - operand = new IncrementOperator(operand, IncrimentType.Preincriment); + operand = new Increment(operand, IncrimentType.Preincriment); } else { while (Tools.IsWhiteSpace(state.Code[i])) i++; var f = (Expression)Parse(state, ref i, true, true, false, true, forForLoop); - operand = new ToNumberOperator(f); + operand = new ConvertToNumber(f); } break; } @@ -1139,24 +1152,24 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, operand = (Expression)Parse(state, ref i, true, true, false, true, forForLoop); - if (((operand as GetPropertyOperator) as object ?? (operand as GetVariableExpression)) == null) + if (((operand as Property) as object ?? (operand as GetVariable)) == null) { ExceptionsHelper.ThrowSyntaxError("Invalid prefix operation.", state.Code, i); } if (state.strict - && (operand is GetVariableExpression) - && ((operand as GetVariableExpression).Name == "arguments" || (operand as GetVariableExpression).Name == "eval")) - ExceptionsHelper.Throw(new SyntaxError("Can not decriment \"" + (operand as GetVariableExpression).Name + "\" in strict mode.")); + && (operand is GetVariable) + && ((operand as GetVariable).Name == "arguments" || (operand as GetVariable).Name == "eval")) + ExceptionsHelper.Throw(new SyntaxError("Can not decriment \"" + (operand as GetVariable).Name + "\" in strict mode.")); - operand = new DecrementOperator(operand, DecrimentType.Predecriment); + operand = new Decrement(operand, DecrimentType.Predecriment); } else { while (Tools.IsWhiteSpace(state.Code[i])) i++; var f = (Expression)Parse(state, ref i, true, true, false, true, forForLoop); - operand = new NegationOperator(f); + operand = new Negation(f); } break; } @@ -1165,7 +1178,7 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, do i++; while (Tools.IsWhiteSpace(state.Code[i])); - operand = new LogicalNegationOperator((Expression)Parse(state, ref i, true, true, false, true, forForLoop)); + operand = new LogicalNegation((Expression)Parse(state, ref i, true, true, false, true, forForLoop)); if (operand == null) { var cord = CodeCoordinates.FromTextPosition(state.Code, i, 0); @@ -1184,7 +1197,7 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, var cord = CodeCoordinates.FromTextPosition(state.Code, i, 0); ExceptionsHelper.Throw((new SyntaxError("Invalid prefix operation. " + cord))); } - operand = new BitwiseNegationOperator(operand); + operand = new BitwiseNegation(operand); break; } case 't': @@ -1199,7 +1212,7 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, var cord = CodeCoordinates.FromTextPosition(state.Code, i, 0); ExceptionsHelper.Throw((new SyntaxError("Invalid prefix operation. " + cord))); } - operand = new TypeOfOperator(operand); + operand = new TypeOf(operand); break; } case 'v': @@ -1209,9 +1222,9 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, i++; while (Tools.IsWhiteSpace(state.Code[i])); - operand = new CommaOperator( + operand = new Comma( (Expression)Parse(state, ref i, true, false, false, true, forForLoop), - new ConstantDefinition(JSValue.undefined)); + new Constant(JSValue.undefined)); if (operand == null) { @@ -1232,7 +1245,7 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, var cord = CodeCoordinates.FromTextPosition(state.Code, i, 0); ExceptionsHelper.Throw((new SyntaxError("Invalid prefix operation. " + cord))); } - operand = new Expressions.DeleteOperator(operand); + operand = new Expressions.Delete(operand); break; } } @@ -1248,17 +1261,17 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, if (operand == null) operand = temp; else - operand = new CommaOperator(operand, temp); + operand = new Comma(operand, temp); while (Tools.IsWhiteSpace(state.Code[i])) i++; if (state.Code[i] != ')' && state.Code[i] != ',') ExceptionsHelper.Throw((new SyntaxError("Expected \")\""))); } i++; - if (((state.CodeContext & CodeContext.InExpression) != 0 && operand is FunctionDefinition) - || (forNew && operand is CallOperator)) + if (((state.CodeContext & (CodeContext.InExpression | CodeContext.InEval)) != 0 && operand is FunctionDefinition) + || (forNew && operand is Call)) { - operand = new Expressions.CommaOperator(operand, null); + operand = new Expressions.Comma(operand, null); } } else @@ -1268,7 +1281,7 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, } } - if (operand == null || operand is EmptyExpression) + if (operand == null || operand is Empty) ExceptionsHelper.ThrowSyntaxError(Strings.UnexpectedToken, state.Code, i); if (operand.Position == 0) @@ -1282,7 +1295,7 @@ private static Expression parseOperand(ParseInfo state, ref int i, bool forNew, private static Expression parseTernaryBranches(ParseInfo state, bool forEnumeration, ref int i) { - ConstantDefinition result = null; + Constant result = null; var oldCodeContext = state.CodeContext; state.CodeContext |= CodeContext.InExpression; try @@ -1299,7 +1312,7 @@ private static Expression parseTernaryBranches(ParseInfo state, bool forEnumerat do i++; while (Tools.IsWhiteSpace(state.Code[i])); - result = new ConstantDefinition(new JSValue() { valueType = JSValueType.Object, oValue = threads }) { Position = position }; + result = new Constant(new JSValue() { valueType = JSValueType.Object, oValue = threads }) { Position = position }; threads[1] = Parse(state, ref i, false, false, false, true, forEnumeration); result.Length = i - position; } diff --git a/NiL.JS/Expressions/FunctionDefinition.cs b/NiL.JS/Expressions/FunctionDefinition.cs index 67459815b..b50ed84e6 100644 --- a/NiL.JS/Expressions/FunctionDefinition.cs +++ b/NiL.JS/Expressions/FunctionDefinition.cs @@ -249,7 +249,7 @@ internal static Expression Parse(ParseInfo state, ref int index, FunctionKind mo i++; while (Tools.IsWhiteSpace(code[i])); if (code[i] == ',') - ExceptionsHelper.ThrowSyntaxError("Unexpected char at ", code, i); + ExceptionsHelper.ThrowSyntaxError(Strings.UnexpectedToken, code, i); while (code[i] != ')') { if (parameters.Count == 255 || (mode == FunctionKind.Setter && parameters.Count == 1) || mode == FunctionKind.Getter) @@ -260,6 +260,7 @@ internal static Expression Parse(ParseInfo state, ref int index, FunctionKind mo int n = i; if (!Parser.ValidateName(code, ref i, state.strict)) ExceptionsHelper.ThrowUnknownToken(code, nameStartPos); + var pname = Tools.Unescape(code.Substring(n, i - n), state.strict); var desc = new ParameterReference(pname, rest, state.lexicalScopeLevel + 1) { @@ -295,6 +296,7 @@ internal static Expression Parse(ParseInfo state, ref int index, FunctionKind mo while (Tools.IsWhiteSpace(code[i])); } } + switch (mode) { case FunctionKind.Setter: @@ -321,7 +323,7 @@ internal static Expression Parse(ParseInfo state, ref int index, FunctionKind mo try { if (mode == FunctionKind.Arrow) - body = new CodeBlock(new CodeNode[] { new ReturnStatement(ExpressionTree.Parse(state, ref i) as Expression) }); + body = new CodeBlock(new CodeNode[] { new Return(ExpressionTree.Parse(state, ref i) as Expression) }); else ExceptionsHelper.ThrowUnknownToken(code, i); } @@ -395,7 +397,7 @@ internal static Expression Parse(ParseInfo state, ref int index, FunctionKind mo func.reference._descriptor.definitionScopeLevel = func.reference.ScopeLevel; } - if (!string.IsNullOrEmpty(name) || parameters.Count != 0) + if (parameters.Count != 0) { var newVariablesCount = body._variables.Length + parameters.Count; @@ -473,7 +475,7 @@ internal static Expression Parse(ParseInfo state, ref int index, FunctionKind mo i++; if (i < code.Length && code[i] == ';') ExceptionsHelper.Throw((new SyntaxError("Expression can not start with word \"function\""))); - return new CallOperator(func, args.ToArray()); + return new Call(func, args.ToArray()); } else i = tindex; @@ -528,10 +530,9 @@ public Function MakeFunction(Module script) /// public Function MakeFunction(Context context) { -#if !PORTABLE if (kind == FunctionKind.Generator || kind == FunctionKind.MethodGenerator || kind == FunctionKind.AnonymousGenerator) - return new GeneratorFunction(new Function(context, this)); -#endif + return new GeneratorFunction(context, this); + return new Function(context, this); } diff --git a/NiL.JS/Expressions/GsPropertyPairExpression.cs b/NiL.JS/Expressions/GetSetPropertyPair.cs similarity index 90% rename from NiL.JS/Expressions/GsPropertyPairExpression.cs rename to NiL.JS/Expressions/GetSetPropertyPair.cs index 6cb0ed0a4..ef4f2bf43 100644 --- a/NiL.JS/Expressions/GsPropertyPairExpression.cs +++ b/NiL.JS/Expressions/GetSetPropertyPair.cs @@ -8,7 +8,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class GsPropertyPairExpression : Expression + public sealed class GetSetPropertyPair : Expression { public Expression Getter { @@ -42,7 +42,7 @@ protected internal override bool ContextIndependent } } - public GsPropertyPairExpression(Expression getter, Expression setter) + public GetSetPropertyPair(Expression getter, Expression setter) : base(getter, setter, true) { tempContainer.valueType = JSValueType.Property; diff --git a/NiL.JS/Expressions/GetVariableExpression.cs b/NiL.JS/Expressions/GetVariable.cs similarity index 96% rename from NiL.JS/Expressions/GetVariableExpression.cs rename to NiL.JS/Expressions/GetVariable.cs index a8aedc293..3247ef1a8 100644 --- a/NiL.JS/Expressions/GetVariableExpression.cs +++ b/NiL.JS/Expressions/GetVariable.cs @@ -10,7 +10,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class GetArgumentsExpression : GetVariableExpression + public sealed class GetArgumentsExpression : GetVariable { internal GetArgumentsExpression(int functionDepth) : base("arguments", functionDepth) @@ -44,7 +44,7 @@ public override JSValue Evaluate(Context context) #if !PORTABLE [Serializable] #endif - public class GetVariableExpression : VariableReference + public class GetVariable : VariableReference { private string variableName; internal bool suspendThrow; @@ -60,7 +60,7 @@ protected internal override bool ContextIndependent } } - internal GetVariableExpression(string name, int scopeDepth) + internal GetVariable(string name, int scopeDepth) { this.ScopeLevel = scopeDepth; int i = 0; @@ -238,8 +238,8 @@ public override void Optimize(ref CodeNode _this, FunctionDefinition owner, Comp lastAssign = assigns[i]; } } - var assign = lastAssign as AssignmentOperator; - if (assign != null && (assign._codeContext & CodeContext.Conditional) == 0 && assign.second is ConstantDefinition) + var assign = lastAssign as Assignment; + if (assign != null && (assign._codeContext & CodeContext.Conditional) == 0 && assign.second is Constant) { _this = assign.second; } diff --git a/NiL.JS/Expressions/InOperator.cs b/NiL.JS/Expressions/In.cs similarity index 94% rename from NiL.JS/Expressions/InOperator.cs rename to NiL.JS/Expressions/In.cs index 889f69413..19123fe08 100644 --- a/NiL.JS/Expressions/InOperator.cs +++ b/NiL.JS/Expressions/In.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class InOperator : Expression + public sealed class In : Expression { protected internal override PredictedType ResultType { @@ -22,7 +22,7 @@ internal override bool ResultInTempContainer get { return false; } } - public InOperator(Expression first, Expression second) + public In(Expression first, Expression second) : base(first, second, false) { diff --git a/NiL.JS/Expressions/IncrementOperator.cs b/NiL.JS/Expressions/Increment.cs similarity index 98% rename from NiL.JS/Expressions/IncrementOperator.cs rename to NiL.JS/Expressions/Increment.cs index 8e2d307bf..e6ac6b0c0 100644 --- a/NiL.JS/Expressions/IncrementOperator.cs +++ b/NiL.JS/Expressions/Increment.cs @@ -14,7 +14,7 @@ public enum IncrimentType #if !PORTABLE [Serializable] #endif - public sealed class IncrementOperator : Expression + public sealed class Increment : Expression { private IncrimentType _type; @@ -70,7 +70,7 @@ protected internal override bool LValueModifier } } - public IncrementOperator(Expression op, IncrimentType type) + public Increment(Expression op, IncrimentType type) : base(op, null, type == IncrimentType.Postincriment) { if (op == null) diff --git a/NiL.JS/Expressions/InstanceOfOperator.cs b/NiL.JS/Expressions/InstanceOf.cs similarity index 92% rename from NiL.JS/Expressions/InstanceOfOperator.cs rename to NiL.JS/Expressions/InstanceOf.cs index 7e8ec381f..433757ffc 100644 --- a/NiL.JS/Expressions/InstanceOfOperator.cs +++ b/NiL.JS/Expressions/InstanceOf.cs @@ -8,7 +8,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class InstanceOfOperator : Expression + public sealed class InstanceOf : Expression { protected internal override PredictedType ResultType { @@ -23,7 +23,7 @@ internal override bool ResultInTempContainer get { return false; } } - public InstanceOfOperator(Expression first, Expression second) + public InstanceOf(Expression first, Expression second) : base(first, second, true) { } @@ -57,7 +57,7 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary(Visitor visitor) public override string ToString() { - if (first is ConstantDefinition - && ((first as ConstantDefinition).value.valueType == JSValueType.Int) - && ((first as ConstantDefinition).value.iValue == -1)) + if (first is Constant + && ((first as Constant).value.valueType == JSValueType.Int) + && ((first as Constant).value.iValue == -1)) return "-" + second; return "(" + first + " * " + second + ")"; } diff --git a/NiL.JS/Expressions/NegationOperator.cs b/NiL.JS/Expressions/Negation.cs similarity index 94% rename from NiL.JS/Expressions/NegationOperator.cs rename to NiL.JS/Expressions/Negation.cs index 83d567add..740e28837 100644 --- a/NiL.JS/Expressions/NegationOperator.cs +++ b/NiL.JS/Expressions/Negation.cs @@ -6,7 +6,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class NegationOperator : Expression + public sealed class Negation : Expression { protected internal override PredictedType ResultType { @@ -21,7 +21,7 @@ internal override bool ResultInTempContainer get { return true; } } - public NegationOperator(Expression first) + public Negation(Expression first) : base(first, null, true) { diff --git a/NiL.JS/Expressions/NewOperator.cs b/NiL.JS/Expressions/New.cs similarity index 83% rename from NiL.JS/Expressions/NewOperator.cs rename to NiL.JS/Expressions/New.cs index e9e3cca8e..04745b38d 100644 --- a/NiL.JS/Expressions/NewOperator.cs +++ b/NiL.JS/Expressions/New.cs @@ -10,7 +10,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class NewOperator : Expression + public sealed class New : Expression { protected internal override bool ContextIndependent { @@ -33,7 +33,7 @@ protected internal override PredictedType ResultType } } - internal NewOperator(CallOperator call) + internal New(Call call) : base(call, null, false) { @@ -52,13 +52,13 @@ public static CodeNode Parse(ParseInfo state, ref int index) var cord = CodeCoordinates.FromTextPosition(state.Code, i, 0); ExceptionsHelper.Throw((new SyntaxError("Invalid prefix operation. " + cord))); } - if (result is CallOperator) - result = new NewOperator(result as CallOperator) { Position = index, Length = i - index }; + if (result is Call) + result = new New(result as Call) { Position = index, Length = i - index }; else { if (state.message != null) state.message(MessageLevel.Warning, CodeCoordinates.FromTextPosition(state.Code, index, 0), "Missed brackets in a constructor invocation."); - result = new Expressions.NewOperator(new CallOperator(result, new Expression[0]) { Position = result.Position, Length = result.Length }) { Position = index, Length = i - index }; + result = new Expressions.New(new Call(result, new Expression[0]) { Position = result.Position, Length = result.Length }) { Position = index, Length = i - index }; } index = i; return result; @@ -74,7 +74,7 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary((Expression)name, new GsPropertyPairExpression((Expression)initializer, null))); + computedProperties.Add(new KeyValuePair((Expression)name, new GetSetPropertyPair((Expression)initializer, null))); break; } case 's': { - computedProperties.Add(new KeyValuePair((Expression)name, new GsPropertyPairExpression(null, (Expression)initializer))); + computedProperties.Add(new KeyValuePair((Expression)name, new GetSetPropertyPair(null, (Expression)initializer))); break; } default: @@ -141,7 +141,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var accessorName = propertyAccessor._name; if (!flds.ContainsKey(accessorName)) { - var propertyPair = new GsPropertyPairExpression + var propertyPair = new GetSetPropertyPair ( mode == FunctionKind.Getter ? propertyAccessor : null, mode == FunctionKind.Setter ? propertyAccessor : null @@ -150,7 +150,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) } else { - var vle = flds[accessorName] as GsPropertyPairExpression; + var vle = flds[accessorName] as GetSetPropertyPair; if (vle == null) ExceptionsHelper.ThrowSyntaxError("Try to define " + mode.ToString().ToLowerInvariant() + " for defined field", state.Code, s); @@ -233,8 +233,8 @@ internal static CodeNode Parse(ParseInfo state, ref int index) Expression aei = null; if (flds.TryGetValue(fieldName, out aei)) { - if (state.strict ? (!(aei is ConstantDefinition) || (aei as ConstantDefinition).value != JSValue.undefined) - : aei is GsPropertyPairExpression) + if (state.strict ? (!(aei is Constant) || (aei as Constant).value != JSValue.undefined) + : aei is GetSetPropertyPair) ExceptionsHelper.ThrowSyntaxError("Try to redefine field \"" + fieldName + "\"", state.Code, s, i - s); if (state.message != null) state.message(MessageLevel.Warning, CodeCoordinates.FromTextPosition(state.Code, i, 0), "Duplicate key \"" + fieldName + "\""); @@ -252,7 +252,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) while (Tools.IsWhiteSpace(state.Code[i])); } - initializer = new GetVariableExpression(fieldName, state.lexicalScopeLevel); + initializer = new GetVariable(fieldName, state.lexicalScopeLevel); } else { @@ -452,7 +452,7 @@ public override void Decompose(ref Expression self, IList result) { if (!(values[i] is ExtractStoredValue)) { - result.Add(new StoreValueStatement(values[i], false)); + result.Add(new StoreValue(values[i], false)); values[i] = new ExtractStoredValue(values[i]); } } @@ -464,12 +464,12 @@ public override void Decompose(ref Expression self, IList result) if (!(computedProperties[i].Key is ExtractStoredValue)) { - result.Add(new StoreValueStatement(computedProperties[i].Key, false)); + result.Add(new StoreValue(computedProperties[i].Key, false)); key = new ExtractStoredValue(computedProperties[i].Key); } if (!(computedProperties[i].Value is ExtractStoredValue)) { - result.Add(new StoreValueStatement(computedProperties[i].Value, false)); + result.Add(new StoreValue(computedProperties[i].Value, false)); value = new ExtractStoredValue(computedProperties[i].Value); } if ((key != null) @@ -485,9 +485,9 @@ public override string ToString() string res = "{ "; for (int i = 0; i < fieldNames.Length; i++) { - if ((values[i] is ConstantDefinition) && ((values[i] as ConstantDefinition).value.valueType == JSValueType.Property)) + if ((values[i] is Constant) && ((values[i] as Constant).value.valueType == JSValueType.Property)) { - var gs = (values[i] as ConstantDefinition).value.oValue as CodeNode[]; + var gs = (values[i] as Constant).value.oValue as CodeNode[]; res += gs[0]; if (gs[0] != null && gs[1] != null) res += ", "; diff --git a/NiL.JS/Expressions/GetPropertyOperator.cs b/NiL.JS/Expressions/Property.cs similarity index 87% rename from NiL.JS/Expressions/GetPropertyOperator.cs rename to NiL.JS/Expressions/Property.cs index 059eb99d0..0a9115ccb 100644 --- a/NiL.JS/Expressions/GetPropertyOperator.cs +++ b/NiL.JS/Expressions/Property.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class GetPropertyOperator : Expression + public sealed class Property : Expression { private JSValue cachedMemberName; private PropertyScope memberScope; @@ -28,7 +28,7 @@ internal override bool ResultInTempContainer get { return false; } } - internal GetPropertyOperator(Expression source, Expression fieldName) + internal Property(Expression source, Expression fieldName) : base(source, fieldName, false) { } @@ -79,13 +79,13 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary 0 - && (Parser.ValidateName((second as ConstantDefinition).value.ToString(), ref i, true))) - res += "." + (second as ConstantDefinition).value; + if (second is Constant + && (second as Constant).value.ToString().Length > 0 + && (Parser.ValidateName((second as Constant).value.ToString(), ref i, true))) + res += "." + (second as Constant).value; else res += "[" + second + "]"; return res; diff --git a/NiL.JS/Expressions/RegExpCreateExpression.cs b/NiL.JS/Expressions/RegExpCreate.cs similarity index 94% rename from NiL.JS/Expressions/RegExpCreateExpression.cs rename to NiL.JS/Expressions/RegExpCreate.cs index 29f203169..4d4fb4897 100644 --- a/NiL.JS/Expressions/RegExpCreateExpression.cs +++ b/NiL.JS/Expressions/RegExpCreate.cs @@ -1,12 +1,7 @@ using System; using NiL.JS.BaseLibrary; -using NiL.JS.Expressions; using NiL.JS.Core; - -#if !PORTABLE -using NiL.JS.Core.JIT; using NiL.JS.Statements; -#endif namespace NiL.JS.Expressions { @@ -65,7 +60,7 @@ public static CodeNode Parse(ParseInfo state, ref int position) { if (state.message != null) state.message(MessageLevel.Error, CodeCoordinates.FromTextPosition(state.Code, i - value.Length, value.Length), string.Format(Strings.InvalidRegExp, value)); - return new ExpressionWrapper(new ThrowStatement(e)); + return new ExpressionWrapper(new Throw(e)); } } diff --git a/NiL.JS/Expressions/SetPropertyExpression.cs b/NiL.JS/Expressions/SetProperty.cs similarity index 92% rename from NiL.JS/Expressions/SetPropertyExpression.cs rename to NiL.JS/Expressions/SetProperty.cs index 3be2dcf23..bb65e021d 100644 --- a/NiL.JS/Expressions/SetPropertyExpression.cs +++ b/NiL.JS/Expressions/SetProperty.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class SetPropertyExpression : Expression + public sealed class SetProperty : Expression { private JSValue tempContainer1; private JSValue tempContainer2; @@ -31,10 +31,10 @@ internal override bool ResultInTempContainer get { return true; } } - internal SetPropertyExpression(Expression obj, Expression fieldName, Expression value) + internal SetProperty(Expression obj, Expression fieldName, Expression value) : base(obj, fieldName, true) { - if (fieldName is ConstantDefinition) + if (fieldName is Constant) cachedMemberName = fieldName.Evaluate(null); else tempContainer1 = new JSValue(); @@ -113,8 +113,8 @@ public override string ToString() { var res = first.ToString(); int i = 0; - var cn = second as ConstantDefinition; - if (second is ConstantDefinition + var cn = second as Constant; + if (second is Constant && cn.value.ToString().Length > 0 && (Parser.ValidateName(cn.value.ToString(), ref i, true))) res += "." + cn.value; diff --git a/NiL.JS/Expressions/SignedShiftLeftOperator.cs b/NiL.JS/Expressions/SignedShiftLeft.cs similarity index 87% rename from NiL.JS/Expressions/SignedShiftLeftOperator.cs rename to NiL.JS/Expressions/SignedShiftLeft.cs index 8197fddd1..7545d75ce 100644 --- a/NiL.JS/Expressions/SignedShiftLeftOperator.cs +++ b/NiL.JS/Expressions/SignedShiftLeft.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class SignedShiftLeftOperator : Expression + public sealed class SignedShiftLeft : Expression { protected internal override PredictedType ResultType { @@ -22,7 +22,7 @@ internal override bool ResultInTempContainer get { return true; } } - public SignedShiftLeftOperator(Expression first, Expression second) + public SignedShiftLeft(Expression first, Expression second) : base(first, second, true) { @@ -43,9 +43,9 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary _parts; @@ -52,7 +52,7 @@ internal override bool ResultInTempContainer get { return true; } } - public StringConcatenationExpression(IList sources) + public StringConcatenation(IList sources) : base(null, null, true) { if (sources.Count < 2) @@ -118,7 +118,7 @@ public override void Decompose(ref Expression self, IList result) { if (!(_parts[i] is ExtractStoredValue)) { - result.Add(new StoreValueStatement(_parts[i], false)); + result.Add(new StoreValue(_parts[i], false)); _parts[i] = new ExtractStoredValue(_parts[i]); } } diff --git a/NiL.JS/Expressions/SubstractOperator.cs b/NiL.JS/Expressions/Substract.cs similarity index 91% rename from NiL.JS/Expressions/SubstractOperator.cs rename to NiL.JS/Expressions/Substract.cs index 44e1f69ef..f3c638dd6 100644 --- a/NiL.JS/Expressions/SubstractOperator.cs +++ b/NiL.JS/Expressions/Substract.cs @@ -10,7 +10,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class SubstractOperator : Expression + public sealed class Substract : Expression { protected internal override PredictedType ResultType { @@ -25,7 +25,7 @@ internal override bool ResultInTempContainer get { return true; } } - public SubstractOperator(Expression first, Expression second) + public Substract(Expression first, Expression second) : base(first, second, true) { @@ -88,9 +88,9 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary variables, CodeContext codeContext, CompilerMessageCallback message, FunctionInfo stats, Options opts) diff --git a/NiL.JS/Expressions/TypeOfOperator.cs b/NiL.JS/Expressions/TypeOf.cs similarity index 93% rename from NiL.JS/Expressions/TypeOfOperator.cs rename to NiL.JS/Expressions/TypeOf.cs index 6c6968b2a..15ae8962a 100644 --- a/NiL.JS/Expressions/TypeOfOperator.cs +++ b/NiL.JS/Expressions/TypeOf.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class TypeOfOperator : Expression + public sealed class TypeOf : Expression { private static readonly JSValue numberString = "number"; private static readonly JSValue undefinedString = "undefined"; @@ -30,7 +30,7 @@ internal override bool ResultInTempContainer get { return false; } } - public TypeOfOperator(Expression first) + public TypeOf(Expression first) : base(first, null, false) { if (second != null) @@ -79,8 +79,8 @@ public override JSValue Evaluate(Context context) public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary variables, CodeContext codeContext, CompilerMessageCallback message, FunctionInfo stats, Options opts) { base.Build(ref _this, expressionDepth, variables, codeContext, message, stats, opts); - if (first is GetVariableExpression) - (first as GetVariableExpression).suspendThrow = true; + if (first is GetVariable) + (first as GetVariable).suspendThrow = true; return false; } diff --git a/NiL.JS/Expressions/UnsignedShiftRightOperator.cs b/NiL.JS/Expressions/UnsignedShiftRight.cs similarity index 88% rename from NiL.JS/Expressions/UnsignedShiftRightOperator.cs rename to NiL.JS/Expressions/UnsignedShiftRight.cs index 948a6c7da..13c1a78de 100644 --- a/NiL.JS/Expressions/UnsignedShiftRightOperator.cs +++ b/NiL.JS/Expressions/UnsignedShiftRight.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Expressions #if !PORTABLE [Serializable] #endif - public sealed class UnsignedShiftRightOperator : Expression + public sealed class UnsignedShiftRight : Expression { internal override bool ResultInTempContainer { @@ -22,7 +22,7 @@ protected internal override PredictedType ResultType } } - public UnsignedShiftRightOperator(Expression first, Expression second) + public UnsignedShiftRight(Expression first, Expression second) : base(first, second, true) { @@ -53,9 +53,9 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary result) if ((_codeContext & CodeContext.InExpression) != 0) { - result.Add(new StoreValueStatement(this, false)); + result.Add(new StoreValue(this, false)); self = new ExtractStoredValue(this); } } diff --git a/NiL.JS/Extensions/IterationProtocolExtensions.cs b/NiL.JS/Extensions/IterationProtocolExtensions.cs index 9e7b1944d..07505630e 100644 --- a/NiL.JS/Extensions/IterationProtocolExtensions.cs +++ b/NiL.JS/Extensions/IterationProtocolExtensions.cs @@ -133,7 +133,7 @@ internal sealed class IterableAdapter : IIterable [Hidden] public IterableAdapter(JSValue source) { - this.source = source; + this.source = source.IsBox ? source.oValue as JSValue : source; } public IIterator iterator() diff --git a/NiL.JS/Extensions/JSValueExtensions.cs b/NiL.JS/Extensions/JSValueExtensions.cs index b7cbe01e7..881fd357f 100644 --- a/NiL.JS/Extensions/JSValueExtensions.cs +++ b/NiL.JS/Extensions/JSValueExtensions.cs @@ -9,8 +9,6 @@ namespace NiL.JS.Extensions { public static class JSValueExtensions { - private static WeakReference dynamicAssembly = new WeakReference(null); - public static bool Is(this JSValue self, JSValueType type) { return self != null && self.valueType == type; @@ -20,7 +18,11 @@ public static bool Is(this JSValue self) { if (self == null) return false; +#if PORTABLE + switch (typeof(T).GetTypeCode()) +#else switch (Type.GetTypeCode(typeof(T))) +#endif { case TypeCode.Boolean: { @@ -93,7 +95,11 @@ public static bool Is(this JSValue self) public static T As(this JSValue self) { +#if PORTABLE + switch (typeof(T).GetTypeCode()) +#else switch (Type.GetTypeCode(typeof(T))) +#endif { case TypeCode.Boolean: return (T)(object)(bool)self; // оптимизатор разруливает такой каскад преобразований @@ -160,7 +166,9 @@ public static T As(this JSValue self) throw new InvalidCastException(); } -#if DEBUG // TODO +#if DEBUG && !PORTABLE // TODO + private static WeakReference dynamicAssembly = new WeakReference(null); + public static T AsImplementationOf(this JSValue self) { if (!typeof(T).IsInterface) diff --git a/NiL.JS/NiL.JS.csproj b/NiL.JS/NiL.JS.csproj index c6e9055ae..daeb2c963 100644 --- a/NiL.JS/NiL.JS.csproj +++ b/NiL.JS/NiL.JS.csproj @@ -244,10 +244,10 @@ - - + + - + @@ -284,9 +284,9 @@ - + - + @@ -317,92 +317,92 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - - - + + + + + + + True True diff --git a/NiL.JS/Statements/BreakStatement.cs b/NiL.JS/Statements/Break.cs similarity index 96% rename from NiL.JS/Statements/BreakStatement.cs rename to NiL.JS/Statements/Break.cs index 388b0a2e0..ed1d518e1 100644 --- a/NiL.JS/Statements/BreakStatement.cs +++ b/NiL.JS/Statements/Break.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class BreakStatement : CodeNode + public sealed class Break : CodeNode { private JSValue label; @@ -33,7 +33,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var pos = index; index = i; state.breaksCount++; - return new BreakStatement() + return new Break() { label = label, Position = pos, diff --git a/NiL.JS/Statements/CodeBlock.cs b/NiL.JS/Statements/CodeBlock.cs index 8b6954506..c70a89bdc 100644 --- a/NiL.JS/Statements/CodeBlock.cs +++ b/NiL.JS/Statements/CodeBlock.cs @@ -165,7 +165,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) } for (var j = body.Count; j-- > 0;) - (body[j] as ConstantDefinition).value.oValue = Tools.Unescape((body[j] as ConstantDefinition).value.oValue.ToString(), state.strict); + (body[j] as Constant).value.oValue = Tools.Unescape((body[j] as Constant).value.oValue.ToString(), state.strict); bool expectSemicolon = false; while ((sroot && position < state.Code.Length) || (!sroot && state.Code[position] != '}')) @@ -252,8 +252,9 @@ internal static VariableDescriptor[] extractVariables(ParseInfo state, int oldVa variables[targetIndex] = state.Variables[i]; if (declaredVariables != null) { - if (declaredVariables.Contains(variables[targetIndex].name)) + if (declaredVariables.Contains(variables[targetIndex].name) && variables[targetIndex].lexicalScope) ExceptionsHelper.ThrowSyntaxError("Variable \"" + variables[targetIndex].name + "\" has already been defined", state.Code, i); + declaredVariables.Add(variables[targetIndex].name); } targetIndex++; @@ -426,7 +427,7 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary(); @@ -456,7 +457,7 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary 0 && (_variables == null || _variables.Length == 0)) { if (lines.Length == 0) - _this = EmptyExpression.Instance; + _this = Empty.Instance; } else { @@ -612,7 +613,7 @@ public override void RebuildScope(FunctionInfo functionInfo, Dictionary 0;) + for (var i = 0; i < _variables.Length; i++) { var v = _variables[i]; @@ -677,8 +678,6 @@ internal void initVariables(Context context) if (v.cacheContext.fields == null) v.cacheContext.fields = JSObject.getFieldsContainer(); v.cacheContext.fields[v.name] = v.cacheRes; - v.cacheContext = null; - v.cacheRes = null; } if (v.lexicalScope) diff --git a/NiL.JS/Statements/ContinueStatement.cs b/NiL.JS/Statements/Continue.cs similarity index 95% rename from NiL.JS/Statements/ContinueStatement.cs rename to NiL.JS/Statements/Continue.cs index d4a290c0b..59f41439c 100644 --- a/NiL.JS/Statements/ContinueStatement.cs +++ b/NiL.JS/Statements/Continue.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class ContinueStatement : CodeNode + public sealed class Continue : CodeNode { private JSValue label; @@ -32,7 +32,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) int pos = index; index = i; state.continiesCount++; - return new ContinueStatement() + return new Continue() { label = label, Position = pos, diff --git a/NiL.JS/Statements/DebuggerStatement.cs b/NiL.JS/Statements/Debugger.cs similarity index 95% rename from NiL.JS/Statements/DebuggerStatement.cs rename to NiL.JS/Statements/Debugger.cs index 51dd00f94..91b780980 100644 --- a/NiL.JS/Statements/DebuggerStatement.cs +++ b/NiL.JS/Statements/Debugger.cs @@ -7,7 +7,7 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class DebuggerStatement : CodeNode + public sealed class Debugger : CodeNode { internal static CodeNode Parse(ParseInfo state, ref int index) { @@ -17,7 +17,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) i ^= index; index ^= i; i ^= index; - return new DebuggerStatement() + return new Debugger() { Position = i, Length = index - i diff --git a/NiL.JS/Statements/DoWhileStatement.cs b/NiL.JS/Statements/DoWhile.cs similarity index 95% rename from NiL.JS/Statements/DoWhileStatement.cs rename to NiL.JS/Statements/DoWhile.cs index 5b8d01a99..4abf422f8 100644 --- a/NiL.JS/Statements/DoWhileStatement.cs +++ b/NiL.JS/Statements/DoWhile.cs @@ -10,7 +10,7 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class DoWhileStatement : CodeNode + public sealed class DoWhile : CodeNode { private bool allowRemove; private CodeNode condition; @@ -21,7 +21,7 @@ public sealed class DoWhileStatement : CodeNode public CodeNode Body { get { return body; } } public ICollection Labels { get { return new ReadOnlyCollection(labels); } } - private DoWhileStatement() + private DoWhile() { } @@ -76,7 +76,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) i++; var pos = index; index = i; - return new DoWhileStatement() + return new DoWhile() { allowRemove = ccs == state.continiesCount && cbs == state.breaksCount, body = body, @@ -152,10 +152,10 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary Labels { get { return new ReadOnlyCollection(labels); } } - private ForStatement() + private For() { } @@ -50,7 +50,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) state.lexicalScopeLevel++; try { - init = VariableDefinitionStatement.Parse(state, ref i, true); + init = VariableDefinition.Parse(state, ref i, true); if (init == null) init = ExpressionTree.Parse(state, ref i, forForLoop: true); if ((init is ExpressionTree) @@ -81,7 +81,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) try { body = Parser.Parse(state, ref i, 0); - var vds = body as VariableDefinitionStatement; + var vds = body as VariableDefinition; if (vds != null) { if (vds.Kind >= VariableKind.ConstantInLexicalScope) @@ -102,7 +102,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) int startPos = index; index = i; - result = new ForStatement() + result = new For() { body = body, condition = condition, @@ -237,9 +237,9 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary= 0 && variable._descriptor.definitionScopeLevel >= 0) { - if (initializer is NiL.JS.Expressions.AssignmentOperator - && (initializer as NiL.JS.Expressions.AssignmentOperator).FirstOperand is GetVariableExpression - && ((initializer as NiL.JS.Expressions.AssignmentOperator).FirstOperand as GetVariableExpression)._descriptor == variable._descriptor) + if (initializer is NiL.JS.Expressions.Assignment + && (initializer as NiL.JS.Expressions.Assignment).FirstOperand is GetVariable + && ((initializer as NiL.JS.Expressions.Assignment).FirstOperand as GetVariable)._descriptor == variable._descriptor) { - var value = (initializer as NiL.JS.Expressions.AssignmentOperator).SecondOperand; - if (value is ConstantDefinition) + var value = (initializer as NiL.JS.Expressions.Assignment).SecondOperand; + if (value is Constant) { var vvalue = value.Evaluate(null); var lvalue = limit.Evaluate(null); @@ -308,14 +308,14 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary Labels } } - private ForInStatement() + private ForIn() { } @@ -55,17 +55,18 @@ internal static CodeNode Parse(ParseInfo state, ref int index) while (Tools.IsWhiteSpace(state.Code[i])) i++; - var result = new ForInStatement() + var result = new ForIn() { labels = state.Labels.GetRange(state.Labels.Count - state.LabelsCount, state.LabelsCount).ToArray() }; + VariableDescriptor[] vars = null; var oldVariablesCount = state.Variables.Count; state.lexicalScopeLevel++; try { var vStart = i; - if ((result._variable = VariableDefinitionStatement.Parse(state, ref i, true)) != null) + if ((result._variable = VariableDefinition.Parse(state, ref i, true)) != null) { } else @@ -96,7 +97,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) if (varName == "arguments" || varName == "eval") ExceptionsHelper.Throw((new SyntaxError("Parameters name may not be \"arguments\" or \"eval\" in strict mode at " + CodeCoordinates.FromTextPosition(state.Code, start, i - start)))); } - result._variable = new GetVariableExpression(varName, state.lexicalScopeLevel) { Position = start, Length = i - start, ScopeLevel = state.lexicalScopeLevel }; + result._variable = new GetVariable(varName, state.lexicalScopeLevel) { Position = start, Length = i - start, ScopeLevel = state.lexicalScopeLevel }; while (Tools.IsWhiteSpace(state.Code[i])) i++; @@ -108,8 +109,8 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var defVal = ExpressionTree.Parse(state, ref i, false, false, false, true, true); if (defVal == null) return defVal; - Expression exp = new AssignmentOperatorCache(result._variable as GetVariableExpression ?? (result._variable as VariableDefinitionStatement).initializers[0] as GetVariableExpression); - exp = new AssignmentOperator( + Expression exp = new AssignmentOperatorCache(result._variable as GetVariable ?? (result._variable as VariableDefinition).initializers[0] as GetVariable); + exp = new Assignment( exp, (Expression)defVal) { @@ -119,7 +120,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) if (result._variable == exp.first.first) result._variable = exp; else - (result._variable as VariableDefinitionStatement).initializers[0] = exp; + (result._variable as VariableDefinition).initializers[0] = exp; while (Tools.IsWhiteSpace(state.Code[i])) i++; } @@ -135,9 +136,9 @@ internal static CodeNode Parse(ParseInfo state, ref int index) state.LabelsCount = 0; Tools.SkipSpaces(state.Code, ref i); - if (result._variable is VariableDefinitionStatement) + if (result._variable is VariableDefinition) { - if ((result._variable as VariableDefinitionStatement).variables.Length > 1) + if ((result._variable as VariableDefinition).variables.Length > 1) ExceptionsHelper.ThrowSyntaxError("Too many variables in for-in loop", state.Code, i); } @@ -156,13 +157,13 @@ internal static CodeNode Parse(ParseInfo state, ref int index) result.Position = index; result.Length = i - index; index = i; + vars = CodeBlock.extractVariables(state, oldVariablesCount); } finally { state.lexicalScopeLevel--; } - var vars = CodeBlock.extractVariables(state, oldVariablesCount); return new CodeBlock(new[] { result }) { _variables = vars, Position = result.Position, Length = result.Length }; } @@ -198,16 +199,16 @@ public override JSValue Evaluate(Context context) if (context.debugging && !(_variable is CodeBlock)) context.raiseDebugger(_variable); #endif - var varialeDefStat = _variable as VariableDefinitionStatement; + var varialeDefStat = _variable as VariableDefinition; if (varialeDefStat != null) { _variable.Evaluate(context); variable = (varialeDefStat.initializers[0].first ?? varialeDefStat.initializers[0]).EvaluateForWrite(context); } - else if (_variable is AssignmentOperator) + else if (_variable is Assignment) { _variable.Evaluate(context); - variable = (_variable as AssignmentOperator).first.Evaluate(context); + variable = (_variable as Assignment).first.Evaluate(context); } else variable = _variable.EvaluateForWrite(context); @@ -308,16 +309,16 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary Labels get { #if PORTABLE - return new ReadOnlyCollection(labels); + return new ReadOnlyCollection(_labels); #else return System.Array.AsReadOnly(_labels); #endif } } - private ForOfStatement() + private ForOf() { } @@ -55,17 +55,18 @@ internal static CodeNode Parse(ParseInfo state, ref int index) while (Tools.IsWhiteSpace(state.Code[i])) i++; - var result = new ForOfStatement() + var result = new ForOf() { _labels = state.Labels.GetRange(state.Labels.Count - state.LabelsCount, state.LabelsCount).ToArray() }; - + + VariableDescriptor[] vars = null; var oldVariablesCount = state.Variables.Count; state.lexicalScopeLevel++; try { var vStart = i; - if ((result._variable = VariableDefinitionStatement.Parse(state, ref i, true)) != null) + if ((result._variable = VariableDefinition.Parse(state, ref i, true)) != null) { } else @@ -84,7 +85,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) if (varName == "arguments" || varName == "eval") ExceptionsHelper.Throw((new SyntaxError("Parameters name may not be \"arguments\" or \"eval\" in strict mode at " + CodeCoordinates.FromTextPosition(state.Code, start, i - start)))); } - result._variable = new GetVariableExpression(varName, state.lexicalScopeLevel) { Position = start, Length = i - start, ScopeLevel = state.lexicalScopeLevel }; + result._variable = new GetVariable(varName, state.lexicalScopeLevel) { Position = start, Length = i - start, ScopeLevel = state.lexicalScopeLevel }; } while (Tools.IsWhiteSpace(state.Code[i])) i++; @@ -96,8 +97,8 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var defVal = ExpressionTree.Parse(state, ref i, false, false, false, true, true); if (defVal == null) return defVal; - Expression exp = new AssignmentOperatorCache(result._variable as GetVariableExpression ?? (result._variable as VariableDefinitionStatement).initializers[0] as GetVariableExpression); - exp = new AssignmentOperator( + Expression exp = new AssignmentOperatorCache(result._variable as GetVariable ?? (result._variable as VariableDefinition).initializers[0] as GetVariable); + exp = new Assignment( exp, (Expression)defVal) { @@ -107,7 +108,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) if (result._variable == exp.first.first) result._variable = exp; else - (result._variable as VariableDefinitionStatement).initializers[0] = exp; + (result._variable as VariableDefinition).initializers[0] = exp; while (Tools.IsWhiteSpace(state.Code[i])) i++; @@ -122,9 +123,9 @@ internal static CodeNode Parse(ParseInfo state, ref int index) state.LabelsCount = 0; Tools.SkipSpaces(state.Code, ref i); - if (result._variable is VariableDefinitionStatement) + if (result._variable is VariableDefinition) { - if ((result._variable as VariableDefinitionStatement).variables.Length > 1) + if ((result._variable as VariableDefinition).variables.Length > 1) ExceptionsHelper.ThrowSyntaxError("Too many variables in for-of loop", state.Code, i); } @@ -143,14 +144,19 @@ internal static CodeNode Parse(ParseInfo state, ref int index) result.Position = index; result.Length = i - index; index = i; + vars = CodeBlock.extractVariables(state, oldVariablesCount); } finally { state.lexicalScopeLevel--; } - var vars = CodeBlock.extractVariables(state, oldVariablesCount); - return new CodeBlock(new[] { result }) { _variables = vars, Position = result.Position, Length = result.Length }; + return new CodeBlock(new[] { result }) + { + _variables = vars, + Position = result.Position, + Length = result.Length + }; } public override JSValue Evaluate(Context context) @@ -185,16 +191,16 @@ public override JSValue Evaluate(Context context) if (context.debugging && !(_variable is CodeBlock)) context.raiseDebugger(_variable); #endif - var varialeDefStat = _variable as VariableDefinitionStatement; + var varialeDefStat = _variable as VariableDefinition; if (varialeDefStat != null) { _variable.Evaluate(context); variable = (varialeDefStat.initializers[0].first ?? varialeDefStat.initializers[0]).EvaluateForWrite(context); } - else if (_variable is AssignmentOperator) + else if (_variable is Assignment) { _variable.Evaluate(context); - variable = (_variable as AssignmentOperator).first.Evaluate(context); + variable = (_variable as Assignment).first.Evaluate(context); } else variable = _variable.EvaluateForWrite(context); @@ -276,16 +282,16 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary Labels { get { return new ReadOnlyCollection(labels); } } - internal InfinityLoopStatement(CodeNode body, string[] labels) + internal InfinityLoop(CodeNode body, string[] labels) { - this.body = body ?? new EmptyExpression(); + this.body = body ?? new Empty(); this.labels = labels; } diff --git a/NiL.JS/Statements/ReturnStatement.cs b/NiL.JS/Statements/Return.cs similarity index 61% rename from NiL.JS/Statements/ReturnStatement.cs rename to NiL.JS/Statements/Return.cs index 0d26b81ee..dc54d97a3 100644 --- a/NiL.JS/Statements/ReturnStatement.cs +++ b/NiL.JS/Statements/Return.cs @@ -13,20 +13,20 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class ReturnStatement : CodeNode + public sealed class Return : CodeNode { - private Expression body; + private Expression value; - public Expression Body { get { return body; } } + public Expression Value { get { return value; } } - internal ReturnStatement() + internal Return() { } - internal ReturnStatement(Expressions.Expression body) + internal Return(Expression value) { - this.body = body; + this.value = value; } internal static CodeNode Parse(ParseInfo state, ref int index) @@ -41,9 +41,9 @@ internal static CodeNode Parse(ParseInfo state, ref int index) var body = state.Code[i] == ';' || Tools.IsLineTerminator(state.Code[i]) ? null : Parser.Parse(state, ref i, CodeFragmentType.Expression); var pos = index; index = i; - return new ReturnStatement() + return new Return() { - body = (Expressions.Expression)body, + value = (Expression)body, Position = pos, Length = index - pos }; @@ -51,7 +51,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) public override JSValue Evaluate(Context context) { - var result = body != null ? body.Evaluate(context) : null; + var result = value != null ? value.Evaluate(context) : null; if (context.abortReason == AbortReason.None) { context.abortInfo = result; @@ -63,62 +63,62 @@ public override JSValue Evaluate(Context context) protected internal override CodeNode[] getChildsImpl() { - if (body != null) - return new CodeNode[] { body }; + if (value != null) + return new CodeNode[] { value }; return new CodeNode[0]; } public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary variables, CodeContext codeContext, CompilerMessageCallback message, FunctionInfo stats, Options opts) { - Parser.Build(ref body, expressionDepth + 1, variables, codeContext | CodeContext.InExpression, message, stats, opts); + Parser.Build(ref value, expressionDepth + 1, variables, codeContext | CodeContext.InExpression, message, stats, opts); // Улучшает работу оптимизатора хвостовой рекурсии - if (message == null && body is NiL.JS.Expressions.ConditionalOperator) + if (message == null && value is Conditional) { - var bat = body as NiL.JS.Expressions.ConditionalOperator; + var bat = value as NiL.JS.Expressions.Conditional; var bts = bat.Threads; - _this = new IfElseStatement(bat.FirstOperand, new ReturnStatement(bts[0]), new ReturnStatement(bts[1])) { Position = bat.Position, Length = bat.Length }; + _this = new IfElse(bat.FirstOperand, new Return(bts[0]), new Return(bts[1])) { Position = bat.Position, Length = bat.Length }; return true; } - else if (body is NiL.JS.Expressions.CallOperator) + else if (value is Call) { - (body as NiL.JS.Expressions.CallOperator).allowTCO = true; + (value as Call).allowTCO = true; } - stats.Returns.Add(body ?? EmptyExpression.Instance); + stats.Returns.Add(value ?? Empty.Instance); return false; } public override void Optimize(ref CodeNode _this, Expressions.FunctionDefinition owner, CompilerMessageCallback message, Options opts, FunctionInfo stats) { - if (body != null) + if (value != null) { - var t = body as CodeNode; - body.Optimize(ref t, owner, message, opts, stats); - body = (Expressions.Expression)t; + var t = value as CodeNode; + value.Optimize(ref t, owner, message, opts, stats); + value = (Expression)t; - if (body is EmptyExpression || ((body is ConstantDefinition) && body.Evaluate(null) == JSValue.undefined)) - body = null; + if (value is Empty || ((value is Constant) && value.Evaluate(null) == JSValue.undefined)) + value = null; } } public override void Decompose(ref CodeNode self) { - if (body != null) - body.Decompose(ref body); + if (value != null) + value.Decompose(ref value); } public override void RebuildScope(FunctionInfo functionInfo, Dictionary transferedVariables, int scopeBias) { - body?.RebuildScope(functionInfo, transferedVariables, scopeBias); + value?.RebuildScope(functionInfo, transferedVariables, scopeBias); } #if !PORTABLE && !NET35 internal override System.Linq.Expressions.Expression TryCompile(bool selfCompile, bool forAssign, Type expectedType, List dynamicValues) { - var b = body.TryCompile(false, false, null, dynamicValues); + var b = value.TryCompile(false, false, null, dynamicValues); if (b != null) - body = new CompiledNode(body, b, JITHelpers._items.GetValue(dynamicValues) as CodeNode[]); + value = new CompiledNode(value, b, JITHelpers._items.GetValue(dynamicValues) as CodeNode[]); return null; } #endif @@ -129,7 +129,7 @@ public override T Visit(Visitor visitor) public override string ToString() { - return "return" + (body != null ? " " + body : ""); + return "return" + (value != null ? " " + value : ""); } } } \ No newline at end of file diff --git a/NiL.JS/Statements/StoreValueStatement.cs b/NiL.JS/Statements/StoreValue.cs similarity index 94% rename from NiL.JS/Statements/StoreValueStatement.cs rename to NiL.JS/Statements/StoreValue.cs index 27e27ffab..c4e2880b6 100644 --- a/NiL.JS/Statements/StoreValueStatement.cs +++ b/NiL.JS/Statements/StoreValue.cs @@ -5,7 +5,7 @@ namespace NiL.JS.Statements { - public sealed class StoreValueStatement : CodeNode + public sealed class StoreValue : CodeNode { private readonly Expression _source; private readonly bool _forWrite; @@ -42,7 +42,7 @@ public bool ForWrite } } - public StoreValueStatement(Expression source, bool forWrite) + public StoreValue(Expression source, bool forWrite) { _source = source; _forWrite = forWrite; diff --git a/NiL.JS/Statements/SwitchStatement.cs b/NiL.JS/Statements/Switch.cs similarity index 97% rename from NiL.JS/Statements/SwitchStatement.cs rename to NiL.JS/Statements/Switch.cs index 4b9989d68..c4a5de62f 100644 --- a/NiL.JS/Statements/SwitchStatement.cs +++ b/NiL.JS/Statements/Switch.cs @@ -22,7 +22,7 @@ public sealed class SwitchCase #if !PORTABLE [Serializable] #endif - public sealed class SwitchStatement : CodeNode + public sealed class Switch : CodeNode { private sealed class SuspendData { @@ -41,7 +41,7 @@ private sealed class SuspendData public SwitchCase[] Cases { get { return cases; } } public CodeNode Image { get { return image; } } - internal SwitchStatement(CodeNode[] body) + internal Switch(CodeNode[] body) { this.lines = body; } @@ -71,6 +71,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) cases.Add(new SwitchCase() { index = int.MaxValue }); state.AllowBreak.Push(true); var oldVariablesCount = state.Variables.Count; + VariableDescriptor[] vars = null; state.lexicalScopeLevel++; try { @@ -121,7 +122,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) i++; var pos = index; index = i; - result = new SwitchStatement(body.ToArray()) + result = new Switch(body.ToArray()) { functions = funcs.ToArray(), cases = cases.ToArray(), @@ -129,13 +130,13 @@ internal static CodeNode Parse(ParseInfo state, ref int index) Position = pos, Length = index - pos }; + vars = CodeBlock.extractVariables(state, oldVariablesCount); } finally { state.lexicalScopeLevel--; } - var vars = CodeBlock.extractVariables(state, oldVariablesCount); return new CodeBlock(new[] { result }) { _variables = vars, Position = result.Position, Length = result.Length }; } @@ -190,7 +191,7 @@ public override JSValue Evaluate(Context context) return null; } - if (Expressions.StrictEqualOperator.Check(imageValue, cseResult)) + if (Expressions.StrictEqual.Check(imageValue, cseResult)) { lineIndex = cases[caseIndex].index; caseIndex = cases.Length; diff --git a/NiL.JS/Statements/ThrowStatement.cs b/NiL.JS/Statements/Throw.cs similarity index 91% rename from NiL.JS/Statements/ThrowStatement.cs rename to NiL.JS/Statements/Throw.cs index 190bdc77e..7d71df712 100644 --- a/NiL.JS/Statements/ThrowStatement.cs +++ b/NiL.JS/Statements/Throw.cs @@ -10,16 +10,16 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class ThrowStatement : CodeNode + public sealed class Throw : CodeNode { private Expression body; - public ThrowStatement(Exception e) + public Throw(Exception e) { - body = new ConstantDefinition(TypeProxy.Marshal(e)); + body = new Constant(TypeProxy.Marshal(e)); } - internal ThrowStatement(Expression statement) + internal Throw(Expression statement) { body = statement; } @@ -34,11 +34,11 @@ internal static CodeNode Parse(ParseInfo state, ref int index) while (i < state.Code.Length && Tools.IsWhiteSpace(state.Code[i]) && !Tools.IsLineTerminator(state.Code[i])) i++; var b = state.Code[i] == ';' || Tools.IsLineTerminator(state.Code[i]) ? null : (Expression)Parser.Parse(state, ref i, CodeFragmentType.Expression); - if (b is EmptyExpression) + if (b is Empty) ExceptionsHelper.Throw((new SyntaxError("Can't throw result of EmptyStatement " + CodeCoordinates.FromTextPosition(state.Code, i - 1, 0)))); var pos = index; index = i; - return new ThrowStatement(b) + return new Throw(b) { Position = pos, Length = index - pos diff --git a/NiL.JS/Statements/TryCatchStatement.cs b/NiL.JS/Statements/TryCatch.cs similarity index 98% rename from NiL.JS/Statements/TryCatchStatement.cs rename to NiL.JS/Statements/TryCatch.cs index 7f56f9afc..2023ec97b 100644 --- a/NiL.JS/Statements/TryCatchStatement.cs +++ b/NiL.JS/Statements/TryCatch.cs @@ -11,7 +11,7 @@ namespace NiL.JS.Statements #if !PORTABLE [Serializable] #endif - public sealed class TryCatchStatement : CodeNode + public sealed class TryCatch : CodeNode { private bool @catch; @@ -86,7 +86,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index) ExceptionsHelper.Throw((new SyntaxError("try block must contain 'catch' or/and 'finally' block"))); var pos = index; index = i; - return new TryCatchStatement() + return new TryCatch() { body = (CodeBlock)b, catchBody = (CodeBlock)cb, @@ -194,7 +194,7 @@ private void catchHandler(Context context, Exception e) if (context.debugging) context.raiseDebugger(catchBody); #endif - if (catchBody is EmptyExpression) + if (catchBody is Empty) return; JSValue cvar = null; #if !PORTABLE @@ -277,13 +277,13 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary= state.Code.Length) break; - s = position; - Tools.SkipSpaces(state.Code, ref s); if (s >= state.Code.Length) break; @@ -116,8 +126,8 @@ internal static CodeNode Parse(ParseInfo state, ref int index, bool forForLoop) } if (names.Count == 0) - throw new ApplicationException("code (" + position + ")"); - + throw new InvalidOperationException("code (" + position + ")"); + if (!forForLoop && position < state.Code.Length && state.Code[position] == ';') position++; else @@ -129,7 +139,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index, bool forForLoop) bool skip = false; for (var j = 0; j < state.Variables.Count - i + skiped; j++) { - if (state.Variables[j].name == names[i] + if (state.Variables[j].name == names[i] && state.Variables[j].definitionScopeLevel >= level) { skip = true; @@ -154,7 +164,7 @@ internal static CodeNode Parse(ParseInfo state, ref int index, bool forForLoop) var inits = initializers.ToArray(); var pos = index; index = position; - return new VariableDefinitionStatement(variables, inits, level, mode) + return new VariableDefinition(variables, inits, level, mode) { Position = pos, Length = index - pos @@ -214,7 +224,7 @@ public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. /// @@ -39,7 +40,7 @@ internal Strings() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NiL.JS.Strings", typeof(Strings).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NiL.JS.Strings", typeof(Strings).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; @@ -177,6 +178,15 @@ internal static string TryingToGetProperty { } } + /// + /// Ищет локализованную строку, похожую на Can't set property "{0}" of "{1}". + /// + internal static string TryingToSetProperty { + get { + return ResourceManager.GetString("TryingToSetProperty", resourceCulture); + } + } + /// /// Ищет локализованную строку, похожую на Unexpected token. /// diff --git a/NiL.JS/Strings.resx b/NiL.JS/Strings.resx index fe278cc11..c0d9e70e4 100644 --- a/NiL.JS/Strings.resx +++ b/NiL.JS/Strings.resx @@ -156,6 +156,9 @@ Can't get property "{0}" of "{1}" + + Can't set property "{0}" of "{1}" + Unexpected token diff --git a/NiL.JS/Strings1.Designer.cs b/NiL.JS/Strings1.Designer.cs deleted file mode 100644 index 250738436..000000000 --- a/NiL.JS/Strings1.Designer.cs +++ /dev/null @@ -1,109 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Этот код создан программой. -// Исполняемая версия:4.0.30319.34209 -// -// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае -// повторной генерации кода. -// -//------------------------------------------------------------------------------ - -namespace NiL.JS.Portable { - using System; - using System.Reflection; - - - /// - /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. - /// - // Этот класс создан автоматически классом StronglyTypedResourceBuilder - // с помощью такого средства, как ResGen или Visual Studio. - // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen - // с параметром /str или перестройте свой проект VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NiL.JS.Portable.Strings", typeof(Strings).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Перезаписывает свойство CurrentUICulture текущего потока для всех - /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Ищет локализованную строку, похожую на Do not define a function inside a loop. - /// - internal static string FunctionInLoop { - get { - return ResourceManager.GetString("FunctionInLoop", resourceCulture); - } - } - - /// - /// Ищет локализованную строку, похожую на Method "{0}" can not be called with new keyword. - /// - internal static string InvalidTryToCallWithNew { - get { - return ResourceManager.GetString("InvalidTryToCallWithNew", resourceCulture); - } - } - - /// - /// Ищет локализованную строку, похожую на Method "{0}" can not be called without new keyword. - /// - internal static string InvalidTryToCallWithoutNew { - get { - return ResourceManager.GetString("InvalidTryToCallWithoutNew", resourceCulture); - } - } - - /// - /// Ищет локализованную строку, похожую на Type "{0}" can not be created with new keyword. - /// - internal static string InvalidTryToCreateWithNew { - get { - return ResourceManager.GetString("InvalidTryToCreateWithNew", resourceCulture); - } - } - - /// - /// Ищет локализованную строку, похожую на Type "{0}" can not be created without new keyword. - /// - internal static string InvalidTryToCreateWithoutNew { - get { - return ResourceManager.GetString("InvalidTryToCreateWithoutNew", resourceCulture); - } - } - } -} diff --git a/Portable.Test.Phone.Windows/MainPage.xaml.cs b/Portable.Test.Phone.Windows/MainPage.xaml.cs index c34abd37a..eb6307c36 100644 --- a/Portable.Test.Phone.Windows/MainPage.xaml.cs +++ b/Portable.Test.Phone.Windows/MainPage.xaml.cs @@ -13,6 +13,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using NiL.JS.Extensions; // Документацию по шаблону элемента "Пустая страница" см. по адресу http://go.microsoft.com/fwlink/?LinkId=391641 @@ -85,8 +86,8 @@ private void test(string code) { Context.RefreshGlobalContext(); - var s = new Script(staCode); // инициализация - s.Context.DefineVariable("console").Assign(TypeProxy.Proxy(logger)); + var s = new Module(staCode); // инициализация + s.Context.DefineVariable("console").Assign(logger.WrapToJSValue()); s.Invoke(); try { diff --git a/Portable.Test.Phone/MainPage.xaml.cs b/Portable.Test.Phone/MainPage.xaml.cs index a8d860f69..443db8703 100644 --- a/Portable.Test.Phone/MainPage.xaml.cs +++ b/Portable.Test.Phone/MainPage.xaml.cs @@ -14,6 +14,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using NiL.JS.Extensions; // Документацию по шаблону элемента "Пустая страница" см. по адресу http://go.microsoft.com/fwlink/?LinkId=391641 @@ -97,8 +98,8 @@ private void test(string code) { Context.RefreshGlobalContext(); - var s = new Script(staCode); // инициализация - s.Context.DefineVariable("console").Assign(TypeProxy.Proxy(logger)); + var s = new Module(staCode); // инициализация + s.Context.DefineVariable("console").Assign(logger.WrapToJSValue()); s.Invoke(); try { diff --git a/README.md b/README.md index 2377b1644..1340744c6 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,8 @@ NiL.JS Open source ECMAScript 6.0 (ES2015) (JavaScript) engine. Licensed under BSD 3-Clause License. -* High performance. +* Fast. * Works on Windows Runtime (Portable version) -* Support .NET 3.5. * Support Mono. * Compatible with ASP.NET. * Automatic wrapping .NET objects. No changes are required. @@ -16,7 +15,6 @@ Licensed under BSD 3-Clause License. * Integrated static analyser. * Integrated debugger ("For developers" version). * You can extend syntax with your own statements ([see examples](https://github.com/nilproject/NiL.JS/wiki/Examples#add-you-own-syntax-extension-dev-brunch-only)). -* 99% of Sputnik tests passed. ## Example diff --git a/Tests/ftest.js b/Tests/ftest.js index 7519876f2b63251cc3571a2ad751214ca97418ef..46b134b197f35e75e0784bedbf94a8dd124693b1 100644 GIT binary patch literal 2 JcmezW4*&xG0sa60 literal 202 zcmezWuZ$s)p@=~Nh^>JnF9R1tCPNyKr2!Pt1kz~?`Cxesh7usp7KjbNDocSZJ0LCr u^GX=Bfe@rVk0BZ;77HX(!K5LORAA5t>x9^m%8 t; t++) n[t][e][1] /= r; else for (t = 0; u > t; t++) n[t][e][1] = o; }); +var undefined; + +try { + undefined.test = 1; + console.log("'undefined.test = 1' did not thrown exception") +} +catch (e) { +} + console.log("test completed"); \ No newline at end of file diff --git a/Tests/uglifyjs.js b/Tests/uglifyjs.js index 110779d27..beb7bc066 100644 --- a/Tests/uglifyjs.js +++ b/Tests/uglifyjs.js @@ -1,4 +1,5 @@ -!function(n,e){"use strict";function t(n){for(var e=Object.create(null),t=0;t=0;)if(e[t]==n)return!0;return!1}function a(n,e){for(var t=0,r=e.length;r>t;++t)if(n(e[t]))return e[t]}function u(n,e){if(0>=e)return"";if(1==e)return n;var t=u(n,e>>1);return t+=t,1&e&&(t+=n),t}function s(n,e){Error.call(this,n),this.msg=n,this.defs=e}function c(n,e,t){n===!0&&(n={});var r=n||{};if(t)for(var o in r)r.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&s.croak("`"+o+"` is not a supported option",e);for(var o in e)e.hasOwnProperty(o)&&(r[o]=n&&n.hasOwnProperty(o)?n[o]:e[o]);return r}function f(n,e){var t=0;for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r],t++);return t}function l(){}function p(n,e){n.indexOf(e)<0&&n.push(e)}function d(n,e){return n.replace(/\{(.+?)\}/g,function(n,t){return e[t]})}function h(n,e){for(var t=n.length;--t>=0;)n[t]===e&&n.splice(t,1)}function _(n,e){function t(n,t){for(var r=[],o=0,i=0,a=0;o=0})}function g(n){function e(n){if(1==n.length)return t+="return str === "+JSON.stringify(n[0])+";";t+="switch(str){";for(var e=0;e3){r.sort(function(n,e){return e.length-n.length}),t+="switch(str.length){";for(var o=0;o=0;)if(!e(n[t]))return!1;return!0}function y(){this._values=Object.create(null),this._size=0}function A(n,e,t,r){arguments.length<4&&(r=G),e=e?e.split(/\s+/):[];var o=e;r&&r.PROPS&&(e=e.concat(r.PROPS));for(var i="return function AST_"+n+"(props){ if (props) { ",a=e.length;--a>=0;)i+="this."+e[a]+" = props."+e[a]+";";var u=r&&new r;(u&&u.initialize||t&&t.initialize)&&(i+="this.initialize();"),i+="}}";var s=new Function(i)();if(u&&(s.prototype=u,s.BASE=r),r&&r.SUBCLASSES.push(s),s.prototype.CTOR=s,s.PROPS=e||null,s.SELF_PROPS=o,s.SUBCLASSES=[],n&&(s.prototype.TYPE=s.TYPE=n),t)for(a in t)t.hasOwnProperty(a)&&(/^\$/.test(a)?s[a.substr(1)]=t[a]:s.prototype[a]=t[a]);return s.DEFMETHOD=function(n,e){this.prototype[n]=e},s}function w(n,e){n.body instanceof J?n.body._walk(e):n.body.forEach(function(n){n._walk(e)})}function E(n){this.visit=n,this.stack=[]}function D(n){return n>=97&&122>=n||n>=65&&90>=n||n>=170&&Pe.letter.test(String.fromCharCode(n))}function F(n){return n>=48&&57>=n}function C(n){return F(n)||D(n)}function S(n){return Pe.digit.test(String.fromCharCode(n))}function k(n){return Pe.non_spacing_mark.test(n)||Pe.space_combining_mark.test(n)}function B(n){return Pe.connector_punctuation.test(n)}function x(n){return!xe(n)&&/^[a-z_$][a-z0-9_$]*$/i.test(n)}function T(n){return 36==n||95==n||D(n)}function O(n){var e=n.charCodeAt(0);return T(e)||F(e)||8204==e||8205==e||k(n)||B(n)||S(e)}function $(n){return/^[a-z_$][a-z0-9_$]*$/i.test(n)}function M(n){return $e.test(n)?parseInt(n.substr(2),16):Me.test(n)?parseInt(n.substr(1),8):qe.test(n)?parseFloat(n):void 0}function q(n,e,t,r,o){this.message=n,this.filename=e,this.line=t,this.col=r,this.pos=o,this.stack=(new Error).stack}function N(n,e,t,r,o){throw new q(n,e,t,r,o)}function z(n,e,t){return n.type==e&&(null==t||n.value==t)}function H(n,e,t){function r(){return D.text.charAt(D.pos)}function o(n,e){var t=D.text.charAt(D.pos++);if(n&&!t)throw Ie;return"\r\n\u2028\u2029".indexOf(t)>=0?(D.newline_before=D.newline_before||!e,++D.line,D.col=0,e||"\r"!=t||"\n"!=r()||(++D.pos,t="\n")):++D.col,t}function i(n){for(;n-->0;)o()}function a(n){return D.text.substr(D.pos,n.length)==n}function u(n,e){var t=D.text.indexOf(n,D.pos);if(e&&-1==t)throw Ie;return t}function s(){D.tokline=D.line,D.tokcol=D.col,D.tokpos=D.pos}function c(n,t,r){D.regex_allowed="operator"==n&&!Le(t)||"keyword"==n&&Te(t)||"punc"==n&&He(t),S="punc"==n&&"."==t;var o={type:n,value:t,line:D.tokline,col:D.tokcol,pos:D.tokpos,endline:D.line,endcol:D.col,endpos:D.pos,nlb:D.newline_before,file:e};if(!r){o.comments_before=D.comments_before,D.comments_before=[];for(var i=0,a=o.comments_before.length;a>i;i++)o.nlb=o.nlb||o.comments_before[i].nlb}return D.newline_before=!1,new X(o)}function f(){for(var n;ze(n=r())||"\u2028"==n||"\u2029"==n;)o()}function l(n){for(var e,t="",i=0;(e=r())&&n(e,i++);)t+=o();return t}function p(n){N(n,e,D.tokline,D.tokcol,D.tokpos)}function d(n){var e=!1,t=!1,r=!1,o="."==n,i=l(function(i,a){var u=i.charCodeAt(0);switch(u){case 120:case 88:return r?!1:r=!0;case 101:case 69:return r?!0:e?!1:e=t=!0;case 45:return t||0==a&&!n;case 43:return t;case t=!1,46:return o||r||e?!1:o=!0}return C(u)});n&&(i=n+i);var a=M(i);return isNaN(a)?void p("Invalid syntax: "+i):c("num",a)}function h(n){var e=o(!0,n);switch(e.charCodeAt(0)){case 110:return"\n";case 114:return"\r";case 116:return" ";case 98:return"\b";case 118:return" ";case 102:return"\f";case 48:return"\x00";case 120:return String.fromCharCode(_(2));case 117:return String.fromCharCode(_(4));case 10:return"";default:return e}}function _(n){for(var e=0;n>0;--n){var t=parseInt(o(!0),16);isNaN(t)&&p("Invalid hex-character pattern in string"),e=e<<4|t}return e}function m(n){var e,t=D.regex_allowed,r=u("\n");return-1==r?(e=D.text.substr(D.pos),D.pos=D.text.length):(e=D.text.substring(D.pos,r),D.pos=r),D.col=D.tokcol+(D.pos-D.tokpos),D.comments_before.push(c(n,e,!0)),D.regex_allowed=t,E()}function v(){for(var n,e,t=!1,i="",a=!1;null!=(n=r());)if(t)"u"!=n&&p("Expecting UnicodeEscapeSequence -- uXXXX"),n=h(),O(n)||p("Unicode char: "+n.charCodeAt(0)+" is not valid in identifier"),i+=n,t=!1;else if("\\"==n)a=t=!0,o();else{if(!O(n))break;i+=o()}return ke(i)&&a&&(e=i.charCodeAt(0).toString(16).toUpperCase(),i="\\u"+"0000".substr(e.length)+e+i.slice(1)),i}function g(n){function e(n){if(!r())return n;var t=n+r();return Ne(t)?(o(),e(t)):n}return c("operator",e(n||o()))}function b(){switch(o(),r()){case"/":return o(),m("comment1");case"*":return o(),B()}return D.regex_allowed?x(""):g("/")}function y(){return o(),F(r().charCodeAt(0))?d("."):c("punc",".")}function A(){var n=v();return S?c("name",n):Be(n)?c("atom",n):ke(n)?Ne(n)?c("operator",n):c("keyword",n):c("name",n)}function w(n,e){return function(t){try{return e(t)}catch(r){if(r!==Ie)throw r;p(n)}}}function E(n){if(null!=n)return x(n);if(f(),s(),t){if(a("")&&D.newline_before)return i(3),m("comment4")}var e=r();if(!e)return c("eof");var u=e.charCodeAt(0);switch(u){case 34:case 39:return k(e);case 46:return y();case 47:return b()}return F(u)?d():Re(e)?c("punc",o()):Oe(e)?g():92==u||T(u)?A():void p("Unexpected character '"+e+"'")}var D={text:n.replace(/\uFEFF/g,""),filename:e,pos:0,tokpos:0,line:1,tokline:0,col:0,tokcol:0,newline_before:!1,regex_allowed:!1,comments_before:[]},S=!1,k=w("Unterminated string constant",function(n){for(var e=o(),t="";;){var r=o(!0);if("\\"==r){var i=0,a=null;r=l(function(n){if(n>="0"&&"7">=n){if(!a)return a=n,++i;if("3">=a&&2>=i)return++i;if(a>="4"&&1>=i)return++i}return!1}),r=i>0?String.fromCharCode(parseInt(r,8)):h(!0)}else if(r==e)break;t+=r}var u=c("string",t);return u.quote=n,u}),B=w("Unterminated multiline comment",function(){var n=D.regex_allowed,e=u("*/",!0),t=D.text.substring(D.pos,e),r=t.split("\n"),o=r.length;D.pos=e+2,D.line+=o-1,o>1?D.col=r[o-1].length:D.col+=r[o-1].length,D.col+=2;var i=D.newline_before=D.newline_before||t.indexOf("\n")>=0;return D.comments_before.push(c("comment2",t,!0)),D.regex_allowed=n,D.newline_before=i,E()}),x=w("Unterminated regular expression",function(n){for(var e,t=!1,r=!1;e=o(!0);)if(t)n+="\\"+e,t=!1;else if("["==e)r=!0,n+=e;else if("]"==e&&r)r=!1,n+=e;else{if("/"==e&&!r)break;"\\"==e?t=!0:n+=e}var i=v();return c("regexp",new RegExp(n,i))});return E.context=function(n){return n&&(D=n),D},E}function R(n,e){function t(n,e){return z(I.token,n,e)}function r(){return I.peeked||(I.peeked=I.input())}function o(){return I.prev=I.token,I.peeked?(I.token=I.peeked,I.peeked=null):I.token=I.input(),I.in_directives=I.in_directives&&("string"==I.token.type||t("punc",";")),I.token}function i(){return I.prev}function u(n,e,t,r){var o=I.input.context();N(n,o.filename,null!=e?e:o.tokline,null!=t?t:o.tokcol,null!=r?r:o.tokpos)}function s(n,e){u(e,n.line,n.col)}function f(n){null==n&&(n=I.token),s(n,"Unexpected token: "+n.type+" ("+n.value+")")}function l(n,e){return t(n,e)?o():void s(I.token,"Unexpected token "+I.token.type+" «"+I.token.value+"», expected "+n+" «"+e+"»")}function p(n){return l("punc",n)}function d(){return!e.strict&&(I.token.nlb||t("eof")||t("punc","}"))}function h(){t("punc",";")?o():d()||f()}function _(){p("(");var n=bn(!0);return p(")"),n}function m(n){return function(){var e=I.token,t=n(),r=i();return t.start=e,t.end=r,t}}function v(){(t("operator","/")||t("operator","/="))&&(I.peeked=null,I.token=I.input(I.token.value.substr(1)))}function g(){var n=M(le);a(function(e){return e.name==n.name},I.labels)&&u("Label "+n.name+" defined twice"),p(":"),I.labels.push(n);var e=U();return I.labels.pop(),e instanceof an||n.references.forEach(function(e){e instanceof Fn&&(e=e.label.start,u("Continue label `"+n.name+"` refers to non-IterationStatement.",e.line,e.col,e.pos))}),new on({body:e,label:n})}function b(n){return new Q({body:(n=bn(!0),h(),n)})}function y(n){var e,t=null;d()||(t=M(de,!0)),null!=t?(e=a(function(n){return n.name==t.name},I.labels),e||u("Undefined label "+t.name),t.thedef=e):0==I.in_loop&&u(n.TYPE+" not inside a loop or switch"),h();var r=new n({label:t});return e&&e.references.push(r),r}function A(){p("(");var n=null;return!t("punc",";")&&(n=t("keyword","var")?(o(),V(!0)):bn(!0,!0),t("operator","in"))?(n instanceof qn&&n.definitions.length>1&&u("Only one variable declaration allowed in for..in loop"),o(),E(n)):w(n)}function w(n){p(";");var e=t("punc",";")?null:bn(!0);p(";");var r=t("punc",")")?null:bn(!0);return p(")"),new fn({init:n,condition:e,step:r,body:P(U)})}function E(n){var e=n instanceof qn?n.definitions[0].name:null,t=bn(!0);return p(")"),new ln({init:n,name:e,object:t,body:P(U)})}function D(){var n=_(),e=U(),r=null;return t("keyword","else")&&(o(),r=U()),new Cn({condition:n,body:e,alternative:r})}function F(){p("{");for(var n=[];!t("punc","}");)t("eof")&&f(),n.push(U());return o(),n}function C(){p("{");for(var n,e=[],r=null,a=null;!t("punc","}");)t("eof")&&f(),t("keyword","case")?(a&&(a.end=i()),r=[],a=new xn({start:(n=I.token,o(),n),expression:bn(!0),body:r}),e.push(a),p(":")):t("keyword","default")?(a&&(a.end=i()),r=[],a=new Bn({start:(n=I.token,o(),p(":"),n),body:r}),e.push(a)):(r||f(),r.push(U()));return a&&(a.end=i()),o(),e}function S(){var n=F(),e=null,r=null;if(t("keyword","catch")){var a=I.token;o(),p("(");var s=M(fe);p(")"),e=new On({start:a,argname:s,body:F(),end:i()})}if(t("keyword","finally")){var a=I.token;o(),r=new $n({start:a,body:F(),end:i()})}return e||r||u("Missing catch/finally blocks"),new Tn({body:n,bcatch:e,bfinally:r})}function k(n,e){for(var r=[];r.push(new zn({start:I.token,name:M(e?ae:ie),value:t("operator","=")?(o(),bn(!1,n)):null,end:i()})),t("punc",",");)o();return r}function B(){var n,e=I.token;switch(e.type){case"name":case"keyword":n=$(pe);break;case"num":n=new ve({start:e,end:e,value:e.value});break;case"string":n=new me({start:e,end:e,value:e.value,quote:e.quote});break;case"regexp":n=new ge({start:e,end:e,value:e.value});break;case"atom":switch(e.value){case"false":n=new Ce({start:e,end:e});break;case"true":n=new Se({start:e,end:e});break;case"null":n=new ye({start:e,end:e})}}return o(),n}function x(n,e,r){for(var i=!0,a=[];!t("punc",n)&&(i?i=!1:p(","),!e||!t("punc",n));)a.push(t("punc",",")&&r?new Ee({start:I.token,end:I.token}):bn(!1));return o(),a}function T(){var n=I.token;switch(o(),n.type){case"num":case"string":case"name":case"operator":case"keyword":case"atom":return n.value;default:f()}}function O(){var n=I.token;switch(o(),n.type){case"name":case"operator":case"keyword":case"atom":return n.value;default:f()}}function $(n){var e=I.token.value;return new("this"==e?he:n)({name:String(e),start:I.token,end:I.token})}function M(n,e){if(!t("name"))return e||u("Name expected"),null;var r=$(n);return o(),r}function q(n,e,t){return"++"!=e&&"--"!=e||j(t)||u("Invalid use of "+e+" operator"),new n({operator:e,expression:t})}function R(n){return un(rn(!0),0,n)}function j(n){return e.strict?n instanceof he?!1:n instanceof Pn||n instanceof te:!0}function P(n){++I.in_loop;var e=n();return--I.in_loop,e}e=c(e,{strict:!1,filename:null,toplevel:null,expression:!1,html5_comments:!0,bare_returns:!1});var I={input:"string"==typeof n?H(n,e.filename,e.html5_comments):n,token:null,prev:null,peeked:null,in_function:0,in_directives:!0,in_loop:0,labels:[]};I.token=o();var U=m(function(){var n;switch(v(),I.token.type){case"string":var a=I.in_directives,s=b();return a&&s.body instanceof me&&!t("punc",",")?new Z({start:s.body.start,end:s.body.end,quote:s.body.quote,value:s.body.value}):s;case"num":case"regexp":case"operator":case"atom":return b();case"name":return z(r(),"punc",":")?g():b();case"punc":switch(I.token.value){case"{":return new en({start:I.token,body:F(),end:i()});case"[":case"(":return b();case";":return o(),new tn;default:f()}case"keyword":switch(n=I.token.value,o(),n){case"break":return y(Dn);case"continue":return y(Fn);case"debugger":return h(),new K;case"do":return new sn({body:P(U),condition:(l("keyword","while"),n=_(),h(),n)});case"while":return new cn({condition:_(),body:P(U)});case"for":return A();case"function":return L(gn);case"if":return D();case"return":return 0!=I.in_function||e.bare_returns||u("'return' outside of function"),new An({value:t("punc",";")?(o(),null):d()?null:(n=bn(!0),h(),n)});case"switch":return new Sn({expression:_(),body:P(C)});case"throw":return I.token.nlb&&u("Illegal newline after 'throw'"),new wn({value:(n=bn(!0),h(),n)});case"try":return S();case"var":return n=V(),h(),n;case"const":return n=W(),h(),n;case"with":return new pn({expression:_(),body:U()});default:f()}}}),L=function(n){var e=n===gn,r=t("name")?M(e?se:ce):null;return e&&!r&&f(),p("("),new n({name:r,argnames:function(n,e){for(;!t("punc",")");)n?n=!1:p(","),e.push(M(ue));return o(),e}(!0,[]),body:function(n,e){++I.in_function,I.in_directives=!0,I.in_loop=0,I.labels=[];var t=F();return--I.in_function,I.in_loop=n,I.labels=e,t}(I.in_loop,I.labels)})},V=function(n){return new qn({start:i(),definitions:k(n,!1),end:i()})},W=function(){return new Nn({start:i(),definitions:k(!1,!0),end:i()})},Y=function(){var n=I.token;l("operator","new");var e,r=X(!1);return t("punc","(")?(o(),e=x(")")):e=[],nn(new Rn({start:n,expression:r,args:e,end:i()}),!0)},X=function(n){if(t("operator","new"))return Y();var e=I.token;if(t("punc")){switch(e.value){case"(":o();var r=bn(!0);return r.start=e,r.end=I.token,p(")"),nn(r,n);case"[":return nn(G(),n);case"{":return nn(J(),n)}f()}if(t("keyword","function")){o();var a=L(vn);return a.start=e,a.end=i(),nn(a,n)}return Xe[I.token.type]?nn(B(),n):void f()},G=m(function(){return p("["),new Jn({elements:x("]",!e.strict,!0)})}),J=m(function(){p("{");for(var n=!0,r=[];!t("punc","}")&&(n?n=!1:p(","),e.strict||!t("punc","}"));){var a=I.token,u=a.type,s=T();if("name"==u&&!t("punc",":")){if("get"==s){r.push(new ee({start:a,key:B(),value:L(mn),end:i()}));continue}if("set"==s){r.push(new ne({start:a,key:B(),value:L(mn),end:i()}));continue}}p(":"),r.push(new Qn({start:a,quote:a.quote,key:s,value:bn(!1),end:i()}))}return o(),new Kn({properties:r})}),nn=function(n,e){var r=n.start;if(t("punc","."))return o(),nn(new In({start:r,expression:n,property:O(),end:i()}),e);if(t("punc","[")){o();var a=bn(!0);return p("]"),nn(new Un({start:r,expression:n,property:a,end:i()}),e)}return e&&t("punc","(")?(o(),nn(new Hn({start:r,expression:n,args:x(")"),end:i()}),!0)):n},rn=function(n){var e=I.token;if(t("operator")&&Ue(e.value)){o(),v();var r=q(Vn,e.value,rn(n));return r.start=e,r.end=i(),r}for(var a=X(n);t("operator")&&Le(I.token.value)&&!I.token.nlb;)a=q(Wn,I.token.value,a),a.start=e,a.end=I.token,o();return a},un=function(n,e,r){var i=t("operator")?I.token.value:null;"in"==i&&r&&(i=null);var a=null!=i?We[i]:null;if(null!=a&&a>e){o();var u=un(rn(!0),a,r);return un(new Yn({start:n.start,left:n,operator:i,right:u,end:u.end}),e,r)}return n},dn=function(n){var e=I.token,r=R(n);if(t("operator","?")){o();var a=bn(!1);return p(":"),new Xn({start:e,condition:r,consequent:a,alternative:bn(!1,n),end:i()})}return r},_n=function(n){var e=I.token,r=dn(n),a=I.token.value;if(t("operator")&&Ve(a)){if(j(r))return o(),new Gn({start:e,left:r,operator:a,right:_n(n),end:i()});u("Invalid assignment")}return r},bn=function(n,e){var i=I.token,a=_n(e);return n&&t("punc",",")?(o(),new jn({start:i,car:a,cdr:bn(!0,e),end:r()})):a};return e.expression?bn(!0):function(){for(var n=I.token,r=[];!t("eof");)r.push(U());var o=i(),a=e.toplevel;return a?(a.body=a.body.concat(r),a.end=o):a=new hn({start:n,body:r,end:o}),a}()}function j(n,e){E.call(this),this.before=n,this.after=e}function P(n,e,t){this.name=t.name,this.orig=[t],this.scope=n,this.references=[],this.global=!1,this.mangled_name=null,this.undeclared=!1,this.constant=!1,this.index=e}function I(n){function e(n,e){return n.replace(/[\u0080-\uffff]/g,function(n){var t=n.charCodeAt(0).toString(16);if(t.length<=2&&!e){for(;t.length<2;)t="0"+t;return"\\x"+t}for(;t.length<4;)t="0"+t;return"\\u"+t})}function t(t,r){function o(){return"'"+t.replace(/\x27/g,"\\'")+"'"}function i(){return'"'+t.replace(/\x22/g,'\\"')+'"'}var a=0,u=0;switch(t=t.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0\ufeff]/g,function(n){switch(n){case"\\":return"\\\\";case"\b":return"\\b";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";case'"':return++a,'"';case"'":return++u,"'";case"\x00":return"\\x00";case"\ufeff":return"\\ufeff"}return n}),n.ascii_only&&(t=e(t)),n.quote_style){case 1:return o();case 2:return i();case 3:return"'"==r?o():i();default:return a>u?o():i()}}function r(e,r){var o=t(e,r);return n.inline_script&&(o=o.replace(/<\x2fscript([>\/\t\n\f\r ])/gi,"<\\/script$1")),o}function o(t){return t=t.toString(),n.ascii_only&&(t=e(t,!0)),t}function i(e){return u(" ",n.indent_start+A-e*n.indent_level)}function a(){return k.charAt(k.length-1)}function s(){n.max_line_len&&w>n.max_line_len&&f("\n")}function f(e){e=String(e);var t=e.charAt(0);if(S&&(t&&!(";}".indexOf(t)<0)||/[;]$/.test(k)||(n.semicolons||B(t)?(F+=";",w++,D++):(F+="\n",D++,E++,w=0),n.beautify||(C=!1)),S=!1,s()),!n.beautify&&n.preserve_line&&z[z.length-1])for(var r=z[z.length-1].start.line;r>E;)F+="\n",D++,E++,w=0,C=!1;if(C){var o=a();(O(o)&&(O(t)||"\\"==t)||/^[\+\-\/]$/.test(t)&&t==o)&&(F+=" ",w++,D++),C=!1}var i=e.split(/\r?\n/),u=i.length-1;E+=u,0==u?w+=i[u].length:w=i[u].length,D+=e.length,k=e,F+=e}function p(){S=!1,f(";")}function d(){return A+n.indent_level}function h(n){var e;return f("{"),M(),$(d(),function(){e=n()}),T(),f("}"),e}function _(n){f("(");var e=n();return f(")"),e}function m(n){f("[");var e=n();return f("]"),e}function v(){f(","),x()}function b(){f(":"),n.space_colon&&x()}function y(){return F}n=c(n,{indent_start:0,indent_level:4,quote_keys:!1,space_colon:!0,ascii_only:!1,unescape_regexps:!1,inline_script:!1,width:80,max_line_len:32e3,beautify:!1,source_map:null,bracketize:!1,semicolons:!0,comments:!1,preserve_line:!1,screw_ie8:!1,preamble:null,quote_style:0},!0);var A=0,w=0,E=1,D=0,F="",C=!1,S=!1,k=null,B=g("( [ + * / - , ."),x=n.beautify?function(){f(" ")}:function(){C=!0},T=n.beautify?function(e){n.beautify&&f(i(e?.5:0))}:l,$=n.beautify?function(n,e){n===!0&&(n=d());var t=A;A=n;var r=e();return A=t,r}:function(n,e){return e()},M=n.beautify?function(){f("\n")}:s,q=n.beautify?function(){f(";")}:function(){S=!0},N=n.source_map?function(e,t){try{e&&n.source_map.add(e.file||"?",E,w,e.line,e.col,t||"name"!=e.type?t:e.value)}catch(r){G.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]",{file:e.file,line:e.line,col:e.col,cline:E,ccol:w,name:t||""})}}:l;n.preamble&&f(n.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g,"\n"));var z=[];return{get:y,toString:y,indent:T,indentation:function(){return A},current_width:function(){return w-A},should_break:function(){return n.width&&this.current_width()>=n.width},newline:M,print:f,space:x,comma:v,colon:b,last:function(){return k},semicolon:q,force_semicolon:p,to_ascii:e,print_name:function(n){f(o(n))},print_string:function(n,e){f(r(n,e))},next_indent:d,with_indent:$,with_block:h,with_parens:_,with_square:m,add_mapping:N,option:function(e){return n[e]},line:function(){return E},col:function(){return w},pos:function(){return D},push_node:function(n){z.push(n)},pop_node:function(){return z.pop()},stack:function(){return z},parent:function(n){return z[z.length-2-(n||0)]}}}function U(n,e){return this instanceof U?(j.call(this,this.before,this.after),void(this.options=c(n,{sequences:!e,properties:!e,dead_code:!e,drop_debugger:!e,unsafe:!1,unsafe_comps:!1,conditionals:!e,comparisons:!e,evaluate:!e,booleans:!e,loops:!e,unused:!e,hoist_funs:!e,keep_fargs:!1,keep_fnames:!1,hoist_vars:!1,if_return:!e,join_vars:!e,cascade:!e,side_effects:!e,pure_getters:!1,pure_funcs:null,negate_iife:!e,screw_ie8:!1,drop_console:!1,angular:!1,warnings:!0,global_defs:{}},!0))):new U(n,e)}function L(n){function e(e,o,i,a,u,s){if(r){var c=r.originalPositionFor({line:a,column:u});if(null===c.source)return;e=c.source,a=c.line,u=c.column,s=c.name||s}t.addMapping({generated:{line:o+n.dest_line_diff,column:i},original:{line:a+n.orig_line_diff,column:u},source:e,name:s})}n=c(n,{file:null,root:null,orig:null,orig_line_diff:0,dest_line_diff:0});var t,r=n.orig&&new MOZ_SourceMap.SourceMapConsumer(n.orig);return t=r?MOZ_SourceMap.SourceMapGenerator.fromSourceMap(r):new MOZ_SourceMap.SourceMapGenerator({file:n.file,sourceRoot:n.root}),{add:e,get:function(){return t},toString:function(){return JSON.stringify(t.toJSON())}}}function V(){function n(n){p(e,n)}var e=[];return[Object,Array,Function,Number,String,Boolean,Error,Math,Date,RegExp].forEach(function(e){Object.getOwnPropertyNames(e).map(n),e.prototype&&Object.getOwnPropertyNames(e.prototype).map(n)}),e}function W(n,e){function t(n){return s.indexOf(n)>=0?!1:/^[0-9.]+$/.test(n)?!1:!0}function r(n){return f.props.has(n)||l.indexOf(n)>=0}function o(n){t(n)&&p(l,n)}function i(n){var e=f.props.get(n);if(!e){do e=Ge(++f.cname);while(!t(e));f.props.set(n,e)}return e}function a(n){var e={};try{!function r(n){n.walk(new E(function(n){if(n instanceof jn)return r(n.cdr),!0;if(n instanceof me)return o(n.value),!0;if(n instanceof Xn)return r(n.consequent),r(n.alternative),!0;throw e}))}(n)}catch(t){if(t!==e)throw t}}function u(n){return n.transform(new j(function(n){return n instanceof jn?n.cdr=u(n.cdr):n instanceof me?r(n.value)&&(n.value=i(n.value)):n instanceof Xn&&(n.consequent=u(n.consequent),n.alternative=u(n.alternative)),n}))}e=c(e,{reserved:null,cache:null});var s=e.reserved;null==s&&(s=V());var f=e.cache;null==f&&(f={cname:-1,props:new y});var l=[];return n.walk(new E(function(n){n instanceof Qn?o(n.key):n instanceof Zn?o(n.key.name):n instanceof In?this.parent()instanceof Gn&&o(n.property):n instanceof Un&&this.parent()instanceof Gn&&a(n.property)})),n.transform(new j(null,function(n){n instanceof Qn?r(n.key)&&(n.key=i(n.key)):n instanceof Zn?r(n.key.name)&&(n.key.name=i(n.key.name)):n instanceof In?r(n.property)&&(n.property=i(n.property)):n instanceof Un&&(n.property=u(n.property))}))}e.UglifyJS=n,s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s.croak=function(n,e){throw new s(n,e)};var Y=function(){function n(n,i,a){function u(){var u=i(n[s],s),l=u instanceof r;return l&&(u=u.v),u instanceof e?(u=u.v,u instanceof t?f.push.apply(f,a?u.v.slice().reverse():u.v):f.push(u)):u!==o&&(u instanceof t?c.push.apply(c,a?u.v.slice().reverse():u.v):c.push(u)),l}var s,c=[],f=[];if(n instanceof Array)if(a){for(s=n.length;--s>=0&&!u(););c.reverse(),f.reverse()}else for(s=0;s SymbolDef for all variables/functions defined in this scope",functions:"[Object/S] like `variables`, but only lists function declarations",uses_with:"[boolean/S] tells whether this scope uses the `with` statement",uses_eval:"[boolean/S] tells whether this scope contains a direct call to the global `eval`",parent_scope:"[AST_Scope?/S] link to the parent scope",enclosed:"[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",cname:"[integer/S] current index for mangling variables (used internally by the mangler)"}},nn),hn=A("Toplevel","globals",{$documentation:"The toplevel scope",$propdoc:{globals:"[Object/S] a map of name -> SymbolDef for all undeclared names"},wrap_enclose:function(n){var e=this,t=[],r=[];n.forEach(function(n){var e=n.lastIndexOf(":");t.push(n.substr(0,e)),r.push(n.substr(e+1))});var o="(function("+r.join(",")+"){ '$ORIG'; })("+t.join(",")+")";return o=R(o),o=o.transform(new j(function(n){return n instanceof Z&&"$ORIG"==n.value?Y.splice(e.body):void 0}))},wrap_commonjs:function(n,e){var t=this,r=[];e&&(t.figure_out_scope(),t.walk(new E(function(n){n instanceof oe&&n.definition().global&&(a(function(e){return e.name==n.name},r)||r.push(n))})));var o="(function(exports, global){ global['"+n+"'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";return o=R(o),o=o.transform(new j(function(n){if(n instanceof Q&&(n=n.body,n instanceof me))switch(n.getValue()){case"$ORIG":return Y.splice(t.body);case"$EXPORTS":var e=[];return r.forEach(function(n){e.push(new Q({body:new Gn({left:new Un({expression:new pe({name:"exports"}),property:new me({value:n.name})}),operator:"=",right:new pe(n)})}))}),Y.splice(e)}}))}},dn),_n=A("Lambda","name argnames uses_arguments",{$documentation:"Base class for functions",$propdoc:{name:"[AST_SymbolDeclaration?] the name of this function",argnames:"[AST_SymbolFunarg*] array of function arguments",uses_arguments:"[boolean/S] tells whether this function accesses the arguments array"},_walk:function(n){return n._visit(this,function(){this.name&&this.name._walk(n),this.argnames.forEach(function(e){e._walk(n)}),w(this,n)})}},dn),mn=A("Accessor",null,{$documentation:"A setter/getter function. The `name` property is always null."},_n),vn=A("Function",null,{$documentation:"A function expression" +!function(n,e){"use strict";function t(n){for(var e=Object.create(null),t=0; +t=0;)if(e[t]==n)return!0;return!1}function a(n,e){for(var t=0,r=e.length;r>t;++t)if(n(e[t]))return e[t]}function u(n,e){if(0>=e)return"";if(1==e)return n;var t=u(n,e>>1);return t+=t,1&e&&(t+=n),t}function s(n,e){Error.call(this,n),this.msg=n,this.defs=e}function c(n,e,t){n===!0&&(n={});var r=n||{};if(t)for(var o in r)r.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&s.croak("`"+o+"` is not a supported option",e);for(var o in e)e.hasOwnProperty(o)&&(r[o]=n&&n.hasOwnProperty(o)?n[o]:e[o]);return r}function f(n,e){var t=0;for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r],t++);return t}function l(){}function p(n,e){n.indexOf(e)<0&&n.push(e)}function d(n,e){return n.replace(/\{(.+?)\}/g,function(n,t){return e[t]})}function h(n,e){for(var t=n.length;--t>=0;)n[t]===e&&n.splice(t,1)}function _(n,e){function t(n,t){for(var r=[],o=0,i=0,a=0;o=0})}function g(n){function e(n){if(1==n.length)return t+="return str === "+JSON.stringify(n[0])+";";t+="switch(str){";for(var e=0;e3){r.sort(function(n,e){return e.length-n.length}),t+="switch(str.length){";for(var o=0;o=0;)if(!e(n[t]))return!1;return!0}function y(){this._values=Object.create(null),this._size=0}function A(n,e,t,r){arguments.length<4&&(r=G),e=e?e.split(/\s+/):[];var o=e;r&&r.PROPS&&(e=e.concat(r.PROPS));for(var i="return function AST_"+n+"(props){ if (props) { ",a=e.length;--a>=0;)i+="this."+e[a]+" = props."+e[a]+";";var u=r&&new r;(u&&u.initialize||t&&t.initialize)&&(i+="this.initialize();"),i+="}}";var s=new Function(i)();if(u&&(s.prototype=u,s.BASE=r),r&&r.SUBCLASSES.push(s),s.prototype.CTOR=s,s.PROPS=e||null,s.SELF_PROPS=o,s.SUBCLASSES=[],n&&(s.prototype.TYPE=s.TYPE=n),t)for(a in t)t.hasOwnProperty(a)&&(/^\$/.test(a)?s[a.substr(1)]=t[a]:s.prototype[a]=t[a]);return s.DEFMETHOD=function(n,e){this.prototype[n]=e},s}function w(n,e){n.body instanceof J?n.body._walk(e):n.body.forEach(function(n){n._walk(e)})}function E(n){this.visit=n,this.stack=[]}function D(n){return n>=97&&122>=n||n>=65&&90>=n||n>=170&&Pe.letter.test(String.fromCharCode(n))}function F(n){return n>=48&&57>=n}function C(n){return F(n)||D(n)}function S(n){return Pe.digit.test(String.fromCharCode(n))}function k(n){return Pe.non_spacing_mark.test(n)||Pe.space_combining_mark.test(n)}function B(n){return Pe.connector_punctuation.test(n)}function x(n){return!xe(n)&&/^[a-z_$][a-z0-9_$]*$/i.test(n)}function T(n){return 36==n||95==n||D(n)}function O(n){var e=n.charCodeAt(0);return T(e)||F(e)||8204==e||8205==e||k(n)||B(n)||S(e)}function $(n){return/^[a-z_$][a-z0-9_$]*$/i.test(n)}function M(n){return $e.test(n)?parseInt(n.substr(2),16):Me.test(n)?parseInt(n.substr(1),8):qe.test(n)?parseFloat(n):void 0}function q(n,e,t,r,o){this.message=n,this.filename=e,this.line=t,this.col=r,this.pos=o,this.stack=(new Error).stack}function N(n,e,t,r,o){throw new q(n,e,t,r,o)}function z(n,e,t){return n.type==e&&(null==t||n.value==t)}function H(n,e,t){function r(){return D.text.charAt(D.pos)}function o(n,e){var t=D.text.charAt(D.pos++);if(n&&!t)throw Ie;return"\r\n\u2028\u2029".indexOf(t)>=0?(D.newline_before=D.newline_before||!e,++D.line,D.col=0,e||"\r"!=t||"\n"!=r()||(++D.pos,t="\n")):++D.col,t}function i(n){for(;n-->0;)o()}function a(n){return D.text.substr(D.pos,n.length)==n}function u(n,e){var t=D.text.indexOf(n,D.pos);if(e&&-1==t)throw Ie;return t}function s(){D.tokline=D.line,D.tokcol=D.col,D.tokpos=D.pos}function c(n,t,r){D.regex_allowed="operator"==n&&!Le(t)||"keyword"==n&&Te(t)||"punc"==n&&He(t),S="punc"==n&&"."==t;var o={type:n,value:t,line:D.tokline,col:D.tokcol,pos:D.tokpos,endline:D.line,endcol:D.col,endpos:D.pos,nlb:D.newline_before,file:e};if(!r){o.comments_before=D.comments_before,D.comments_before=[];for(var i=0,a=o.comments_before.length;a>i;i++)o.nlb=o.nlb||o.comments_before[i].nlb}return D.newline_before=!1,new X(o)}function f(){for(var n;ze(n=r())||"\u2028"==n||"\u2029"==n;)o()}function l(n){for(var e,t="",i=0;(e=r())&&n(e,i++);)t+=o();return t}function p(n){N(n,e,D.tokline,D.tokcol,D.tokpos)}function d(n){var e=!1,t=!1,r=!1,o="."==n,i=l(function(i,a){var u=i.charCodeAt(0);switch(u){case 120:case 88:return r?!1:r=!0;case 101:case 69:return r?!0:e?!1:e=t=!0;case 45:return t||0==a&&!n;case 43:return t;case t=!1,46:return o||r||e?!1:o=!0}return C(u)});n&&(i=n+i);var a=M(i);return isNaN(a)?void p("Invalid syntax: "+i):c("num",a)}function h(n){var e=o(!0,n);switch(e.charCodeAt(0)){case 110:return"\n";case 114:return"\r";case 116:return" ";case 98:return"\b";case 118:return" ";case 102:return"\f";case 48:return"\x00";case 120:return String.fromCharCode(_(2));case 117:return String.fromCharCode(_(4));case 10:return"";default:return e}}function _(n){for(var e=0;n>0;--n){var t=parseInt(o(!0),16);isNaN(t)&&p("Invalid hex-character pattern in string"),e=e<<4|t}return e}function m(n){var e,t=D.regex_allowed,r=u("\n");return-1==r?(e=D.text.substr(D.pos),D.pos=D.text.length):(e=D.text.substring(D.pos,r),D.pos=r),D.col=D.tokcol+(D.pos-D.tokpos),D.comments_before.push(c(n,e,!0)),D.regex_allowed=t,E()}function v(){for(var n,e,t=!1,i="",a=!1;null!=(n=r());)if(t)"u"!=n&&p("Expecting UnicodeEscapeSequence -- uXXXX"),n=h(),O(n)||p("Unicode char: "+n.charCodeAt(0)+" is not valid in identifier"),i+=n,t=!1;else if("\\"==n)a=t=!0,o();else{if(!O(n))break;i+=o()}return ke(i)&&a&&(e=i.charCodeAt(0).toString(16).toUpperCase(),i="\\u"+"0000".substr(e.length)+e+i.slice(1)),i}function g(n){function e(n){if(!r())return n;var t=n+r();return Ne(t)?(o(),e(t)):n}return c("operator",e(n||o()))}function b(){switch(o(),r()){case"/":return o(),m("comment1");case"*":return o(),B()}return D.regex_allowed?x(""):g("/")}function y(){return o(),F(r().charCodeAt(0))?d("."):c("punc",".")}function A(){var n=v();return S?c("name",n):Be(n)?c("atom",n):ke(n)?Ne(n)?c("operator",n):c("keyword",n):c("name",n)}function w(n,e){return function(t){try{return e(t)}catch(r){if(r!==Ie)throw r;p(n)}}}function E(n){if(null!=n)return x(n);if(f(),s(),t){if(a("")&&D.newline_before)return i(3),m("comment4")}var e=r();if(!e)return c("eof");var u=e.charCodeAt(0);switch(u){case 34:case 39:return k(e);case 46:return y();case 47:return b()}return F(u)?d():Re(e)?c("punc",o()):Oe(e)?g():92==u||T(u)?A():void p("Unexpected character '"+e+"'")}var D={text:n.replace(/\uFEFF/g,""),filename:e,pos:0,tokpos:0,line:1,tokline:0,col:0,tokcol:0,newline_before:!1,regex_allowed:!1,comments_before:[]},S=!1,k=w("Unterminated string constant",function(n){for(var e=o(),t="";;){var r=o(!0);if("\\"==r){var i=0,a=null;r=l(function(n){if(n>="0"&&"7">=n){if(!a)return a=n,++i;if("3">=a&&2>=i)return++i;if(a>="4"&&1>=i)return++i}return!1}),r=i>0?String.fromCharCode(parseInt(r,8)):h(!0)}else if(r==e)break;t+=r}var u=c("string",t);return u.quote=n,u}),B=w("Unterminated multiline comment",function(){var n=D.regex_allowed,e=u("*/",!0),t=D.text.substring(D.pos,e),r=t.split("\n"),o=r.length;D.pos=e+2,D.line+=o-1,o>1?D.col=r[o-1].length:D.col+=r[o-1].length,D.col+=2;var i=D.newline_before=D.newline_before||t.indexOf("\n")>=0;return D.comments_before.push(c("comment2",t,!0)),D.regex_allowed=n,D.newline_before=i,E()}),x=w("Unterminated regular expression",function(n){for(var e,t=!1,r=!1;e=o(!0);)if(t)n+="\\"+e,t=!1;else if("["==e)r=!0,n+=e;else if("]"==e&&r)r=!1,n+=e;else{if("/"==e&&!r)break;"\\"==e?t=!0:n+=e}var i=v();return c("regexp",new RegExp(n,i))});return E.context=function(n){return n&&(D=n),D},E}function R(n,e){function t(n,e){return z(I.token,n,e)}function r(){return I.peeked||(I.peeked=I.input())}function o(){return I.prev=I.token,I.peeked?(I.token=I.peeked,I.peeked=null):I.token=I.input(),I.in_directives=I.in_directives&&("string"==I.token.type||t("punc",";")),I.token}function i(){return I.prev}function u(n,e,t,r){var o=I.input.context();N(n,o.filename,null!=e?e:o.tokline,null!=t?t:o.tokcol,null!=r?r:o.tokpos)}function s(n,e){u(e,n.line,n.col)}function f(n){null==n&&(n=I.token),s(n,"Unexpected token: "+n.type+" ("+n.value+")")}function l(n,e){return t(n,e)?o():void s(I.token,"Unexpected token "+I.token.type+" «"+I.token.value+"», expected "+n+" «"+e+"»")}function p(n){return l("punc",n)}function d(){return!e.strict&&(I.token.nlb||t("eof")||t("punc","}"))}function h(){t("punc",";")?o():d()||f()}function _(){p("(");var n=bn(!0);return p(")"),n}function m(n){return function(){var e=I.token,t=n(),r=i();return t.start=e,t.end=r,t}}function v(){(t("operator","/")||t("operator","/="))&&(I.peeked=null,I.token=I.input(I.token.value.substr(1)))}function g(){var n=M(le);a(function(e){return e.name==n.name},I.labels)&&u("Label "+n.name+" defined twice"),p(":"),I.labels.push(n);var e=U();return I.labels.pop(),e instanceof an||n.references.forEach(function(e){e instanceof Fn&&(e=e.label.start,u("Continue label `"+n.name+"` refers to non-IterationStatement.",e.line,e.col,e.pos))}),new on({body:e,label:n})}function b(n){return new Q({body:(n=bn(!0),h(),n)})}function y(n){var e,t=null;d()||(t=M(de,!0)),null!=t?(e=a(function(n){return n.name==t.name},I.labels),e||u("Undefined label "+t.name),t.thedef=e):0==I.in_loop&&u(n.TYPE+" not inside a loop or switch"),h();var r=new n({label:t});return e&&e.references.push(r),r}function A(){p("(");var n=null;return!t("punc",";")&&(n=t("keyword","var")?(o(),V(!0)):bn(!0,!0),t("operator","in"))?(n instanceof qn&&n.definitions.length>1&&u("Only one variable declaration allowed in for..in loop"),o(),E(n)):w(n)}function w(n){p(";");var e=t("punc",";")?null:bn(!0);p(";");var r=t("punc",")")?null:bn(!0);return p(")"),new fn({init:n,condition:e,step:r,body:P(U)})}function E(n){var e=n instanceof qn?n.definitions[0].name:null,t=bn(!0);return p(")"),new ln({init:n,name:e,object:t,body:P(U)})}function D(){var n=_(),e=U(),r=null;return t("keyword","else")&&(o(),r=U()),new Cn({condition:n,body:e,alternative:r})}function F(){p("{");for(var n=[];!t("punc","}");)t("eof")&&f(),n.push(U());return o(),n}function C(){p("{");for(var n,e=[],r=null,a=null;!t("punc","}");)t("eof")&&f(),t("keyword","case")?(a&&(a.end=i()),r=[],a=new xn({start:(n=I.token,o(),n),expression:bn(!0),body:r}),e.push(a),p(":")):t("keyword","default")?(a&&(a.end=i()),r=[],a=new Bn({start:(n=I.token,o(),p(":"),n),body:r}),e.push(a)):(r||f(),r.push(U()));return a&&(a.end=i()),o(),e}function S(){var n=F(),e=null,r=null;if(t("keyword","catch")){var a=I.token;o(),p("(");var s=M(fe);p(")"),e=new On({start:a,argname:s,body:F(),end:i()})}if(t("keyword","finally")){var a=I.token;o(),r=new $n({start:a,body:F(),end:i()})}return e||r||u("Missing catch/finally blocks"),new Tn({body:n,bcatch:e,bfinally:r})}function k(n,e){for(var r=[];r.push(new zn({start:I.token,name:M(e?ae:ie),value:t("operator","=")?(o(),bn(!1,n)):null,end:i()})),t("punc",",");)o();return r}function B(){var n,e=I.token;switch(e.type){case"name":case"keyword":n=$(pe);break;case"num":n=new ve({start:e,end:e,value:e.value});break;case"string":n=new me({start:e,end:e,value:e.value,quote:e.quote});break;case"regexp":n=new ge({start:e,end:e,value:e.value});break;case"atom":switch(e.value){case"false":n=new Ce({start:e,end:e});break;case"true":n=new Se({start:e,end:e});break;case"null":n=new ye({start:e,end:e})}}return o(),n}function x(n,e,r){for(var i=!0,a=[];!t("punc",n)&&(i?i=!1:p(","),!e||!t("punc",n));)a.push(t("punc",",")&&r?new Ee({start:I.token,end:I.token}):bn(!1));return o(),a}function T(){var n=I.token;switch(o(),n.type){case"num":case"string":case"name":case"operator":case"keyword":case"atom":return n.value;default:f()}}function O(){var n=I.token;switch(o(),n.type){case"name":case"operator":case"keyword":case"atom":return n.value;default:f()}}function $(n){var e=I.token.value;return new("this"==e?he:n)({name:String(e),start:I.token,end:I.token})}function M(n,e){if(!t("name"))return e||u("Name expected"),null;var r=$(n);return o(),r}function q(n,e,t){return"++"!=e&&"--"!=e||j(t)||u("Invalid use of "+e+" operator"),new n({operator:e,expression:t})}function R(n){return un(rn(!0),0,n)}function j(n){return e.strict?n instanceof he?!1:n instanceof Pn||n instanceof te:!0}function P(n){++I.in_loop;var e=n();return--I.in_loop,e}e=c(e,{strict:!1,filename:null,toplevel:null,expression:!1,html5_comments:!0,bare_returns:!1});var I={input:"string"==typeof n?H(n,e.filename,e.html5_comments):n,token:null,prev:null,peeked:null,in_function:0,in_directives:!0,in_loop:0,labels:[]};I.token=o();var U=m(function(){var n;switch(v(),I.token.type){case"string":var a=I.in_directives,s=b();return a&&s.body instanceof me&&!t("punc",",")?new Z({start:s.body.start,end:s.body.end,quote:s.body.quote,value:s.body.value}):s;case"num":case"regexp":case"operator":case"atom":return b();case"name":return z(r(),"punc",":")?g():b();case"punc":switch(I.token.value){case"{":return new en({start:I.token,body:F(),end:i()});case"[":case"(":return b();case";":return o(),new tn;default:f()}case"keyword":switch(n=I.token.value,o(),n){case"break":return y(Dn);case"continue":return y(Fn);case"debugger":return h(),new K;case"do":return new sn({body:P(U),condition:(l("keyword","while"),n=_(),h(),n)});case"while":return new cn({condition:_(),body:P(U)});case"for":return A();case"function":return L(gn);case"if":return D();case"return":return 0!=I.in_function||e.bare_returns||u("'return' outside of function"),new An({value:t("punc",";")?(o(),null):d()?null:(n=bn(!0),h(),n)});case"switch":return new Sn({expression:_(),body:P(C)});case"throw":return I.token.nlb&&u("Illegal newline after 'throw'"),new wn({value:(n=bn(!0),h(),n)});case"try":return S();case"var":return n=V(),h(),n;case"const":return n=W(),h(),n;case"with":return new pn({expression:_(),body:U()});default:f()}}}),L=function(n){var e=n===gn,r=t("name")?M(e?se:ce):null;return e&&!r&&f(),p("("),new n({name:r,argnames:function(n,e){for(;!t("punc",")");)n?n=!1:p(","),e.push(M(ue));return o(),e}(!0,[]),body:function(n,e){++I.in_function,I.in_directives=!0,I.in_loop=0,I.labels=[];var t=F();return--I.in_function,I.in_loop=n,I.labels=e,t}(I.in_loop,I.labels)})},V=function(n){return new qn({start:i(),definitions:k(n,!1),end:i()})},W=function(){return new Nn({start:i(),definitions:k(!1,!0),end:i()})},Y=function(){var n=I.token;l("operator","new");var e,r=X(!1);return t("punc","(")?(o(),e=x(")")):e=[],nn(new Rn({start:n,expression:r,args:e,end:i()}),!0)},X=function(n){if(t("operator","new"))return Y();var e=I.token;if(t("punc")){switch(e.value){case"(":o();var r=bn(!0);return r.start=e,r.end=I.token,p(")"),nn(r,n);case"[":return nn(G(),n);case"{":return nn(J(),n)}f()}if(t("keyword","function")){o();var a=L(vn);return a.start=e,a.end=i(),nn(a,n)}return Xe[I.token.type]?nn(B(),n):void f()},G=m(function(){return p("["),new Jn({elements:x("]",!e.strict,!0)})}),J=m(function(){p("{");for(var n=!0,r=[];!t("punc","}")&&(n?n=!1:p(","),e.strict||!t("punc","}"));){var a=I.token,u=a.type,s=T();if("name"==u&&!t("punc",":")){if("get"==s){r.push(new ee({start:a,key:B(),value:L(mn),end:i()}));continue}if("set"==s){r.push(new ne({start:a,key:B(),value:L(mn),end:i()}));continue}}p(":"),r.push(new Qn({start:a,quote:a.quote,key:s,value:bn(!1),end:i()}))}return o(),new Kn({properties:r})}),nn=function(n,e){var r=n.start;if(t("punc","."))return o(),nn(new In({start:r,expression:n,property:O(),end:i()}),e);if(t("punc","[")){o();var a=bn(!0);return p("]"),nn(new Un({start:r,expression:n,property:a,end:i()}),e)}return e&&t("punc","(")?(o(),nn(new Hn({start:r,expression:n,args:x(")"),end:i()}),!0)):n},rn=function(n){var e=I.token;if(t("operator")&&Ue(e.value)){o(),v();var r=q(Vn,e.value,rn(n));return r.start=e,r.end=i(),r}for(var a=X(n);t("operator")&&Le(I.token.value)&&!I.token.nlb;)a=q(Wn,I.token.value,a),a.start=e,a.end=I.token,o();return a},un=function(n,e,r){var i=t("operator")?I.token.value:null;"in"==i&&r&&(i=null);var a=null!=i?We[i]:null;if(null!=a&&a>e){o();var u=un(rn(!0),a,r);return un(new Yn({start:n.start,left:n,operator:i,right:u,end:u.end}),e,r)}return n},dn=function(n){var e=I.token,r=R(n);if(t("operator","?")){o();var a=bn(!1);return p(":"),new Xn({start:e,condition:r,consequent:a,alternative:bn(!1,n),end:i()})}return r},_n=function(n){var e=I.token,r=dn(n),a=I.token.value;if(t("operator")&&Ve(a)){if(j(r))return o(),new Gn({start:e,left:r,operator:a,right:_n(n),end:i()});u("Invalid assignment")}return r},bn=function(n,e){var i=I.token,a=_n(e);return n&&t("punc",",")?(o(),new jn({start:i,car:a,cdr:bn(!0,e),end:r()})):a};return e.expression?bn(!0):function(){for(var n=I.token,r=[];!t("eof");)r.push(U());var o=i(),a=e.toplevel;return a?(a.body=a.body.concat(r),a.end=o):a=new hn({start:n,body:r,end:o}),a}()}function j(n,e){E.call(this),this.before=n,this.after=e}function P(n,e,t){this.name=t.name,this.orig=[t],this.scope=n,this.references=[],this.global=!1,this.mangled_name=null,this.undeclared=!1,this.constant=!1,this.index=e}function I(n){function e(n,e){return n.replace(/[\u0080-\uffff]/g,function(n){var t=n.charCodeAt(0).toString(16);if(t.length<=2&&!e){for(;t.length<2;)t="0"+t;return"\\x"+t}for(;t.length<4;)t="0"+t;return"\\u"+t})}function t(t,r){function o(){return"'"+t.replace(/\x27/g,"\\'")+"'"}function i(){return'"'+t.replace(/\x22/g,'\\"')+'"'}var a=0,u=0;switch(t=t.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0\ufeff]/g,function(n){switch(n){case"\\":return"\\\\";case"\b":return"\\b";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";case'"':return++a,'"';case"'":return++u,"'";case"\x00":return"\\x00";case"\ufeff":return"\\ufeff"}return n}),n.ascii_only&&(t=e(t)),n.quote_style){case 1:return o();case 2:return i();case 3:return"'"==r?o():i();default:return a>u?o():i()}}function r(e,r){var o=t(e,r);return n.inline_script&&(o=o.replace(/<\x2fscript([>\/\t\n\f\r ])/gi,"<\\/script$1")),o}function o(t){return t=t.toString(),n.ascii_only&&(t=e(t,!0)),t}function i(e){return u(" ",n.indent_start+A-e*n.indent_level)}function a(){return k.charAt(k.length-1)}function s(){n.max_line_len&&w>n.max_line_len&&f("\n")}function f(e){e=String(e);var t=e.charAt(0);if(S&&(t&&!(";}".indexOf(t)<0)||/[;]$/.test(k)||(n.semicolons||B(t)?(F+=";",w++,D++):(F+="\n",D++,E++,w=0),n.beautify||(C=!1)),S=!1,s()),!n.beautify&&n.preserve_line&&z[z.length-1])for(var r=z[z.length-1].start.line;r>E;)F+="\n",D++,E++,w=0,C=!1;if(C){var o=a();(O(o)&&(O(t)||"\\"==t)||/^[\+\-\/]$/.test(t)&&t==o)&&(F+=" ",w++,D++),C=!1}var i=e.split(/\r?\n/),u=i.length-1;E+=u,0==u?w+=i[u].length:w=i[u].length,D+=e.length,k=e,F+=e}function p(){S=!1,f(";")}function d(){return A+n.indent_level}function h(n){var e;return f("{"),M(),$(d(),function(){e=n()}),T(),f("}"),e}function _(n){f("(");var e=n();return f(")"),e}function m(n){f("[");var e=n();return f("]"),e}function v(){f(","),x()}function b(){f(":"),n.space_colon&&x()}function y(){return F}n=c(n,{indent_start:0,indent_level:4,quote_keys:!1,space_colon:!0,ascii_only:!1,unescape_regexps:!1,inline_script:!1,width:80,max_line_len:32e3,beautify:!1,source_map:null,bracketize:!1,semicolons:!0,comments:!1,preserve_line:!1,screw_ie8:!1,preamble:null,quote_style:0},!0);var A=0,w=0,E=1,D=0,F="",C=!1,S=!1,k=null,B=g("( [ + * / - , ."),x=n.beautify?function(){f(" ")}:function(){C=!0},T=n.beautify?function(e){n.beautify&&f(i(e?.5:0))}:l,$=n.beautify?function(n,e){n===!0&&(n=d());var t=A;A=n;var r=e();return A=t,r}:function(n,e){return e()},M=n.beautify?function(){f("\n")}:s,q=n.beautify?function(){f(";")}:function(){S=!0},N=n.source_map?function(e,t){try{e&&n.source_map.add(e.file||"?",E,w,e.line,e.col,t||"name"!=e.type?t:e.value)}catch(r){G.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]",{file:e.file,line:e.line,col:e.col,cline:E,ccol:w,name:t||""})}}:l;n.preamble&&f(n.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g,"\n"));var z=[];return{get:y,toString:y,indent:T,indentation:function(){return A},current_width:function(){return w-A},should_break:function(){return n.width&&this.current_width()>=n.width},newline:M,print:f,space:x,comma:v,colon:b,last:function(){return k},semicolon:q,force_semicolon:p,to_ascii:e,print_name:function(n){f(o(n))},print_string:function(n,e){f(r(n,e))},next_indent:d,with_indent:$,with_block:h,with_parens:_,with_square:m,add_mapping:N,option:function(e){return n[e]},line:function(){return E},col:function(){return w},pos:function(){return D},push_node:function(n){z.push(n)},pop_node:function(){return z.pop()},stack:function(){return z},parent:function(n){return z[z.length-2-(n||0)]}}}function U(n,e){return this instanceof U?(j.call(this,this.before,this.after),void(this.options=c(n,{sequences:!e,properties:!e,dead_code:!e,drop_debugger:!e,unsafe:!1,unsafe_comps:!1,conditionals:!e,comparisons:!e,evaluate:!e,booleans:!e,loops:!e,unused:!e,hoist_funs:!e,keep_fargs:!1,keep_fnames:!1,hoist_vars:!1,if_return:!e,join_vars:!e,cascade:!e,side_effects:!e,pure_getters:!1,pure_funcs:null,negate_iife:!e,screw_ie8:!1,drop_console:!1,angular:!1,warnings:!0,global_defs:{}},!0))):new U(n,e)}function L(n){function e(e,o,i,a,u,s){if(r){var c=r.originalPositionFor({line:a,column:u});if(null===c.source)return;e=c.source,a=c.line,u=c.column,s=c.name||s}t.addMapping({generated:{line:o+n.dest_line_diff,column:i},original:{line:a+n.orig_line_diff,column:u},source:e,name:s})}n=c(n,{file:null,root:null,orig:null,orig_line_diff:0,dest_line_diff:0});var t,r=n.orig&&new MOZ_SourceMap.SourceMapConsumer(n.orig);return t=r?MOZ_SourceMap.SourceMapGenerator.fromSourceMap(r):new MOZ_SourceMap.SourceMapGenerator({file:n.file,sourceRoot:n.root}),{add:e,get:function(){return t},toString:function(){return JSON.stringify(t.toJSON())}}}function V(){function n(n){p(e,n)}var e=[];return[Object,Array,Function,Number,String,Boolean,Error,Math,Date,RegExp].forEach(function(e){Object.getOwnPropertyNames(e).map(n),e.prototype&&Object.getOwnPropertyNames(e.prototype).map(n)}),e}function W(n,e){function t(n){return s.indexOf(n)>=0?!1:/^[0-9.]+$/.test(n)?!1:!0}function r(n){return f.props.has(n)||l.indexOf(n)>=0}function o(n){t(n)&&p(l,n)}function i(n){var e=f.props.get(n);if(!e){do e=Ge(++f.cname);while(!t(e));f.props.set(n,e)}return e}function a(n){var e={};try{!function r(n){n.walk(new E(function(n){if(n instanceof jn)return r(n.cdr),!0;if(n instanceof me)return o(n.value),!0;if(n instanceof Xn)return r(n.consequent),r(n.alternative),!0;throw e}))}(n)}catch(t){if(t!==e)throw t}}function u(n){return n.transform(new j(function(n){return n instanceof jn?n.cdr=u(n.cdr):n instanceof me?r(n.value)&&(n.value=i(n.value)):n instanceof Xn&&(n.consequent=u(n.consequent),n.alternative=u(n.alternative)),n}))}e=c(e,{reserved:null,cache:null});var s=e.reserved;null==s&&(s=V());var f=e.cache;null==f&&(f={cname:-1,props:new y});var l=[];return n.walk(new E(function(n){n instanceof Qn?o(n.key):n instanceof Zn?o(n.key.name):n instanceof In?this.parent()instanceof Gn&&o(n.property):n instanceof Un&&this.parent()instanceof Gn&&a(n.property)})),n.transform(new j(null,function(n){n instanceof Qn?r(n.key)&&(n.key=i(n.key)):n instanceof Zn?r(n.key.name)&&(n.key.name=i(n.key.name)):n instanceof In?r(n.property)&&(n.property=i(n.property)):n instanceof Un&&(n.property=u(n.property))}))}e.UglifyJS=n,s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s.croak=function(n,e){throw new s(n,e)};var Y=function(){function n(n,i,a){function u(){var u=i(n[s],s),l=u instanceof r;return l&&(u=u.v),u instanceof e?(u=u.v,u instanceof t?f.push.apply(f,a?u.v.slice().reverse():u.v):f.push(u)):u!==o&&(u instanceof t?c.push.apply(c,a?u.v.slice().reverse():u.v):c.push(u)),l}var s,c=[],f=[];if(n instanceof Array)if(a){for(s=n.length;--s>=0&&!u(););c.reverse(),f.reverse()}else for(s=0;s SymbolDef for all variables/functions defined in this scope",functions:"[Object/S] like `variables`, but only lists function declarations",uses_with:"[boolean/S] tells whether this scope uses the `with` statement",uses_eval:"[boolean/S] tells whether this scope contains a direct call to the global `eval`",parent_scope:"[AST_Scope?/S] link to the parent scope",enclosed:"[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",cname:"[integer/S] current index for mangling variables (used internally by the mangler)"}},nn),hn=A("Toplevel","globals",{$documentation:"The toplevel scope",$propdoc:{globals:"[Object/S] a map of name -> SymbolDef for all undeclared names"},wrap_enclose:function(n){var e=this,t=[],r=[];n.forEach(function(n){var e=n.lastIndexOf(":");t.push(n.substr(0,e)),r.push(n.substr(e+1))});var o="(function("+r.join(",")+"){ '$ORIG'; })("+t.join(",")+")";return o=R(o),o=o.transform(new j(function(n){return n instanceof Z&&"$ORIG"==n.value?Y.splice(e.body):void 0}))},wrap_commonjs:function(n,e){var t=this,r=[];e&&(t.figure_out_scope(),t.walk(new E(function(n){n instanceof oe&&n.definition().global&&(a(function(e){return e.name==n.name},r)||r.push(n))})));var o="(function(exports, global){ global['"+n+"'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";return o=R(o),o=o.transform(new j(function(n){if(n instanceof Q&&(n=n.body,n instanceof me))switch(n.getValue()){case"$ORIG":return Y.splice(t.body);case"$EXPORTS":var e=[];return r.forEach(function(n){e.push(new Q({body:new Gn({left:new Un({expression:new pe({name:"exports"}),property:new me({value:n.name})}),operator:"=",right:new pe(n)})}))}),Y.splice(e)}}))}},dn),_n=A("Lambda","name argnames uses_arguments",{$documentation:"Base class for functions",$propdoc:{name:"[AST_SymbolDeclaration?] the name of this function",argnames:"[AST_SymbolFunarg*] array of function arguments",uses_arguments:"[boolean/S] tells whether this function accesses the arguments array"},_walk:function(n){return n._visit(this,function(){this.name&&this.name._walk(n),this.argnames.forEach(function(e){e._walk(n)}),w(this,n)})}},dn),mn=A("Accessor",null,{$documentation:"A setter/getter function. The `name` property is always null."},_n),vn=A("Function",null,{$documentation:"A function expression" },_n),gn=A("Defun",null,{$documentation:"A function definition"},_n),bn=A("Jump",null,{$documentation:"Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"},J),yn=A("Exit","value",{$documentation:"Base class for “exits” (`return` and `throw`)",$propdoc:{value:"[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"},_walk:function(n){return n._visit(this,this.value&&function(){this.value._walk(n)})}},bn),An=A("Return",null,{$documentation:"A `return` statement"},yn),wn=A("Throw",null,{$documentation:"A `throw` statement"},yn),En=A("LoopControl","label",{$documentation:"Base class for loop control statements (`break` and `continue`)",$propdoc:{label:"[AST_LabelRef?] the label, or null if none"},_walk:function(n){return n._visit(this,this.label&&function(){this.label._walk(n)})}},bn),Dn=A("Break",null,{$documentation:"A `break` statement"},En),Fn=A("Continue",null,{$documentation:"A `continue` statement"},En),Cn=A("If","condition alternative",{$documentation:"A `if` statement",$propdoc:{condition:"[AST_Node] the `if` condition",alternative:"[AST_Statement?] the `else` part, or null if not present"},_walk:function(n){return n._visit(this,function(){this.condition._walk(n),this.body._walk(n),this.alternative&&this.alternative._walk(n)})}},rn),Sn=A("Switch","expression",{$documentation:"A `switch` statement",$propdoc:{expression:"[AST_Node] the `switch` “discriminant”"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n),w(this,n)})}},nn),kn=A("SwitchBranch",null,{$documentation:"Base class for `switch` branches"},nn),Bn=A("Default",null,{$documentation:"A `default` switch branch"},kn),xn=A("Case","expression",{$documentation:"A `case` switch branch",$propdoc:{expression:"[AST_Node] the `case` expression"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n),w(this,n)})}},kn),Tn=A("Try","bcatch bfinally",{$documentation:"A `try` statement",$propdoc:{bcatch:"[AST_Catch?] the catch block, or null if not present",bfinally:"[AST_Finally?] the finally block, or null if not present"},_walk:function(n){return n._visit(this,function(){w(this,n),this.bcatch&&this.bcatch._walk(n),this.bfinally&&this.bfinally._walk(n)})}},nn),On=A("Catch","argname",{$documentation:"A `catch` node; only makes sense as part of a `try` statement",$propdoc:{argname:"[AST_SymbolCatch] symbol for the exception"},_walk:function(n){return n._visit(this,function(){this.argname._walk(n),w(this,n)})}},nn),$n=A("Finally",null,{$documentation:"A `finally` node; only makes sense as part of a `try` statement"},nn),Mn=A("Definitions","definitions",{$documentation:"Base class for `var` or `const` nodes (variable declarations/initializations)",$propdoc:{definitions:"[AST_VarDef*] array of variable definitions"},_walk:function(n){return n._visit(this,function(){this.definitions.forEach(function(e){e._walk(n)})})}},J),qn=A("Var",null,{$documentation:"A `var` statement"},Mn),Nn=A("Const",null,{$documentation:"A `const` statement"},Mn),zn=A("VarDef","name value",{$documentation:"A variable declaration; only appears in a AST_Definitions node",$propdoc:{name:"[AST_SymbolVar|AST_SymbolConst] name of the variable",value:"[AST_Node?] initializer, or null of there's no initializer"},_walk:function(n){return n._visit(this,function(){this.name._walk(n),this.value&&this.value._walk(n)})}}),Hn=A("Call","expression args",{$documentation:"A function call expression",$propdoc:{expression:"[AST_Node] expression to invoke as function",args:"[AST_Node*] array of arguments"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n),this.args.forEach(function(e){e._walk(n)})})}}),Rn=A("New",null,{$documentation:"An object instantiation. Derives from a function call since it has exactly the same properties"},Hn),jn=A("Seq","car cdr",{$documentation:"A sequence expression (two comma-separated expressions)",$propdoc:{car:"[AST_Node] first element in sequence",cdr:"[AST_Node] second element in sequence"},$cons:function(n,e){var t=new jn(n);return t.car=n,t.cdr=e,t},$from_array:function(n){if(0==n.length)return null;if(1==n.length)return n[0].clone();for(var e=null,t=n.length;--t>=0;)e=jn.cons(n[t],e);for(var r=e;r;){if(r.cdr&&!r.cdr.cdr){r.cdr=r.cdr.car;break}r=r.cdr}return e},to_array:function(){for(var n=this,e=[];n;){if(e.push(n.car),n.cdr&&!(n.cdr instanceof jn)){e.push(n.cdr);break}n=n.cdr}return e},add:function(n){for(var e=this;e;){if(!(e.cdr instanceof jn)){var t=jn.cons(e.cdr,n);return e.cdr=t}e=e.cdr}},_walk:function(n){return n._visit(this,function(){this.car._walk(n),this.cdr&&this.cdr._walk(n)})}}),Pn=A("PropAccess","expression property",{$documentation:'Base class for property access expressions, i.e. `a.foo` or `a["foo"]`',$propdoc:{expression:"[AST_Node] the “container” expression",property:"[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node"}}),In=A("Dot",null,{$documentation:"A dotted property access expression",_walk:function(n){return n._visit(this,function(){this.expression._walk(n)})}},Pn),Un=A("Sub",null,{$documentation:'Index-style property access, i.e. `a["foo"]`',_walk:function(n){return n._visit(this,function(){this.expression._walk(n),this.property._walk(n)})}},Pn),Ln=A("Unary","operator expression",{$documentation:"Base class for unary expressions",$propdoc:{operator:"[string] the operator",expression:"[AST_Node] expression that this unary operator applies to"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n)})}}),Vn=A("UnaryPrefix",null,{$documentation:"Unary prefix expression, i.e. `typeof i` or `++i`"},Ln),Wn=A("UnaryPostfix",null,{$documentation:"Unary postfix expression, i.e. `i++`"},Ln),Yn=A("Binary","left operator right",{$documentation:"Binary expression, i.e. `a + b`",$propdoc:{left:"[AST_Node] left-hand side expression",operator:"[string] the operator",right:"[AST_Node] right-hand side expression"},_walk:function(n){return n._visit(this,function(){this.left._walk(n),this.right._walk(n)})}}),Xn=A("Conditional","condition consequent alternative",{$documentation:"Conditional expression using the ternary operator, i.e. `a ? b : c`",$propdoc:{condition:"[AST_Node]",consequent:"[AST_Node]",alternative:"[AST_Node]"},_walk:function(n){return n._visit(this,function(){this.condition._walk(n),this.consequent._walk(n),this.alternative._walk(n)})}}),Gn=A("Assign",null,{$documentation:"An assignment expression — `a = b + 5`"},Yn),Jn=A("Array","elements",{$documentation:"An array literal",$propdoc:{elements:"[AST_Node*] array of elements"},_walk:function(n){return n._visit(this,function(){this.elements.forEach(function(e){e._walk(n)})})}}),Kn=A("Object","properties",{$documentation:"An object literal",$propdoc:{properties:"[AST_ObjectProperty*] array of properties"},_walk:function(n){return n._visit(this,function(){this.properties.forEach(function(e){e._walk(n)})})}}),Zn=A("ObjectProperty","key value",{$documentation:"Base class for literal object properties",$propdoc:{key:"[string] the property name converted to a string for ObjectKeyVal. For setters and getters this is an arbitrary AST_Node.",value:"[AST_Node] property value. For setters and getters this is an AST_Function."},_walk:function(n){return n._visit(this,function(){this.value._walk(n)})}}),Qn=A("ObjectKeyVal","quote",{$documentation:"A key: value object property",$propdoc:{quote:"[string] the original quote character"}},Zn),ne=A("ObjectSetter",null,{$documentation:"An object setter property"},Zn),ee=A("ObjectGetter",null,{$documentation:"An object getter property"},Zn),te=A("Symbol","scope name thedef",{$propdoc:{name:"[string] name of this symbol",scope:"[AST_Scope/S] the current scope (not necessarily the definition scope)",thedef:"[SymbolDef/S] the definition of this symbol"},$documentation:"Base class for all symbols"}),re=A("SymbolAccessor",null,{$documentation:"The name of a property accessor (setter/getter function)"},te),oe=A("SymbolDeclaration","init",{$documentation:"A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",$propdoc:{init:"[AST_Node*/S] array of initializers for this declaration."}},te),ie=A("SymbolVar",null,{$documentation:"Symbol defining a variable"},oe),ae=A("SymbolConst",null,{$documentation:"A constant declaration"},oe),ue=A("SymbolFunarg",null,{$documentation:"Symbol naming a function argument"},ie),se=A("SymbolDefun",null,{$documentation:"Symbol defining a function"},oe),ce=A("SymbolLambda",null,{$documentation:"Symbol naming a function expression"},oe),fe=A("SymbolCatch",null,{$documentation:"Symbol naming the exception in catch"},oe),le=A("Label","references",{$documentation:"Symbol naming a label (declaration)",$propdoc:{references:"[AST_LoopControl*] a list of nodes referring to this label"},initialize:function(){this.references=[],this.thedef=this}},te),pe=A("SymbolRef",null,{$documentation:"Reference to some symbol (not definition/declaration)"},te),de=A("LabelRef",null,{$documentation:"Reference to a label symbol"},te),he=A("This",null,{$documentation:"The `this` symbol"},te),_e=A("Constant",null,{$documentation:"Base class for all constants",getValue:function(){return this.value}}),me=A("String","value quote",{$documentation:"A string literal",$propdoc:{value:"[string] the contents of this string",quote:"[string] the original quote character"}},_e),ve=A("Number","value",{$documentation:"A number literal",$propdoc:{value:"[number] the numeric value"}},_e),ge=A("RegExp","value",{$documentation:"A regexp literal",$propdoc:{value:"[RegExp] the actual regexp"}},_e),be=A("Atom",null,{$documentation:"Base class for atoms"},_e),ye=A("Null",null,{$documentation:"The `null` atom",value:null},be),Ae=A("NaN",null,{$documentation:"The impossible value",value:0/0},be),we=A("Undefined",null,{$documentation:"The `undefined` value",value:void 0},be),Ee=A("Hole",null,{$documentation:"A hole in an array",value:void 0},be),De=A("Infinity",null,{$documentation:"The `Infinity` value",value:1/0},be),Fe=A("Boolean",null,{$documentation:"Base class for booleans"},be),Ce=A("False",null,{$documentation:"The `false` atom",value:!1},Fe),Se=A("True",null,{$documentation:"The `true` atom",value:!0},Fe);E.prototype={_visit:function(n,e){this.stack.push(n);var t=this.visit(n,e?function(){e.call(n)}:l);return!t&&e&&e.call(n),this.stack.pop(),t},parent:function(n){return this.stack[this.stack.length-2-(n||0)]},push:function(n){this.stack.push(n)},pop:function(){return this.stack.pop()},self:function(){return this.stack[this.stack.length-1]},find_parent:function(n){for(var e=this.stack,t=e.length;--t>=0;){var r=e[t];if(r instanceof n)return r}},has_directive:function(n){return this.find_parent(dn).has_directive(n)},in_boolean_context:function(){for(var n=this.stack,e=n.length,t=n[--e];e>0;){var r=n[--e];if(r instanceof Cn&&r.condition===t||r instanceof Xn&&r.condition===t||r instanceof un&&r.condition===t||r instanceof fn&&r.condition===t||r instanceof Vn&&"!"==r.operator&&r.expression===t)return!0;if(!(r instanceof Yn)||"&&"!=r.operator&&"||"!=r.operator)return!1;t=r}},loopcontrol_target:function(n){var e=this.stack;if(n)for(var t=e.length;--t>=0;){var r=e[t];if(r instanceof on&&r.label.name==n.name)return r.body}else for(var t=e.length;--t>=0;){var r=e[t];if(r instanceof Sn||r instanceof an)return r}}};var ke="break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with",Be="false null true",xe="abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield "+Be+" "+ke,Te="return new delete throw else case";ke=g(ke),xe=g(xe),Te=g(Te),Be=g(Be);var Oe=g(o("+-*&%=<>!?|~^")),$e=/^0x[0-9a-f]+$/i,Me=/^0[0-7]+$/,qe=/^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i,Ne=g(["in","instanceof","typeof","new","void","delete","++","--","+","-","!","~","&","|","^","*","/","%",">>","<<",">>>","<",">","<=",">=","==","===","!=","!==","?","=","+=","-=","/=","*=","%=",">>=","<<=",">>>=","|=","^=","&=","&&","||"]),ze=g(o("  \n\r \f ​᠎              ")),He=g(o("[{(,.;:")),Re=g(o("[]{}(),;:")),je=g(o("gmsiy")),Pe={letter:new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),digit:new RegExp("[\\u0030-\\u0039\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE6-\\u0BEF\\u0C66-\\u0C6F\\u0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0DE6-\\u0DEF\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29\\u1040-\\u1049\\u1090-\\u1099\\u17E0-\\u17E9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19D9\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\uA620-\\uA629\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uA9F0-\\uA9F9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]"),non_spacing_mark:new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),space_combining_mark:new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),connector_punctuation:new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")};q.prototype.toString=function(){return this.message+" (line: "+this.line+", col: "+this.col+", pos: "+this.pos+")\n\n"+this.stack};var Ie={},Ue=g(["typeof","void","delete","--","++","!","~","-","+"]),Le=g(["--","++"]),Ve=g(["=","+=","-=","/=","*=","%=",">>=","<<=",">>>=","|=","^=","&="]),We=function(n,e){for(var t=0;t","<=",">=","in","instanceof"],[">>","<<",">>>"],["+","-"],["*","/","%"]],{}),Ye=t(["for","do","while","switch"]),Xe=t(["atom","num","string","regexp","name"]);j.prototype=new E,function(n){function e(e,t){e.DEFMETHOD("transform",function(e,r){var o,i;return e.push(this),e.before&&(o=e.before(this,t,r)),o===n&&(e.after?(e.stack[e.stack.length-1]=o=this.clone(),t(o,e),i=e.after(o,r),i!==n&&(o=i)):(o=this,t(o,e))),e.pop(),o})}function t(n,e){return Y(n,function(n){return n.transform(e,!0)})}e(G,l),e(on,function(n,e){n.label=n.label.transform(e),n.body=n.body.transform(e)}),e(Q,function(n,e){n.body=n.body.transform(e)}),e(nn,function(n,e){n.body=t(n.body,e)}),e(un,function(n,e){n.condition=n.condition.transform(e),n.body=n.body.transform(e)}),e(fn,function(n,e){n.init&&(n.init=n.init.transform(e)),n.condition&&(n.condition=n.condition.transform(e)),n.step&&(n.step=n.step.transform(e)),n.body=n.body.transform(e)}),e(ln,function(n,e){n.init=n.init.transform(e),n.object=n.object.transform(e),n.body=n.body.transform(e)}),e(pn,function(n,e){n.expression=n.expression.transform(e),n.body=n.body.transform(e)}),e(yn,function(n,e){n.value&&(n.value=n.value.transform(e))}),e(En,function(n,e){n.label&&(n.label=n.label.transform(e))}),e(Cn,function(n,e){n.condition=n.condition.transform(e),n.body=n.body.transform(e),n.alternative&&(n.alternative=n.alternative.transform(e))}),e(Sn,function(n,e){n.expression=n.expression.transform(e),n.body=t(n.body,e)}),e(xn,function(n,e){n.expression=n.expression.transform(e),n.body=t(n.body,e)}),e(Tn,function(n,e){n.body=t(n.body,e),n.bcatch&&(n.bcatch=n.bcatch.transform(e)),n.bfinally&&(n.bfinally=n.bfinally.transform(e))}),e(On,function(n,e){n.argname=n.argname.transform(e),n.body=t(n.body,e)}),e(Mn,function(n,e){n.definitions=t(n.definitions,e)}),e(zn,function(n,e){n.name=n.name.transform(e),n.value&&(n.value=n.value.transform(e))}),e(_n,function(n,e){n.name&&(n.name=n.name.transform(e)),n.argnames=t(n.argnames,e),n.body=t(n.body,e)}),e(Hn,function(n,e){n.expression=n.expression.transform(e),n.args=t(n.args,e)}),e(jn,function(n,e){n.car=n.car.transform(e),n.cdr=n.cdr.transform(e)}),e(In,function(n,e){n.expression=n.expression.transform(e)}),e(Un,function(n,e){n.expression=n.expression.transform(e),n.property=n.property.transform(e)}),e(Ln,function(n,e){n.expression=n.expression.transform(e)}),e(Yn,function(n,e){n.left=n.left.transform(e),n.right=n.right.transform(e)}),e(Xn,function(n,e){n.condition=n.condition.transform(e),n.consequent=n.consequent.transform(e),n.alternative=n.alternative.transform(e)}),e(Jn,function(n,e){n.elements=t(n.elements,e)}),e(Kn,function(n,e){n.properties=t(n.properties,e)}),e(Zn,function(n,e){n.value=n.value.transform(e)})}(),P.prototype={unmangleable:function(n){return n||(n={}),this.global&&!n.toplevel||this.undeclared||!n.eval&&(this.scope.uses_eval||this.scope.uses_with)||n.keep_fnames&&(this.orig[0]instanceof ce||this.orig[0]instanceof se)},mangle:function(n){var e=n.cache&&n.cache.props;if(this.global&&e&&e.has(this.name))this.mangled_name=e.get(this.name);else if(!this.mangled_name&&!this.unmangleable(n)){var t=this.scope;!n.screw_ie8&&this.orig[0]instanceof ce&&(t=t.parent_scope),this.mangled_name=t.next_mangled(n,this),this.global&&e&&e.set(this.name,this.mangled_name)}}},hn.DEFMETHOD("figure_out_scope",function(n){n=c(n,{screw_ie8:!1,cache:null});var e=this,t=e.parent_scope=null,r=null,o=0,i=new E(function(e,a){if(n.screw_ie8&&e instanceof On){var u=t;return t=new dn(e),t.init_scope_vars(o),t.parent_scope=u,a(),t=u,!0}if(e instanceof dn){e.init_scope_vars(o);var u=e.parent_scope=t,s=r;return r=t=e,++o,a(),--o,t=u,r=s,!0}if(e instanceof Z)return e.scope=t,p(t.directives,e.value),!0;if(e instanceof pn)for(var c=t;c;c=c.parent_scope)c.uses_with=!0;else if(e instanceof te&&(e.scope=t),e instanceof ce)r.def_function(e);else if(e instanceof se)(e.scope=r.parent_scope).def_function(e);else if(e instanceof ie||e instanceof ae){var f=r.def_variable(e);f.constant=e instanceof ae,f.init=i.parent().value}else e instanceof fe&&(n.screw_ie8?t:r).def_variable(e)});e.walk(i);var a=null,u=e.globals=new y,i=new E(function(n,t){if(n instanceof _n){var r=a;return a=n,t(),a=r,!0}if(n instanceof pe){var o=n.name,s=n.scope.find_variable(o);if(s)n.thedef=s;else{var c;if(u.has(o)?c=u.get(o):(c=new P(e,u.size(),n),c.undeclared=!0,c.global=!0,u.set(o,c)),n.thedef=c,"eval"==o&&i.parent()instanceof Hn)for(var f=n.scope;f&&!f.uses_eval;f=f.parent_scope)f.uses_eval=!0;a&&"arguments"==o&&(a.uses_arguments=!0)}return n.reference(),!0}});e.walk(i),n.cache&&(this.cname=n.cache.cname)}),dn.DEFMETHOD("init_scope_vars",function(n){this.directives=[],this.variables=new y,this.functions=new y,this.uses_with=!1,this.uses_eval=!1,this.parent_scope=null,this.enclosed=[],this.cname=-1,this.nesting=n}),dn.DEFMETHOD("strict",function(){return this.has_directive("use strict")}),_n.DEFMETHOD("init_scope_vars",function(){dn.prototype.init_scope_vars.apply(this,arguments),this.uses_arguments=!1}),pe.DEFMETHOD("reference",function(){var n=this.definition();n.references.push(this);for(var e=this.scope;e&&(p(e.enclosed,n),e!==n.scope);)e=e.parent_scope;this.frame=this.scope.nesting-n.scope.nesting}),dn.DEFMETHOD("find_variable",function(n){return n instanceof te&&(n=n.name),this.variables.get(n)||this.parent_scope&&this.parent_scope.find_variable(n)}),dn.DEFMETHOD("has_directive",function(n){return this.parent_scope&&this.parent_scope.has_directive(n)||(this.directives.indexOf(n)>=0?this:null)}),dn.DEFMETHOD("def_function",function(n){this.functions.set(n.name,this.def_variable(n))}),dn.DEFMETHOD("def_variable",function(n){var e;return this.variables.has(n.name)?(e=this.variables.get(n.name),e.orig.push(n)):(e=new P(this,this.variables.size(),n),this.variables.set(n.name,e),e.global=!this.parent_scope),n.thedef=e}),dn.DEFMETHOD("next_mangled",function(n){var e=this.enclosed;n:for(;;){var t=Ge(++this.cname);if(x(t)&&!(n.except.indexOf(t)>=0)){for(var r=e.length;--r>=0;){var o=e[r],i=o.mangled_name||o.unmangleable(n)&&o.name;if(t==i)continue n}return t}}}),vn.DEFMETHOD("next_mangled",function(n,e){for(var t=e.orig[0]instanceof ue&&this.name&&this.name.definition();;){var r=_n.prototype.next_mangled.call(this,n,e);if(!t||t.mangled_name!=r)return r}}),dn.DEFMETHOD("references",function(n){return n instanceof te&&(n=n.definition()),this.enclosed.indexOf(n)<0?null:n}),te.DEFMETHOD("unmangleable",function(n){return this.definition().unmangleable(n)}),re.DEFMETHOD("unmangleable",function(){return!0}),le.DEFMETHOD("unmangleable",function(){return!1}),te.DEFMETHOD("unreferenced",function(){return 0==this.definition().references.length&&!(this.scope.uses_eval||this.scope.uses_with)}),te.DEFMETHOD("undeclared",function(){return this.definition().undeclared}),de.DEFMETHOD("undeclared",function(){return!1}),le.DEFMETHOD("undeclared",function(){return!1}),te.DEFMETHOD("definition",function(){return this.thedef}),te.DEFMETHOD("global",function(){return this.definition().global}),hn.DEFMETHOD("_default_mangler_options",function(n){return c(n,{except:[],eval:!1,sort:!1,toplevel:!1,screw_ie8:!1,keep_fnames:!1})}),hn.DEFMETHOD("mangle_names",function(n){n=this._default_mangler_options(n);var e=-1,t=[];n.cache&&this.globals.each(function(e){n.except.indexOf(e.name)<0&&t.push(e)});var r=new E(function(o,i){if(o instanceof on){var a=e;return i(),e=a,!0}if(o instanceof dn){var u=(r.parent(),[]);return o.variables.each(function(e){n.except.indexOf(e.name)<0&&u.push(e)}),n.sort&&u.sort(function(n,e){return e.references.length-n.references.length}),void t.push.apply(t,u)}if(o instanceof le){var s;do s=Ge(++e);while(!x(s));return o.mangled_name=s,!0}return n.screw_ie8&&o instanceof fe?void t.push(o.definition()):void 0});this.walk(r),t.forEach(function(e){e.mangle(n)}),n.cache&&(n.cache.cname=this.cname)}),hn.DEFMETHOD("compute_char_frequency",function(n){n=this._default_mangler_options(n);var e=new E(function(e){e instanceof _e?Ge.consider(e.print_to_string()):e instanceof An?Ge.consider("return"):e instanceof wn?Ge.consider("throw"):e instanceof Fn?Ge.consider("continue"):e instanceof Dn?Ge.consider("break"):e instanceof K?Ge.consider("debugger"):e instanceof Z?Ge.consider(e.value):e instanceof cn?Ge.consider("while"):e instanceof sn?Ge.consider("do while"):e instanceof Cn?(Ge.consider("if"),e.alternative&&Ge.consider("else")):e instanceof qn?Ge.consider("var"):e instanceof Nn?Ge.consider("const"):e instanceof _n?Ge.consider("function"):e instanceof fn?Ge.consider("for"):e instanceof ln?Ge.consider("for in"):e instanceof Sn?Ge.consider("switch"):e instanceof xn?Ge.consider("case"):e instanceof Bn?Ge.consider("default"):e instanceof pn?Ge.consider("with"):e instanceof ne?Ge.consider("set"+e.key):e instanceof ee?Ge.consider("get"+e.key):e instanceof Qn?Ge.consider(e.key):e instanceof Rn?Ge.consider("new"):e instanceof he?Ge.consider("this"):e instanceof Tn?Ge.consider("try"):e instanceof On?Ge.consider("catch"):e instanceof $n?Ge.consider("finally"):e instanceof te&&e.unmangleable(n)?Ge.consider(e.name):e instanceof Ln||e instanceof Yn?Ge.consider(e.operator):e instanceof In&&Ge.consider(e.property)});this.walk(e),Ge.sort()});var Ge=function(){function n(){r=Object.create(null),t=o.split("").map(function(n){return n.charCodeAt(0)}),t.forEach(function(n){r[n]=0})}function e(n){var e="",r=54;n++;do n--,e+=String.fromCharCode(t[n%r]),n=Math.floor(n/r),r=64;while(n>0);return e}var t,r,o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";return e.consider=function(n){for(var e=n.length;--e>=0;){var t=n.charCodeAt(e);t in r&&++r[t]}},e.sort=function(){t=_(t,function(n,e){return F(n)&&!F(e)?1:F(e)&&!F(n)?-1:r[e]-r[n]})},e.reset=n,n(),e.get=function(){return t},e.freq=function(){return r},e}();hn.DEFMETHOD("scope_warnings",function(n){n=c(n,{undeclared:!1,unreferenced:!0,assign_to_global:!0,func_arguments:!0,nested_defuns:!0,eval:!0});var e=new E(function(t){if(n.undeclared&&t instanceof pe&&t.undeclared()&&G.warn("Undeclared symbol: {name} [{file}:{line},{col}]",{name:t.name,file:t.start.file,line:t.start.line,col:t.start.col}),n.assign_to_global){ var r=null;t instanceof Gn&&t.left instanceof pe?r=t.left:t instanceof ln&&t.init instanceof pe&&(r=t.init),r&&(r.undeclared()||r.global()&&r.scope!==r.definition().scope)&&G.warn("{msg}: {name} [{file}:{line},{col}]",{msg:r.undeclared()?"Accidental global?":"Assignment to global",name:r.name,file:r.start.file,line:r.start.line,col:r.start.col})}n.eval&&t instanceof pe&&t.undeclared()&&"eval"==t.name&&G.warn("Eval is used [{file}:{line},{col}]",t.start),n.unreferenced&&(t instanceof oe||t instanceof le)&&!(t instanceof fe)&&t.unreferenced()&&G.warn("{type} {name} is declared but not referenced [{file}:{line},{col}]",{type:t instanceof le?"Label":"Symbol",name:t.name,file:t.start.file,line:t.start.line,col:t.start.col}),n.func_arguments&&t instanceof _n&&t.uses_arguments&&G.warn("arguments used in function {name} [{file}:{line},{col}]",{name:t.name?t.name.name:"anonymous",file:t.start.file,line:t.start.line,col:t.start.col}),n.nested_defuns&&t instanceof gn&&!(e.parent()instanceof dn)&&G.warn('Function {name} declared in nested statement "{type}" [{file}:{line},{col}]',{name:t.name.name,type:e.parent().TYPE,file:t.start.file,line:t.start.line,col:t.start.col})});this.walk(e)}),function(){function n(n,e){n.DEFMETHOD("_codegen",e)}function e(n,t){Array.isArray(n)?n.forEach(function(n){e(n,t)}):n.DEFMETHOD("needs_parens",t)}function t(n,e,t){var r=n.length-1;n.forEach(function(n,o){n instanceof tn||(t.indent(),n.print(t),o==r&&e||(t.newline(),e&&t.newline()))})}function r(n,e){n.length>0?e.with_block(function(){t(n,!1,e)}):e.print("{}")}function o(n,e){if(e.option("bracketize"))return void d(n.body,e);if(!n.body)return e.force_semicolon();if(n.body instanceof sn&&!e.option("screw_ie8"))return void d(n.body,e);for(var t=n.body;;)if(t instanceof Cn){if(!t.alternative)return void d(n.body,e);t=t.alternative}else{if(!(t instanceof rn))break;t=t.body}u(n.body,e)}function i(n,e,t){if(t)try{n.walk(new E(function(n){if(n instanceof Yn&&"in"==n.operator)throw e})),n.print(e)}catch(r){if(r!==e)throw r;n.print(e,!0)}else n.print(e)}function a(n){return[92,47,46,43,42,63,40,41,91,93,123,125,36,94,58,124,33,10,13,0,65279,8232,8233].indexOf(n)<0}function u(n,e){e.option("bracketize")?!n||n instanceof tn?e.print("{}"):n instanceof en?n.print(e):e.with_block(function(){e.indent(),n.print(e),e.newline()}):!n||n instanceof tn?e.force_semicolon():n.print(e)}function s(n){for(var e=n.stack(),t=e.length,r=e[--t],o=e[--t];t>0;){if(o instanceof J&&o.body===r)return!0;if(!(o instanceof jn&&o.car===r||o instanceof Hn&&o.expression===r&&!(o instanceof Rn)||o instanceof In&&o.expression===r||o instanceof Un&&o.expression===r||o instanceof Xn&&o.condition===r||o instanceof Yn&&o.left===r||o instanceof Wn&&o.expression===r))return!1;r=o,o=e[--t]}}function c(n,e){return 0==n.args.length&&!e.option("beautify")}function f(n){for(var e=n[0],t=e.length,r=1;r=0?r.push("0x"+n.toString(16).toLowerCase(),"0"+n.toString(8)):r.push("-0x"+(-n).toString(16).toLowerCase(),"-0"+(-n).toString(8)),(e=/^(.*?)(0+)$/.exec(n))&&r.push(e[1]+"e"+e[2].length)):(e=/^0?\.(0+)(.*)$/.exec(n))&&r.push(e[2]+"e-"+(e[1].length+e[2].length),t.substr(t.indexOf("."))),f(r)}function d(n,e){return n instanceof en?void n.print(e):void e.with_block(function(){e.indent(),n.print(e),e.newline()})}function h(n,e){n.DEFMETHOD("add_source_map",function(n){e(this,n)})}function _(n,e){e.add_mapping(n.start)}G.DEFMETHOD("print",function(n,e){function t(){r.add_comments(n),r.add_source_map(n),o(r,n)}var r=this,o=r._codegen;n.push_node(r),e||r.needs_parens(n)?n.with_parens(t):t(),n.pop_node()}),G.DEFMETHOD("print_to_string",function(n){var e=I(n);return this.print(e),e.get()}),G.DEFMETHOD("add_comments",function(n){var e=n.option("comments"),t=this;if(e){var r=t.start;if(r&&!r._comments_dumped){r._comments_dumped=!0;var o=r.comments_before||[];t instanceof yn&&t.value&&t.value.walk(new E(function(n){return n.start&&n.start.comments_before&&(o=o.concat(n.start.comments_before),n.start.comments_before=[]),n instanceof vn||n instanceof Jn||n instanceof Kn?!0:void 0})),e.test?o=o.filter(function(n){return e.test(n.value)}):"function"==typeof e&&(o=o.filter(function(n){return e(t,n)})),!n.option("beautify")&&o.length>0&&/comment[134]/.test(o[0].type)&&0!==n.col()&&o[0].nlb&&n.print("\n"),o.forEach(function(e){/comment[134]/.test(e.type)?(n.print("//"+e.value+"\n"),n.indent()):"comment2"==e.type&&(n.print("/*"+e.value+"*/"),r.nlb?(n.print("\n"),n.indent()):n.space())})}}}),e(G,function(){return!1}),e(vn,function(n){return s(n)}),e(Kn,function(n){return s(n)}),e([Ln,we],function(n){var e=n.parent();return e instanceof Pn&&e.expression===this}),e(jn,function(n){var e=n.parent();return e instanceof Hn||e instanceof Ln||e instanceof Yn||e instanceof zn||e instanceof Pn||e instanceof Jn||e instanceof Zn||e instanceof Xn}),e(Yn,function(n){var e=n.parent();if(e instanceof Hn&&e.expression===this)return!0;if(e instanceof Ln)return!0;if(e instanceof Pn&&e.expression===this)return!0;if(e instanceof Yn){var t=e.operator,r=We[t],o=this.operator,i=We[o];if(r>i||r==i&&this===e.right)return!0}}),e(Pn,function(n){var e=n.parent();if(e instanceof Rn&&e.expression===this)try{this.walk(new E(function(n){if(n instanceof Hn)throw e}))}catch(t){if(t!==e)throw t;return!0}}),e(Hn,function(n){var e,t=n.parent();return t instanceof Rn&&t.expression===this?!0:this.expression instanceof vn&&t instanceof Pn&&t.expression===this&&(e=n.parent(1))instanceof Gn&&e.left===t}),e(Rn,function(n){var e=n.parent();return c(this,n)&&(e instanceof Pn||e instanceof Hn&&e.expression===this)?!0:void 0}),e(ve,function(n){var e=n.parent();return this.getValue()<0&&e instanceof Pn&&e.expression===this?!0:void 0}),e([Gn,Xn],function(n){var e=n.parent();return e instanceof Ln?!0:e instanceof Yn&&!(e instanceof Gn)?!0:e instanceof Hn&&e.expression===this?!0:e instanceof Xn&&e.condition===this?!0:e instanceof Pn&&e.expression===this?!0:void 0}),n(Z,function(n,e){e.print_string(n.value,n.quote),e.semicolon()}),n(K,function(n,e){e.print("debugger"),e.semicolon()}),rn.DEFMETHOD("_do_print_body",function(n){u(this.body,n)}),n(J,function(n,e){n.body.print(e),e.semicolon()}),n(hn,function(n,e){t(n.body,!0,e),e.print("")}),n(on,function(n,e){n.label.print(e),e.colon(),n.body.print(e)}),n(Q,function(n,e){n.body.print(e),e.semicolon()}),n(en,function(n,e){r(n.body,e)}),n(tn,function(n,e){e.semicolon()}),n(sn,function(n,e){e.print("do"),e.space(),n._do_print_body(e),e.space(),e.print("while"),e.space(),e.with_parens(function(){n.condition.print(e)}),e.semicolon()}),n(cn,function(n,e){e.print("while"),e.space(),e.with_parens(function(){n.condition.print(e)}),e.space(),n._do_print_body(e)}),n(fn,function(n,e){e.print("for"),e.space(),e.with_parens(function(){!n.init||n.init instanceof tn?e.print(";"):(n.init instanceof Mn?n.init.print(e):i(n.init,e,!0),e.print(";"),e.space()),n.condition?(n.condition.print(e),e.print(";"),e.space()):e.print(";"),n.step&&n.step.print(e)}),e.space(),n._do_print_body(e)}),n(ln,function(n,e){e.print("for"),e.space(),e.with_parens(function(){n.init.print(e),e.space(),e.print("in"),e.space(),n.object.print(e)}),e.space(),n._do_print_body(e)}),n(pn,function(n,e){e.print("with"),e.space(),e.with_parens(function(){n.expression.print(e)}),e.space(),n._do_print_body(e)}),_n.DEFMETHOD("_do_print",function(n,e){var t=this;e||n.print("function"),t.name&&(n.space(),t.name.print(n)),n.with_parens(function(){t.argnames.forEach(function(e,t){t&&n.comma(),e.print(n)})}),n.space(),r(t.body,n)}),n(_n,function(n,e){n._do_print(e)}),yn.DEFMETHOD("_do_print",function(n,e){n.print(e),this.value&&(n.space(),this.value.print(n)),n.semicolon()}),n(An,function(n,e){n._do_print(e,"return")}),n(wn,function(n,e){n._do_print(e,"throw")}),En.DEFMETHOD("_do_print",function(n,e){n.print(e),this.label&&(n.space(),this.label.print(n)),n.semicolon()}),n(Dn,function(n,e){n._do_print(e,"break")}),n(Fn,function(n,e){n._do_print(e,"continue")}),n(Cn,function(n,e){e.print("if"),e.space(),e.with_parens(function(){n.condition.print(e)}),e.space(),n.alternative?(o(n,e),e.space(),e.print("else"),e.space(),u(n.alternative,e)):n._do_print_body(e)}),n(Sn,function(n,e){e.print("switch"),e.space(),e.with_parens(function(){n.expression.print(e)}),e.space(),n.body.length>0?e.with_block(function(){n.body.forEach(function(n,t){t&&e.newline(),e.indent(!0),n.print(e)})}):e.print("{}")}),kn.DEFMETHOD("_do_print_body",function(n){this.body.length>0&&(n.newline(),this.body.forEach(function(e){n.indent(),e.print(n),n.newline()}))}),n(Bn,function(n,e){e.print("default:"),n._do_print_body(e)}),n(xn,function(n,e){e.print("case"),e.space(),n.expression.print(e),e.print(":"),n._do_print_body(e)}),n(Tn,function(n,e){e.print("try"),e.space(),r(n.body,e),n.bcatch&&(e.space(),n.bcatch.print(e)),n.bfinally&&(e.space(),n.bfinally.print(e))}),n(On,function(n,e){e.print("catch"),e.space(),e.with_parens(function(){n.argname.print(e)}),e.space(),r(n.body,e)}),n($n,function(n,e){e.print("finally"),e.space(),r(n.body,e)}),Mn.DEFMETHOD("_do_print",function(n,e){n.print(e),n.space(),this.definitions.forEach(function(e,t){t&&n.comma(),e.print(n)});var t=n.parent(),r=t instanceof fn||t instanceof ln,o=r&&t.init===this;o||n.semicolon()}),n(qn,function(n,e){n._do_print(e,"var")}),n(Nn,function(n,e){n._do_print(e,"const")}),n(zn,function(n,e){if(n.name.print(e),n.value){e.space(),e.print("="),e.space();var t=e.parent(1),r=t instanceof fn||t instanceof ln;i(n.value,e,r)}}),n(Hn,function(n,e){n.expression.print(e),n instanceof Rn&&c(n,e)||e.with_parens(function(){n.args.forEach(function(n,t){t&&e.comma(),n.print(e)})})}),n(Rn,function(n,e){e.print("new"),e.space(),Hn.prototype._codegen(n,e)}),jn.DEFMETHOD("_do_print",function(n){this.car.print(n),this.cdr&&(n.comma(),n.should_break()&&(n.newline(),n.indent()),this.cdr.print(n))}),n(jn,function(n,e){n._do_print(e)}),n(In,function(n,e){var t=n.expression;t.print(e),t instanceof ve&&t.getValue()>=0&&(/[xa-f.]/i.test(e.last())||e.print(".")),e.print("."),e.add_mapping(n.end),e.print_name(n.property)}),n(Un,function(n,e){n.expression.print(e),e.print("["),n.property.print(e),e.print("]")}),n(Vn,function(n,e){var t=n.operator;e.print(t),(/^[a-z]/i.test(t)||/[+-]$/.test(t)&&n.expression instanceof Vn&&/^[+-]/.test(n.expression.operator))&&e.space(),n.expression.print(e)}),n(Wn,function(n,e){n.expression.print(e),e.print(n.operator)}),n(Yn,function(n,e){n.left.print(e),e.space(),e.print(n.operator),"<"==n.operator&&n.right instanceof Vn&&"!"==n.right.operator&&n.right.expression instanceof Vn&&"--"==n.right.expression.operator?e.print(" "):e.space(),n.right.print(e)}),n(Xn,function(n,e){n.condition.print(e),e.space(),e.print("?"),e.space(),n.consequent.print(e),e.space(),e.colon(),n.alternative.print(e)}),n(Jn,function(n,e){e.with_square(function(){var t=n.elements,r=t.length;r>0&&e.space(),t.forEach(function(n,t){t&&e.comma(),n.print(e),t===r-1&&n instanceof Ee&&e.comma()}),r>0&&e.space()})}),n(Kn,function(n,e){n.properties.length>0?e.with_block(function(){n.properties.forEach(function(n,t){t&&(e.print(","),e.newline()),e.indent(),n.print(e)}),e.newline()}):e.print("{}")}),n(Qn,function(n,e){var t=n.key,r=n.quote;e.option("quote_keys")?e.print_string(t+""):("number"==typeof t||!e.option("beautify")&&+t+""==t)&&parseFloat(t)>=0?e.print(p(t)):(xe(t)?e.option("screw_ie8"):$(t))?e.print_name(t):e.print_string(t,r),e.colon(),n.value.print(e)}),n(ne,function(n,e){e.print("set"),e.space(),n.key.print(e),n.value._do_print(e,!0)}),n(ee,function(n,e){e.print("get"),e.space(),n.key.print(e),n.value._do_print(e,!0)}),n(te,function(n,e){var t=n.definition();e.print_name(t?t.mangled_name||t.name:n.name)}),n(we,function(n,e){e.print("void 0")}),n(Ee,l),n(De,function(n,e){e.print("Infinity")}),n(Ae,function(n,e){e.print("NaN")}),n(he,function(n,e){e.print("this")}),n(_e,function(n,e){e.print(n.getValue())}),n(me,function(n,e){e.print_string(n.getValue(),n.quote)}),n(ve,function(n,e){e.print(p(n.getValue()))}),n(ge,function(n,e){var t=n.getValue().toString();e.option("ascii_only")?t=e.to_ascii(t):e.option("unescape_regexps")&&(t=t.split("\\\\").map(function(n){return n.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g,function(n){var e=parseInt(n.substr(2),16);return a(e)?String.fromCharCode(e):n})}).join("\\\\")),e.print(t);var r=e.parent();r instanceof Yn&&/^in/.test(r.operator)&&r.left===n&&e.print(" ")}),h(G,l),h(Z,_),h(K,_),h(te,_),h(bn,_),h(rn,_),h(on,l),h(_n,_),h(Sn,_),h(kn,_),h(en,_),h(hn,l),h(Rn,_),h(Tn,_),h(On,_),h($n,_),h(Mn,_),h(_e,_),h(Zn,function(n,e){e.add_mapping(n.start,n.key)})}(),U.prototype=new j,f(U.prototype,{option:function(n){return this.options[n]},warn:function(){this.options.warnings&&G.warn.apply(G,arguments)},before:function(n,e,t){if(n._squeezed)return n;var r=!1;return n instanceof dn&&(n=n.hoist_declarations(this),r=!0),e(n,this),n=n.optimize(this),r&&n instanceof dn&&(n.drop_unused(this),e(n,this)),n._squeezed=!0,n}}),function(){function n(n,e){n.DEFMETHOD("optimize",function(n){var t=this;if(t._optimized)return t;var r=e(t,n);return r._optimized=!0,r===t?r:r.transform(n)})}function e(n,e,t){return t||(t={}),e&&(t.start||(t.start=e.start),t.end||(t.end=e.end)),new n(t)}function t(n,t,r){if(t instanceof G)return t.transform(n);switch(typeof t){case"string":return e(me,r,{value:t}).optimize(n);case"number":return e(isNaN(t)?Ae:ve,r,{value:t}).optimize(n);case"boolean":return e(t?Se:Ce,r).optimize(n);case"undefined":return e(we,r).optimize(n);default:if(null===t)return e(ye,r,{value:null}).optimize(n);if(t instanceof RegExp)return e(ge,r,{value:t}).optimize(n);throw new Error(d("Can't handle constant of type: {type}",{type:typeof t}))}}function r(n){if(null===n)return[];if(n instanceof en)return n.body;if(n instanceof tn)return[];if(n instanceof J)return[n];throw new Error("Can't convert thing to statement array")}function o(n){return null===n?!0:n instanceof tn?!0:n instanceof en?0==n.body.length:!1}function u(n){return n instanceof Sn?n:(n instanceof fn||n instanceof ln||n instanceof un)&&n.body instanceof en?n.body:n}function s(n,t){function o(n){function r(n){return/@ngInject/.test(n.value)}function o(n){return n.argnames.map(function(n){return e(me,n,{value:n.name})})}function i(n,t){return e(Jn,n,{elements:t})}function a(n,t){return e(Q,n,{body:e(Gn,n,{operator:"=",left:e(In,t,{expression:e(pe,t,t),property:"$inject"}),right:i(n,o(n))})})}function u(n){n&&n.args&&(n.args.forEach(function(n,e,t){var a=n.start.comments_before;n instanceof _n&&a.length&&r(a[0])&&(t[e]=i(n,o(n).concat(n)))}),n.expression&&n.expression.expression&&u(n.expression.expression))}return n.reduce(function(n,e){if(n.push(e),e.body&&e.body.args)u(e.body);else{var o=e.start,i=o.comments_before;if(i&&i.length>0){var s=i.pop();r(s)&&(e instanceof gn?n.push(a(e,e.name)):e instanceof Mn?e.definitions.forEach(function(e){e.value&&e.value instanceof _n&&n.push(a(e.value,e.name))}):t.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]",o))}}return n},[])}function i(n){var e=[];return n.reduce(function(n,t){return t instanceof en?(_=!0,n.push.apply(n,i(t.body))):t instanceof tn?_=!0:t instanceof Z?e.indexOf(t.value)<0?(n.push(t),e.push(t.value)):_=!0:n.push(t),n},[])}function a(n,t){var o=t.self(),i=o instanceof _n,a=[];n:for(var s=n.length;--s>=0;){var c=n[s];switch(!0){case i&&c instanceof An&&!c.value&&0==a.length:_=!0;continue n;case c instanceof Cn:if(c.body instanceof An){if((i&&0==a.length||a[0]instanceof An&&!a[0].value)&&!c.body.value&&!c.alternative){_=!0;var f=e(Q,c.condition,{body:c.condition});a.unshift(f);continue n}if(a[0]instanceof An&&c.body.value&&a[0].value&&!c.alternative){_=!0,c=c.clone(),c.alternative=a[0],a[0]=c.transform(t);continue n}if((0==a.length||a[0]instanceof An)&&c.body.value&&!c.alternative&&i){_=!0,c=c.clone(),c.alternative=a[0]||e(An,c,{value:e(we,c)}),a[0]=c.transform(t);continue n}if(!c.body.value&&i){_=!0,c=c.clone(),c.condition=c.condition.negate(t),c.body=e(en,c,{body:r(c.alternative).concat(a)}),c.alternative=null,a=[c.transform(t)];continue n}if(1==a.length&&i&&a[0]instanceof Q&&(!c.alternative||c.alternative instanceof Q)){_=!0,a.push(e(An,a[0],{value:e(we,a[0])}).transform(t)),a=r(c.alternative).concat(a),a.unshift(c);continue n}}var l=m(c.body),p=l instanceof En?t.loopcontrol_target(l.label):null;if(l&&(l instanceof An&&!l.value&&i||l instanceof Fn&&o===u(p)||l instanceof Dn&&p instanceof en&&o===p)){l.label&&h(l.label.thedef.references,l),_=!0;var d=r(c.body).slice(0,-1);c=c.clone(),c.condition=c.condition.negate(t),c.body=e(en,c,{body:r(c.alternative).concat(a)}),c.alternative=e(en,c,{body:d}),a=[c.transform(t)];continue n}var l=m(c.alternative),p=l instanceof En?t.loopcontrol_target(l.label):null;if(l&&(l instanceof An&&!l.value&&i||l instanceof Fn&&o===u(p)||l instanceof Dn&&p instanceof en&&o===p)){l.label&&h(l.label.thedef.references,l),_=!0,c=c.clone(),c.body=e(en,c.body,{body:r(c.body).concat(a)}),c.alternative=e(en,c.alternative,{body:r(c.alternative).slice(0,-1)}),a=[c.transform(t)];continue n}a.unshift(c);break;default:a.unshift(c)}}return a}function s(n,e){var t=!1,r=n.length,o=e.self();return n=n.reduce(function(n,r){if(t)c(e,r,n);else{if(r instanceof En){var i=e.loopcontrol_target(r.label);r instanceof Dn&&i instanceof en&&u(i)===o||r instanceof Fn&&u(i)===o?r.label&&h(r.label.thedef.references,r):n.push(r)}else n.push(r);m(r)&&(t=!0)}return n},[]),_=n.length!=r,n}function f(n,t){function r(){o=jn.from_array(o),o&&i.push(e(Q,o,{body:o})),o=[]}if(n.length<2)return n;var o=[],i=[];return n.forEach(function(n){n instanceof Q&&o.length<2e3?o.push(n.body):(r(),i.push(n))}),r(),i=l(i,t),_=i.length!=n.length,i}function l(n,t){function r(n){o.pop();var e=i.body;return e instanceof jn?e.add(n):e=jn.cons(e,n),e.transform(t)}var o=[],i=null;return n.forEach(function(n){if(i)if(n instanceof fn){var t={};try{i.body.walk(new E(function(n){if(n instanceof Yn&&"in"==n.operator)throw t})),!n.init||n.init instanceof Mn?n.init||(n.init=i.body,o.pop()):n.init=r(n.init)}catch(a){if(a!==t)throw a}}else n instanceof Cn?n.condition=r(n.condition):n instanceof pn?n.expression=r(n.expression):n instanceof yn&&n.value?n.value=r(n.value):n instanceof yn?n.value=r(e(we,n)):n instanceof Sn&&(n.expression=r(n.expression));o.push(n),i=n instanceof Q?n:null}),o}function p(n,e){var t=null;return n.reduce(function(n,e){return e instanceof Mn&&t&&t.TYPE==e.TYPE?(t.definitions=t.definitions.concat(e.definitions),_=!0):e instanceof fn&&t instanceof Mn&&(!e.init||e.init.TYPE==t.TYPE)?(_=!0,n.pop(),e.init?e.init.definitions=t.definitions.concat(e.init.definitions):e.init=t,n.push(e),t=e):(t=e,n.push(e)),n},[])}function d(n,t){n.forEach(function(n){n instanceof Q&&(n.body=function t(n){return n.transform(new j(function(n){if(n instanceof Hn&&n.expression instanceof vn)return e(Vn,n,{operator:"!",expression:n});if(n instanceof Hn)n.expression=t(n.expression);else if(n instanceof jn)n.car=t(n.car);else if(n instanceof Xn){var r=t(n.condition);if(r!==n.condition){n.condition=r;var o=n.consequent;n.consequent=n.alternative,n.alternative=o}}return n}))}(n.body))})}var _;do _=!1,t.option("angular")&&(n=o(n)),n=i(n),t.option("dead_code")&&(n=s(n,t)),t.option("if_return")&&(n=a(n,t)),t.option("sequences")&&(n=f(n,t)),t.option("join_vars")&&(n=p(n,t));while(_);return t.option("negate_iife")&&d(n,t),n}function c(n,e,t){n.warn("Dropping unreachable code [{file}:{line},{col}]",e.start),e.walk(new E(function(e){return e instanceof Mn?(n.warn("Declarations in unreachable code! [{file}:{line},{col}]",e.start),e.remove_initializers(),t.push(e),!0):e instanceof gn?(t.push(e),!0):e instanceof dn?!0:void 0}))}function f(n,e){return n.print_to_string().length>e.print_to_string().length?e:n}function m(n){return n&&n.aborts()}function v(n,t){function o(o){o=r(o),n.body instanceof en?(n.body=n.body.clone(),n.body.body=o.concat(n.body.body.slice(1)),n.body=n.body.transform(t)):n.body=e(en,n.body,{body:o}).transform(t),v(n,t)}var i=n.body instanceof en?n.body.body[0]:n.body;i instanceof Cn&&(i.body instanceof Dn&&t.loopcontrol_target(i.body.label)===n?(n.condition=n.condition?e(Yn,n.condition,{left:n.condition,operator:"&&",right:i.condition.negate(t)}):i.condition.negate(t),o(i.alternative)):i.alternative instanceof Dn&&t.loopcontrol_target(i.alternative.label)===n&&(n.condition=n.condition?e(Yn,n.condition,{left:n.condition,operator:"&&",right:i.condition}):i.condition,o(i.body)))}function A(n,e){var t=e.option("pure_getters");e.options.pure_getters=!1;var r=n.has_side_effects(e);return e.options.pure_getters=t,r}function w(n,t){return t.option("booleans")&&t.in_boolean_context()&&!n.has_side_effects(t)?e(Se,n):n}n(G,function(n,e){return n}),G.DEFMETHOD("equivalent_to",function(n){return this.print_to_string()==n.print_to_string()}),function(n){var e=["!","delete"],t=["in","instanceof","==","!=","===","!==","<","<=",">=",">"];n(G,function(){return!1}),n(Vn,function(){return i(this.operator,e)}),n(Yn,function(){return i(this.operator,t)||("&&"==this.operator||"||"==this.operator)&&this.left.is_boolean()&&this.right.is_boolean()}),n(Xn,function(){return this.consequent.is_boolean()&&this.alternative.is_boolean()}),n(Gn,function(){return"="==this.operator&&this.right.is_boolean()}),n(jn,function(){return this.cdr.is_boolean()}),n(Se,function(){return!0}),n(Ce,function(){return!0})}(function(n,e){n.DEFMETHOD("is_boolean",e)}),function(n){n(G,function(){return!1}),n(me,function(){return!0}),n(Vn,function(){return"typeof"==this.operator}),n(Yn,function(n){return"+"==this.operator&&(this.left.is_string(n)||this.right.is_string(n))}),n(Gn,function(n){return("="==this.operator||"+="==this.operator)&&this.right.is_string(n)}),n(jn,function(n){return this.cdr.is_string(n)}),n(Xn,function(n){return this.consequent.is_string(n)&&this.alternative.is_string(n)}),n(Hn,function(n){return n.option("unsafe")&&this.expression instanceof pe&&"String"==this.expression.name&&this.expression.undeclared()})}(function(n,e){n.DEFMETHOD("is_string",e)}),function(n){function e(n,e){if(!e)throw new Error("Compressor must be passed");return n._eval(e)}G.DEFMETHOD("evaluate",function(e){if(!e.option("evaluate"))return[this];try{var r=this._eval(e);return[f(t(e,r,this),this),r]}catch(o){if(o!==n)throw o;return[this]}}),n(J,function(){throw new Error(d("Cannot evaluate a statement [{file}:{line},{col}]",this.start))}),n(vn,function(){throw n}),n(G,function(){throw n}),n(_e,function(){return this.getValue()}),n(Vn,function(t){var r=this.expression;switch(this.operator){case"!":return!e(r,t);case"typeof":if(r instanceof vn)return"function";if(r=e(r,t),r instanceof RegExp)throw n;return typeof r;case"void":return void e(r,t);case"~":return~e(r,t);case"-":if(r=e(r,t),0===r)throw n;return-r;case"+":return+e(r,t)}throw n}),n(Yn,function(t){var r=this.left,o=this.right;switch(this.operator){case"&&":return e(r,t)&&e(o,t);case"||":return e(r,t)||e(o,t);case"|":return e(r,t)|e(o,t);case"&":return e(r,t)&e(o,t);case"^":return e(r,t)^e(o,t);case"+":return e(r,t)+e(o,t);case"*":return e(r,t)*e(o,t);case"/":return e(r,t)/e(o,t);case"%":return e(r,t)%e(o,t);case"-":return e(r,t)-e(o,t);case"<<":return e(r,t)<>":return e(r,t)>>e(o,t);case">>>":return e(r,t)>>>e(o,t);case"==":return e(r,t)==e(o,t);case"===":return e(r,t)===e(o,t);case"!=":return e(r,t)!=e(o,t);case"!==":return e(r,t)!==e(o,t);case"<":return e(r,t)":return e(r,t)>e(o,t);case">=":return e(r,t)>=e(o,t);case"in":return e(r,t)in e(o,t);case"instanceof":return e(r,t)instanceof e(o,t)}throw n}),n(Xn,function(n){return e(this.condition,n)?e(this.consequent,n):e(this.alternative,n)}),n(pe,function(t){var r=this.definition();if(r&&r.constant&&r.init)return e(r.init,t);throw n}),n(In,function(t){if(t.option("unsafe")&&"length"==this.property){var r=e(this.expression,t);if("string"==typeof r)return r.length}throw n})}(function(n,e){n.DEFMETHOD("_eval",e)}),function(n){function t(n){return e(Vn,n,{operator:"!",expression:n})}n(G,function(){return t(this)}),n(J,function(){throw new Error("Cannot negate a statement")}),n(vn,function(){return t(this)}),n(Vn,function(){return"!"==this.operator?this.expression:t(this)}),n(jn,function(n){var e=this.clone();return e.cdr=e.cdr.negate(n),e}),n(Xn,function(n){var e=this.clone();return e.consequent=e.consequent.negate(n),e.alternative=e.alternative.negate(n),f(t(this),e)}),n(Yn,function(n){var e=this.clone(),r=this.operator;if(n.option("unsafe_comps"))switch(r){case"<=":return e.operator=">",e;case"<":return e.operator=">=",e;case">=":return e.operator="<",e;case">":return e.operator="<=",e}switch(r){case"==":return e.operator="!=",e;case"!=":return e.operator="==",e;case"===":return e.operator="!==",e;case"!==":return e.operator="===",e;case"&&":return e.operator="||",e.left=e.left.negate(n),e.right=e.right.negate(n),f(t(this),e);case"||":return e.operator="&&",e.left=e.left.negate(n),e.right=e.right.negate(n),f(t(this),e)}return t(this)})}(function(n,e){n.DEFMETHOD("negate",function(n){return e.call(this,n)})}),function(n){n(G,function(n){return!0}),n(tn,function(n){return!1}),n(_e,function(n){return!1}),n(he,function(n){return!1}),n(Hn,function(n){var e=n.option("pure_funcs");return e?e.indexOf(this.expression.print_to_string())<0:!0}),n(nn,function(n){for(var e=this.body.length;--e>=0;)if(this.body[e].has_side_effects(n))return!0;return!1}),n(Q,function(n){return this.body.has_side_effects(n)}),n(gn,function(n){return!0}),n(vn,function(n){return!1}),n(Yn,function(n){return this.left.has_side_effects(n)||this.right.has_side_effects(n)}),n(Gn,function(n){return!0}),n(Xn,function(n){return this.condition.has_side_effects(n)||this.consequent.has_side_effects(n)||this.alternative.has_side_effects(n)}),n(Ln,function(n){return"delete"==this.operator||"++"==this.operator||"--"==this.operator||this.expression.has_side_effects(n)}),n(pe,function(n){return this.global()&&this.undeclared()}),n(Kn,function(n){for(var e=this.properties.length;--e>=0;)if(this.properties[e].has_side_effects(n))return!0;return!1}),n(Zn,function(n){return this.value.has_side_effects(n)}),n(Jn,function(n){for(var e=this.elements.length;--e>=0;)if(this.elements[e].has_side_effects(n))return!0;return!1}),n(In,function(n){return n.option("pure_getters")?this.expression.has_side_effects(n):!0}),n(Un,function(n){return n.option("pure_getters")?this.expression.has_side_effects(n)||this.property.has_side_effects(n):!0}),n(Pn,function(n){return!n.option("pure_getters")}),n(jn,function(n){return this.car.has_side_effects(n)||this.cdr.has_side_effects(n)})}(function(n,e){n.DEFMETHOD("has_side_effects",e)}),function(n){function e(){var n=this.body.length;return n>0&&m(this.body[n-1])}n(J,function(){return null}),n(bn,function(){return this}),n(en,e),n(kn,e),n(Cn,function(){return this.alternative&&m(this.body)&&m(this.alternative)&&this})}(function(n,e){n.DEFMETHOD("aborts",e)}),n(Z,function(n,t){return n.scope.has_directive(n.value)!==n.scope?e(tn,n):n}),n(K,function(n,t){return t.option("drop_debugger")?e(tn,n):n}),n(on,function(n,t){return n.body instanceof Dn&&t.loopcontrol_target(n.body.label)===n.body?e(tn,n):0==n.label.references.length?n.body:n}),n(nn,function(n,e){return n.body=s(n.body,e),n}),n(en,function(n,t){switch(n.body=s(n.body,t),n.body.length){case 1:return n.body[0];case 0:return e(tn,n)}return n}),dn.DEFMETHOD("drop_unused",function(n){var t=this;if(n.option("unused")&&!(t instanceof hn)&&!t.uses_eval){var r=[],o=new y,a=this,u=new E(function(e,i){if(e!==t){if(e instanceof gn)return o.add(e.name.name,e),!0;if(e instanceof Mn&&a===t)return e.definitions.forEach(function(e){e.value&&(o.add(e.name.name,e.value),e.value.has_side_effects(n)&&e.value.walk(u))}),!0;if(e instanceof pe)return p(r,e.definition()),!0;if(e instanceof dn){var s=a;return a=e,i(),a=s,!0}}});t.walk(u);for(var s=0;s=0;){var l=s[f];if(!l.unreferenced())break;s.pop(),n.warn("Dropping unused function argument {name} [{file}:{line},{col}]",{name:l.name,file:l.start.file,line:l.start.line,col:l.start.col})}if(o instanceof gn&&o!==t)return i(o.name.definition(),r)?o:(n.warn("Dropping unused function {name} [{file}:{line},{col}]",{name:o.name.name,file:o.name.start.file,line:o.name.start.line,col:o.name.start.col}),e(tn,o));if(o instanceof Mn&&!(c.parent()instanceof ln)){var p=o.definitions.filter(function(e){if(i(e.name.definition(),r))return!0;var t={name:e.name.name,file:e.name.start.file,line:e.name.start.line,col:e.name.start.col};return e.value&&e.value.has_side_effects(n)?(e._unused_side_effects=!0,n.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]",t),!0):(n.warn("Dropping unused variable {name} [{file}:{line},{col}]",t),!1)});p=_(p,function(n,e){return!n.value&&e.value?-1:!e.value&&n.value?1:0});for(var d=[],f=0;f0&&(d.push(h.value),h.value=jn.from_array(d),d=[]),++f)}return d=d.length>0?e(en,o,{body:[e(Q,o,{body:jn.from_array(d)})]}):null,0!=p.length||d?0==p.length?d:(o.definitions=p,d&&(d.body.unshift(o),o=d),o):e(tn,o)}if(o instanceof fn&&(a(o,this),o.init instanceof en)){var m=o.init.body.slice(0,-1);return o.init=o.init.body.slice(-1)[0].body,m.push(o),u?Y.splice(m):e(en,o,{body:m})}return o instanceof dn&&o!==t?o:void 0});t.transform(c)}}),dn.DEFMETHOD("hoist_declarations",function(n){var t=n.option("hoist_funs"),r=n.option("hoist_vars"),o=this;if(t||r){var i=[],u=[],s=new y,c=0,f=0;o.walk(new E(function(n){return n instanceof dn&&n!==o?!0:n instanceof qn?(++f,!0):void 0})),r=r&&f>1;var l=new j(function(n){if(n!==o){if(n instanceof Z)return i.push(n),e(tn,n);if(n instanceof gn&&t)return u.push(n),e(tn,n);if(n instanceof qn&&r){n.definitions.forEach(function(n){s.set(n.name.name,n),++c});var a=n.to_assignments(),f=l.parent();return f instanceof ln&&f.init===n?null==a?n.definitions[0].name:a:f instanceof fn&&f.init===n?a:a?e(Q,n,{body:a}):e(tn,n)}if(n instanceof dn)return n}});if(o=o.transform(l),c>0){var p=[];if(s.each(function(n,e){o instanceof _n&&a(function(e){return e.name==n.name.name},o.argnames)?s.del(e):(n=n.clone(),n.value=null,p.push(n),s.set(e,n))}),p.length>0){for(var d=0;d1){if(r[1])return e(fn,n,{body:n.body});if(n instanceof cn&&t.option("dead_code")){var o=[];return c(t,n.body,o),e(en,n,{body:o})}}return n}),n(cn,function(n,t){return t.option("loops")?(n=un.prototype.optimize.call(n,t),n instanceof cn&&(v(n,t),n=e(fn,n,n).transform(t)),n):n}),n(fn,function(n,t){var r=n.condition;if(r&&(r=r.evaluate(t),n.condition=r[0]),!t.option("loops"))return n;if(r&&r.length>1&&!r[1]&&t.option("dead_code")){ var o=[];return n.init instanceof J?o.push(n.init):n.init&&o.push(e(Q,n.init,{body:n.init})),c(t,n.body,o),e(en,n,{body:o})}return v(n,t),n}),n(Cn,function(n,t){if(!t.option("conditionals"))return n;var r=n.condition.evaluate(t);if(n.condition=r[0],r.length>1)if(r[1]){if(t.warn("Condition always true [{file}:{line},{col}]",n.condition.start),t.option("dead_code")){var i=[];return n.alternative&&c(t,n.alternative,i),i.push(n.body),e(en,n,{body:i}).transform(t)}}else if(t.warn("Condition always false [{file}:{line},{col}]",n.condition.start),t.option("dead_code")){var i=[];return c(t,n.body,i),n.alternative&&i.push(n.alternative),e(en,n,{body:i}).transform(t)}o(n.alternative)&&(n.alternative=null);var a=n.condition.negate(t),u=f(n.condition,a)===a;if(n.alternative&&u){u=!1,n.condition=a;var s=n.body;n.body=n.alternative||e(tn),n.alternative=s}if(o(n.body)&&o(n.alternative))return e(Q,n.condition,{body:n.condition}).transform(t);if(n.body instanceof Q&&n.alternative instanceof Q)return e(Q,n,{body:e(Xn,n,{condition:n.condition,consequent:n.body.body,alternative:n.alternative.body})}).transform(t);if(o(n.alternative)&&n.body instanceof Q)return u?e(Q,n,{body:e(Yn,n,{operator:"||",left:a,right:n.body.body})}).transform(t):e(Q,n,{body:e(Yn,n,{operator:"&&",left:n.condition,right:n.body.body})}).transform(t);if(n.body instanceof tn&&n.alternative&&n.alternative instanceof Q)return e(Q,n,{body:e(Yn,n,{operator:"||",left:n.condition,right:n.alternative.body})}).transform(t);if(n.body instanceof yn&&n.alternative instanceof yn&&n.body.TYPE==n.alternative.TYPE)return e(n.body.CTOR,n,{value:e(Xn,n,{condition:n.condition,consequent:n.body.value||e(we,n.body).optimize(t),alternative:n.alternative.value||e(we,n.alternative).optimize(t)})}).transform(t);if(n.body instanceof Cn&&!n.body.alternative&&!n.alternative&&(n.condition=e(Yn,n.condition,{operator:"&&",left:n.condition,right:n.body.condition}).transform(t),n.body=n.body.body),m(n.body)&&n.alternative){var l=n.alternative;return n.alternative=null,e(en,n,{body:[n,l]}).transform(t)}if(m(n.alternative)){var p=n.body;return n.body=n.alternative,n.condition=u?a:n.condition.negate(t),n.alternative=null,e(en,n,{body:[n,p]}).transform(t)}return n}),n(Sn,function(n,t){if(0==n.body.length&&t.option("conditionals"))return e(Q,n,{body:n.expression}).transform(t);for(;;){var r=n.body[n.body.length-1];if(r){var o=r.body[r.body.length-1];if(o instanceof Dn&&u(t.loopcontrol_target(o.label))===n&&r.body.pop(),r instanceof Bn&&0==r.body.length){n.body.pop();continue}}break}var i=n.expression.evaluate(t);n:if(2==i.length)try{if(n.expression=i[0],!t.option("dead_code"))break n;var a=i[1],s=!1,c=!1,f=!1,l=!1,p=!1,d=new j(function(r,o,i){if(r instanceof _n||r instanceof Q)return r;if(r instanceof Sn&&r===n)return r=r.clone(),o(r,this),p?r:e(en,r,{body:r.body.reduce(function(n,e){return n.concat(e.body)},[])}).transform(t);if(r instanceof Cn||r instanceof Tn){var u=s;return s=!c,o(r,this),s=u,r}if(r instanceof rn||r instanceof Sn){var u=c;return c=!0,o(r,this),c=u,r}if(r instanceof Dn&&this.loopcontrol_target(r.label)===n)return s?(p=!0,r):c?r:(l=!0,i?Y.skip:e(tn,r));if(r instanceof kn&&this.parent()===n){if(l)return Y.skip;if(r instanceof xn){var d=r.expression.evaluate(t);if(d.length<2)throw n;return d[1]===a||f?(f=!0,m(r)&&(l=!0),o(r,this),r):Y.skip}return o(r,this),r}});d.stack=t.stack.slice(),n=n.transform(d)}catch(h){if(h!==n)throw h}return n}),n(xn,function(n,e){return n.body=s(n.body,e),n}),n(Tn,function(n,e){return n.body=s(n.body,e),n}),Mn.DEFMETHOD("remove_initializers",function(){this.definitions.forEach(function(n){n.value=null})}),Mn.DEFMETHOD("to_assignments",function(){var n=this.definitions.reduce(function(n,t){if(t.value){var r=e(pe,t.name,t.name);n.push(e(Gn,t,{operator:"=",left:r,right:t.value}))}return n},[]);return 0==n.length?null:jn.from_array(n)}),n(Mn,function(n,t){return 0==n.definitions.length?e(tn,n):n}),n(vn,function(n,e){return n=_n.prototype.optimize.call(n,e),e.option("unused")&&!e.option("keep_fnames")&&n.name&&n.name.unreferenced()&&(n.name=null),n}),n(Hn,function(n,r){if(r.option("unsafe")){var o=n.expression;if(o instanceof pe&&o.undeclared())switch(o.name){case"Array":if(1!=n.args.length)return e(Jn,n,{elements:n.args}).transform(r);break;case"Object":if(0==n.args.length)return e(Kn,n,{properties:[]});break;case"String":if(0==n.args.length)return e(me,n,{value:""});if(n.args.length<=1)return e(Yn,n,{left:n.args[0],operator:"+",right:e(me,n,{value:""})}).transform(r);break;case"Number":if(0==n.args.length)return e(ve,n,{value:0});if(1==n.args.length)return e(Vn,n,{expression:n.args[0],operator:"+"}).transform(r);case"Boolean":if(0==n.args.length)return e(Ce,n);if(1==n.args.length)return e(Vn,n,{expression:e(Vn,null,{expression:n.args[0],operator:"!"}),operator:"!"}).transform(r);break;case"Function":if(0==n.args.length)return e(vn,n,{argnames:[],body:[]});if(b(n.args,function(n){return n instanceof me}))try{var i="(function("+n.args.slice(0,-1).map(function(n){return n.value}).join(",")+"){"+n.args[n.args.length-1].value+"})()",a=R(i);a.figure_out_scope({screw_ie8:r.option("screw_ie8")});var u=new U(r.options);a=a.transform(u),a.figure_out_scope({screw_ie8:r.option("screw_ie8")}),a.mangle_names();var s;try{a.walk(new E(function(n){if(n instanceof _n)throw s=n,a}))}catch(c){if(c!==a)throw c}if(!s)return n;var l=s.argnames.map(function(t,r){return e(me,n.args[r],{value:t.print_to_string()})}),i=I();return en.prototype._codegen.call(s,s,i),i=i.toString().replace(/^\{|\}$/g,""),l.push(e(me,n.args[n.args.length-1],{value:i})),n.args=l,n}catch(c){if(!(c instanceof q))throw console.log(c),c;r.warn("Error parsing code passed to new Function [{file}:{line},{col}]",n.args[n.args.length-1].start),r.warn(c.toString())}}else{if(o instanceof In&&"toString"==o.property&&0==n.args.length)return e(Yn,n,{left:e(me,n,{value:""}),operator:"+",right:o.expression}).transform(r);if(o instanceof In&&o.expression instanceof Jn&&"join"==o.property){var p=0==n.args.length?",":n.args[0].evaluate(r)[1];if(null!=p){var d=o.expression.elements.reduce(function(n,e){if(e=e.evaluate(r),0==n.length||1==e.length)n.push(e);else{var o=n[n.length-1];if(2==o.length){var i=""+o[1]+p+e[1];n[n.length-1]=[t(r,i,o[0]),i]}else n.push(e)}return n},[]);if(0==d.length)return e(me,n,{value:""});if(1==d.length)return d[0][0];if(""==p){var h;return h=d[0][0]instanceof me||d[1][0]instanceof me?d.shift()[0]:e(me,n,{value:""}),d.reduce(function(n,t){return e(Yn,t[0],{operator:"+",left:n,right:t[0]})},h).transform(r)}var _=n.clone();return _.expression=_.expression.clone(),_.expression.expression=_.expression.expression.clone(),_.expression.expression.elements=d.map(function(n){return n[0]}),f(n,_)}}}}if(r.option("side_effects")&&n.expression instanceof vn&&0==n.args.length&&!nn.prototype.has_side_effects.call(n.expression,r))return e(we,n).transform(r);if(r.option("drop_console")&&n.expression instanceof Pn){for(var m=n.expression.expression;m.expression;)m=m.expression;if(m instanceof pe&&"console"==m.name&&m.undeclared())return e(we,n).transform(r)}return n.evaluate(r)[0]}),n(Rn,function(n,t){if(t.option("unsafe")){var r=n.expression;if(r instanceof pe&&r.undeclared())switch(r.name){case"Object":case"RegExp":case"Function":case"Error":case"Array":return e(Hn,n,n).transform(t)}}return n}),n(jn,function(n,t){if(!t.option("side_effects"))return n;if(!n.car.has_side_effects(t)){var r;if(!(n.cdr instanceof pe&&"eval"==n.cdr.name&&n.cdr.undeclared()&&(r=t.parent())instanceof Hn&&r.expression===n))return n.cdr}if(t.option("cascade")){if(n.car instanceof Gn&&!n.car.left.has_side_effects(t)){if(n.car.left.equivalent_to(n.cdr))return n.car;if(n.cdr instanceof Hn&&n.cdr.expression.equivalent_to(n.car.left))return n.cdr.expression=n.car,n.cdr}if(!n.car.has_side_effects(t)&&!n.cdr.has_side_effects(t)&&n.car.equivalent_to(n.cdr))return n.car}return n.cdr instanceof Vn&&"void"==n.cdr.operator&&!n.cdr.expression.has_side_effects(t)?(n.cdr.expression=n.car,n.cdr):n.cdr instanceof we?e(Vn,n,{operator:"void",expression:n.car}):n}),Ln.DEFMETHOD("lift_sequences",function(n){if(n.option("sequences")&&this.expression instanceof jn){var e=this.expression,t=e.to_array();return this.expression=t.pop(),t.push(this),e=jn.from_array(t).transform(n)}return this}),n(Wn,function(n,e){return n.lift_sequences(e)}),n(Vn,function(n,t){n=n.lift_sequences(t);var r=n.expression;if(t.option("booleans")&&t.in_boolean_context()){switch(n.operator){case"!":if(r instanceof Vn&&"!"==r.operator)return r.expression;break;case"typeof":return t.warn("Boolean expression always true [{file}:{line},{col}]",n.start),e(Se,n)}r instanceof Yn&&"!"==n.operator&&(n=f(n,r.negate(t)))}return n.evaluate(t)[0]}),Yn.DEFMETHOD("lift_sequences",function(n){if(n.option("sequences")){if(this.left instanceof jn){var e=this.left,t=e.to_array();return this.left=t.pop(),t.push(this),e=jn.from_array(t).transform(n)}if(this.right instanceof jn&&this instanceof Gn&&!A(this.left,n)){var e=this.right,t=e.to_array();return this.right=t.pop(),t.push(this),e=jn.from_array(t).transform(n)}}return this});var D=g("== === != !== * & | ^");n(Yn,function(n,t){var r=t.has_directive("use asm")?l:function(e,r){if(r||!n.left.has_side_effects(t)&&!n.right.has_side_effects(t)){e&&(n.operator=e);var o=n.left;n.left=n.right,n.right=o}};if(D(n.operator)&&(n.right instanceof _e&&!(n.left instanceof _e)&&(n.left instanceof Yn&&We[n.left.operator]>=We[n.operator]||r(null,!0)),/^[!=]==?$/.test(n.operator))){if(n.left instanceof pe&&n.right instanceof Xn){if(n.right.consequent instanceof pe&&n.right.consequent.definition()===n.left.definition()){if(/^==/.test(n.operator))return n.right.condition;if(/^!=/.test(n.operator))return n.right.condition.negate(t)}if(n.right.alternative instanceof pe&&n.right.alternative.definition()===n.left.definition()){if(/^==/.test(n.operator))return n.right.condition.negate(t);if(/^!=/.test(n.operator))return n.right.condition}}if(n.right instanceof pe&&n.left instanceof Xn){if(n.left.consequent instanceof pe&&n.left.consequent.definition()===n.right.definition()){if(/^==/.test(n.operator))return n.left.condition;if(/^!=/.test(n.operator))return n.left.condition.negate(t)}if(n.left.alternative instanceof pe&&n.left.alternative.definition()===n.right.definition()){if(/^==/.test(n.operator))return n.left.condition.negate(t);if(/^!=/.test(n.operator))return n.left.condition}}}if(n=n.lift_sequences(t),t.option("comparisons"))switch(n.operator){case"===":case"!==":(n.left.is_string(t)&&n.right.is_string(t)||n.left.is_boolean()&&n.right.is_boolean())&&(n.operator=n.operator.substr(0,2));case"==":case"!=":n.left instanceof me&&"undefined"==n.left.value&&n.right instanceof Vn&&"typeof"==n.right.operator&&t.option("unsafe")&&(n.right.expression instanceof pe&&n.right.expression.undeclared()||(n.right=n.right.expression,n.left=e(we,n.left).optimize(t),2==n.operator.length&&(n.operator+="=")))}if(t.option("booleans")&&t.in_boolean_context())switch(n.operator){case"&&":var o=n.left.evaluate(t),i=n.right.evaluate(t);if(o.length>1&&!o[1]||i.length>1&&!i[1])return t.warn("Boolean && always false [{file}:{line},{col}]",n.start),n.left.has_side_effects(t)?e(jn,n,{car:n.left,cdr:e(Ce)}).optimize(t):e(Ce,n);if(o.length>1&&o[1])return i[0];if(i.length>1&&i[1])return o[0];break;case"||":var o=n.left.evaluate(t),i=n.right.evaluate(t);if(o.length>1&&o[1]||i.length>1&&i[1])return t.warn("Boolean || always true [{file}:{line},{col}]",n.start),n.left.has_side_effects(t)?e(jn,n,{car:n.left,cdr:e(Se)}).optimize(t):e(Se,n);if(o.length>1&&!o[1])return i[0];if(i.length>1&&!i[1])return o[0];break;case"+":var o=n.left.evaluate(t),i=n.right.evaluate(t);if(o.length>1&&o[0]instanceof me&&o[1]||i.length>1&&i[0]instanceof me&&i[1])return t.warn("+ in boolean context always true [{file}:{line},{col}]",n.start),e(Se,n)}if(t.option("comparisons")){if(!(t.parent()instanceof Yn)||t.parent()instanceof Gn){var a=e(Vn,n,{operator:"!",expression:n.negate(t)});n=f(n,a)}switch(n.operator){case"<":r(">");break;case"<=":r(">=")}}return"+"==n.operator&&n.right instanceof me&&""===n.right.getValue()&&n.left instanceof Yn&&"+"==n.left.operator&&n.left.is_string(t)?n.left:(t.option("evaluate")&&"+"==n.operator&&(n.left instanceof _e&&n.right instanceof Yn&&"+"==n.right.operator&&n.right.left instanceof _e&&n.right.is_string(t)&&(n=e(Yn,n,{operator:"+",left:e(me,null,{value:""+n.left.getValue()+n.right.left.getValue(),start:n.left.start,end:n.right.left.end}),right:n.right.right})),n.right instanceof _e&&n.left instanceof Yn&&"+"==n.left.operator&&n.left.right instanceof _e&&n.left.is_string(t)&&(n=e(Yn,n,{operator:"+",left:n.left.left,right:e(me,null,{value:""+n.left.right.getValue()+n.right.getValue(),start:n.left.right.start,end:n.right.end})})),n.left instanceof Yn&&"+"==n.left.operator&&n.left.is_string(t)&&n.left.right instanceof _e&&n.right instanceof Yn&&"+"==n.right.operator&&n.right.left instanceof _e&&n.right.is_string(t)&&(n=e(Yn,n,{operator:"+",left:e(Yn,n.left,{operator:"+",left:n.left.left,right:e(me,null,{value:""+n.left.right.getValue()+n.right.left.getValue(),start:n.left.right.start,end:n.right.left.end})}),right:n.right.right}))),n.right instanceof Yn&&n.right.operator==n.operator&&("*"==n.operator||"&&"==n.operator||"||"==n.operator)?(n.left=e(Yn,n.left,{operator:n.operator,left:n.left,right:n.right.left}),n.right=n.right.right,n.transform(t)):n.evaluate(t)[0])}),n(pe,function(n,r){if(n.undeclared()){var o=r.option("global_defs");if(o&&o.hasOwnProperty(n.name))return t(r,o[n.name],n);switch(n.name){case"undefined":return e(we,n);case"NaN":return e(Ae,n).transform(r);case"Infinity":return e(De,n).transform(r)}}return n}),n(De,function(n,t){return e(Yn,n,{operator:"/",left:e(ve,n,{value:1}),right:e(ve,n,{value:0})})}),n(Ae,function(n,t){return e(Yn,n,{operator:"/",left:e(ve,n,{value:0}),right:e(ve,n,{value:0})})}),n(we,function(n,t){if(t.option("unsafe")){var r=t.find_parent(dn),o=r.find_variable("undefined");if(o){var i=e(pe,n,{name:"undefined",scope:r,thedef:o});return i.reference(),i}}return n});var F=["+","-","/","*","%",">>","<<",">>>","|","^","&"];n(Gn,function(n,e){return n=n.lift_sequences(e),"="==n.operator&&n.left instanceof pe&&n.right instanceof Yn&&n.right.left instanceof pe&&n.right.left.name==n.left.name&&i(n.right.operator,F)&&(n.operator=n.right.operator+"=",n.right=n.right.right),n}),n(Xn,function(n,r){if(!r.option("conditionals"))return n;if(n.condition instanceof jn){var o=n.condition.car;return n.condition=n.condition.cdr,jn.cons(o,n)}var i=n.condition.evaluate(r);if(i.length>1)return i[1]?(r.warn("Condition always true [{file}:{line},{col}]",n.start),n.consequent):(r.warn("Condition always false [{file}:{line},{col}]",n.start),n.alternative);var a=i[0].negate(r);f(i[0],a)===a&&(n=e(Xn,n,{condition:a,consequent:n.alternative,alternative:n.consequent}));var u=n.consequent,s=n.alternative;if(u instanceof Gn&&s instanceof Gn&&u.operator==s.operator&&u.left.equivalent_to(s.left))return e(Gn,n,{operator:u.operator,left:u.left,right:e(Xn,n,{condition:n.condition,consequent:u.right,alternative:s.right})});if(u instanceof Hn&&s.TYPE===u.TYPE&&u.args.length==s.args.length&&u.expression.equivalent_to(s.expression)){if(0==u.args.length)return e(jn,n,{car:n.condition,cdr:u});if(1==u.args.length)return u.args[0]=e(Xn,n,{condition:n.condition,consequent:u.args[0],alternative:s.args[0]}),u}return u instanceof Xn&&u.alternative.equivalent_to(s)?e(Xn,n,{condition:e(Yn,n,{left:n.condition,operator:"&&",right:u.condition}),consequent:u.consequent,alternative:s}):u instanceof _e&&s instanceof _e&&u.equivalent_to(s)?n.condition.has_side_effects(r)?jn.from_array([n.condition,t(r,u.value,n)]):t(r,u.value,n):u instanceof Se&&s instanceof Ce?(n.condition=n.condition.negate(r),e(Vn,n.condition,{operator:"!",expression:n.condition})):u instanceof Ce&&s instanceof Se?n.condition.negate(r):n}),n(Fe,function(n,t){if(t.option("booleans")){var r=t.parent();return r instanceof Yn&&("=="==r.operator||"!="==r.operator)?(t.warn("Non-strict equality against boolean: {operator} {value} [{file}:{line},{col}]",{operator:r.operator,value:n.value,file:r.start.file,line:r.start.line,col:r.start.col}),e(ve,n,{value:+n.value})):e(Vn,n,{operator:"!",expression:e(ve,n,{value:1-n.value})})}return n}),n(Un,function(n,t){var r=n.property;if(r instanceof me&&t.option("properties")){if(r=r.getValue(),xe(r)?t.option("screw_ie8"):$(r))return e(In,n,{expression:n.expression,property:r}).optimize(t);var o=parseFloat(r);isNaN(o)||o.toString()!=r||(n.property=e(ve,n.property,{value:o}))}return n}),n(In,function(n,t){var r=n.property;return xe(r)&&!t.option("screw_ie8")?e(Un,n,{expression:n.expression,property:e(me,n,{value:r})}).optimize(t):n.evaluate(t)[0]}),n(Jn,w),n(Kn,w),n(ge,w)}(),function(){function n(n){var e=n.loc,t=e&&e.start,r=n.range;return new X({file:e&&e.source,line:t&&t.line,col:t&&t.column,pos:r?r[0]:n.start,endline:t&&t.line,endcol:t&&t.column,endpos:r?r[0]:n.start})}function e(n){var e=n.loc,t=e&&e.end,r=n.range;return new X({file:e&&e.source,line:t&&t.line,col:t&&t.column,pos:r?r[1]:n.end,endline:t&&t.line,endcol:t&&t.column,endpos:r?r[1]:n.end})}function t(t,o,c){var f="function From_Moz_"+t+"(M){\n";f+="return new "+o.name+"({\nstart: my_start_token(M),\nend: my_end_token(M)";var l="function To_Moz_"+t+"(M){\n";l+="return {\ntype: "+JSON.stringify(t),c&&c.split(/\s*,\s*/).forEach(function(n){var e=/([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(n);if(!e)throw new Error("Can't understand property map: "+n);var t=e[1],r=e[2],o=e[3];switch(f+=",\n"+o+": ",l+=",\n"+t+": ",r){case"@":f+="M."+t+".map(from_moz)",l+="M."+o+".map(to_moz)";break;case">":f+="from_moz(M."+t+")",l+="to_moz(M."+o+")";break;case"=":f+="M."+t,l+="M."+o;break;case"%":f+="from_moz(M."+t+").body",l+="to_moz_block(M)";break;default:throw new Error("Can't understand operator in propmap: "+n)}}),f+="\n})\n}",l+="\n}\n}",f=new Function("my_start_token","my_end_token","from_moz","return("+f+")")(n,e,r),l=new Function("to_moz","to_moz_block","return("+l+")")(a,u),s[t]=f,i(o,l)}function r(n){c.push(n);var e=null!=n?s[n.type](n):null;return c.pop(),e}function o(n,e,t){var r=n.start,o=n.end;return null!=r.pos&&null!=o.endpos&&(e.range=[r.pos,o.endpos]),r.line&&(e.loc={start:{line:r.line,column:r.col},end:o.endline?{line:o.endline,column:o.endcol}:null},r.file&&(e.loc.source=r.file)),e}function i(n,e){n.DEFMETHOD("to_mozilla_ast",function(){return o(this,e(this))})}function a(n){return null!=n?n.to_mozilla_ast():null}function u(n){return{type:"BlockStatement",body:n.body.map(a)}}var s={ExpressionStatement:function(t){var o=t.expression;return"Literal"===o.type&&"string"==typeof o.value?new Z({start:n(t),end:e(t),value:o.value}):new Q({start:n(t),end:e(t),body:r(o)})},TryStatement:function(t){var o=t.handlers||[t.handler];if(o.length>1||t.guardedHandlers&&t.guardedHandlers.length)throw new Error("Multiple catch clauses are not supported.");return new Tn({start:n(t),end:e(t),body:r(t.block).body,bcatch:r(o[0]),bfinally:t.finalizer?new $n(r(t.finalizer)):null})},Property:function(t){var o=t.key,i="Identifier"==o.type?o.name:o.value,a={start:n(o),end:e(t.value),key:i,value:r(t.value)};switch(t.kind){case"init":return new Qn(a);case"set":return a.value.name=r(o),new ne(a);case"get":return a.value.name=r(o),new ee(a)}},ObjectExpression:function(t){return new Kn({start:n(t),end:e(t),properties:t.properties.map(function(n){return n.type="Property",r(n)})})},SequenceExpression:function(n){return jn.from_array(n.expressions.map(r))},MemberExpression:function(t){return new(t.computed?Un:In)({start:n(t),end:e(t),property:t.computed?r(t.property):t.property.name,expression:r(t.object)})},SwitchCase:function(t){return new(t.test?xn:Bn)({start:n(t),end:e(t),expression:r(t.test),body:t.consequent.map(r)})},VariableDeclaration:function(t){return new("const"===t.kind?Nn:qn)({start:n(t),end:e(t),definitions:t.declarations.map(r)})},Literal:function(t){var r=t.value,o={start:n(t),end:e(t)};if(null===r)return new ye(o);switch(typeof r){case"string":return o.value=r,new me(o);case"number":return o.value=r,new ve(o);case"boolean":return new(r?Se:Ce)(o);default:return o.value=r,new ge(o)}},Identifier:function(t){var r=c[c.length-2];return new("LabeledStatement"==r.type?le:"VariableDeclarator"==r.type&&r.id===t?"const"==r.kind?ae:ie:"FunctionExpression"==r.type?r.id===t?ce:ue:"FunctionDeclaration"==r.type?r.id===t?se:ue:"CatchClause"==r.type?fe:"BreakStatement"==r.type||"ContinueStatement"==r.type?de:pe)({start:n(t),end:e(t),name:t.name})}};s.UpdateExpression=s.UnaryExpression=function(t){var o="prefix"in t?t.prefix:"UnaryExpression"==t.type?!0:!1;return new(o?Vn:Wn)({start:n(t),end:e(t),operator:t.operator,expression:r(t.argument)})},t("Program",hn,"body@body"),t("EmptyStatement",tn),t("BlockStatement",en,"body@body"),t("IfStatement",Cn,"test>condition, consequent>body, alternate>alternative"),t("LabeledStatement",on,"label>label, body>body"),t("BreakStatement",Dn,"label>label"),t("ContinueStatement",Fn,"label>label"),t("WithStatement",pn,"object>expression, body>body"),t("SwitchStatement",Sn,"discriminant>expression, cases@body"),t("ReturnStatement",An,"argument>value"),t("ThrowStatement",wn,"argument>value"),t("WhileStatement",cn,"test>condition, body>body"),t("DoWhileStatement",sn,"test>condition, body>body"),t("ForStatement",fn,"init>init, test>condition, update>step, body>body"),t("ForInStatement",ln,"left>init, right>object, body>body"),t("DebuggerStatement",K),t("FunctionDeclaration",gn,"id>name, params@argnames, body%body"),t("VariableDeclarator",zn,"id>name, init>value"),t("CatchClause",On,"param>argname, body%body"),t("ThisExpression",he),t("ArrayExpression",Jn,"elements@elements"),t("FunctionExpression",vn,"id>name, params@argnames, body%body"),t("BinaryExpression",Yn,"operator=operator, left>left, right>right"),t("LogicalExpression",Yn,"operator=operator, left>left, right>right"),t("AssignmentExpression",Gn,"operator=operator, left>left, right>right"),t("ConditionalExpression",Xn,"test>condition, consequent>consequent, alternate>alternative"),t("NewExpression",Rn,"callee>expression, arguments@args"),t("CallExpression",Hn,"callee>expression, arguments@args"),i(Z,function(n){return{type:"ExpressionStatement",expression:{type:"Literal",value:n.value}}}),i(Q,function(n){return{type:"ExpressionStatement",expression:a(n.body)}}),i(kn,function(n){return{type:"SwitchCase",test:a(n.expression),consequent:n.body.map(a)}}),i(Tn,function(n){return{type:"TryStatement",block:u(n),handler:a(n.bcatch),guardedHandlers:[],finalizer:a(n.bfinally)}}),i(On,function(n){return{type:"CatchClause",param:a(n.argname),guard:null,body:u(n)}}),i(Mn,function(n){return{type:"VariableDeclaration",kind:n instanceof Nn?"const":"var",declarations:n.definitions.map(a)}}),i(jn,function(n){return{type:"SequenceExpression",expressions:n.to_array().map(a)}}),i(Pn,function(n){var e=n instanceof Un;return{type:"MemberExpression",object:a(n.expression),computed:e,property:e?a(n.property):{type:"Identifier",name:n.property}}}),i(Ln,function(n){return{type:"++"==n.operator||"--"==n.operator?"UpdateExpression":"UnaryExpression",operator:n.operator,prefix:n instanceof Vn,argument:a(n.expression)}}),i(Yn,function(n){return{type:"&&"==n.operator||"||"==n.operator?"LogicalExpression":"BinaryExpression",left:a(n.left),operator:n.operator,right:a(n.right)}}),i(Kn,function(n){return{type:"ObjectExpression",properties:n.properties.map(a)}}),i(Zn,function(n){var e,t=x(n.key)?{type:"Identifier",name:n.key}:{type:"Literal",value:n.key};return n instanceof Qn?e="init":n instanceof ee?e="get":n instanceof ne&&(e="set"),{type:"Property",kind:e,key:t,value:a(n.value)}}),i(te,function(n){var e=n.definition();return{type:"Identifier",name:e?e.mangled_name||e.name:n.name}}),i(_e,function(n){var e=n.value;return"number"==typeof e&&(0>e||0===e&&0>1/e)?{type:"UnaryExpression",operator:"-",prefix:!0,argument:{type:"Literal",value:-e}}:{type:"Literal",value:e}}),i(be,function(n){return{type:"Identifier",name:String(n.value)}}),Fe.DEFMETHOD("to_mozilla_ast",_e.prototype.to_mozilla_ast),ye.DEFMETHOD("to_mozilla_ast",_e.prototype.to_mozilla_ast),Ee.DEFMETHOD("to_mozilla_ast",function(){return null}),nn.DEFMETHOD("to_mozilla_ast",en.prototype.to_mozilla_ast),_n.DEFMETHOD("to_mozilla_ast",vn.prototype.to_mozilla_ast);var c=null;G.from_mozilla_ast=function(n){var e=c;c=[];var t=r(n);return c=e,t}}(),n.array_to_hash=t,n.slice=r,n.characters=o,n.member=i,n.find_if=a,n.repeat_string=u,n.DefaultsError=s,n.defaults=c,n.merge=f,n.noop=l,n.MAP=Y,n.push_uniq=p,n.string_template=d,n.remove=h,n.mergeSort=_,n.set_difference=m,n.set_intersection=v,n.makePredicate=g,n.all=b,n.Dictionary=y,n.DEFNODE=A,n.AST_Token=X,n.AST_Node=G,n.AST_Statement=J,n.AST_Debugger=K,n.AST_Directive=Z,n.AST_SimpleStatement=Q,n.walk_body=w,n.AST_Block=nn,n.AST_BlockStatement=en,n.AST_EmptyStatement=tn,n.AST_StatementWithBody=rn,n.AST_LabeledStatement=on,n.AST_IterationStatement=an,n.AST_DWLoop=un,n.AST_Do=sn,n.AST_While=cn,n.AST_For=fn,n.AST_ForIn=ln,n.AST_With=pn,n.AST_Scope=dn,n.AST_Toplevel=hn,n.AST_Lambda=_n,n.AST_Accessor=mn,n.AST_Function=vn,n.AST_Defun=gn,n.AST_Jump=bn,n.AST_Exit=yn,n.AST_Return=An,n.AST_Throw=wn,n.AST_LoopControl=En,n.AST_Break=Dn,n.AST_Continue=Fn,n.AST_If=Cn,n.AST_Switch=Sn,n.AST_SwitchBranch=kn,n.AST_Default=Bn,n.AST_Case=xn,n.AST_Try=Tn,n.AST_Catch=On,n.AST_Finally=$n,n.AST_Definitions=Mn,n.AST_Var=qn,n.AST_Const=Nn,n.AST_VarDef=zn,n.AST_Call=Hn,n.AST_New=Rn,n.AST_Seq=jn,n.AST_PropAccess=Pn,n.AST_Dot=In,n.AST_Sub=Un,n.AST_Unary=Ln,n.AST_UnaryPrefix=Vn,n.AST_UnaryPostfix=Wn,n.AST_Binary=Yn,n.AST_Conditional=Xn,n.AST_Assign=Gn,n.AST_Array=Jn,n.AST_Object=Kn,n.AST_ObjectProperty=Zn,n.AST_ObjectKeyVal=Qn,n.AST_ObjectSetter=ne,n.AST_ObjectGetter=ee,n.AST_Symbol=te,n.AST_SymbolAccessor=re,n.AST_SymbolDeclaration=oe,n.AST_SymbolVar=ie,n.AST_SymbolConst=ae,n.AST_SymbolFunarg=ue,n.AST_SymbolDefun=se,n.AST_SymbolLambda=ce,n.AST_SymbolCatch=fe,n.AST_Label=le,n.AST_SymbolRef=pe,n.AST_LabelRef=de,n.AST_This=he,n.AST_Constant=_e,n.AST_String=me,n.AST_Number=ve,n.AST_RegExp=ge,n.AST_Atom=be,n.AST_Null=ye,n.AST_NaN=Ae,n.AST_Undefined=we,n.AST_Hole=Ee,n.AST_Infinity=De,n.AST_Boolean=Fe,n.AST_False=Ce,n.AST_True=Se,n.TreeWalker=E,n.KEYWORDS=ke,n.KEYWORDS_ATOM=Be,n.RESERVED_WORDS=xe,n.KEYWORDS_BEFORE_EXPRESSION=Te,n.OPERATOR_CHARS=Oe,n.RE_HEX_NUMBER=$e,n.RE_OCT_NUMBER=Me,n.RE_DEC_NUMBER=qe,n.OPERATORS=Ne,n.WHITESPACE_CHARS=ze,n.PUNC_BEFORE_EXPRESSION=He,n.PUNC_CHARS=Re,n.REGEXP_MODIFIERS=je,n.UNICODE=Pe,n.is_letter=D,n.is_digit=F,n.is_alphanumeric_char=C,n.is_unicode_digit=S,n.is_unicode_combining_mark=k,n.is_unicode_connector_punctuation=B,n.is_identifier=x,n.is_identifier_start=T,n.is_identifier_char=O,n.is_identifier_string=$,n.parse_js_number=M,n.JS_Parse_Error=q,n.js_error=N,n.is_token=z,n.EX_EOF=Ie,n.tokenizer=H,n.UNARY_PREFIX=Ue,n.UNARY_POSTFIX=Le,n.ASSIGNMENT=Ve,n.PRECEDENCE=We,n.STATEMENTS_WITH_LABELS=Ye,n.ATOMIC_START_TOKEN=Xe,n.parse=R,n.TreeTransformer=j,n.SymbolDef=P,n.base54=Ge,n.OutputStream=I,n.Compressor=U,n.SourceMap=L,n.find_builtins=V,n.mangle_properties=W}({},function(){return this}()); \ No newline at end of file diff --git a/portable.test/portable.test.csproj b/portable.test/portable.test.csproj index 312b06172..905e79547 100644 --- a/portable.test/portable.test.csproj +++ b/portable.test/portable.test.csproj @@ -31,6 +31,26 @@ prompt 4 + + true + bin\x86\Debug\ + TRACE;DEBUG;PORTABLE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE;PORTABLE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + @@ -42,7 +62,7 @@ - + Program.cs