Exemplo n.º 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;
 }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 8
0
 /// <inheritdoc />
 public override void Visit(ScalarType scalarType)
 {
     Write(scalarType.Qualifiers, true);
     Write(scalarType.Name);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }