Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MatrixType"/> class.
 /// </summary>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="rowCount">
 /// The row count.
 /// </param>
 /// <param name="columnCount">
 /// The column count.
 /// </param>
 public MatrixType(ScalarType type, int rowCount, int columnCount)
     : this()
 {
     Type        = type;
     RowCount    = rowCount;
     ColumnCount = columnCount;
 }
Пример #2
0
        /// <summary>
        /// Equalses the specified other.
        /// </summary>
        /// <param name="other">
        /// The other.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="ScalarType"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(ScalarType other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(base.Equals(other) && Equals(other.Type, Type));
        }
Пример #3
0
        /// <summary>
        /// Creates a type based on a new base type. If type is a matrix or vector, then the base type is changed to match the newBaseType.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="newBaseType">New type of the base.</param>
        /// <returns>A new type</returns>
        public static TypeBase CreateWithBaseType(TypeBase type, ScalarType newBaseType)
        {
            if (type is MatrixType)
            {
                return(new MatrixType(newBaseType, ((MatrixType)type).RowCount, ((MatrixType)type).ColumnCount));
            }

            if (type is VectorType)
            {
                return(new VectorType(newBaseType, ((VectorType)type).Dimension));
            }

            return(newBaseType);
        }
Пример #4
0
        /// <summary>
        /// Creates a type based on a new base type. If type is a matrix or vector, then the base type is changed to match the newBaseType.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="newBaseType">New type of the base.</param>
        /// <returns>A new type</returns>
        public static TypeBase CreateWithBaseType(TypeBase type, ScalarType newBaseType)
        {
            if (type is MatrixType)
                return new MatrixType(newBaseType, ((MatrixType)type).RowCount, ((MatrixType)type).ColumnCount);

            if (type is VectorType)
                return new VectorType(newBaseType, ((VectorType)type).Dimension);

            return newBaseType;
        }
Пример #5
0
 public virtual void Visit(ScalarType scalarType)
 {
     Write(scalarType.Qualifiers, true);
     Write(scalarType.Name);
 }
 /// <inheritdoc />
 public override void Visit(ScalarType scalarType)
 {
     base.Visit(scalarType);
     ProcessInitialValueStatus = true;
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VectorType"/> class.
 /// </summary>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="dimension">
 /// The dimension.
 /// </param>
 public VectorType(ScalarType type, int dimension)
     : this()
 {
     Type = type;
     Dimension = dimension;
 }
Пример #8
0
 /// <inheritdoc />
 public override void Visit(ScalarType scalarType)
 {
     Write(scalarType.Qualifiers, true);
     Write(scalarType.Name);
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VectorType"/> class.
 /// </summary>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="dimension">
 /// The dimension.
 /// </param>
 public VectorType(ScalarType type, int dimension)
     : this()
 {
     Type      = type;
     Dimension = dimension;
 }
Пример #10
0
 /// <summary>
 /// Finds the member type reference.
 /// </summary>
 /// <param name="scalarType">Type of the scalar.</param>
 /// <param name="memberReference">The member reference.</param>
 protected virtual void FindMemberTypeReference(ScalarType scalarType, MemberReferenceExpression memberReference)
 {
     var components = memberReference.Member.Text;
     if (components.Length <= 4 && (
         components.All(x => x == 'x' || x == 'y' || x == 'z' || x == 'w') ||
         components.All(x => x == 'r' || x == 'g' || x == 'b' || x == 'a') ||
         components.All(x => x == 's' || x == 't' || x == 'u' || x == 'v')
         ))
     {
         memberReference.TypeInference.TargetType = components.Length == 1 ? (TypeBase)scalarType : new VectorType(scalarType, components.Length);
     }
 }
Пример #11
0
        /// <summary>
        /// Equalses the specified other.
        /// </summary>
        /// <param name="other">
        /// The other.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="ScalarType"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(ScalarType other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return base.Equals(other) && Equals(other.Type, Type);
        }