示例#1
0
        /// <summary>
        /// Check the name conflict between the two virtual tables
        /// </summary>
        public bool CheckNameConflict(MixinVirtualTable virtualTable, LoggerResult log)
        {
            var conflict = false;

            foreach (var variable in virtualTable.Variables.Where(variable => Variables.Any(x => x.Variable.Name.Text == variable.Variable.Name.Text)))
            {
                log.Error(XenkoMessageCode.ErrorVariableNameConflict, variable.Variable.Span, variable.Variable, "");
                conflict = true;
            }

            return(conflict);
        }
示例#2
0
        /// <summary>
        /// Check the name conflict between the two virtual tables
        /// </summary>
        public bool CheckNameConflict(MixinVirtualTable virtualTable, LoggerResult log)
        {
            var conflict = false;

            // Note: we allow conflicts for static variables
            foreach (var variable in virtualTable.Variables.Where(variable => !variable.Variable.Qualifiers.Contains(SiliconStudio.Shaders.Ast.Hlsl.StorageQualifier.Static) && Variables.Any(x => x.Variable.Name.Text == variable.Variable.Name.Text)))
            {
                log.Error(XenkoMessageCode.ErrorVariableNameConflict, variable.Variable.Span, variable.Variable, "");
                conflict = true;
            }

            return(conflict);
        }
示例#3
0
        /// <summary>
        /// Merge with a local virtual table =  need to check override keywords
        /// </summary>
        /// <param name="virtualTable">the virtual table to add</param>
        /// <param name="mixinName">the name of the mixin</param>
        /// <param name="log">the error logger</param>
        public void MergeWithLocalVirtualTable(MixinVirtualTable virtualTable, string mixinName, LoggerResult log)
        {
            foreach (var method in virtualTable.Methods)
            {
                var methodDecl = Methods.LastOrDefault(x => x.Method.IsSameSignature(method.Method));
                if (methodDecl != null)
                {
                    var isBaseMethod = method.Shader.BaseClasses.Any(x => x.Name.Text == methodDecl.Shader.Name.Text);

                    if (isBaseMethod)
                    {
                        if (methodDecl.Method is MethodDefinition)
                        {
                            if (!method.Method.Qualifiers.Contains(XenkoStorageQualifier.Override))
                            {
                                log.Error(XenkoMessageCode.ErrorMissingOverride, method.Method.Span, method.Method, mixinName);
                                continue;
                            }
                        }
                        else if (method.Method.Qualifiers.Contains(XenkoStorageQualifier.Override))
                        {
                            log.Error(XenkoMessageCode.ErrorOverrideDeclaration, method.Method.Span, method.Method, mixinName);
                            continue;
                        }
                    }

                    Methods.Remove(methodDecl);
                }
                else
                {
                    if (method.Method.Qualifiers.Contains(XenkoStorageQualifier.Override))
                    {
                        log.Error(XenkoMessageCode.ErrorNoMethodToOverride, method.Method.Span, method.Method, mixinName);
                        continue;
                    }
                }

                Methods.Add(method);

                // TODO: handle declarations vs definitions
            }

            Variables.UnionWith(virtualTable.Variables.Where(x => !Variables.Contains(x)));
            StructureTypes.AddRange(virtualTable.StructureTypes.Where(x => !StructureTypes.Contains(x)));
            Typedefs.AddRange(virtualTable.Typedefs.Where(x => !Typedefs.Contains(x)));
        }
示例#4
0
        /// <summary>
        /// Merge with a local virtual table =  need to check override keywords
        /// </summary>
        /// <param name="virtualTable">the virtual table to add</param>
        /// <param name="mixinName">the name of the mixin</param>
        /// <param name="log">the error logger</param>
        public void MergeWithLocalVirtualTable(MixinVirtualTable virtualTable, string mixinName, LoggerResult log)
        {
            foreach (var method in virtualTable.Methods)
            {
                var methodDecl = Methods.LastOrDefault(x => x.Method.IsSameSignature(method.Method));
                if (methodDecl != null)
                {
                    var isBaseMethod = method.Shader.BaseClasses.Any(x => x.Name.Text == methodDecl.Shader.Name.Text);

                    if (isBaseMethod)
                    {
                        if (methodDecl.Method is MethodDefinition)
                        {
                            if (!method.Method.Qualifiers.Contains(XenkoStorageQualifier.Override))
                            {
                                log.Error(XenkoMessageCode.ErrorMissingOverride, method.Method.Span, method.Method, mixinName);
                                continue;
                            }
                        }
                        else if (method.Method.Qualifiers.Contains(XenkoStorageQualifier.Override))
                        {
                            log.Error(XenkoMessageCode.ErrorOverrideDeclaration, method.Method.Span, method.Method, mixinName);
                            continue;
                        }
                    }

                    Methods.Remove(methodDecl);
                }
                else
                {
                    if (method.Method.Qualifiers.Contains(XenkoStorageQualifier.Override))
                    {
                        log.Error(XenkoMessageCode.ErrorNoMethodToOverride, method.Method.Span, method.Method, mixinName);
                        continue;
                    }
                }

                Methods.Add(method);
                
                // TODO: handle declarations vs definitions
            }

            Variables.UnionWith(virtualTable.Variables.Where(x => !Variables.Contains(x)));
            StructureTypes.AddRange(virtualTable.StructureTypes.Where(x => !StructureTypes.Contains(x)));
            Typedefs.AddRange(virtualTable.Typedefs.Where(x => !Typedefs.Contains(x)));
        }
示例#5
0
        /// <summary>
        /// Check the name conflict between the two virtual tables
        /// </summary>
        public bool CheckNameConflict(MixinVirtualTable virtualTable, LoggerResult log)
        {
            var conflict = false;

            foreach (var variable in virtualTable.Variables.Where(variable => Variables.Any(x => x.Variable.Name.Text == variable.Variable.Name.Text)))
            {
                log.Error(XenkoMessageCode.ErrorVariableNameConflict, variable.Variable.Span, variable.Variable, "");
                conflict = true;
            }

            return conflict;
        }