public SerializedType VisitRangeType(RangeType rangeType) { var low = rangeType.Low.Accept(ceval).ToInt64(); var hi = rangeType.High.Accept(ceval).ToInt64(); var delta = hi - low + 1; if (delta < 0) { throw new NotImplementedException("Range overflow."); } if (delta < 256) { return(low < 0 ? PrimitiveType_v1.SChar8() : PrimitiveType_v1.UChar8()); } if (delta < 65536) { return(low <= 0 ? PrimitiveType_v1.Int16() : PrimitiveType_v1.UInt16()); } if (delta < (1L << 32)) { return(low <= 0 ? PrimitiveType_v1.Int32() : PrimitiveType_v1.UInt32()); } return(PrimitiveType_v1.Int64()); }
public void SvArm32Ps_Load_IntArgs() { var ssig = new SerializedSignature { Arguments = new Argument_v1[] { new Argument_v1 { Name = "dc", Type = PrimitiveType_v1.Int16(), }, new Argument_v1 { Name = "b1", Type = PrimitiveType_v1.SChar8(), }, new Argument_v1 { Name = "w2", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "h3", Type = PrimitiveType_v1.Int16(), }, new Argument_v1 { Name = "b4", Type = PrimitiveType_v1.UChar8(), }, new Argument_v1 { Name = "w5", Type = PrimitiveType_v1.Int32(), }, new Argument_v1 { Name = "foo", Type = PrimitiveType_v1.Int32() } } }; Given_ProcedureSerializer(); mr.ReplayAll(); var sig = ser.Deserialize(ssig, arch.CreateFrame()); var args = sig.Parameters; Assert.AreEqual("r0", args[0].Storage.ToString()); Assert.AreEqual("r1", args[1].Storage.ToString()); Assert.AreEqual("r2", args[2].Storage.ToString()); Assert.AreEqual("r3", args[3].Storage.ToString()); Assert.AreEqual("Stack +0000", args[4].Storage.ToString()); Assert.AreEqual("Stack +0004", args[5].Storage.ToString()); Assert.AreEqual("Stack +0008", args[6].Storage.ToString()); }