コード例 #1
0
        /// <summary>
        /// Equalses the specified other.
        /// </summary>
        /// <param name="other">
        /// The other.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="GenericType"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(GenericType other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

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

            //return base.Equals(other) && ParameterTypes.SequenceEqual(other.ParameterTypes) && Parameters.SequenceEqual(other.Parameters);
            return(base.Equals(other) && Parameters.SequenceEqual(other.Parameters));
        }
コード例 #2
0
        /// <summary>
        /// Visit a generic type and test that it has no shader class type
        /// </summary>
        /// <param name="genericType">the generic type</param>
        public override Node Visit(GenericType genericType)
        {
            base.Visit(genericType);

            foreach (var param in genericType.Parameters.OfType<TypeName>())
            {
                if (param.TypeInference.TargetType is ShaderClassType)
                    Error(XenkoMessageCode.ErrorMixinAsGeneric, param.Span, param, genericType, analyzedModuleMixin.MixinName);
            }

            return genericType;
        }
コード例 #3
0
ファイル: ShaderWriter.cs プロジェクト: cg123/xenko
        public virtual void Visit(GenericType genericType)
        {
            Write(genericType.Name).Write("<");
            for (int i = 0; i < genericType.Parameters.Count; i++)
            {
                var parameter = genericType.Parameters[i];
                if (i > 0) Write(",").WriteSpace();

                VisitDynamic(parameter);
            }

            Write(">");
        }
コード例 #4
0
 protected virtual void Visit(GenericType<ObjectType> type)
 {
     var typeName = type.Name.Text;
     if (typeName.Contains("Texture"))
     {
         Write("Texture");
     }
     else if (typeName.Contains("Buffer"))
     {
         Write("Buffer");
     }
     else
     {
         Visit((GenericType)type);
     }
     ProcessInitialValueStatus = false;
 }
コード例 #5
0
        protected override void Visit(GenericType genericType)
        {
            base.Visit(genericType);

            foreach (var param in genericType.Parameters.OfType<TypeName>())
            {
                if (param.TypeInference.TargetType is ShaderClassType)
                    Error(ParadoxMessageCode.ErrorMixinAsGeneric, param.Span, param, genericType, analyzedModuleMixin.MixinName);
            }
        }
コード例 #6
0
ファイル: GenericType.cs プロジェクト: h78hy78yhoi8j/xenko
        /// <summary>
        /// Equalses the specified other.
        /// </summary>
        /// <param name="other">
        /// The other.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="GenericType"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(GenericType other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

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

            //return base.Equals(other) && ParameterTypes.SequenceEqual(other.ParameterTypes) && Parameters.SequenceEqual(other.Parameters);
            return base.Equals(other) && Parameters.SequenceEqual(other.Parameters);
        }
コード例 #7
0
 public override void Visit(GenericType type)
 {
     if (IsTextureType(type))
     {
         Write("Texture");
     }
     else if (IsBufferType(type))
     {
         Write("Buffer");
     }
     else
     {
         base.Visit(type);
     }
     ProcessInitialValueStatus = false;
 }
コード例 #8
0
        private static TypeBase GetGenericInstance(string typename, GenericType genericType, TypeBase predefinedType)
        {
            var key = new GenericInstanceKey(typename, genericType.Parameters);

            TypeBase instanciatedType;
            lock (InstanciatedTypes)
            {
                if (!InstanciatedTypes.TryGetValue(key, out instanciatedType))
                {
                    instanciatedType = genericType.MakeGenericInstance(predefinedType);
                    InstanciatedTypes.Add(key, instanciatedType);
                }
            }
            return instanciatedType;
        }
コード例 #9
0
        private void AssociatePredefinedObjects(TypeBase typebase)
        {
            // Use the returned name in order to support case insensitive names 
            TypeBase predefinedType;
            if (typebase.TypeInference.TargetType == null && BuiltinObjects.TryGetValue(typebase.Name.Text, out predefinedType))
            {
                var textureType = new GenericType<TypeBase>();
                textureType.Parameters[0] = VectorType.Float4;

                typebase.TypeInference.TargetType = GetGenericInstance(typebase.Name.Text, textureType, predefinedType);
            }
        }
コード例 #10
0
        protected virtual void Visit(GenericType genericType)
        {
            Visit((Node)genericType);

            string genericName = genericType.Name.Text;

            // Get the case insenti
            var value = TextureType.Parse(genericName);
            if (value != null)
                genericName = value.Name.Text;

            TypeBase typeBase;
            if (BuiltinObjects.TryGetValue(genericName, out typeBase))
            {
                genericType.TypeInference.TargetType = GetGenericInstance(genericName, genericType, typeBase);
            }
        }
コード例 #11
0
        /// <summary>
        /// Visits the specified type name.
        /// </summary>
        /// <param name="typeName">Name of the type.</param>
        public override Node Visit(GenericType genericType)
        {
            base.Visit(genericType);

            string genericName = genericType.Name.Text;

            // Get the case insenti
            var value = TextureType.Parse(genericName);
            if (value != null)
                genericName = value.Name.Text;

            TypeBase typeBase;
            if (BuiltinObjects.TryGetValue(genericName, out typeBase))
            {
                genericType.TypeInference.TargetType = GetGenericInstance(genericName, genericType, typeBase);
            }

            return genericType;
        }
コード例 #12
0
ファイル: ShaderMixinCodeGen.cs プロジェクト: cg123/xenko
 protected virtual void Visit(GenericType<ObjectType> type)
 {
     if (IsTextureType(type))
     {
         Write("Texture");
     }
     else if (IsBufferType(type))
     {
         Write("Buffer");
     }
     else
     {
         Visit((GenericType)type);
     }
     ProcessInitialValueStatus = false;
 }