示例#1
0
 protected UnionPartBase([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                         bool hasPublicNestedTypes, bool isSingleCaseUnion) : base(declaration, cacheBuilder)
 {
     HasPublicNestedTypes       = hasPublicNestedTypes;
     RepresentationAccessRights = GetRepresentationAccessRights(declaration);
     IsSingleCaseUnion          = isSingleCaseUnion;
 }
示例#2
0
        public static bool HasAttribute([NotNull] this IFSharpTypeDeclaration typeDeclaration, [NotNull] string shortName)
        {
            foreach (var attr in typeDeclaration.Attributes)
            {
                if (attr.ShortNameEquals(shortName))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        public static INestedModuleDeclaration GetAssociatedModuleDeclaration(
            [NotNull] this IFSharpTypeDeclaration typeDeclaration)
        {
            if (!(typeDeclaration.Parent is IModuleLikeDeclaration parentModule))
            {
                return(null);
            }

            foreach (var moduleDeclaration in parentModule.Children <INestedModuleDeclaration>())
            {
                if (moduleDeclaration.GetAssociatedTypeDeclaration(out _) == typeDeclaration)
                {
                    return(moduleDeclaration);
                }
            }

            return(null);
        }
示例#4
0
        protected FSharpFunctionBase([NotNull] ITypeMemberDeclaration declaration,
                                     [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
            : base(declaration, mfv)
        {
            var mfvTypeParams        = mfv.GenericParameters;
            var typeParams           = new FrugalLocalList <ITypeParameter>();
            var outerTypeParamsCount = typeDeclaration?.TypeParameters.Count ?? 0;

            for (var i = outerTypeParamsCount; i < mfvTypeParams.Count; i++)
            {
                typeParams.Add(new FSharpTypeParameterOfMethod(this, mfvTypeParams[i].DisplayName, i - outerTypeParamsCount));
            }
            TypeParameters = typeParams.ToList();

            ReturnType = mfv.IsConstructor || mfv.ReturnParameter.Type.IsUnit
        ? Module.GetPredefinedType().Void
        : FSharpTypesUtil.GetType(mfv.ReturnParameter.Type, declaration, TypeParameters, Module, true) ??
                         TypeFactory.CreateUnknownType(Module);

            var methodParams   = new FrugalLocalList <IParameter>();
            var mfvParamGroups = mfv.CurriedParameterGroups;

            if (mfvParamGroups.Count == 1 && mfvParamGroups[0].Count == 1 && mfvParamGroups[0][0].Type.IsUnit)
            {
                Parameters = EmptyList <IParameter> .InstanceList;
                return;
            }

            foreach (var paramsGroup in mfv.CurriedParameterGroups)
            {
                foreach (var param in paramsGroup)
                {
                    var paramType = param.Type;
                    var paramName = param.DisplayName;
                    methodParams.Add(new FSharpMethodParameter(param, this, methodParams.Count,
                                                               FSharpTypesUtil.GetParameterKind(param),
                                                               FSharpTypesUtil.GetType(paramType, declaration, TypeParameters, Module, false),
                                                               paramName.IsEmpty() ? SharedImplUtil.MISSING_DECLARATION_NAME : paramName));
                }
            }
            Parameters = methodParams.ToList();
        }
示例#5
0
        private Part CreateObjectTypePart(IFSharpTypeDeclaration decl, bool isExtension)
        {
            switch (decl.TypePartKind)
            {
            case PartKind.Class:
                return(isExtension ? (Part) new ClassExtensionPart(decl, Builder) : new ClassPart(decl, Builder));

            case PartKind.Struct:
                return(isExtension ? (Part) new StructExtensionPart(decl, Builder) : new StructPart(decl, Builder));

            case PartKind.Interface:
                return(new InterfacePart(decl, Builder));

            case PartKind.Enum:
                return(new EnumPart(decl, Builder));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#6
0
 protected RecordPartBase([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
     CliMutable = declaration.HasAttribute("CLIMutable");
     RepresentationAccessRights = declaration.GetRepresentationAccessRights();
 }
示例#7
0
 public InterfacePart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
 }
示例#8
0
 public HiddenTypePart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
 }
 internal FSharpConversionOperator([NotNull] ITypeMemberDeclaration declaration,
                                   [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration,
                                   bool isExplicitCast)
     : base(declaration, mfv, typeDeclaration)
 {
     myIsExplicitCast = isExplicitCast;
 }
 protected SimpleTypePartBase([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
 }
示例#11
0
 public ExceptionPart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
 }
示例#12
0
 protected TypeAbbreviationOrDeclarationPartBase([NotNull] IFSharpTypeDeclaration declaration,
                                                 [NotNull] ICacheBuilder cacheBuilder) : base(declaration, cacheBuilder, false, true)
 {
 }
示例#13
0
 public FSharpConstructor([NotNull] ITypeMemberDeclaration declaration,
                          [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
     : base(declaration, mfv, typeDeclaration)
 {
 }
示例#14
0
 protected FSharpConstructorBase([NotNull] ITypeMemberDeclaration declaration,
                                 [NotNull] FSharpMemberOrFunctionOrValue mfv, IFSharpTypeDeclaration typeDeclaration)
     : base(declaration, mfv, typeDeclaration)
 {
 }
示例#15
0
 public UnionPart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder, bool hasNestedTypes,
                  bool isSingleCase) : base(declaration, cacheBuilder, hasNestedTypes, isSingleCase)
 {
 }
示例#16
0
 public StructUnionPart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                        bool isSingleCase) : base(declaration, cacheBuilder, false, isSingleCase)
 {
 }
示例#17
0
 public RecordPart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
     HasCliMutable = declaration.Attributes.Any(attr => attr.ShortNameEquals("CLIMutable")); // todo: resolve
 }
示例#18
0
 internal FSharpOperator([NotNull] ITypeMemberDeclaration declaration,
                         [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
     : base(declaration, mfv, typeDeclaration)
 {
 }
示例#19
0
 protected RecordPartBase([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder) =>
 protected FSharpMethodBase([NotNull] ITypeMemberDeclaration declaration,
                            [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
     : base(declaration, mfv, typeDeclaration)
 {
     ShortName = mfv.GetMemberCompiledName();
 }
示例#21
0
 private void ProcessHiddenTypeDeclaration(IFSharpTypeDeclaration decl) =>
 ProcessPart(new HiddenTypePart(decl, Builder));
示例#22
0
 public StructExtensionPart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder)
     : base(declaration, cacheBuilder)
 {
 }
示例#23
0
 public StructUnionPart([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                        bool hasPublicNestedTypes) : base(declaration, cacheBuilder, hasPublicNestedTypes)
 {
 }
示例#24
0
 public StructTypeAbbreviationOrDeclarationPart([NotNull] IFSharpTypeDeclaration declaration,
                                                [NotNull] ICacheBuilder cacheBuilder) : base(declaration, cacheBuilder)
 {
 }
示例#25
0
 protected UnionPartBase([NotNull] IFSharpTypeDeclaration declaration, [NotNull] ICacheBuilder cacheBuilder,
                         bool hasPublicNestedTypes) : base(declaration, cacheBuilder) =>
示例#26
0
 public ModuleFunction([NotNull] ITypeMemberDeclaration declaration, [NotNull] FSharpMemberOrFunctionOrValue mfv,
                       [CanBeNull] IFSharpTypeDeclaration typeDeclaration) : base(declaration, mfv, typeDeclaration)
 {
 }
示例#27
0
 protected FSharpMethodBase([NotNull] ITypeMemberDeclaration declaration,
                            [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
     : base(declaration, mfv, typeDeclaration)
 {
 }