3 using System.Collections.Generic;
6 using SiliconStudio.Paradox.Shaders.Parser.Ast;
7 using SiliconStudio.Paradox.Shaders.Parser.Utility;
8 using SiliconStudio.Shaders.Ast;
9 using SiliconStudio.Shaders.Ast.Hlsl;
10 using SiliconStudio.Shaders.Utility;
12 namespace SiliconStudio.
Paradox.Shaders.Parser.Mixins
14 internal class MixinVirtualTable : ShaderVirtualTable
16 #region Public properties
21 public HashSet<MethodDeclarationShaderCouple> Methods {
get;
private set; }
26 public HashSet<VariableShaderCouple> Variables {
get;
private set; }
31 public List<StructType> StructureTypes {
get;
private set; }
36 public List<Typedef> Typedefs {
get;
private set; }
42 public MixinVirtualTable()
44 Methods =
new HashSet<MethodDeclarationShaderCouple>();
45 Variables =
new HashSet<VariableShaderCouple>();
46 StructureTypes =
new List<StructType>();
47 Typedefs =
new List<Typedef>();
52 #region Public methods
60 public void MergeWithLocalVirtualTable(MixinVirtualTable virtualTable,
string mixinName,
LoggerResult log)
62 foreach (var method
in virtualTable.Methods)
64 var methodDecl = Methods.LastOrDefault(x => x.Method.IsSameSignature(method.Method));
65 if (methodDecl != null)
67 var isBaseMethod = method.Shader.BaseClasses.Any(x => x.Name.Text == methodDecl.Shader.Name.Text);
75 log.Error(ParadoxMessageCode.ErrorMissingOverride, method.Method.Span, method.Method, mixinName);
81 log.Error(ParadoxMessageCode.ErrorOverrideDeclaration, method.Method.Span, method.Method, mixinName);
86 Methods.Remove(methodDecl);
92 log.Error(ParadoxMessageCode.ErrorNoMethodToOverride, method.Method.Span, method.Method, mixinName);
102 Variables.UnionWith(virtualTable.Variables.Where(x => !Variables.Contains(x)));
103 StructureTypes.AddRange(virtualTable.StructureTypes.Where(x => !StructureTypes.Contains(x)));
104 Typedefs.AddRange(virtualTable.Typedefs.Where(x => !Typedefs.Contains(x)));
112 var conflict =
false;
114 foreach (var variable
in virtualTable.Variables.Where(variable => Variables.Any(x => x.Variable.Name.Text == variable.Variable.Name.Text)))
116 log.Error(ParadoxMessageCode.ErrorVariableNameConflict, variable.Variable.Span, variable.Variable,
"");
A class to collect parsing/expression messages.
static readonly SiliconStudio.Shaders.Ast.StorageQualifier Override
Override keyword (override).
A method definition with a body of statements.