public static string GetVariableDeclaration(VariableDeclarationNode variable, string prefix = "") { string arrayStuff = (variable.IsArray && variable.ArraySize != null) ? "[" + variable.ArraySize + "]" : string.Empty; string semantic = (!string.IsNullOrEmpty(variable.Semantic)) ? " : " + variable.Semantic : string.Empty; string initialValue; if (!string.IsNullOrEmpty(variable.InitialValue)) { string variableInitialValue = variable.InitialValue; if (variableInitialValue.StartsWith("sampler_state")) variableInitialValue = Regex.Replace(variableInitialValue, @"(Texture=\()([\w]+)(\);)", "$1" + prefix + "$2$3"); initialValue = " = " + variableInitialValue; } else initialValue = string.Empty; return string.Format("{0} {1}{2}{3}{4}{5};", Token.GetString(variable.DataType), prefix, variable.Name, arrayStuff, semantic, initialValue); }
public string GetNextSemantic(VariableDeclarationNode variable) { if (!string.IsNullOrEmpty(variable.Semantic)) return variable.Semantic; return _semanticPrefix + _currentIndex++; }
internal string GetVariableDeclaration(StitchedFragmentSymbol stitchedFragment, VariableDeclarationNode variable) { return GetVariableDeclaration(variable, stitchedFragment.UniqueName + "_"); }
private static string GetVertexPassThroughCode(StitchedFragmentSymbol stitchedFragment, VariableDeclarationNode variable) { return string.Format("\toutput.{0}.{1} = input.{1};", stitchedFragment.UniqueName, variable.Name); }