internal FSharpFieldProperty([NotNull] ITypeMemberDeclaration declaration, [NotNull] FSharpField field)
     : base(declaration)
 {
     Field      = field;
     ReturnType = FSharpTypesUtil.GetType(field.FieldType, declaration, Module) ??
                  TypeFactory.CreateUnknownType(Module);
 }
Exemplo n.º 2
0
 public FSharpLiteral([NotNull] ITypeMemberDeclaration declaration, FSharpMemberOrFunctionOrValue mfv) :
     base(declaration)
 {
     Type = FSharpTypesUtil.GetType(mfv.FullType, declaration, Module) ??
            TypeFactory.CreateUnknownType(Module);
     ConstantValue = new ConstantValue(mfv.LiteralValue.Value, Type);
 }
 public FSharpCliEvent([NotNull] ITypeMemberDeclaration declaration, FSharpMemberOrFunctionOrValue mfv)
     : base(declaration, mfv)
 {
     try
     {
         ReturnType = FSharpTypesUtil.GetType(mfv.FullType, declaration, Module) ??
                      TypeFactory.CreateUnknownType(Module);
     }
     catch (ErrorLogger.ReportedError e)
     {
         ReturnType = TypeFactory.CreateUnknownType(Module);
     }
 }
Exemplo n.º 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();
        }
Exemplo n.º 5
0
        protected FSharpPropertyBase([NotNull] ITypeMemberDeclaration declaration,
                                     [NotNull] FSharpMemberOrFunctionOrValue mfv)
            : base(declaration, mfv)
        {
            var property =
                mfv.IsModuleValueOrMember
          ? mfv.DeclaringEntity?.Value.MembersFunctionsAndValues.FirstOrDefault(
                    m => m.IsProperty && m.DisplayName == mfv.DisplayName) ?? mfv
          : mfv;

            IsReadable = property.HasGetterMethod || property.IsPropertyGetterMethod ||
                         property.IsModuleValueOrMember && !property.IsMember;
            IsWritable = property.IsMutable || property.HasSetterMethod || property.IsPropertySetterMethod;
            var returnType = property.IsPropertySetterMethod
        ? property.CurriedParameterGroups[0][0].Type
        : property.ReturnParameter.Type;

            ReturnType = FSharpTypesUtil.GetType(returnType, declaration, Module) ??
                         TypeFactory.CreateUnknownType(Module);
        }
 private AttributeValue GetAttributeValue(Tuple <FSharpType, object> param) =>
 new AttributeValue(new ConstantValue(param.Item2,
                                      FSharpTypesUtil.GetType(param.Item1, EmptyList <ITypeParameter> .Instance, myModule)));
Exemplo n.º 7
0
 public FSharpValField([NotNull] ValField declaration, [NotNull] FSharpField field) : base(declaration)
 {
     Field = field;
     Type  = FSharpTypesUtil.GetType(field.FieldType, declaration, Module) ??
             TypeFactory.CreateUnknownType(Module);
 }