public override void Visit(UsingParametersStatement usingParametersStatement) { if (currentContext == null) { logging.Error("Unexpected 'using params' outside of shader block declaration", usingParametersStatement.Span); return; } HashSet <string> usings = currentContext.DeclaredParameters; // If this is a using params without a body, it is a simple reference of a ParameterBlock if (usingParametersStatement.Body == null) { var simpleName = usingParametersStatement.Name as VariableReferenceExpression; if (simpleName != null) { string typeName = simpleName.Name.Text; if (usings.Contains(typeName)) { logging.Error("Unexpected declaration of using params. This variable is already declared in this scope", usingParametersStatement.Span); return; } usings.Add(typeName); } } else { // using params with a body is to enter the context of the parameters passed to the using statements VisitDynamic(usingParametersStatement.Body); } }
/// <summary> /// Visits the specified using parameters statement. /// </summary> /// <param name="usingParametersStatement">The using parameters statement.</param> public override void Visit(UsingParametersStatement usingParametersStatement) { if (usingParametersStatement.Body == null) { return; } Identifier parameterType; Identifier parameterMember; if (!TryParameters(usingParametersStatement.Name, out parameterType, out parameterMember)) { Write(@"#error ""Unexpected parameter for 'using params' ["); VisitDynamic(usingParametersStatement.Name); WriteLine(@"]. Expecting single property access"""); return; } AddPushPopParameters(usingParametersStatement.Body, parameterType, parameterMember, usingParametersStatement.Name, usingParametersStatement.Span); Visit(usingParametersStatement.Body); }