예제 #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));
        }
        /// <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
        /// <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);
        }
 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);
            }
        }
        /// <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
 protected virtual void Visit(GenericType<ObjectType> type)
 {
     if (IsTextureType(type))
     {
         Write("Texture");
     }
     else if (IsBufferType(type))
     {
         Write("Buffer");
     }
     else
     {
         Visit((GenericType)type);
     }
     ProcessInitialValueStatus = false;
 }