public void EqbTypeReference()
 {
     var a = new Identifier("a", new TypeReference("INT", PrimitiveType.Int32), new TemporaryStorage("a", 43, PrimitiveType.Int32));
     var b = new Identifier("b", new TypeReference("INT", PrimitiveType.Int32), new TemporaryStorage("b", 44, PrimitiveType.Int32));
     a.Accept(eqb);
     b.Accept(eqb);
     Assert.AreSame(a.TypeVariable.Class, b.TypeVariable.Class);
 }
Esempio n. 2
0
        public override void Accept(SyntaxVisitor visitor)
        {
            if (visitor.VisitNodeStatementSyntax(this, VisitKind.Enter))
            {
                Identifier.Accept(visitor);
                Attributes?.Accept(visitor);
                TerminatingSemicolonToken.Accept(visitor);

                visitor.VisitNodeStatementSyntax(this, VisitKind.Leave);
            }
        }
Esempio n. 3
0
        public Result VisitIdentifier(Identifier id)
        {
            var ev = id.Accept(eval);

            if (!MayReplace(ev))
            {
                return new Result {
                           Value = ctx.GetValue(id), PropagatedExpression = id
                }
            }
            ;
            else
            {
                return(SimplifyExpression(ev));
            }
        }
Esempio n. 4
0
        public void DtbUnion()
        {
            Identifier id1 = new Identifier("foo", PrimitiveType.Int32, null);          // note signed: can't be unified with real
            Identifier id2 = new Identifier("bar", PrimitiveType.Real32, null);

            id1.Accept(eqb);
            id2.Accept(eqb);
            store.MergeClasses(id1.TypeVariable, id2.TypeVariable);

            dtb.DataTypeTrait(id1.TypeVariable, id1.DataType);
            dtb.DataTypeTrait(id2.TypeVariable, id2.DataType);
            dtb.BuildEquivalenceClassDataTypes();

            UnionType u = (UnionType)id1.TypeVariable.Class.DataType;

            Assert.AreEqual(2, u.Alternatives.Count);
        }
Esempio n. 5
0
        public void DtbEqClass()
        {
            Identifier id1 = new Identifier("foo", PrimitiveType.Word32, null);
            Identifier id2 = new Identifier("bar", PrimitiveType.Real32, null);

            id1.Accept(eqb);
            id2.Accept(eqb);
            store.MergeClasses(id1.TypeVariable, id2.TypeVariable);

            dtb.DataTypeTrait(id1.TypeVariable, id1.DataType);
            dtb.DataTypeTrait(id2.TypeVariable, id2.DataType);
            dtb.BuildEquivalenceClassDataTypes();

            IList <EquivalenceClass> used = store.UsedEquivalenceClasses;

            Assert.AreEqual(1, used.Count);
            Verify("Typing/DtbEqClass.txt");
        }
Esempio n. 6
0
        public void DtbEqClassType()
        {
            Identifier id1 = new Identifier("foo", PrimitiveType.Word32, null);
            Identifier id2 = new Identifier("bar", PrimitiveType.Real32, null);

            id1.Accept(eqb);
            id2.Accept(eqb);
            store.MergeClasses(id1.TypeVariable, id2.TypeVariable);

            dtb.DataTypeTrait(id1.TypeVariable, id1.DataType);
            dtb.DataTypeTrait(id2.TypeVariable, id2.DataType);
            dtb.BuildEquivalenceClassDataTypes();

            EquivalenceClass e = id1.TypeVariable.Class;
            PrimitiveType    p = (PrimitiveType)e.DataType;

            Assert.AreEqual(PrimitiveType.Real32, p);

            Verify("Typing/DtbEqClassType.txt");
        }
Esempio n. 7
0
        public void DtbUnion()
        {
            Identifier id1 = new Identifier("foo", PrimitiveType.Int32, null);		// note signed: can't be unified with real
            Identifier id2 = new Identifier("bar", PrimitiveType.Real32, null);
            id1.Accept(eqb);
            id2.Accept(eqb);
            store.MergeClasses(id1.TypeVariable, id2.TypeVariable);

            dtb.DataTypeTrait(id1.TypeVariable, id1.DataType);
            dtb.DataTypeTrait(id2.TypeVariable, id2.DataType);
            dtb.BuildEquivalenceClassDataTypes();

            UnionType u = (UnionType) id1.TypeVariable.Class.DataType;
            Assert.AreEqual(2, u.Alternatives.Count);
        }
Esempio n. 8
0
        public void DtbEqClassType()
        {
            Identifier id1 = new Identifier("foo", PrimitiveType.Word32, null);
            Identifier id2 = new Identifier("bar", PrimitiveType.Real32, null);
            id1.Accept(eqb);
            id2.Accept(eqb);
            store.MergeClasses(id1.TypeVariable, id2.TypeVariable);

            dtb.DataTypeTrait(id1.TypeVariable, id1.DataType);
            dtb.DataTypeTrait(id2.TypeVariable, id2.DataType);
            dtb.BuildEquivalenceClassDataTypes();

            EquivalenceClass e = id1.TypeVariable.Class;
            PrimitiveType p = (PrimitiveType) e.DataType;
            Assert.AreEqual(PrimitiveType.Real32, p);

            Verify("Typing/DtbEqClassType.txt");
        }
Esempio n. 9
0
        public void DtbEqClass()
        {
            Identifier id1 = new Identifier("foo", PrimitiveType.Word32, null);
            Identifier id2 = new Identifier("bar", PrimitiveType.Real32, null);
            id1.Accept(eqb);
            id2.Accept(eqb);
            store.MergeClasses(id1.TypeVariable, id2.TypeVariable);

            dtb.DataTypeTrait(id1.TypeVariable, id1.DataType);
            dtb.DataTypeTrait(id2.TypeVariable, id2.DataType);
            dtb.BuildEquivalenceClassDataTypes();

            IList<EquivalenceClass> used = store.UsedEquivalenceClasses;
            Assert.AreEqual(1, used.Count);
            Verify("Typing/DtbEqClass.txt");
        }
Esempio n. 10
0
 public void EqbTypeReference()
 {
     var a = new Identifier("a", new TypeReference("INT", PrimitiveType.Int32), new TemporaryStorage("a", 43, PrimitiveType.Int32));
     var b = new Identifier("b", new TypeReference("INT", PrimitiveType.Int32), new TemporaryStorage("b", 44, PrimitiveType.Int32));
     a.Accept(eqb);
     b.Accept(eqb);
     Assert.AreSame(a.TypeVariable.Class, b.TypeVariable.Class);
 }