public IsAndrewProgram(
            PrintValueNewLine<NameQuestionProvider> a,
            ReadLine c,
            PushValue<AndrewProvider> d,
            If<StackEquals, PrintValueNewLine<SuccessValue>, PrintValueNewLine<FailureValue>> e)
        {

        }
 public GameLoop(
     PopValue cleanupPreviousRun,
     PrintValueNewLine<GuessANumber> a,
     ReadLine c,
     If<GreaterThan<StaticRandomNumberValueProvider>, PrintValueNewLine<TooLow>,
         If<LessThan<StaticRandomNumberValueProvider>, PrintValueNewLine<TooHigh>, NoOp>> d
     )
 {
 }
Example #3
0
        protected override void TraverseIf(If @if)
        {
            var @break = il.DefineLabel();
            var iffalse = il.DefineLabel();

            Traverse(@if.Test);
            il.brfalse(iffalse);
            Traverse(@if.IfTrue);
            il.br(@break);
            il.label(iffalse);
            Traverse(@if.IfFalse);
            il.label(@break);
        }
Example #4
0
            internal If(IfStatement stmt)
                : this() {
                If current = this;
                If parent = null;
                foreach (IfStatementTest ifTest in stmt.Tests) {
                    if (parent != null) {
                        current = new If();
                        parent._orelse = PythonOps.MakeListNoCopy(current);
                    }

                    current.Initialize(ifTest);
                    parent = current;
                }

                current._orelse = ConvertStatements(stmt.ElseStatement, true);
            }
Example #5
0
 public virtual Statement VisitIf(If If){
   if (If == null) return null;
   If.Condition = this.VisitExpression(If.Condition);
   If.TrueBlock = this.VisitBlock(If.TrueBlock);
   If.FalseBlock = this.VisitBlock(If.FalseBlock);
   return If;
 }
Example #6
0
 public override Statement VisitIf(If If) {
   if (If == null) return null;
   If.Condition =  this.VisitBooleanExpression(If.Condition);
   If.TrueBlock = this.VisitBlock(If.TrueBlock);
   If.FalseBlock = this.VisitBlock(If.FalseBlock);
   return If;
 }
Example #7
0
        public Expression TypeCheck(If conditional, Scope scope)
        {
            var position = conditional.Position;
            var condition = conditional.Condition;
            var bodyWhenTrue = conditional.BodyWhenTrue;
            var bodyWhenFalse = conditional.BodyWhenFalse;

            var typedCondition = TypeCheck(condition, scope);
            var typedWhenTrue = TypeCheck(bodyWhenTrue, scope);
            var typedWhenFalse = TypeCheck(bodyWhenFalse, scope);

            Unify(typedCondition.Position, NamedType.Boolean, typedCondition.Type);
            Unify(typedWhenFalse.Position, typedWhenTrue.Type, typedWhenFalse.Type);

            return new If(position, typedCondition, typedWhenTrue, typedWhenFalse, typedWhenTrue.Type);
        }
 public void Visit(If ifs)
 {
     var oldRet = _foundReturn;
     _foundReturn = false;
     ifs.Body.Accept(this);
     _foundReturn = oldRet;
 }
Example #9
0
 public void Visit(If ifs)
 {
     ifs.Guard.Accept(this);
     MustBeBool("The if guard");
     ifs.Body.Accept(this);
 }
Example #10
0
        public void IfResultsTestAll()
        {
            var ifStringValue = If.Value <string, int>("foo");

            Assert.IsNotNull(ifStringValue.Is);
            //Assert.IsNotNull(ifStringValue.IsNot);
            Assert.IsNotNull(ifStringValue.Does);
            //Assert.IsNotNull(ifStringValue.DoesNot);

            //
            // Is/IsNot
            //
            // Empty/NotEmpty
            var isEmpty = ifStringValue.Is.Empty().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(isEmpty.Results == 2);
            Assert.IsTrue(isEmpty.HasError == false);
            Assert.IsTrue(isEmpty.Exception == null);

            //var isNotEmpty1 = ifStringValue.Is.NotEmpty().Then(a => 1).Else(a => 2).Error((a, e) => 3);
            //Assert.IsTrue(isNotEmpty1.Results == 1);
            //Assert.IsTrue(isNotEmpty1.HasError == false);
            //Assert.IsTrue(isNotEmpty1.Exception == null);

            var isNotEmpty2 = ifStringValue.Is.Not.Empty().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(isNotEmpty2.Results == 1);
            Assert.IsTrue(isNotEmpty2.HasError == false);
            Assert.IsTrue(isNotEmpty2.Exception == null);

            // Null/NotNull
            var isNull = ifStringValue.Is.Null().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(isNull.Results == 2);
            Assert.IsTrue(isNull.HasError == false);
            Assert.IsTrue(isNull.Exception == null);

            //var isNotNull1 = ifStringValue.Is.NotNull().Then(a => 1).Else(a => 2).Error((a, e) => 3);
            //Assert.IsTrue(isNotNull1.Results == 1);
            //Assert.IsTrue(isNotNull1.HasError == false);
            //Assert.IsTrue(isNotNull1.Exception == null);

            var isNotNull2 = ifStringValue.Is.Not.Null().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(isNotNull2.Results == 1);
            Assert.IsTrue(isNotNull2.HasError == false);
            Assert.IsTrue(isNotNull2.Exception == null);

            // TypeOf
            var typeofGood1 = ifStringValue.Is.TypeOf <string>().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(typeofGood1.Results == 1);
            Assert.IsTrue(typeofGood1.HasError == false);
            Assert.IsTrue(typeofGood1.Exception == null);

            var typeofGood2 = ifStringValue.Is.Not.TypeOf <string>().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(typeofGood2.Results == 2);
            Assert.IsTrue(typeofGood2.HasError == false);
            Assert.IsTrue(typeofGood2.Exception == null);

            var typeofBad = ifStringValue.Is.TypeOf <System.TimeZone>().Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(typeofBad.Results == 2);
            Assert.IsTrue(typeofBad.HasError == false);
            Assert.IsTrue(typeofBad.Exception == null);

            // GreaterThan
            var gtThen1 = If.Value <int, int>(6).Is.GreaterThan(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gtThen1.Results == 1);
            Assert.IsTrue(gtThen1.HasError == false);
            Assert.IsTrue(gtThen1.Exception == null);

            var gtElse1 = If.Value <int, int>(5).Is.GreaterThan(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gtElse1.Results == 2);
            Assert.IsTrue(gtElse1.HasError == false);
            Assert.IsTrue(gtElse1.Exception == null);

            var gtElse2 = If.Value <int, int>(6).Is.Not.GreaterThan(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gtElse2.Results == 2);
            Assert.IsTrue(gtElse2.HasError == false);
            Assert.IsTrue(gtElse2.Exception == null);

            var gtError = ifStringValue.Is.GreaterThan(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gtError.Results == 3);
            Assert.IsTrue(gtError.HasError == true);
            Assert.IsTrue(gtError.Exception != null);

            // GreaterThanOrEqual
            var gteThen1 = If.Value <int, int>(6).Is.GreaterThanOrEqual(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gteThen1.Results == 1);
            Assert.IsTrue(gteThen1.HasError == false);
            Assert.IsTrue(gteThen1.Exception == null);

            var gteThen2 = If.Value <int, int>(5).Is.GreaterThanOrEqual(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gteThen2.Results == 1);
            Assert.IsTrue(gteThen2.HasError == false);
            Assert.IsTrue(gteThen2.Exception == null);

            var gteElse1 = If.Value <int, int>(6).Is.Not.GreaterThanOrEqual(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gteElse1.Results == 2);
            Assert.IsTrue(gteElse1.HasError == false);
            Assert.IsTrue(gteElse1.Exception == null);

            var gteError = ifStringValue.Is.GreaterThanOrEqual(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(gteError.Results == 3);
            Assert.IsTrue(gteError.HasError == true);
            Assert.IsTrue(gteError.Exception != null);

            // LessThan
            var ltThen1 = If.Value <int, int>(5).Is.LessThan(6).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(ltThen1.Results == 1);
            Assert.IsTrue(ltThen1.HasError == false);
            Assert.IsTrue(ltThen1.Exception == null);

            var ltElse1 = If.Value <int, int>(5).Is.LessThan(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(ltElse1.Results == 2);
            Assert.IsTrue(ltElse1.HasError == false);
            Assert.IsTrue(ltElse1.Exception == null);

            var ltElse2 = If.Value <int, int>(5).Is.Not.LessThan(6).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(ltElse2.Results == 2);
            Assert.IsTrue(ltElse2.HasError == false);
            Assert.IsTrue(ltElse2.Exception == null);

            var ltError = ifStringValue.Is.LessThan(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(ltError.Results == 3);
            Assert.IsTrue(ltError.HasError == true);
            Assert.IsTrue(ltError.Exception != null);

            // LessThanOrEqual
            var lteThen1 = If.Value <int, int>(5).Is.LessThanOrEqual(6).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(lteThen1.Results == 1);
            Assert.IsTrue(lteThen1.HasError == false);
            Assert.IsTrue(lteThen1.Exception == null);

            var lteThen2 = If.Value <int, int>(5).Is.LessThanOrEqual(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(lteThen2.Results == 1);
            Assert.IsTrue(lteThen2.HasError == false);
            Assert.IsTrue(lteThen2.Exception == null);

            var lteElse1 = If.Value <int, int>(5).Is.Not.LessThanOrEqual(6).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(lteElse1.Results == 2);
            Assert.IsTrue(lteElse1.HasError == false);
            Assert.IsTrue(lteElse1.Exception == null);

            var lteError = ifStringValue.Is.LessThanOrEqual(5).Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(lteError.Results == 3);
            Assert.IsTrue(lteError.HasError == true);
            Assert.IsTrue(lteError.Exception != null);

            //
            // Does/DoesNot
            //
            // Contain
            var doesContain = ifStringValue.Does.Contain("fo").Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(doesContain.Results == 1);
            Assert.IsTrue(doesContain.HasError == false);
            Assert.IsTrue(doesContain.Exception == null);

            var doesNotContain1 = ifStringValue.Does.Not.Contain("fo").Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(doesNotContain1.Results == 2);
            Assert.IsTrue(doesNotContain1.HasError == false);
            Assert.IsTrue(doesNotContain1.Exception == null);

            var doesNotContain2 = ifStringValue.Does.Not.Contain("bar").Then(a => 1).Else(a => 2).Error((a, e) => 3);

            Assert.IsTrue(doesNotContain2.Results == 1);
            Assert.IsTrue(doesNotContain2.HasError == false);
            Assert.IsTrue(doesNotContain2.Exception == null);

            // Does/DoesNot Contain on IEnumberable
            //var stringArray = new string[] { "Foo", "Bar" };
            //var doesContainIEnumThen = If.Value(stringArray).Does.Contain("Foo").Then(a => 1).Else(a => 2).Error((a, e) => 3);
            //Assert.IsTrue(doesContainIEnumThen.HasResults == true);
            //Assert.IsTrue(doesContainIEnumThen.Results == 2);
            //Assert.IsTrue(doesContainIEnumThen.HasError == false);
            //Assert.IsTrue(doesContainIEnumThen.Exception == null);

            //var doesContainIEnumElse = If.Value(stringArray).Does.Contain("fo").Then(a => 1).Else(a => 2).Error((a, e) => 3);
            //Assert.IsTrue(doesContainIEnumElse.HasResults == true);
            //Assert.IsTrue(doesContainIEnumElse.Results == 2);
            //Assert.IsTrue(doesContainIEnumElse.HasError == false);
            //Assert.IsTrue(doesContainIEnumElse.Exception == null);



            // TODO: transformresults


            //
            // Throws
            //
            try
            {
                If.Value <string, int>("asdf").Is.Not.Null().Throw(new NullReferenceException());
            }
            catch (NullReferenceException)
            {
            }
            catch (Exception)
            {
                Assert.Fail();
            }

            try
            {
                If.Value <string, int>("asdf").Is.Not.Null().Throw <NullReferenceException>();
            }
            catch (NullReferenceException)
            {
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Example #11
0
            Method GenerateNumberMatcher()
            {
                var loc        = Location;
                var parameters = ParametersCompiled.CreateFullyResolved(
                    new [] {
                    new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc),
                    new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, loc), "value", 0, null, loc),
                    new Parameter(new TypeExpression(Compiler.BuiltinTypes.Bool, loc), "enumType", 0, null, loc),
                },
                    new [] {
                    Compiler.BuiltinTypes.Object,
                    Compiler.BuiltinTypes.Object,
                    Compiler.BuiltinTypes.Bool
                });

                var m = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Bool, loc),
                                   Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName("NumberMatcher", loc),
                                   parameters, null);

                parameters [0].Resolve(m, 0);
                parameters [1].Resolve(m, 1);
                parameters [2].Resolve(m, 2);

                ToplevelBlock top_block = new ToplevelBlock(Compiler, parameters, loc);

                m.Block = top_block;

                //
                // if (enumType)
                //        return Equals (obj, value);
                //
                var equals_args = new Arguments(2);

                equals_args.Add(new Argument(top_block.GetParameterReference(0, loc)));
                equals_args.Add(new Argument(top_block.GetParameterReference(1, loc)));

                var if_type = new If(
                    top_block.GetParameterReference(2, loc),
                    new Return(new Invocation(new SimpleName("Equals", loc), equals_args), loc),
                    loc);

                top_block.AddStatement(if_type);

                //
                // if (obj is Enum || obj == null)
                //        return false;
                //

                var if_enum = new If(
                    new Binary(Binary.Operator.LogicalOr,
                               new Is(top_block.GetParameterReference(0, loc), new TypeExpression(Compiler.BuiltinTypes.Enum, loc), loc),
                               new Binary(Binary.Operator.Equality, top_block.GetParameterReference(0, loc), new NullLiteral(loc))),
                    new Return(new BoolLiteral(Compiler.BuiltinTypes, false, loc), loc),
                    loc);

                top_block.AddStatement(if_enum);


                var system_convert = new MemberAccess(new QualifiedAliasMember("global", "System", loc), "Convert", loc);
                var expl_block     = new ExplicitBlock(top_block, loc, loc);

                //
                // var converted = System.Convert.ChangeType (obj, System.Convert.GetTypeCode (value));
                //
                var lv_converted = LocalVariable.CreateCompilerGenerated(Compiler.BuiltinTypes.Object, top_block, loc);

                var arguments_gettypecode = new Arguments(1);

                arguments_gettypecode.Add(new Argument(top_block.GetParameterReference(1, loc)));

                var gettypecode = new Invocation(new MemberAccess(system_convert, "GetTypeCode", loc), arguments_gettypecode);

                var arguments_changetype = new Arguments(1);

                arguments_changetype.Add(new Argument(top_block.GetParameterReference(0, loc)));
                arguments_changetype.Add(new Argument(gettypecode));

                var changetype = new Invocation(new MemberAccess(system_convert, "ChangeType", loc), arguments_changetype);

                expl_block.AddStatement(new StatementExpression(new SimpleAssign(new LocalVariableReference(lv_converted, loc), changetype, loc)));


                //
                // return converted.Equals (value)
                //
                var equals_arguments = new Arguments(1);

                equals_arguments.Add(new Argument(top_block.GetParameterReference(1, loc)));
                var equals_invocation = new Invocation(new MemberAccess(new LocalVariableReference(lv_converted, loc), "Equals"), equals_arguments);

                expl_block.AddStatement(new Return(equals_invocation, loc));

                var catch_block = new ExplicitBlock(top_block, loc, loc);

                catch_block.AddStatement(new Return(new BoolLiteral(Compiler.BuiltinTypes, false, loc), loc));
                top_block.AddStatement(new TryCatch(expl_block, new List <Catch> ()
                {
                    new Catch(catch_block, loc)
                }, loc, false));

                m.Define();
                m.PrepareEmit();
                AddMember(m);

                return(m);
            }
Example #12
0
        public override void Step()
        {
            var gamepad = Module <Gamepads>()[0];

            If.True(gamepad.WasPressed(NES.Button.Start), () => Module <SceneManager>().Queue(Module <FlickerTest>()));
        }
Example #13
0
 public virtual void Visit(If node)
 {
 }
Example #14
0
        public void ShouldCheckOperationInstanceOnSuccessfull()
        {
            var operation = new Mock <IOperation <string> >();

            Assert.Throws <InvalidCastException>(() => If.Successfull(operation.Object), "Exception");
        }
Example #15
0
 [NotNull] protected virtual BaseStatement Visit([NotNull] If @if)
 {
     return(new If(Visit(@if.Condition), Visit(@if.TrueBranch), Visit(@if.FalseBranch)));
 }
Example #16
0
 public Executor(If aggregator) => _aggregator = aggregator;
Example #17
0
 private static void AddFieldDisposeBlock(ElementBuilder elementBuilder, If parentIfDisposingBlock, BaseVariable field)
 {
     If ifFieldIsAssignedBlock = new If();
       ifFieldIsAssignedBlock.Expression = CodeRush.Language.GetNullCheck(field.Name).Invert();
       elementBuilder.AddMethodCall(ifFieldIsAssignedBlock, field.Name + CodeRush.Language.MemberAccessOperator + STR_Dispose);
       if (!field.IsReadOnly)
       elementBuilder.AddAssignment(ifFieldIsAssignedBlock, field.Name, CodeRush.Language.GetNullReferenceExpression());
       parentIfDisposingBlock.AddNode(ifFieldIsAssignedBlock);
 }
Example #18
0
 public string Visit(If conditional)
 {
     return(String.Format("(if ({0}) ({1}) else ({2}))", Translate(conditional.Condition), Translate(conditional.BodyWhenTrue), Translate(conditional.BodyWhenFalse)));
 }
Example #19
0
 public override Statement VisitIf(If If)
 {
     if (If == null) return null;
     return base.VisitIf((If)If.Clone());
 }
Example #20
0
 public override bool HasVariableDefined(Interpreter interpreter)
 {
     return((If != null && If.HasVariableDefined(interpreter)) || (ElseIf != null && ElseIf.Any(e => e.HasVariableDefined(interpreter))) || (Else != null && Else.HasVariableDefined(interpreter)));
 }
Example #21
0
 public virtual void VisitIf(If If)
 {
   if (If == null) return;
   this.VisitExpression(If.Condition);
   this.VisitBlock(If.TrueBlock);
   this.VisitBlock(If.FalseBlock);
 }
Example #22
0
    public void AnalyzeDeeper(object obj)
    {
        object[] items = {};
        // <If Condition="HasQuest(26761) &amp;&amp; IsQuestCompleted(26761)">
        If    If    = null;
        While While = null;

        if (obj is QuestOrderType)
        {
            var questOrder = obj as QuestOrderType;
            items = questOrder.Items;
        }
        else if (obj is If)
        {
            If    = obj as If;
            items = If.Items;
        }
        else if (obj is While)
        {
            While = obj as While;
            items = While.Items;
        }
        if (!(obj is QuestOrderType) && !(obj is If) && !(obj is While))
        {
            return;
        }
        for (int j = 0; j < items.Length; j++)
        {
            object qOrder = items[j];
            if (qOrder is PickUp)
            {
                var pickUp = qOrder as PickUp;
                CreateEmptyQuestFromPickUp(pickUp);
                var tnbNpc = new Npc
                {
                    Entry    = (int)pickUp.GiverId,
                    Name     = pickUp.GiverName,
                    Position = new Point {
                        X = pickUp.X, Y = pickUp.Y, Z = pickUp.Z
                    },
                };
                if (tnbNpc.Position.IsValid)
                {
                    _tnbTmpNpcList.Add(tnbNpc);
                }
                if (pickUp.GiverType == "Item")
                {
                    _itemPickUpList.Add(new KeyValuePair <int, uint>((int)pickUp.QuestId, pickUp.GiverId));
                }
                else
                {
                    _pickUpList.Add(new KeyValuePair <int, uint>((int)pickUp.QuestId, pickUp.GiverId));
                }
            }
            else if (qOrder is TurnIn)
            {
                var turnIn = qOrder as TurnIn;
                CreateEmptyQuestFromTurnIn(turnIn);
                var tnbNpc = new Npc
                {
                    Entry    = (int)turnIn.TurnInId,
                    Name     = turnIn.TurnInName,
                    Position = new Point {
                        X = turnIn.X, Y = turnIn.Y, Z = turnIn.Z
                    },
                };
                if (tnbNpc.Position.IsValid)
                {
                    _tnbTmpNpcList.Add(tnbNpc);
                }
                _turnInList.Add(new KeyValuePair <int, uint>((int)turnIn.QuestId, turnIn.TurnInId));
            }
            else if (qOrder is If)
            {
                var qOrderIf = qOrder as If;
                if (qOrderIf.Items == null)
                {
                    continue;
                }
                AnalyzeDeeper(qOrderIf);
            }
            else if (qOrder is While)
            {
                var qOrderWhile = qOrder as While;
                if (qOrderWhile.Items == null)
                {
                    continue;
                }
                AnalyzeDeeper(qOrderWhile);
            }
            else if (qOrder is CustomBehavior)
            {
                var emptyObjective = new QuestObjective();
                var qOrderCustom   = qOrder as CustomBehavior;
                if (qOrderCustom.QuestId == 0)
                {
                    if (If != null)
                    {
                        qOrderCustom.QuestId = GetQuestIdFromCondition(If.Condition);
                    }
                    else if (While != null)
                    {
                        qOrderCustom.QuestId = GetQuestIdFromCondition(While.Condition);
                    }
                }
                if (qOrderCustom.File == "MoveTo")
                {
                    emptyObjective = new QuestObjective {
                        Objective = Objective.MoveTo, Position = new Point {
                            X = qOrderCustom.X, Y = qOrderCustom.Y, Z = qOrderCustom.Z
                        }
                    };
                }
                else if (qOrderCustom.File == "WaitTimer")
                {
                    emptyObjective = new QuestObjective {
                        Objective = Objective.Wait, WaitMs = (int)qOrderCustom.WaitTime
                    };
                }
                else if (qOrderCustom.File == "")
                {
                    // more else/if to add with a valid .File argument here.
                }
                if (emptyObjective.Objective != Objective.None)
                {
                    foreach (Quester.Profile.Quest q in _tnbProfile.Quests)
                    {
                        if (q.Id == qOrderCustom.QuestId)
                        {
                            q.Objectives.Add(emptyObjective);
                        }
                    }
                }
            }
            else if (qOrder is ObjectiveMetaType)
            {
            }
        }
    }
Example #23
0
        private void ReadIfInternal(If target)
        {
            var cb1 = CondBlock.New(target);
            cb1.Cond = ReadCond(target, "if");
            cb1.Block = ReadSentenceBlock(target, "if");
            target.Blocks.Add(cb1);

            var t1 = Read();
            if (t1 != "else")
            {
                if (t1 != null) Rewind();
                return;
            }

            var t2 = Read();
            if (t2 == "if")
            {
                ReadIfInternal(target);
                return;
            }

            Rewind();
            var cb2 = CondBlock.New(target);
            cb2.Block = ReadSentenceBlock(target, "else");
            target.Blocks.Add(cb2);
        }
Example #24
0
        public static string GenerateLaTexString(Expression exp)
        {
            switch (exp.ExpressionType)
            {
            case ExpressionType.Variable:
                return(exp.ToString());

            case ExpressionType.Constant:
                if (exp is BoolConstant)
                {
                    return(((BoolConstant)exp).Value.ToString());
                }
                else
                {
                    return(exp.ToString());
                }

            case ExpressionType.Record:
            {
                Record record = exp as Record;

                StringBuilder sb = new StringBuilder("[");

                for (int i = 0; i < record.Associations.Length - 1; i++)
                {
                    Expression con = record.Associations[i];
                    sb.Append(GenerateLaTexString(con) + ", ");
                }
                sb.Append(GenerateLaTexString(record.Associations[record.Associations.Length - 1]));

                sb.Append("]");
                return(sb.ToString());
            }

            case ExpressionType.PrimitiveApplication:
                // First evaluate the first argument, then the second, and
                // then evaluate using evalPrimAppl.
            {
                PrimitiveApplication newexp = exp as PrimitiveApplication;



                if (newexp.Argument2 == null)
                {
                    if (newexp.Operator == "~")
                    {
                        return("-" + GenerateLaTexString(newexp.Argument1));
                    }
                    else
                    {
                        return(newexp.Operator + GenerateLaTexString(newexp.Argument1));
                    }
                }
                else
                {
                    if (newexp.Operator == ".")
                    {
                        return(GenerateLaTexString(newexp.Argument1) + "[" + GenerateLaTexString(newexp.Argument2) + "]");
                    }
                    else if (newexp.Operator == "mod")
                    {
                        return("(" + GenerateLaTexString(newexp.Argument1) + " \\% " + GenerateLaTexString(newexp.Argument2) + ")");
                    }
                    else
                    {
                        string op = "";
                        switch (newexp.Operator)
                        {
                        case "&&":
                            op = @"\land";
                            break;

                        case "||":
                            op = @"\lor";
                            break;

                        case "==":
                            op = @"==";
                            break;

                        case "!=":
                            op = @"\neq";
                            break;

                        case ">=":
                            op = @"\geq";
                            break;

                        case "<=":
                            op = @"\leq";
                            break;

                        case "\\":
                            op = @"\backslash";
                            break;

                        default:
                            op = newexp.Operator;
                            break;
                        }

                        return("(" + GenerateLaTexString(newexp.Argument1) + " " + op + " " + GenerateLaTexString(newexp.Argument2) + ")");
                    }
                }
            }

            case ExpressionType.Assignment:
            {
                Assignment assign = exp as Assignment;
                return(assign.LeftHandSide + " = " + GenerateLaTexString(assign.RightHandSide) + ";");
            }

            case ExpressionType.PropertyAssignment:
            {
                PropertyAssignment pa = (PropertyAssignment)exp;
                return(GenerateLaTexString(pa.RecordExpression) + "[" + GenerateLaTexString(pa.PropertyExpression) + "]=" + GenerateLaTexString(pa.RightHandExpression) + ";");
            }

            case ExpressionType.If:
                // Conditionals are evaluated by evaluating the then-part or
                // else-part depending of the result of evaluating the condition.
            {
                If ifC = (If)exp;
                if (ifC.ElsePart != null)
                {
                    return(" if (" + GenerateLaTexString(ifC.Condition) + ") \\{" + GenerateLaTexString(ifC.ThenPart) + "\\} else \\{" + GenerateLaTexString(ifC.ElsePart) + "\\}");
                }
                else
                {
                    return(" if (" + GenerateLaTexString(ifC.Condition) + ") \\{" + GenerateLaTexString(ifC.ThenPart) + "\\}");
                }
            }

            case ExpressionType.Sequence:

                return(GenerateLaTexString(((Sequence)exp).FirstPart) + ";" + GenerateLaTexString(((Sequence)exp).SecondPart));

            case ExpressionType.While:

                return("while (" + GenerateLaTexString(((While)exp).Test) + ") \\{" + GenerateLaTexString(((While)exp).Body) + "\\}");

            case ExpressionType.StaticMethodCall:
                StaticMethodCall call   = exp as StaticMethodCall;
                StringBuilder    strbui = new StringBuilder("call(" + call.MethodName + ",");
                for (int i = 0; i < call.Arguments.Length; i++)
                {
                    if (i == call.Arguments.Length - 1)
                    {
                        strbui.Append(call.Arguments[i].ToString());
                    }
                    else
                    {
                        strbui.Append(call.Arguments[i] + ",~");
                    }
                }
                strbui.Append(")");
                return(strbui.ToString());
            }

            return("");
        }
Example #25
0
void case_912()
#line 6100 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);
		
		yyVal = new If ((BooleanExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
Example #26
0
        /// <summary>
        /// Create activity
        /// </summary>
        /// <returns>Activity object</returns>
        protected override Activity CreateInternalBody()
        {
            var workingDirectory = new Variable <string>
            {
                Name = "WorkingDirectory"
            };

            var sequence = new Sequence()
            {
                Variables = { workingDirectory }
            };


            sequence.Activities.Add(new Assign <string>
            {
                To          = workingDirectory,
                Value       = new InArgument <string>(x => Path.GetDirectoryName(this.Assemblies.Get(x).First())),
                DisplayName = "Assign working directory"
            });

            this.AddActivity(sequence);

            var processXml = new ProcessXmlResultsFile()
            {
                DisplayName      = "Process XML Results",
                Errors           = new OutArgument <int>(x => this.Errors.GetLocation(x).Value),
                Failures         = new OutArgument <int>(x => this.Failures.GetLocation(x).Value),
                Ignored          = new OutArgument <int>(x => this.Ignored.GetLocation(x).Value),
                Inconclusive     = new OutArgument <int>(x => this.Inconclusive.GetLocation(x).Value),
                Invalid          = new OutArgument <int>(x => this.Invalid.GetLocation(x).Value),
                NotRun           = new OutArgument <int>(x => this.NotRun.GetLocation(x).Value),
                Skipped          = new OutArgument <int>(x => this.Skipped.GetLocation(x).Value),
                Total            = new OutArgument <int>(x => this.Total.GetLocation(x).Value),
                OutputXmlFile    = new InArgument <string>(x => this.OutputXmlFile.Get(x)),
                WorkingDirectory = new InArgument <string>(x => workingDirectory.Get(x))
            };

            sequence.Activities.Add(processXml);

            var publishResults = new PublishTestResultsToTfs()
            {
                DisplayName      = "Publish to TFS",
                Flavor           = new InArgument <string>(x => this.Flavor.Get(x)),
                OutputXmlFile    = new InArgument <string>(x => this.OutputXmlFile.Get(x)),
                Platform         = new InArgument <string>(x => this.Platform.Get(x)),
                WorkingDirectory = new InArgument <string>(x => workingDirectory.Get(x)),
                ReportName       = new InArgument <string>(x => string.Join(", ", this.Assemblies.Get(x)))
            };

            var condition = new If
            {
                DisplayName = "If PublishTestResults",
                Condition   = new InArgument <bool>(x => this.PublishTestResults.Get(x)),
                Then        = publishResults,
                Else        = new WriteBuildMessage()
                {
                    Message = new InArgument <string>("Results not published"), Importance = new InArgument <BuildMessageImportance>(BuildMessageImportance.High)
                }
            };

            sequence.Activities.Add(condition);
            return(sequence);
        }
		protected void EmitCall (EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
		{
			//
			// This method generates all internal infrastructure for a dynamic call. The
			// reason why it's quite complicated is the mixture of dynamic and anonymous
			// methods. Dynamic itself requires a temporary class (ContainerX) and anonymous
			// methods can generate temporary storey as well (AnonStorey). Handling MVAR
			// type parameters rewrite is non-trivial in such case as there are various
			// combinations possible therefore the mutator is not straightforward. Secondly
			// we need to keep both MVAR(possibly VAR for anon storey) and type VAR to emit
			// correct Site field type and its access from EmitContext.
			//

			int dyn_args_count = arguments == null ? 0 : arguments.Count;
			int default_args = isStatement ? 1 : 2;
			var module = ec.Module;

			bool has_ref_out_argument = false;
			var targs = new TypeExpression[dyn_args_count + default_args];
			targs[0] = new TypeExpression (module.PredefinedTypes.CallSite.TypeSpec, loc);

			TypeExpression[] targs_for_instance = null;
			TypeParameterMutator mutator;

			var site_container = ec.CreateDynamicSite ();

			if (context_mvars != null) {
				TypeParameters tparam;
				TypeContainer sc = site_container;
				do {
					tparam = sc.CurrentTypeParameters;
					sc = sc.Parent;
				} while (tparam == null);

				mutator = new TypeParameterMutator (context_mvars, tparam);

				if (!ec.IsAnonymousStoreyMutateRequired) {
					targs_for_instance = new TypeExpression[targs.Length];
					targs_for_instance[0] = targs[0];
				}
			} else {
				mutator = null;
			}

			for (int i = 0; i < dyn_args_count; ++i) {
				Argument a = arguments[i];
				if (a.ArgType == Argument.AType.Out || a.ArgType == Argument.AType.Ref)
					has_ref_out_argument = true;

				var t = a.Type;

				// Convert any internal type like dynamic or null to object
				if (t.Kind == MemberKind.InternalCompilerType)
					t = ec.BuiltinTypes.Object;

				if (targs_for_instance != null)
					targs_for_instance[i + 1] = new TypeExpression (t, loc);

				if (mutator != null)
					t = t.Mutate (mutator);

				targs[i + 1] = new TypeExpression (t, loc);
			}

			TypeExpr del_type = null;
			TypeExpr del_type_instance_access = null;
			if (!has_ref_out_argument) {
				string d_name = isStatement ? "Action" : "Func";

				TypeExpr te = null;
				Namespace type_ns = module.GlobalRootNamespace.GetNamespace ("System", true);
				if (type_ns != null) {
					te = type_ns.LookupType (module, d_name, dyn_args_count + default_args, LookupMode.Normal, loc);
				}

				if (te != null) {
					if (!isStatement) {
						var t = type;
						if (t.Kind == MemberKind.InternalCompilerType)
							t = ec.BuiltinTypes.Object;

						if (targs_for_instance != null)
							targs_for_instance[targs_for_instance.Length - 1] = new TypeExpression (t, loc);

						if (mutator != null)
							t = t.Mutate (mutator);

						targs[targs.Length - 1] = new TypeExpression (t, loc);
					}

					del_type = new GenericTypeExpr (te.Type, new TypeArguments (targs), loc);
					if (targs_for_instance != null)
						del_type_instance_access = new GenericTypeExpr (te.Type, new TypeArguments (targs_for_instance), loc);
					else
						del_type_instance_access = del_type;
				}
			}

			//
			// Create custom delegate when no appropriate predefined delegate has been found
			//
			Delegate d;
			if (del_type == null) {
				TypeSpec rt = isStatement ? ec.BuiltinTypes.Void : type;
				Parameter[] p = new Parameter[dyn_args_count + 1];
				p[0] = new Parameter (targs[0], "p0", Parameter.Modifier.NONE, null, loc);

				var site = ec.CreateDynamicSite ();
				int index = site.Containers == null ? 0 : site.Containers.Count;

				if (mutator != null)
					rt = mutator.Mutate (rt);

				for (int i = 1; i < dyn_args_count + 1; ++i) {
					p[i] = new Parameter (targs[i], "p" + i.ToString ("X"), arguments[i - 1].Modifier, null, loc);
				}

				d = new Delegate (site, new TypeExpression (rt, loc),
					Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED,
					new MemberName ("Container" + index.ToString ("X")),
					new ParametersCompiled (p), null);

				d.CreateContainer ();
				d.DefineContainer ();
				d.Define ();

				site.AddTypeContainer (d);
				del_type = new TypeExpression (d.CurrentType, loc);
				if (targs_for_instance != null) {
					del_type_instance_access = null;
				} else {
					del_type_instance_access = del_type;
				}
			} else {
				d = null;
			}

			var site_type_decl = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc);
			var field = site_container.CreateCallSiteField (site_type_decl, loc);
			if (field == null)
				return;

			if (del_type_instance_access == null) {
				var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Types);
				del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc);
			}

			var instanceAccessExprType = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec,
				new TypeArguments (del_type_instance_access), loc);

			if (instanceAccessExprType.ResolveAsType (ec.MemberContext) == null)
				return;

			bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired;

			TypeSpec gt;
			if (inflate_using_mvar || context_mvars == null) {
				gt = site_container.CurrentType;
			} else {
				gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
			}

			// When site container already exists the inflated version has to be
			// updated manually to contain newly created field
			if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
				var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
				var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
				gt.MemberCache.AddMember (field.InflateMember (inflator));
			}

			FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc);

			BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void);

			Arguments args = new Arguments (1);
			args.Add (new Argument (binder));
			StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args)));

			using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
				if (s.Resolve (bc)) {
					Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
					init.Emit (ec);
				}

				args = new Arguments (1 + dyn_args_count);
				args.Add (new Argument (site_field_expr));
				if (arguments != null) {
					int arg_pos = 1;
					foreach (Argument a in arguments) {
						if (a is NamedArgument) {
							// Name is not valid in this context
							args.Add (new Argument (a.Expr, a.ArgType));
						} else {
							args.Add (a);
						}

						if (inflate_using_mvar && a.Type != targs[arg_pos].Type)
							a.Expr.Type = targs[arg_pos].Type;

						++arg_pos;
					}
				}

				Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc);
				if (target != null)
					target.Emit (ec);
			}
		}
Example #28
0
 public static Object Sub(Object[] args)
 {
     return(If.Is <Double, Double>(args, SubNumbers) ??
            If.Is <Double[, ], Double[, ]>(args, SubMatrices) ??
            If.IsNotNull(args, AsNumber, SubNumbers));
 }
			public override object Visit (If ifStatement)
			{
				var result = new IfElseStatement ();
				
				var location = LocationsBag.GetLocations (ifStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (ifStatement.loc), IfElseStatement.IfKeywordRole), IfElseStatement.IfKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar);
				if (ifStatement.Expr != null)
					result.AddChild ((Expression)ifStatement.Expr.Accept (this), Roles.Condition);
				if (location != null && location.Count > 1)
					result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar);
				
				if (ifStatement.TrueStatement != null)
					result.AddChild ((Statement)ifStatement.TrueStatement.Accept (this), IfElseStatement.TrueRole);
				
				if (ifStatement.FalseStatement != null) {
					if (location != null && location.Count > 2)
						result.AddChild (new CSharpTokenNode (Convert (location [2]), IfElseStatement.ElseKeywordRole), IfElseStatement.ElseKeywordRole);
					result.AddChild ((Statement)ifStatement.FalseStatement.Accept (this), IfElseStatement.FalseRole);
				}
				
				return result;
			}
Example #30
0
 public static Object RDiv(Object[] args)
 {
     return(If.Is <Double, Double>(args, RDivNumbers) ??
            If.Is <Double, Double[, ]>(args, RDivNumMat) ??
            If.IsNotNull(args, AsNumber, RDivNumbers));
 }
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["rank"]        = new Rank();
     Functions["rank.eq"]     = new Rank();
     Functions["rank.avg"]    = new Rank(true);
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     // Logical
     Functions["if"]      = new If();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
Example #32
0
 public static Object LDiv(Object[] args)
 {
     return(If.Is <Double, Double>(args, LDivNumbers) ??
            If.Is <Double[, ], Double>(args, LDivMatNum) ??
            If.IsNotNull(args, AsNumber, LDivNumbers));
 }
Example #33
0
 [NotNull] protected abstract TResult Visit([NotNull] If @if);
Example #34
0
 public static Object Mod(Object[] args)
 {
     return(If.Is <Double, Double>(args, ModNumbers) ??
            If.IsNotNull(args, AsNumber, ModNumbers));
 }
Example #35
0
        private void AddVirtualDisposeMethod(ElementBuilder elementBuilder)
        {
            TypeDeclaration activeType = _ActiveClass;
              Method virtualDisposeMethod = elementBuilder.AddMethod(null, null, STR_Dispose);

              if (activeType.ElementType == LanguageElementType.Struct)
              {
            virtualDisposeMethod.Visibility = MemberVisibility.Public;
              }
              else
              {
              virtualDisposeMethod.Visibility = MemberVisibility.Protected;
              virtualDisposeMethod.IsVirtual = true;
              }

              string typeName = CodeRush.Language.GetSimpleTypeName("System.Boolean");
              virtualDisposeMethod.AddParameter(new Param(typeName, "disposing"));
              If ifDisposingBlock = new If();
              ifDisposingBlock.Expression = new ElementReferenceExpression("disposing");
              virtualDisposeMethod.AddNode(ifDisposingBlock);
              // Dispose fields individually...
              foreach (BaseVariable field in _ActiveClass.AllFields)
              {
            if (!field.IsStatic && field.Is("System.IDisposable"))
              AddFieldDisposeBlock(elementBuilder, ifDisposingBlock, field);
            }
        }
Example #36
0
 public static Object Pipe(Object[] args)
 {
     return(If.Is <Function, Object>(args, InvokeFunction));
 }
Example #37
0
 public virtual Statement VisitIf(If If1, If If2)
 {
     if (If1 == null) return null;
     if (If2 == null)
     {
         If1.Condition = this.VisitExpression(If1.Condition, null);
         If1.TrueBlock = this.VisitBlock(If1.TrueBlock, null);
         If1.FalseBlock = this.VisitBlock(If1.FalseBlock, null);
     }
     else
     {
         If1.Condition = this.VisitExpression(If1.Condition, If2.Condition);
         If1.TrueBlock = this.VisitBlock(If1.TrueBlock, If2.TrueBlock);
         If1.FalseBlock = this.VisitBlock(If1.FalseBlock, If2.FalseBlock);
     }
     return If1;
 }
Example #38
0
        // visibility raised for testing
        /* package */
        public ValueEval EvaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs)
        {
            String dbgIndentStr = "";           // always init. to non-null just for defensive avoiding NPE

            if (dbgEvaluationOutputForNextEval)
            {
                // first evaluation call when ouput is desired, so iit. this evaluator instance
                dbgEvaluationOutputIndent      = 1;
                dbgEvaluationOutputForNextEval = false;
            }
            if (dbgEvaluationOutputIndent > 0)
            {
                // init. indent string to needed spaces (create as substring vom very long space-only string;
                // limit indendation for deep recursions)
                dbgIndentStr = "                                                                                                    ";
                dbgIndentStr = dbgIndentStr.Substring(0, Math.Min(dbgIndentStr.Length, dbgEvaluationOutputIndent * 2));
                EVAL_LOG.Log(POILogger.WARN, dbgIndentStr
                             + "- evaluateFormula('" + ec.GetRefEvaluatorForCurrentSheet().SheetNameRange
                             + "'/" + new CellReference(ec.RowIndex, ec.ColumnIndex).FormatAsString()
                             + "): " + Arrays.ToString(ptgs).Replace("\\Qorg.apache.poi.ss.formula.ptg.\\E", ""));
                dbgEvaluationOutputIndent++;
            }

            Stack <ValueEval> stack = new Stack <ValueEval>();

            for (int i = 0, iSize = ptgs.Length; i < iSize; i++)
            {
                // since we don't know how To handle these yet :(
                Ptg ptg = ptgs[i];
                if (dbgEvaluationOutputIndent > 0)
                {
                    EVAL_LOG.Log(POILogger.INFO, dbgIndentStr + "  * ptg " + i + ": " + ptg.ToString());
                }
                if (ptg is AttrPtg)
                {
                    AttrPtg attrPtg = (AttrPtg)ptg;
                    if (attrPtg.IsSum)
                    {
                        // Excel prefers To encode 'SUM()' as a tAttr Token, but this evaluator
                        // expects the equivalent function Token
                        //byte nArgs = 1;  // tAttrSum always Has 1 parameter
                        ptg = FuncVarPtg.SUM;//.Create("SUM", nArgs);
                    }
                    if (attrPtg.IsOptimizedChoose)
                    {
                        ValueEval arg0      = stack.Pop();
                        int[]     jumpTable = attrPtg.JumpTable;
                        int       dist;
                        int       nChoices = jumpTable.Length;
                        try
                        {
                            int switchIndex = Choose.EvaluateFirstArg(arg0, ec.RowIndex, ec.ColumnIndex);
                            if (switchIndex < 1 || switchIndex > nChoices)
                            {
                                stack.Push(ErrorEval.VALUE_INVALID);
                                dist = attrPtg.ChooseFuncOffset + 4; // +4 for tFuncFar(CHOOSE)
                            }
                            else
                            {
                                dist = jumpTable[switchIndex - 1];
                            }
                        }
                        catch (EvaluationException e)
                        {
                            stack.Push(e.GetErrorEval());
                            dist = attrPtg.ChooseFuncOffset + 4; // +4 for tFuncFar(CHOOSE)
                        }
                        // Encoded dist for tAttrChoose includes size of jump table, but
                        // countTokensToBeSkipped() does not (it counts whole tokens).
                        dist -= nChoices * 2 + 2; // subtract jump table size
                        i    += CountTokensToBeSkipped(ptgs, i, dist);
                        continue;
                    }
                    if (attrPtg.IsOptimizedIf)
                    {
                        ValueEval arg0 = stack.Pop();
                        bool      evaluatedPredicate;
                        try
                        {
                            evaluatedPredicate = If.EvaluateFirstArg(arg0, ec.RowIndex, ec.ColumnIndex);
                        }
                        catch (EvaluationException e)
                        {
                            stack.Push(e.GetErrorEval());
                            int dist = attrPtg.Data;
                            i      += CountTokensToBeSkipped(ptgs, i, dist);
                            attrPtg = (AttrPtg)ptgs[i];
                            dist    = attrPtg.Data + 1;
                            i      += CountTokensToBeSkipped(ptgs, i, dist);
                            continue;
                        }
                        if (evaluatedPredicate)
                        {
                            // nothing to skip - true param folows
                        }
                        else
                        {
                            int dist = attrPtg.Data;
                            i += CountTokensToBeSkipped(ptgs, i, dist);
                            Ptg nextPtg = ptgs[i + 1];
                            if (ptgs[i] is AttrPtg && nextPtg is FuncVarPtg &&
                                // in order to verify that there is no third param, we need to check
                                // if we really have the IF next or some other FuncVarPtg as third param, e.g. ROW()/COLUMN()!
                                ((FuncVarPtg)nextPtg).FunctionIndex == FunctionMetadataRegistry.FUNCTION_INDEX_IF)
                            {
                                // this is an if statement without a false param (as opposed to MissingArgPtg as the false param)
                                i++;
                                stack.Push(BoolEval.FALSE);
                            }
                        }
                        continue;
                    }
                    if (attrPtg.IsSkip)
                    {
                        int dist = attrPtg.Data + 1;
                        i += CountTokensToBeSkipped(ptgs, i, dist);
                        if (stack.Peek() == MissingArgEval.instance)
                        {
                            stack.Pop();
                            stack.Push(BlankEval.instance);
                        }
                        continue;
                    }
                }
                if (ptg is ControlPtg)
                {
                    // skip Parentheses, Attr, etc
                    continue;
                }
                if (ptg is MemFuncPtg || ptg is MemAreaPtg)
                {
                    // can ignore, rest of Tokens for this expression are in OK RPN order
                    continue;
                }
                if (ptg is MemErrPtg)
                {
                    continue;
                }

                ValueEval opResult;
                if (ptg is OperationPtg)
                {
                    OperationPtg optg = (OperationPtg)ptg;

                    if (optg is UnionPtg)
                    {
                        continue;
                    }

                    int         numops = optg.NumberOfOperands;
                    ValueEval[] ops    = new ValueEval[numops];

                    // storing the ops in reverse order since they are popping
                    for (int j = numops - 1; j >= 0; j--)
                    {
                        ValueEval p = (ValueEval)stack.Pop();
                        ops[j] = p;
                    }
                    //				logDebug("Invoke " + operation + " (nAgs=" + numops + ")");
                    opResult = OperationEvaluatorFactory.Evaluate(optg, ops, ec);
                }
                else
                {
                    opResult = GetEvalForPtg(ptg, ec);
                }
                if (opResult == null)
                {
                    throw new Exception("Evaluation result must not be null");
                }
                //			logDebug("push " + opResult);
                stack.Push(opResult);
                if (dbgEvaluationOutputIndent > 0)
                {
                    EVAL_LOG.Log(POILogger.INFO, dbgIndentStr + "    = " + opResult.ToString());
                }
            }

            ValueEval value = ((ValueEval)stack.Pop());

            if (stack.Count != 0)
            {
                throw new InvalidOperationException("evaluation stack not empty");
            }
            ValueEval result = DereferenceResult(value, ec.RowIndex, ec.ColumnIndex);

            if (dbgEvaluationOutputIndent > 0)
            {
                EVAL_LOG.Log(POILogger.INFO, dbgIndentStr + "finshed eval of "
                             + new CellReference(ec.RowIndex, ec.ColumnIndex).FormatAsString()
                             + ": " + result.ToString());
                dbgEvaluationOutputIndent--;
                if (dbgEvaluationOutputIndent == 1)
                {
                    // this evaluation is done, reset indent to stop logging
                    dbgEvaluationOutputIndent = -1;
                }
            } // if
            return(result);
        }
Example #39
0
		public virtual object Visit (If ifStatement)
		{
			return null;
		}
Example #40
0
        private void Expand(Node node)
        {
            if (node is Expression)
            {
                var expr    = (Expression)node;
                var inlined = expr.Expand(Ctx);
                inlined.Stmts.ForEach(Stmts.Add);
                if (inlined.Result != null)
                {
                    Stmts.Add(inlined.Result);
                }
            }
            else if (node is Block)
            {
                var block = (Block)node;
                Stmts.Add(block.Expand(Ctx.SpinOff()));
            }
            else if (node is Break)
            {
                Stmts.Add(node);
            }
            else if (node is Continue)
            {
                Stmts.Add(node);
            }
            else if (node is Goto)
            {
                Stmts.Add(node);
            }
            else if (node is Label)
            {
                Stmts.Add(node);
            }
            else if (node is If)
            {
                var @if = (If)node;

                var test = @if.Test.Expand(Ctx);
                test.Stmts.ForEach(Stmts.Add);
                test.Result.AssertNotNull();

                var if_true  = @if.IfTrue.Expand(Ctx.SpinOff());
                var if_false = @if.IfFalse.Expand(Ctx.SpinOff());
                var expanded = new If(test.Result, if_true, if_false);
                Stmts.Add(expanded);
            }
            else if (node is Loop)
            {
                var loop = (Loop)node;

                var test = loop.Test.Expand(Ctx);
                test.Result.AssertNotNull();
                var init = loop.Init.Expand(Ctx.SpinOff());
                var iter = loop.Iter.Expand(Ctx.SpinOff());
                var body = loop.Body.Expand(Ctx.SpinOff());

                var prepend_test = loop.IsWhileDo && test.Stmts.IsNotEmpty();
                if (init.IsNotEmpty() && prepend_test)
                {
                    Stmts.Add(init); init = new Block();
                }
                if (prepend_test)
                {
                    test.Stmts.ForEach(Stmts.Add);
                }
                test.Stmts.ForEach(iter.Add);

                var xloop = new Loop(test.Result, body, loop.IsWhileDo)
                {
                    Init = init, Iter = iter
                };
                var cloned_locals = loop.Locals.Select(l => l.DeepClone());
                cloned_locals.ForEach(local => xloop.Locals.Add(local));

                Stmts.Add(xloop);
            }
            else if (node is Return)
            {
                var ret = (Return)node;
                (ret.Value == null).AssertEquiv(Ret == null);
                if (ret.Value != null)
                {
                    Expand(new Assign(Ret, ret.Value));
                }
                Stmts.Add(new Goto(RetLabel));
            }
            else if (node is Try || node is Clause || node is Throw ||
                     node is Using || node is Iter)
            {
                // todo. implement support for non-linear control flow
                // this is only possible when we fully implement decompilation of tries
                // until now I leave this marked as "to be implemented"
                throw AssertionHelper.Fail();
            }
            else
            {
                throw AssertionHelper.Fail();
            }
        }
 public override Statement VisitIf(If If)
 {
   throw new ApplicationException("unimplemented");
 }
Example #42
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            If t = target as If;

            var flowchart = (Flowchart)t.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            EditorGUILayout.PropertyField(variableProp);

            if (variableProp.objectReferenceValue == null)
            {
                serializedObject.ApplyModifiedProperties();
                return;
            }

            Variable selectedVariable = variableProp.objectReferenceValue as Variable;

            System.Type variableType = selectedVariable.GetType();

            List <GUIContent> operatorList = new List <GUIContent>();

            operatorList.Add(new GUIContent("=="));
            operatorList.Add(new GUIContent("!="));
            if (variableType == typeof(IntegerVariable) ||
                variableType == typeof(FloatVariable))
            {
                operatorList.Add(new GUIContent("<"));
                operatorList.Add(new GUIContent(">"));
                operatorList.Add(new GUIContent("<="));
                operatorList.Add(new GUIContent(">="));
            }

            compareOperatorProp.enumValueIndex = EditorGUILayout.Popup(new GUIContent("Compare", "The comparison operator to use when comparing values"),
                                                                       compareOperatorProp.enumValueIndex,
                                                                       operatorList.ToArray());

            if (variableType == typeof(BooleanVariable))
            {
                EditorGUILayout.PropertyField(booleanDataProp);
            }
            else if (variableType == typeof(IntegerVariable))
            {
                EditorGUILayout.PropertyField(integerDataProp);
            }
            else if (variableType == typeof(FloatVariable))
            {
                EditorGUILayout.PropertyField(floatDataProp);
            }
            else if (variableType == typeof(StringVariable))
            {
                EditorGUILayout.PropertyField(stringDataProp);
            }

            serializedObject.ApplyModifiedProperties();
        }
 protected internal override void TraverseIf(If @if)
 {
     Dispatch(@if);
 }
Example #44
0
 /// <summary>Handler for event command changes</summary>
 /// <param name="d">Source object</param>
 /// <param name="e">Event arguments</param>
 private static void EventCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     If.Real <FrameworkElement, EventCommand>(d, e.NewValue, (e2, c) => c.SetUIElement(e2));
     If.Real <FrameworkContentElement, EventCommand>(d, e.NewValue, (e2, c) => c.SetUIElement(e2));
 }
Example #45
0
 public void Visit(If ifs)
 {
     Indent();
     _sb.Append("if (");
     ifs.Guard.Accept(this);
     _sb.Append(")\r\n");
     ++_level;
     ifs.Body.Accept(this);
     --_level;
 }
Example #46
0
 public static Object Pipe(Object[] args)
 {
     return(Curry.MinTwo(StandardOperators.Pipe, args) ??
            If.Is <Function>(args, f => f.Invoke(new[] { args[1] })));
 }
Example #47
0
        private void Expand(Node node)
        {
            if (node is Expression)
            {
                var expr = (Expression)node;
                var inlined = expr.Expand(Ctx);
                inlined.Stmts.ForEach(Stmts.Add);
                if (inlined.Result != null) Stmts.Add(inlined.Result);
            }
            else if (node is Block)
            {
                var block = (Block)node;
                Stmts.Add(block.Expand(Ctx.SpinOff()));
            }
            else if (node is Break)
            {
                Stmts.Add(node);
            }
            else if (node is Continue)
            {
                Stmts.Add(node);
            }
            else if (node is Goto)
            {
                Stmts.Add(node);
            }
            else if (node is Label)
            {
                Stmts.Add(node);
            }
            else if (node is If)
            {
                var @if = (If)node;

                var test = @if.Test.Expand(Ctx);
                test.Stmts.ForEach(Stmts.Add);
                test.Result.AssertNotNull();

                var if_true = @if.IfTrue.Expand(Ctx.SpinOff());
                var if_false = @if.IfFalse.Expand(Ctx.SpinOff());
                var expanded = new If(test.Result, if_true, if_false);
                Stmts.Add(expanded);
            }
            else if (node is Loop)
            {
                var loop = (Loop)node;

                var test = loop.Test.Expand(Ctx);
                test.Result.AssertNotNull();
                var init = loop.Init.Expand(Ctx.SpinOff());
                var iter = loop.Iter.Expand(Ctx.SpinOff());
                var body = loop.Body.Expand(Ctx.SpinOff());

                var prepend_test = loop.IsWhileDo && test.Stmts.IsNotEmpty();
                if (init.IsNotEmpty() && prepend_test) { Stmts.Add(init); init = new Block(); }
                if (prepend_test) test.Stmts.ForEach(Stmts.Add);
                test.Stmts.ForEach(iter.Add);

                var xloop = new Loop(test.Result, body, loop.IsWhileDo){Init = init, Iter = iter};
                var cloned_locals = loop.Locals.Select(l => l.DeepClone());
                cloned_locals.ForEach(local => xloop.Locals.Add(local));

                Stmts.Add(xloop);
            }
            else if (node is Return)
            {
                var ret = (Return)node;
                (ret.Value == null).AssertEquiv(Ret == null);
                if (ret.Value != null) Expand(new Assign(Ret, ret.Value));
                Stmts.Add(new Goto(RetLabel));
            }
            else if (node is Try || node is Clause || node is Throw ||
                node is Using || node is Iter)
            {
                // todo. implement support for non-linear control flow
                // this is only possible when we fully implement decompilation of tries
                // until now I leave this marked as "to be implemented"
                throw AssertionHelper.Fail();
            }
            else
            {
                throw AssertionHelper.Fail();
            }
        }
Example #48
0
 public static Object Sub(Object[] args)
 {
     return(Curry.MinTwo(StandardOperators.Sub, args) ??
            If.Is <Double, Double>(args, (y, x) => x - y) ??
            If.Is <Double[, ], Double[, ]>(args, (y, x) => x.Subtract(y)));
 }
Example #49
0
void case_911()
#line 6090 "cs-parser.jay"
{
		yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
		
		if (yyVals[-2+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[-2+yyTop]));
		if (yyVals[0+yyTop] is EmptyStatement)
			Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
Example #50
0
 public static Object RDiv(Object[] args)
 {
     return(Curry.MinTwo(StandardOperators.RDiv, args) ??
            If.Is <Double, Double>(args, (y, x) => x / y) ??
            If.Is <Double, Double[, ]>(args, (y, x) => x.Divide(y)));
 }
 protected internal virtual void TraverseIf(If @if) { @if.Unsupported(); }
Example #52
0
 public static Object LDiv(Object[] args)
 {
     return(Curry.MinTwo(StandardOperators.LDiv, args) ??
            If.Is <Double, Double>(args, (y, x) => y / x) ??
            If.Is <Double[, ], Double>(args, (y, x) => y.Divide(x)));
 }
    public virtual Differences VisitIf(If if1, If if2){
      Differences differences = new Differences(if1, if2);
      if (if1 == null || if2 == null){
        if (if1 != if2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      If changes = (If)if2.Clone();
      If deletions = (If)if2.Clone();
      If insertions = (If)if2.Clone();

      Differences diff = this.VisitExpression(if1.Condition, if2.Condition);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Condition = diff.Changes as Expression;
      deletions.Condition = diff.Deletions as Expression;
      insertions.Condition = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.Condition && diff.Deletions == deletions.Condition && diff.Insertions == insertions.Condition);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitBlock(if1.FalseBlock, if2.FalseBlock);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.FalseBlock = diff.Changes as Block;
      deletions.FalseBlock = diff.Deletions as Block;
      insertions.FalseBlock = diff.Insertions as Block;
      Debug.Assert(diff.Changes == changes.FalseBlock && diff.Deletions == deletions.FalseBlock && diff.Insertions == insertions.FalseBlock);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitBlock(if1.TrueBlock, if2.TrueBlock);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.TrueBlock = diff.Changes as Block;
      deletions.TrueBlock = diff.Deletions as Block;
      insertions.TrueBlock = diff.Insertions as Block;
      Debug.Assert(diff.Changes == changes.TrueBlock && diff.Deletions == deletions.TrueBlock && diff.Insertions == insertions.TrueBlock);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Example #54
0
 public static Object Mod(Object[] args)
 {
     return(Curry.MinTwo(StandardOperators.Mod, args) ??
            If.Is <Double, Double>(args, (y, x) => x % y));
 }
		public override void EmitStatement (EmitContext ec)
		{
			var stmt = new If (condition, new StatementExpression (invoke), new StatementExpression (assign), loc);
			using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
				stmt.Emit (ec);
			}
		}
Example #56
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["textjoin"]    = new Textjoin();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value(CultureInfo.CurrentCulture);
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdevp"]          = new StdevP();
     Functions["stdev.s"]         = new StdevDotS();
     Functions["stdev.p"]         = new StdevDotP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mode"]            = new Mode();
     Functions["mode.sngl"]       = new ModeSngl();
     Functions["mround"]          = new Mround();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new RankEq();
     Functions["rank.avg"]        = new RankAvg();
     Functions["percentile"]      = new Percentile();
     Functions["percentile.inc"]  = new PercentileInc();
     Functions["percentrank"]     = new Percentrank();
     Functions["percentrank.inc"] = new PercentrankInc();
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["var"]             = new Var();
     Functions["var.s"]           = new VarDotS();
     Functions["varp"]            = new VarP();
     Functions["var.p"]           = new VarDotP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["maxifs"]  = new MaxIfs();
     Functions["minifs"]  = new MinIfs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["cumipmt"]    = new Cumipmt();
     Functions["cumprinc"]   = new Cumprinc();
     Functions["ddb"]        = new Ddb();
     Functions["effect"]     = new Effect();
     Functions["fvschedule"] = new FvSchedule();
     Functions["pduration"]  = new Pduration();
     Functions["rri"]        = new Rri();
     Functions["pmt"]        = new Pmt();
     Functions["ppmt"]       = new Ppmt();
     Functions["ipmt"]       = new Ipmt();
     Functions["ispmt"]      = new IsPmt();
     Functions["pv"]         = new Pv();
     Functions["fv"]         = new Fv();
     Functions["npv"]        = new Npv();
     Functions["rate"]       = new Rate();
     Functions["nper"]       = new Nper();
     Functions["nominal"]    = new Nominal();
     Functions["irr"]        = new Irr();
     Functions["mirr"]       = new Mirr();
     Functions["xirr"]       = new Xirr();
     Functions["sln"]        = new Sln();
     Functions["syd"]        = new Syd();
     Functions["xnpv"]       = new Xnpv();
     Functions["coupdays"]   = new Coupdays();
     Functions["coupdaysnc"] = new Coupdaysnc();
     Functions["coupdaybs"]  = new Coupdaybs();
     Functions["coupnum"]    = new Coupnum();
     Functions["coupncd"]    = new Coupncd();
     Functions["couppcd"]    = new Couppcd();
     Functions["price"]      = new Price();
     Functions["yield"]      = new Yield();
     Functions["duration"]   = new Duration();
     Functions["disc"]       = new Disc();
     //Engineering
     Functions["bitand"]       = new BitAnd();
     Functions["bitor"]        = new BitOr();
     Functions["bitxor"]       = new BitXor();
     Functions["bitlshift"]    = new BitLshift();
     Functions["bitrshift"]    = new BitRshift();
     Functions["convert"]      = new ConvertFunction();
     Functions["bin2dec"]      = new Bin2Dec();
     Functions["bin2hex"]      = new Bin2Hex();
     Functions["bin2oct"]      = new Bin2Oct();
     Functions["dec2bin"]      = new Dec2Bin();
     Functions["dec2hex"]      = new Dec2Hex();
     Functions["dec2oct"]      = new Dec2Oct();
     Functions["hex2bin"]      = new Hex2Bin();
     Functions["hex2dec"]      = new Hex2Dec();
     Functions["hex2oct"]      = new Hex2Oct();
     Functions["oct2bin"]      = new Oct2Bin();
     Functions["oct2dec"]      = new Oct2Dec();
     Functions["oct2hex"]      = new Oct2Hex();
     Functions["delta"]        = new Delta();
     Functions["erf"]          = new Erf();
     Functions["erf.precise"]  = new ErfPrecise();
     Functions["erfc"]         = new Erfc();
     Functions["erfc.precise"] = new ErfcPrecise();
     Functions["besseli"]      = new BesselI();
     Functions["besselj"]      = new BesselJ();
     Functions["besselk"]      = new BesselK();
     Functions["bessely"]      = new BesselY();
 }
Example #57
0
            internal static stmt Convert(Statement stmt) {
                stmt ast;

                if (stmt is FunctionDefinition)
                    ast = new FunctionDef((FunctionDefinition)stmt);
                else if (stmt is ReturnStatement)
                    ast = new Return((ReturnStatement)stmt);
                else if (stmt is AssignmentStatement)
                    ast = new Assign((AssignmentStatement)stmt);
                else if (stmt is AugmentedAssignStatement)
                    ast = new AugAssign((AugmentedAssignStatement)stmt);
                else if (stmt is DelStatement)
                    ast = new Delete((DelStatement)stmt);
                else if (stmt is PrintStatement)
                    ast = new Print((PrintStatement)stmt);
                else if (stmt is ExpressionStatement)
                    ast = new Expr((ExpressionStatement)stmt);
                else if (stmt is ForStatement)
                    ast = new For((ForStatement)stmt);
                else if (stmt is WhileStatement)
                    ast = new While((WhileStatement)stmt);
                else if (stmt is IfStatement)
                    ast = new If((IfStatement)stmt);
                else if (stmt is WithStatement)
                    ast = new With((WithStatement)stmt);
                else if (stmt is RaiseStatement)
                    ast = new Raise((RaiseStatement)stmt);
                else if (stmt is TryStatement)
                    ast = Convert((TryStatement)stmt);
                else if (stmt is AssertStatement)
                    ast = new Assert((AssertStatement)stmt);
                else if (stmt is ImportStatement)
                    ast = new Import((ImportStatement)stmt);
                else if (stmt is FromImportStatement)
                    ast = new ImportFrom((FromImportStatement)stmt);
                else if (stmt is ExecStatement)
                    ast = new Exec((ExecStatement)stmt);
                else if (stmt is GlobalStatement)
                    ast = new Global((GlobalStatement)stmt);
                else if (stmt is ClassDefinition)
                    ast = new ClassDef((ClassDefinition)stmt);
                else if (stmt is BreakStatement)
                    ast = new Break();
                else if (stmt is ContinueStatement)
                    ast = new Continue();
                else if (stmt is EmptyStatement)
                    ast = new Pass();
                else
                    throw new ArgumentTypeException("Unexpected statement type: " + stmt.GetType());

                ast.GetSourceLocation(stmt);
                return ast;
            }
 protected internal override Node TransformIf(If @if)
 {
     return Dispatch(@if);
 }
Example #59
0
 public virtual Statement VisitIf(If If, If changes, If deletions, If insertions){
   this.UpdateSourceContext(If, changes);
   if (If == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return If;
 }
 public virtual void Reverse(object sender, EventArgs e)
 {
     If.Walk(sender as IVertex, param => param != null);
 }