Beispiel #1
0
        public void Visit(WhenLiteralStatement statement)
        {
            CodeStatementCollection collection = new CodeStatementCollection();
            var arg = VisitChild(statement.Literal);

            var condition = new CodeConditionStatement();

            if (arg.Tag != null) //this is a null literal
            {
                condition.Condition = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("var"), CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null));
            }
            else
            {
                //always convert from object to type
                var leftArgs = new CodeDomArg()
                {
                    Scope = new ScopeData <Type> {
                        Type = typeof(object), CodeDomReference = new CodeTypeReference(typeof(object))
                    }, CodeExpression = new CodeVariableReferenceExpression("var")
                };
                var preCondition = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("var"), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
                condition.Condition = new CodeBinaryOperatorExpression(preCondition, CodeBinaryOperatorType.BooleanAnd, DoBoolean(leftArgs, arg, CodeBinaryOperatorType.IdentityEquality));
            }

            var then = VisitChild(statement.Then);

            condition.TrueStatements.Add(new CodeMethodReturnStatement(then.CodeExpression));
            _codeStack.Peek().Tag = then.Tag;
            _codeStack.Peek().ParentStatements.Add(condition);
        }
        public void Visit(WhenLiteralStatement statement)
        {
            CodeStatementCollection collection = new CodeStatementCollection();
            var arg = VisitChild(statement.Literal);

            var condition = new CodeConditionStatement();
            if (arg.Tag != null) //this is a null literal
            {
                condition.Condition = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("var"), CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null));
            }
            else
            {
                var preCondition = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("var"), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
                condition.Condition = new CodeBinaryOperatorExpression(preCondition, CodeBinaryOperatorType.BooleanAnd, new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("var"), "Equals", arg.CodeExpression));
            }

            var then = VisitChild(statement.Then);
            condition.TrueStatements.Add(new CodeMethodReturnStatement(then.CodeExpression));
            _codeStack.Peek().Tag = then.Tag;
            _codeStack.Peek().ParentStatements.Add(condition);
        }
        public void Visit(WhenLiteralStatement statement)
        {
            CodeStatementCollection collection = new CodeStatementCollection();
            var arg = VisitChild(statement.Literal);

            var condition = new CodeConditionStatement();

            if (arg.Tag != null) //this is a null literal
            {
                condition.Condition = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("var"), CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null));
            }
            else
            {
                var preCondition = new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("var"), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
                condition.Condition = new CodeBinaryOperatorExpression(preCondition, CodeBinaryOperatorType.BooleanAnd, new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("var"), "Equals", arg.CodeExpression));
            }

            var then = VisitChild(statement.Then);

            condition.TrueStatements.Add(new CodeMethodReturnStatement(then.CodeExpression));
            _codeStack.Peek().Tag = then.Tag;
            _codeStack.Peek().ParentStatements.Add(condition);
        }
Beispiel #4
0
 public void Visit(WhenLiteralStatement statement, CommonTree tree)
 {
     SetLine(statement, tree);
     Parent(tree).Children.Add(statement);
     VisitChildren(tree);
 }
Beispiel #5
0
 public void Visit(WhenLiteralStatement statement, CommonTree tree)
 {
     SetLine(statement, tree);
     Parent(tree).Children.Add(statement);
     VisitChildren(tree);
 }