예제 #1
0
        public IntrinsicSignature AddSignature(TypeName returnType,
                                               TypeName param0Type, string param0Name,
                                               TypeName param1Type, string param1Name,
                                               TypeName param2Type, string param2Name,
                                               TypeName param3Type, string param3Name,
                                               TypeName param4Type, string param4Name)
        {
            var signature = new IntrinsicSignature()
            {
                ReturnTypeName = returnType
            };

            signature.Parameters.Add(new ParameterDescription {
                TypeName = param0Type, ParameterName = param0Name
            });
            signature.Parameters.Add(new ParameterDescription {
                TypeName = param1Type, ParameterName = param1Name
            });
            signature.Parameters.Add(new ParameterDescription {
                TypeName = param2Type, ParameterName = param2Name
            });
            signature.Parameters.Add(new ParameterDescription {
                TypeName = param3Type, ParameterName = param3Name
            });
            signature.Parameters.Add(new ParameterDescription {
                TypeName = param4Type, ParameterName = param4Name
            });
            Signatures.Add(signature);
            return(signature);
        }
예제 #2
0
        public void Generate(IntrinsicDescription intrinsic, IntrinsicSignature signature)
        {
            WriteComments(intrinsic, signature);

            Writer.WriteIndentation();
            // If this intrinsic is disabled, comment it out
            if (intrinsic.Disabled)
            {
                Writer.Write("//");
            }

            WriteAttributes(intrinsic, signature);

            Writer.Write(signature.Qualifiers);
            Writer.Write(" ");
            Writer.Write(signature.ReturnTypeName.ToString());
            Writer.Write(" ");
            Writer.Write(intrinsic.FunctionName);
            Writer.Write("(");

            for (var i = 0; i < signature.Parameters.Count; ++i)
            {
                var param = signature.Parameters[i];
                Writer.Write(param.GetDeclaration());

                if (i != signature.Parameters.Count - 1)
                {
                    Writer.Write(", ");
                }
            }
            Writer.Write(");\n");
        }
예제 #3
0
        public IntrinsicSignature AddSignature(TypeName returnType, List <ParameterDescription> parameters)
        {
            var signature = new IntrinsicSignature()
            {
                ReturnTypeName = returnType, Parameters = parameters
            };

            Signatures.Add(signature);
            return(signature);
        }
예제 #4
0
        public IntrinsicSignature AddSignature(IAttributesGenerator attributes, TypeName returnType, TypeName param0Type, string param0Name)
        {
            var signature = new IntrinsicSignature()
            {
                Attributes = attributes, ReturnTypeName = returnType
            };

            signature.Parameters.Add(new ParameterDescription {
                TypeName = param0Type, ParameterName = param0Name
            });
            Signatures.Add(signature);
            return(signature);
        }
 public void Generate(CodeWriter writer, IntrinsicDescription intrinsic, IntrinsicSignature signature)
 {
     writer.WriteIndentation();
     writer.Write(GetVariableName(signature.ReturnTypeName));
     writer.Write(" = Shader.Intrinsics.");
     writer.Write(intrinsic.FunctionName);
     writer.Write("(");
     for (var i = 0; i < signature.Parameters.Count; ++i)
     {
         var param = signature.Parameters[i];
         writer.Write(GetVariableName(param.TypeName));
         if (i != signature.Parameters.Count - 1)
         {
             writer.Write(", ");
         }
     }
     writer.WriteLine(");");
 }
예제 #6
0
        void WriteAttributes(IntrinsicDescription intrinsic, IntrinsicSignature signature)
        {
            string attributes = null;

            if (signature.Attributes != null)
            {
                attributes = signature.Attributes.GetAttributes();
            }
            else if (intrinsic.Attributes != null)
            {
                attributes = intrinsic.Attributes.GetAttributes();
            }

            if (!string.IsNullOrEmpty(attributes))
            {
                Writer.Write(attributes);
                Writer.Write(" ");
            }
        }
예제 #7
0
        void WriteComments(IntrinsicDescription intrinsic, IntrinsicSignature signature)
        {
            List <string> comments = null;

            if (signature.Comments != null)
            {
                comments = signature.Comments;
            }
            else
            {
                comments = intrinsic.Comments;
            }

            if (comments != null)
            {
                foreach (var comment in comments)
                {
                    Writer.WriteIndentation();
                    Writer.Write("// ");
                    Writer.WriteLine(comment);
                }
            }
        }