Пример #1
0
 public Expression MaybeConvert(DataType?type, Expression e)
 {
     if (type != null)
     {
         return(m.Convert(e, e.DataType, type));
     }
     else
     {
         return(e);
     }
 }
Пример #2
0
 public DataType DataTypeTrait(Expression exp, DataType?dt)
 {
     if (dt == PrimitiveType.SegmentSelector)
     {
         var seg = factory.CreateStructureType(null, 0);
         seg.IsSegment = true;
         var ptr = factory.CreatePointer(seg, dt.BitSize);
         dt = ptr;
     }
     return(MergeIntoDataType(exp, dt));
 }
Пример #3
0
 public void Generate(ICallingConventionEmitter ccr, DataType?dtRet, DataType?dtThis, List <DataType> dtParams)
 {
     ccr.LowLevelDetails(8, 0);
     foreach (var dt in dtParams)
     {
         ccr.StackParam(dt);
     }
     if (dtRet != null)
     {
         ccr.RegReturn(arch.GetRegister("r12") !);
     }
 }
Пример #4
0
 public void Generate(ICallingConventionEmitter ccr, DataType?dtRet, DataType?dtThis, List <DataType> dtParams)
 {
     ccr.LowLevelDetails(4, 4);
     foreach (var dtParam in dtParams)
     {
         ccr.StackParam(dtParam);
     }
     if (dtRet != null)
     {
         ccr.RegReturn(regRet);
     }
 }
Пример #5
0
        public Tensor variable(Array array, DataType?dtype = null, string name = null)
        {
            // https://github.com/fchollet/keras/blob/f65a56fb65062c8d14d215c9f4b1015b97cc5bf3/keras/backend/cntk_backend.py#L133

            NDArrayView v = In(array, dtype);

            var p = new Parameter(v, name: _prepare_name(name, "variable"));

            Tensor t = Out(p);

            return(t);
        }
Пример #6
0
        protected virtual DataTypeInfo?GetDataType(string?typeName, DataType?dataType, GetSchemaOptions options)
        {
            if (typeName == null)
            {
                return(null);
            }

            return
                (options.PreferProviderSpecificTypes
                                ? (ProviderSpecificDataTypesDic.TryGetValue(typeName, out var dt) ? dt : DataTypesDic.TryGetValue(typeName, out dt) ? dt : null)
                                : (DataTypesDic.TryGetValue(typeName, out dt)     ? dt : ProviderSpecificDataTypesDic.TryGetValue(typeName, out dt) ? dt : null));
        }
Пример #7
0
 public override bool Equals(DataType?other)
 {
     if (other is null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other is AnyType otherType &&
            ReferenceCapability == otherType.ReferenceCapability);
 }
 public override bool Equals(DataType?other)
 {
     if (other is null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other is IntegerConstantType otherType &&
            Value == otherType.Value);
 }
Пример #9
0
 public void Generate(ICallingConventionEmitter ccr, DataType?dtRet, DataType?dtThis, List <DataType> dtParams)
 {
     //$BUG: this is all just to get the ELF loader up and running.
     ccr.LowLevelDetails(4, 0);
     if (dtRet != null && !(dtRet is VoidType))
     {
         ccr.RegReturn(arch.GetRegister("r0") !);
     }
     foreach (var dt in dtParams)
     {
         ccr.RegParam(arch.GetRegister("r0") !);
     }
 }
Пример #10
0
        // T_1 --> C_1 --> S_1
        // T_2 --> C_2 --> S_2
        // T_3 --> C_3 --> S_3

        // T_1 --> C_1 --> S_New
        // T_2 --> C_1
        // T_3 --> C_1
        public void Merge()
        {
            Unifier  un = new Unifier(new TypeFactory());
            DataType?dt = null;

            foreach (StructureType str in structures)
            {
                dt = un.Unify(dt, str);
            }
            StructureType strNew = (StructureType)dt !;

            eqMin !.DataType = strNew;
        }
 protected static FunctionSymbol Func(
     FunctionSymbol mother,
     string?name = null,
     NamespaceOrPackageSymbol?ns   = null,
     FixedList <DataType>? @params = null,
     DataType? @return             = null)
 {
     return(new FunctionSymbol(
                ns ?? mother.ContainingSymbol,
                Name(name) ?? mother.Name,
                @params ?? mother.ParameterDataTypes,
                @return ?? mother.ReturnDataType));
 }
Пример #12
0
 public override bool Equals(DataType?other)
 {
     if (other is null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other is OptionalType otherType &&
            Equals(Referent, otherType.Referent));
 }
Пример #13
0
        public override DataType VisitEquivalenceClass(EquivalenceClass eq)
        {
            if (!classesVisited.Contains(eq))
            {
                classesVisited.Add(eq);
                if (eq.DataType != null)
                {
                    eq.DataType = eq.DataType.Accept(this);
                }
            }

            DataType?dt = eq.DataType;

            if (dt is PrimitiveType pr)
            {
                changed = true;
                return(pr);
            }
            if (dt is VoidType)
            {
                changed = true;
                return(dt);
            }
            if (dt is CodeType)
            {
                changed = true;
                return(dt);
            }
            if (dt is Pointer ptr)
            {
                changed = true;
                DataType pointee = eq;
                return(factory.CreatePointer(pointee, ptr.BitSize));
            }
            if (dt is MemberPointer mp)
            {
                changed = true;
                return(factory.CreateMemberPointer(mp.BasePointer, eq, mp.BitSize));
            }
            if (dt is ArrayType array)
            {
                changed = true;
                return(factory.CreateArrayType(array.ElementType, array.Length));
            }
            if (dt is EquivalenceClass eq2)
            {
                changed = true;
                return(eq2);
            }
            return(eq);
        }
Пример #14
0
 public DataPropertyBase(int?pId, bool pAutoCreateMissing, List <Reference> pChildren, int?pChildrenCount, Reference pClass, int?pClassId, string pDescription, string pDisplayName, bool pIsAllowAddInForm, bool pIsAllowCreateInForm, bool pIsAllowEditInForm, bool pIsAllowFreeText, bool pIsAllowRemoveInForm, bool pIsAudited, bool pIsCompressed, bool pIsDisplayInForm, bool pIsDisplayInGrid, bool pIsEditColumn, bool pIsInsertOnly, bool pIsJSON, bool pIsLazy, bool pIsNullOnUpgrade, bool pIsReadOnly, bool pIsRelationship, bool pIsRequired, bool pIsRequiredInForm, bool pIsVirtual, string pJsonType, Reference pLookupTableEnum, int?pLookupTableEnumId, string pName, int?pOrder, Reference pOwner, int?pOwnerId, int?pPrecision, OnRemoveAction?pRelationshipOnOwnerRemove, OnRemoveAction?pRelationshipOnTargetRemove, Reference pRelationshipPairTo, int?pRelationshipPairToId, int?pScale, string pSetDefaultValue, Reference pTab, int?pTabId, Reference pTarget, int?pTargetId, string pTargetAlias, DataType?pType, UiType?pUIType) : this(DocConvert.ToInt(pId))
 {
     AutoCreateMissing   = pAutoCreateMissing;
     Children            = pChildren;
     ChildrenCount       = pChildrenCount;
     Class               = pClass;
     ClassId             = pClassId;
     Description         = pDescription;
     DisplayName         = pDisplayName;
     IsAllowAddInForm    = pIsAllowAddInForm;
     IsAllowCreateInForm = pIsAllowCreateInForm;
     IsAllowEditInForm   = pIsAllowEditInForm;
     IsAllowFreeText     = pIsAllowFreeText;
     IsAllowRemoveInForm = pIsAllowRemoveInForm;
     IsAudited           = pIsAudited;
     IsCompressed        = pIsCompressed;
     IsDisplayInForm     = pIsDisplayInForm;
     IsDisplayInGrid     = pIsDisplayInGrid;
     IsEditColumn        = pIsEditColumn;
     IsInsertOnly        = pIsInsertOnly;
     IsJSON              = pIsJSON;
     IsLazy              = pIsLazy;
     IsNullOnUpgrade     = pIsNullOnUpgrade;
     IsReadOnly          = pIsReadOnly;
     IsRelationship      = pIsRelationship;
     IsRequired          = pIsRequired;
     IsRequiredInForm    = pIsRequiredInForm;
     IsVirtual           = pIsVirtual;
     JsonType            = pJsonType;
     LookupTableEnum     = pLookupTableEnum;
     LookupTableEnumId   = pLookupTableEnumId;
     Name      = pName;
     Order     = pOrder;
     Owner     = pOwner;
     OwnerId   = pOwnerId;
     Precision = pPrecision;
     RelationshipOnOwnerRemove  = pRelationshipOnOwnerRemove;
     RelationshipOnTargetRemove = pRelationshipOnTargetRemove;
     RelationshipPairTo         = pRelationshipPairTo;
     RelationshipPairToId       = pRelationshipPairToId;
     Scale           = pScale;
     SetDefaultValue = pSetDefaultValue;
     Tab             = pTab;
     TabId           = pTabId;
     Target          = pTarget;
     TargetId        = pTargetId;
     TargetAlias     = pTargetAlias;
     Type            = pType;
     UIType          = pUIType;
 }
Пример #15
0
 public void Generate(ICallingConventionEmitter ccr, DataType?dtRet, DataType?dtThis, List <DataType> dtParams)
 {
     ccr.LowLevelDetails(2, 4);
     for (int i = dtParams.Count - 1; i >= 0; --i)
     {
         ccr.StackParam(dtParams[i]);
     }
     ccr.ReverseParameters();
     ccr.CalleeCleanup();
     if (dtRet != null && !(dtRet is VoidType))
     {
         ccr.StackReturn(dtRet);
     }
 }
 protected VariableSymbol Variable(
     string?name = null,
     InvocableSymbol?containing = null,
     int?declaration            = null,
     bool?mut      = null,
     DataType?type = null)
 {
     return(new VariableSymbol(
                containing ?? Func(),
                Name(name) ?? DefaultName("variable"),
                declaration ?? ++unique,
                mut ?? true,
                type ?? DataType()));
 }
Пример #17
0
 /// <summary>
 /// 设置数据类型
 /// </summary>
 /// <param name="dataType">数据类型,可以不设置</param>
 /// <param name="length">类型长度</param>
 /// <param name="decimals">小数点位数</param>
 /// <returns>列信息设置器</returns>
 public IColumnSetter DataType(DataType?dataType = null, int?length = null, int?decimals = null)
 {
     //设置数据类型
     if (dataType != null)
     {
         _columnMapper.DataType = dataType.Value;
     }
     //设置类型长度
     _columnMapper.Length = length;
     //设置小数点位数
     _columnMapper.Decimals = decimals;
     //获取当前设置对象
     return(this);
 }
Пример #18
0
        public static void SetReturnStorage(ICallingConventionEmitter ccr, DataType?dtRet, int stackAlignment)
        {
            if (dtRet == null)
            {
                return;
            }

            int retSize = dtRet.Size;

            if (retSize > 8)
            {
                // returns a pointer to the stack-allocated large return value
                ccr.RegReturn(Registers.eax);
                return;
            }
            else
            {
                var pt = dtRet.ResolveAs <PrimitiveType>();
                if (pt != null && pt.Domain == Domain.Real)
                {
                    ccr.FpuReturn(-1, PrimitiveType.Real64);
                    return;
                }
                if (retSize > 4)
                {
                    ccr.SequenceReturn(Registers.edx, Registers.eax);
                    return;
                }
                if (retSize > 2)
                {
                    if (stackAlignment == 4)
                    {
                        ccr.RegReturn(Registers.eax);
                    }
                    else
                    {
                        ccr.SequenceReturn(Registers.dx, Registers.ax);
                    }
                    return;
                }
                if (retSize > 1)
                {
                    ccr.RegReturn(Registers.ax);
                    return;
                }
                ccr.RegReturn(Registers.al);
                return;
            }
        }
Пример #19
0
 public void Generate(ICallingConventionEmitter ccr, DataType?dtRet, DataType?dtThis, List <DataType> dtParams)
 {
     //$BUG: this is all just to get the ELF loader up and running.
     // fill in with details from
     // https://blackfin.uclinux.org/doku.php?id=toolchain:application_binary_interface
     ccr.LowLevelDetails(4, 0);
     if (dtRet != null && !(dtRet is VoidType))
     {
         ccr.RegReturn(arch.GetRegister("R0") !);
     }
     foreach (var dt in dtParams)
     {
         ccr.RegParam(arch.GetRegister("R0") !);
     }
 }
Пример #20
0
        private static DataType ParseCompositeType(string s, DataType subtype)
        {
            var      typeTuple = ParseTypeNameArgs(s);
            DataType?dataType  = null;

            if (typeTuple != null)
            {
                var typeName = typeTuple.Item1;
                var typeArgs = typeTuple.Item2;

                dataType ??= AggregateType.ParseType(typeName, typeArgs, subtype);
                dataType ??= LevelType.ParseType(typeName, typeArgs, subtype);
            }
            return(dataType ?? new UnknownType(s));
        }
 protected static VariableSymbol Variable(
     VariableSymbol mother,
     string?name = null,
     InvocableSymbol?containing = null,
     int?declaration            = null,
     bool?mut      = null,
     DataType?type = null)
 {
     return(new VariableSymbol(
                containing ?? mother.ContainingSymbol,
                Name(name) ?? mother.Name,
                declaration ?? mother.DeclarationNumber,
                mut ?? mother.IsMutableBinding,
                type ?? mother.DataType));
 }
 protected MethodSymbol Method(
     string?name = null,
     ObjectTypeSymbol?containing = null,
     DataType?self = null,
     FixedList <DataType>? @params = null,
     DataType? @return             = null)
 {
     containing ??= Type();
     return(new MethodSymbol(
                containing,
                Name(name) ?? DefaultName("method"),
                self ?? containing.DeclaresDataType,
                @params ?? Params(),
                @return ?? DataType()));
 }
Пример #23
0
        /// <summary>
        ///   Input() is used to instantiate a Keras tensor.
        /// </summary>
        ///
        /// <remarks>
        ///   A Keras tensor is a tensor object from the underlying backend (Theano or TensorFlow), which we
        ///   augment with certain attributes that allow us to build a Keras model just by knowing the inputs
        ///   and outputs of the model.
        /// </remarks>
        ///
        /// <param name="shape">A shape tuple (integer), including the batch size. For instance,
        ///   <c>batch_shape= (10, 32)</c> indicates that the expected input will be batches of 10 32-dimensional
        ///   vectors. <c>batch_shape= (None, 32)</c> indicates batches of an arbitrary number of 32-dimensional
        ///   vectors.</param>
        /// <param name="batch_shape">The batch shape.</param>
        /// <param name="name">An optional name string for the layer. Should be unique in a model (do not reuse
        ///   the same name twice). It will be autogenerated if it isn't provided.</param>
        /// <param name="dtype">The data type expected by the input, as a string
        ///   (`float32`, `float64`, `int32`...)</param>
        /// <param name="sparse">A boolean specifying whether the placeholder to be created is sparse.</param>
        /// <param name="tensor">Optional existing tensor to wrap into the `Input` layer.
        ///   If set, the layer will not create a placeholder tensor.</param>
        ///
        public static List <Tensor> Input(int?[] shape   = null, int?[] batch_shape = null, string name    = null,
                                          DataType?dtype = null, bool sparse        = false, Tensor tensor = null)
        {
            // https://github.com/fchollet/keras/blob/f65a56fb65062c8d14d215c9f4b1015b97cc5bf3/keras/engine/topology.py#L1416

            if (batch_shape == null && tensor == null)
            {
                throw new ArgumentException("Please provide to Input either a 'shape' or a 'batch_shape' argument. Note that " +
                                            "'shape' does not include the batch dimension.");
            }

            if (shape != null && batch_shape != null)
            {
                batch_shape = new int?[] { null }
            }
 protected static MethodSymbol Method(
     MethodSymbol mother,
     string?name = null,
     ObjectTypeSymbol?containing = null,
     DataType?self = null,
     FixedList <DataType>? @params = null,
     DataType? @return             = null)
 {
     return(new MethodSymbol(
                containing ?? mother.ContainingSymbol,
                Name(name) ?? mother.Name,
                self ?? mother.SelfDataType,
                @params ?? mother.ParameterDataTypes,
                @return ?? mother.ReturnDataType));
 }
Пример #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InputLayer"/> class.
        /// </summary>
        ///
        /// <param name="input_shape">Shape vector, not including the batch axis.</param>
        /// <param name="batch_size">Optional input batch size (integer or null).</param>
        /// <param name="batch_input_shape">Shape vector, including the batch axis.</param>
        /// <param name="name">The name of the layer.</param>
        /// <param name="dtype">The datatype of the input.</param>
        /// <param name="sparse">Whether the placeholder created is meant to be sparse.</param>
        /// <param name="input_tensor">The optional tensor to use as layer input.</param>
        ///
        public InputLayer(int?[] input_shape = null, int?batch_size = null, int?[] batch_input_shape = null, string name = null,
                          DataType?dtype     = null, bool sparse    = false, Tensor input_tensor     = null)
            : base(dtype: GetType(dtype, input_tensor), name: GetName(name))
        {
            // https://github.com/fchollet/keras/blob/f65a56fb65062c8d14d215c9f4b1015b97cc5bf3/keras/engine/topology.py#L1291

            this.input_tensor = input_tensor;

            this.trainable = false;
            this.built     = true;
            this.sparse    = sparse;

            if (input_shape != null && batch_input_shape != null)
            {
                throw new Exception("Only provide the input_shape OR batch_input_shape argument to  InputLayer, not both at the same time.");
            }

            if (input_tensor != null && batch_input_shape == null)
            {
                // If input_tensor is set, and batch_input_shape is not set:
                // Attempt automatic input shape inference.
                try
                {
                    batch_input_shape = K.int_shape(input_tensor);
                }
                catch
                {
                    if (input_shape == null && batch_input_shape == null)
                    {
                        throw new Exception("InputLayer was provided an input_tensor argument, but its input shape " +
                                            "cannot be automatically inferred. You should pass an input_shape or batch_input_shape argument.");
                    }
                }
            }
            if (batch_input_shape == null)
            {
                if (input_shape == null)
                {
                    throw new Exception("An Input layer should be passed either a `batch_input_shape` or an `input_shape`.");
                }
                else if (batch_size != null && input_shape != null)
                {
                    batch_input_shape = batch_size.Concatenate(input_shape);
                }
                else if (input_shape != null)
                {
                    batch_input_shape = new int?[] { null }
                }
Пример #26
0
        public void Generate(ICallingConventionEmitter ccr, DataType?dtRet, DataType?dtThis, List <DataType> dtParams)
        {
            int stackOffset = 4;        // return address

            ccr.LowLevelDetails(4, stackOffset);
            if (dtRet != null)
            {
                ccr.RegReturn(Registers.d0);
            }

            for (int i = 0; i < dtParams.Count; ++i)
            {
                ccr.StackParam(dtParams[i]);
            }
            ccr.CallerCleanup(4);
        }
Пример #27
0
        private static DataType?GetType(DataType?dtype, Tensor input_tensor)
        {
            if (dtype == null)
            {
                if (input_tensor == null)
                {
                    dtype = K.floatx();
                }
                else
                {
                    dtype = K.dtype(input_tensor);
                }
            }

            return(dtype.Value);
        }
 public override bool Equals(DataType?other)
 {
     if (other is null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other is ObjectType otherType &&
            ContainingNamespace == otherType.ContainingNamespace &&
            Name == otherType.Name &&
            DeclaredMutable == otherType.DeclaredMutable &&
            ReferenceCapability == otherType.ReferenceCapability);
 }
Пример #29
0
        public DataType?LoadFile(string path)
        {
            path = FileSystem.GetFullPath(path);
            if (!FileSystem.FileExists(path))
            {
                return(null);
            }

            ModuleType?module = GetCachedModule(path);

            if (module is not null)
            {
                return(module);
            }

            // detect circular import
            if (InImportStack(path))
            {
                return(null);
            }

            // set new CWD and save the old one on stack
            string?oldcwd = cwd;

            setCWD(FileSystem.GetDirectoryName(path));

            PushImportStack(path);
            loadingProgress?.Tick();

            var      ast  = GetAstForFile(path);
            DataType?type = null;

            if (ast == null)
            {
                failedToParse.Add(path);
            }
            else
            {
                loadedFiles.Add(path);
                type = LoadModule(ast);
            }
            PopImportStack(path);

            // restore old CWD
            setCWD(oldcwd !);
            return(type);
        }
Пример #30
0
        public static string PerformSecondDataExtraction(string data, DataType?type = null)
        {
            string extract = "";

            try
            {
                List <char> charList = new List <char>();
                List <char> dataList = new List <char>();
                dataList.AddRange(data);

                foreach (var _char in dataList)
                {
                    if (char.IsLetter(_char))
                    {
                        break;
                    }
                    charList.Add(_char);
                }
                var _extract = new string(charList.ToArray());
                _extract = _extract.Trim();

                if (_extract.Contains("\n"))
                {
                    _extract = _extract.Replace("\n", " ");
                }

                _extract = Helper.GetBeforeChar(_extract, ' ');

                if (!string.IsNullOrEmpty(_extract))
                {
                    var format = new NumberFormatInfo();
                    format.NegativeSign           = "-";
                    format.NumberDecimalSeparator = ".";

                    if (double.TryParse(_extract, NumberStyles.Any, format, out double _data))
                    {
                        extract = _data.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"PerformSecondDataExtraction Exception: {ex.Message} - {type} = {data}");
            }

            return(extract);
        }
 /// <summary>
 /// 初始化数据库列特性
 /// </summary>
 /// <param name="columnName">数据库列名</param>
 /// <param name="dataType">数据类型</param>
 public DatabaseColumnAttribute(String columnName, DataType dataType)
 {
     this._columnName = columnName;
     this._dataType = dataType;
 }
Пример #32
0
        /// <summary>
        /// Define the result data type for the formula.
        /// </summary>
        /// <param name="dataType">The result data type for the formula.</param>
        /// <returns>The <see cref="FormulaBuilder"/> instance.</returns>
        public FormulaBuilder Result(DataType dataType)
        {
            if (resultDataType.HasValue)
                throw new InvalidOperationException("The result can only be defined once for a given formula.");

            resultDataType = dataType;
            return this;
        }
Пример #33
0
 public FormulaBuilder Result(DataType dataType)
 {
     resultDataType = dataType;
     return this;
 }