예제 #1
0
        /// <summary>
        /// Build the array of generic parameters
        /// </summary>
        /// <param name="genericClass">the shader with its generics</param>
        /// <returns>the array of generic parameters</returns>
        private static string[] BuildShaderGenericParameters(IdentifierGeneric genericClass)
        {
            var genericParameters = new List <string>();

            for (int i = 0; i < genericClass.Identifiers.Count; ++i)
            {
                var genericName = GetIdentifierName(genericClass.Identifiers[i]);
                genericParameters.Add(genericName);
            }

            return(genericParameters.ToArray());
        }
예제 #2
0
        protected void Visit(IdentifierGeneric identifierGeneric)
        {
            Visit((Node)identifierGeneric);

            for (var i = 0; i < identifierGeneric.Identifiers.Count; ++i)
            {
                Identifier replacement;
                if (identifiersGenerics.TryGetValue(identifierGeneric.Identifiers[i].ToString(), out replacement))
                {
                    identifierGeneric.Identifiers[i] = replacement;
                }
            }
        }
예제 #3
0
        public override void Visit(IdentifierGeneric identifierGeneric)
        {
            base.Visit(identifierGeneric);

            for (var i = 0; i < identifierGeneric.Identifiers.Count; ++i)
            {
                Identifier replacement;
                if (identifiersGenerics.TryGetValue(identifierGeneric.Identifiers[i].ToString(), out replacement))
                {
                    identifierGeneric.Identifiers[i] = replacement;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Build the ModuleMixinInfo class
        /// </summary>
        /// <param name="shaderSource">the ShaderSource to load</param>
        /// <param name="macros">the macros applied on the source</param>
        /// <returns>the ModuleMixinInfo</returns>
        private ModuleMixinInfo BuildMixinInfo(ShaderSource shaderSource, Stride.Core.Shaders.Parser.ShaderMacro[] macros)
        {
            ModuleMixinInfo mixinInfo = null;

            if (shaderSource is ShaderClassCode)
            {
                var shaderClassSource = shaderSource as ShaderClassCode;
                mixinInfo = new ModuleMixinInfo
                {
                    ShaderSource      = shaderClassSource,
                    Macros            = macros,
                    ReferencedShaders = { shaderClassSource.ClassName }
                };
                LoadMixinFromClassSource(mixinInfo);
            }
            else if (shaderSource is ShaderMixinSource)
            {
                var shaderMixinSource = shaderSource as ShaderMixinSource;

                var shaderName = "Mix" + lastMixIndex;
                ++lastMixIndex;
                var fakeAst = new ShaderClassType(shaderName);
                foreach (var classSource in shaderMixinSource.Mixins)
                {
                    Identifier name;
                    if (classSource.GenericArguments != null && classSource.GenericArguments.Length > 0)
                    {
                        name = new IdentifierGeneric(classSource.ClassName, classSource.GenericArguments.Select(x => new Identifier(x.ToString())).ToArray());
                    }
                    else
                    {
                        name = new Identifier(classSource.ClassName);
                    }

                    fakeAst.BaseClasses.Add(new TypeName(name));
                }

                mixinInfo = new ModuleMixinInfo
                {
                    MixinGenericName = shaderName,
                    Macros           = macros,
                    MixinAst         = fakeAst,
                    ShaderSource     = shaderSource,
                    SourceHash       = ObjectId.FromBytes(Encoding.UTF8.GetBytes(shaderName)),
                    Instanciated     = true
                };
            }

            return(mixinInfo);
        }
예제 #5
0
        public override void Visit(IdentifierGeneric identifier)
        {
            base.Visit(identifier);

            FoundIdentifiers.Add(Tuple.Create(identifier, ParentNode));
        }
예제 #6
0
        private void Visit(IdentifierGeneric identifier)
        {
            Visit((Node)identifier);

            FoundIdentifiers.Add(Tuple.Create(identifier, ParentNode));
        }
예제 #7
0
 /// <summary>
 /// Visits the specified composite identifier.
 /// </summary>
 /// <param name="compositeIdentifier">The composite identifier.</param>
 public override void Visit(IdentifierGeneric compositeIdentifier)
 {
     Write((Identifier)compositeIdentifier);
 }