예제 #1
0
        /// <summary>
        /// Create a function type with the specified parameters.
        /// </summary>
        public static FunctionType Create(IChelaType ret, IChelaType[] arguments, bool variable, MemberFlags flags)
        {
            // Use an empty array when the arguments are null.
            if (arguments == null)
            {
                arguments = new IChelaType[] {}
            }
            ;

            // First create a new function.
            FunctionType function = new FunctionType(ret, arguments, variable, flags & MemberFlags.LanguageMask);

            // Try to add it into the set.
            return(functionTypes.GetOrAdd(function));
        }
예제 #2
0
        public static IChelaType Create(IChelaType primitiveType, int numcomponents)
        {
            if (numcomponents == 1)
            {
                return(primitiveType);
            }
            else if (numcomponents < 1)
            {
                throw new ModuleException("invalid vector number of components.");
            }

            // Create a new vector type.
            VectorType vector = new VectorType(primitiveType, numcomponents);

            return(vectorTypes.GetOrAdd(vector));
        }
예제 #3
0
        /// <summary>
        /// Create a matrix type.
        /// </summary>
        public static IChelaType Create(IChelaType primitiveType, int numrows, int numcolumns)
        {
            if (numrows == 1)
            {
                return(VectorType.Create(primitiveType, numcolumns));
            }
            else if (numcolumns == 1)
            {
                return(VectorType.Create(primitiveType, numrows));
            }
            else if (numrows < 1 || numcolumns < 1)
            {
                throw new ModuleException("invalid vector number of components.");
            }

            // First create a new matrix type.
            MatrixType matrix = new MatrixType(primitiveType, numrows, numcolumns);

            return(matrixTypes.GetOrAdd(matrix));
        }
예제 #4
0
        /// <summary>
        /// Create the specified array type.
        /// </summary>
        public static ArrayType Create(IChelaType valueType, int dimensions, bool readOnly)
        {
            // Remove the reference layer.
            if (valueType.IsReference())
            {
                ReferenceType refType = (ReferenceType)valueType;
                valueType = refType.GetReferencedType();
            }

            // Don't allow 0 dimensions.
            if (dimensions == 0)
            {
                dimensions = 1;
            }

            // Create the array type.
            ArrayType array = new ArrayType(valueType, dimensions, readOnly);

            return(arrayTypes.GetOrAdd(array));
        }
예제 #5
0
        public static ReferenceType Create(IChelaType actualType, ReferenceFlow flow, bool streamReference)
        {
            ReferenceType reference = new ReferenceType(actualType, flow, streamReference);

            return(referenceTypes.GetOrAdd(reference));
        }
예제 #6
0
        /// <summary>
        /// Create the specified constant type.
        /// </summary>
        public static ConstantType Create(IChelaType valueType)
        {
            ConstantType constant = new ConstantType(valueType);

            return(constantTypes.GetOrAdd(constant));
        }
예제 #7
0
        /// <summary>
        /// Create the specified meta type.
        /// </summary>
        public static MetaType Create(IChelaType actualType)
        {
            MetaType meta = new MetaType(actualType);

            return(metaTypes.GetOrAdd(meta));
        }
예제 #8
0
        /// <summary>
        /// Create the specified pointer type.
        /// </summary>
        public static PointerType Create(IChelaType pointedType)
        {
            PointerType pointer = new PointerType(pointedType);

            return(pointerTypes.GetOrAdd(pointer));
        }