static bool TypeMatches(FunctionDeclaration decl, TypeSpec ts, SwiftType st, TypeMapper typeMap) { switch (ts.Kind) { case TypeSpecKind.Named: return(TypeMatches(decl, ts as NamedTypeSpec, st, typeMap)); case TypeSpecKind.Closure: return(TypeMatches(decl, ts as ClosureTypeSpec, st, typeMap)); case TypeSpecKind.Tuple: return(TypeMatches(decl, ts as TupleTypeSpec, st, typeMap)); case TypeSpecKind.ProtocolList: return(TypeMatches(decl, ts as ProtocolListTypeSpec, st, typeMap)); default: throw new ArgumentOutOfRangeException(nameof(ts)); } }
static SwiftType ProjectAsNonReference(SwiftType a) { if (a.IsReference) { return(a.NonReferenceCloneOf()); } var bgt = a as SwiftBoundGenericType; if (bgt != null && bgt.BoundTypes.Count == 1) { var baseType = bgt.BaseType as SwiftClassType; if (baseType != null) { string name = baseType.ClassName.ToFullyQualifiedName(true); if (name == "Swift.UnsafePointer" || name == "Swift.UnsafeMutablePointer") { return(bgt.BoundTypes [0]); } } } return(a); }
public SwiftConstructorType(bool isAllocating, SwiftType unCurriedParameter, SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftType extensionOn = null) : base(isAllocating ? MemberType.Allocator : MemberType.Constructor, unCurriedParameter, parms, ret, isReference, canThrow, isAllocating ? Decomposer.kSwiftAllocatingConstructorName : Decomposer.kSwiftNonAllocatingConstructorName, extensionOn) { }
protected override bool LLEquals(SwiftType other) { var ucf = other as SwiftUncurriedFunctionType; return(ucf != null && ucf.UncurriedParameter.Equals(UncurriedParameter) && base.LLEquals(other)); }
protected SwiftUncurriedFunctionType(MemberType memberType, SwiftType unCurriedParameter, SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftName name = null, SwiftType extensionOn = null) : base(parms, ret, isReference, canThrow, name, extensionOn) { // oddly enough, this is allowed to be null UncurriedParameter = unCurriedParameter; this.memberType = memberType; }
public SwiftUncurriedFunctionType(SwiftType unCurriedParameter, SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftName name = null, SwiftType extensionOn = null) : this(MemberType.UncurriedFunction, unCurriedParameter, parms, ret, isReference, canThrow, name, extensionOn) { }
protected override bool LLEquals(SwiftType other) { var meta = other as SwiftMetaClassType; return(meta != null && Class.Equals(meta.Class)); }
protected override bool LLEquals(SwiftType other) { SwiftBuiltInType sb = other as SwiftBuiltInType; return(sb != null && BuiltInType == sb.BuiltInType); }
public SwiftInitializerType(InitializerType initType, SwiftType ret, SwiftClassType owner, SwiftName name) : base(SwiftTupleType.Empty, ret, false, false, name, null) { Owner = Ex.ThrowOnNull(owner, nameof(owner)); InitializerType = initType; }
public SwiftAddressorType(AddressorType addressor, SwiftType ret, bool isReference, SwiftName name = null) : base(SwiftTupleType.Empty, ret, isReference, false, name, null) { AddressorType = addressor; }
public SwiftCFunctionType(SwiftType parms, SwiftType ret, bool isReference, SwiftName name = null) : base(parms, ret, isReference, false, name, null) { }
public SwiftBaseFunctionType(SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftName name = null, SwiftType extensionOn = null) : base(CoreCompoundType.Function, isReference, name) { Parameters = Ex.ThrowOnNull(parms, nameof(parms)); ReturnType = Ex.ThrowOnNull(ret, nameof(ret)); GenericArguments = new List <GenericArgument> (); CanThrow = canThrow; ExtensionOn = extensionOn; }
protected virtual bool LLEquals(SwiftType other) { return(true); }
public SwiftUnboundGenericType(SwiftType dependentType, List <GenericArgument> parms, bool isReference, SwiftName name = null) : base(CoreCompoundType.UnboundGeneric, isReference, name) { DependentType = Ex.ThrowOnNull(dependentType, nameof(dependentType)); Arguments = Ex.ThrowOnNull(parms, nameof(parms)); }
public SwiftPropertyType(SwiftType unCurriedParameter, PropertyType propType, SwiftName propName, SwiftName privateName, SwiftType ofType, bool isStatic, bool isReference, SwiftType extensionOn = null) : base(unCurriedParameter, (propType == PropertyType.Setter || propType == PropertyType.Materializer) ? ofType : SwiftTupleType.Empty, (propType == PropertyType.Getter) ? ofType : SwiftTupleType.Empty, isReference, false, propName, extensionOn) { PropertyType = propType; PrivateName = privateName; OfType = Ex.ThrowOnNull(ofType, "ofType"); IsSubscript = false; IsStatic = isStatic; }
public SwiftFunctionType(SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftName name = null, SwiftType extensionOn = null, bool isEscaping = true) : base(parms, ret, isReference, canThrow, name, extensionOn) { IsEscaping = isEscaping; }
public SwiftPropertyType(SwiftType unCurriedParameter, PropertyType propType, SwiftName propName, SwiftName privateName, SwiftFunctionType accessor, bool isStatic, bool isReference, SwiftType extensionOn = null) : base(unCurriedParameter, accessor.Parameters, accessor.ReturnType, isReference, false, propName, extensionOn) { PropertyType = propType; PrivateName = privateName; OfType = accessor; IsSubscript = true; IsStatic = isStatic; }
public SwiftCFunctionPointerType(SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftName name = null) : base(parms, ret, isReference, canThrow, name, null) { }
protected override bool LLEquals(SwiftType other) { var sct = other as SwiftClassType; return(sct != null && ClassName.Equals(sct.ClassName)); }
public SwiftStaticFunctionType(SwiftType parms, SwiftType ret, bool isReference, bool canThrow, SwiftClassType ofClass, SwiftName name = null, SwiftType extensionOn = null) : base(parms, ret, isReference, canThrow, name, extensionOn) { OfClass = ofClass; }
protected override bool LLEquals(SwiftType other) { var meta = other as SwiftExistentialMetaType; return(meta != null && Protocol.Equals(meta.Protocol)); }
public CSProperty CompileProperty(string propertyName, CSUsingPackages packs, SwiftType swiftPropertyType, bool hasGetter, bool hasSetter, CSMethodKind methodKind) { propertyName = typeMap.SanitizeIdentifier(propertyName); NetTypeBundle propertyType = typeMap.MapType(swiftPropertyType, false); if (!(swiftPropertyType is SwiftGenericArgReferenceType)) { AddUsingBlock(packs, propertyType); } ICodeElement [] uselessLine = new ICodeElement [] { CSReturn.ReturnLine(new CSIdentifier("useless")) }; CSCodeBlock getterBlock = null; if (hasGetter) { getterBlock = new CSCodeBlock(uselessLine); } CSCodeBlock setterBlock = null; if (hasSetter) { setterBlock = new CSCodeBlock(uselessLine); } CSProperty theProp = new CSProperty(propertyType.ToCSType(packs), methodKind, new CSIdentifier(propertyName), CSVisibility.Public, getterBlock, CSVisibility.Public, setterBlock); if (getterBlock != null) { getterBlock.Clear(); } if (setterBlock != null) { setterBlock.Clear(); } return(theProp); }