static bool TypeMatches(FunctionDeclaration decl, NamedTypeSpec ts, SwiftBuiltInType st, TypeMapper typeMap) { if (st == null) { return(false); } if (ts.IsInOut != st.IsReference) { return(false); } switch (st.BuiltInType) { case CoreBuiltInType.Bool: return(ts.Name == "Swift.Bool"); case CoreBuiltInType.Double: return(ts.Name == "Swift.Double"); case CoreBuiltInType.Float: return(ts.Name == "Swift.Float"); case CoreBuiltInType.Int: return(ts.Name == "Swift.Int"); case CoreBuiltInType.UInt: return(ts.Name == "Swift.UInt"); default: throw new ArgumentOutOfRangeException("st"); } }
static void BuiltInTypeIsA(SwiftType t, CoreBuiltInType ct) { SwiftBuiltInType bit = t as SwiftBuiltInType; if (bit == null) { Assert.Fail("Not a SwiftBuiltInType: " + t.GetType().Name); } Assert.AreEqual(ct, bit.BuiltInType, "same built in type"); }
public void DecomposeVariableInitializer() { var func = "_$s17unitHelpFrawework5MontyC3valSbvpfi"; var tlf = Decomposer.Decompose(func, false) as TLFunction; Assert.IsNotNull(tlf, "tlf"); SwiftInitializerType sit = tlf.Signature as SwiftInitializerType; Assert.IsNotNull(sit, "sit"); Assert.AreEqual("val", sit.Name.Name, "name equal"); SwiftBuiltInType bit = sit.ReturnType as SwiftBuiltInType; Assert.IsNotNull(bit, "bit"); Assert.AreEqual(CoreBuiltInType.Bool, bit.BuiltInType); }
void TestFunc3XXXReturningVoid(string funcmangle, CoreBuiltInType csv) { var func = Decomposer.Decompose(funcmangle, true) as TLFunction; Assert.IsNotNull(func, "func"); Assert.AreEqual("foo", func.Module.Name, "module"); Assert.IsNotNull(func.Signature, "signature"); Assert.IsTrue(func.Signature.IsVoid, "IsVoid"); var parms = func.Signature.Parameters; Assert.IsNotNull(parms, "parms"); var tt = parms as SwiftTupleType; Assert.IsNotNull(tt, "tt"); Assert.AreEqual(3, tt.Contents.Count, "tuple size"); foreach (SwiftType st in tt.Contents) { SwiftBuiltInType scalar = st as SwiftBuiltInType; Assert.IsNotNull(scalar, "scalar"); Assert.AreEqual(csv, scalar.BuiltInType, "scalar type"); } }
protected override bool LLEquals(SwiftType other) { SwiftBuiltInType sb = other as SwiftBuiltInType; return(sb != null && BuiltInType == sb.BuiltInType); }