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); }
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); } }
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)); } }
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); }
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"); }
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"); }
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); }
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"); }
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"); }