Exemplo n.º 1
0
        public override IAssignableExpression VisitUncheckedExpression(IUncheckedExpression expr,
                                                                       IList <IStatement> body)
        {
            var uncheckedBlock = new UncheckedBlock();
            var assignable     = ToAssignableExpr(expr.Operand, uncheckedBlock.Body);

            if (assignable is IConstantValueExpression)
            {
                return(assignable);
            }

            var newRef = new VariableReference {
                Identifier = _nameGen.GetNextVariableName()
            };

            body.Add(
                new VariableDeclaration
            {
                Reference = newRef,
                Type      = expr.Type().GetName()
            });

            uncheckedBlock.Body.Add(
                new Assignment
            {
                Reference  = newRef,
                Expression = assignable
            });

            body.Add(uncheckedBlock);

            return(new ReferenceExpression {
                Reference = newRef
            });
        }
Exemplo n.º 2
0
        public void Equality_Default()
        {
            var a = new UncheckedBlock();
            var b = new UncheckedBlock();

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
Exemplo n.º 3
0
        public void ChildrenIdentity()
        {
            var sut = new UncheckedBlock {
                Body = { new BreakStatement() }
            };

            AssertChildren(sut, sut.Body.First());
        }
Exemplo n.º 4
0
        public void SettingValues()
        {
            var sut = new UncheckedBlock {
                Body = { new BreakStatement() }
            };

            Assert.AreEqual(Lists.NewList(new BreakStatement()), sut.Body);
        }
Exemplo n.º 5
0
        public void DefaultValues()
        {
            var sut = new UncheckedBlock();

            Assert.AreEqual(Lists.NewList <IStatement>(), sut.Body);
            Assert.AreNotEqual(0, sut.GetHashCode());
            Assert.AreNotEqual(1, sut.GetHashCode());
        }
Exemplo n.º 6
0
        public void Equality_DifferentBody()
        {
            var a = new UncheckedBlock();

            a.Body.Add(new BreakStatement());
            var b = new UncheckedBlock();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
Exemplo n.º 7
0
        public void Equality_ReallyTheSame()
        {
            var a = new UncheckedBlock();

            a.Body.Add(new BreakStatement());
            var b = new UncheckedBlock();

            b.Body.Add(new BreakStatement());
            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
Exemplo n.º 8
0
        public override void VisitUncheckedStatement(IUncheckedStatement block, IList <IStatement> body)
        {
            AddIf(block, CompletionCase.EmptyCompletionBefore, body);

            var uncheckedBlock = new UncheckedBlock();

            AddIf(block, CompletionCase.InBody, uncheckedBlock.Body);
            block.Body.Accept(this, uncheckedBlock.Body);
            body.Add(uncheckedBlock);

            AddIf(block, CompletionCase.EmptyCompletionAfter, body);
        }
Exemplo n.º 9
0
        public void UncheckedBlock()
        {
            var sst = new UncheckedBlock
            {
                Body = { new BreakStatement() }
            };

            AssertPrint(
                sst,
                "unchecked",
                "{",
                "    break;",
                "}");
        }
Exemplo n.º 10
0
        public void VisitorIsImplemented()
        {
            var sut = new UncheckedBlock();

            sut.Accept(23).Verify(v => v.Visit(sut, 23));
        }