コード例 #1
0
 public override void Visit(Parameter parameter)
 {
     base.Visit(parameter);
     var containers = GetDeclarationContainers();
     var container = containers[containers.Count - 2];
     AddReference((Node)container, parameter);
 }
コード例 #2
0
ファイル: StripVisitor.cs プロジェクト: h78hy78yhoi8j/xenko
 public void Visit(Parameter parameter)
 {
     Visit((Node)parameter);
     var containers = GetDeclarationContainers();
     var container = containers[containers.Count - 2];
     AddReference((Node)container, parameter);
 }
コード例 #3
0
ファイル: ShaderWriter.cs プロジェクト: cg123/xenko
 public virtual void Visit(Parameter parameter)
 {
     WriteVariable(parameter);
 }
コード例 #4
0
 /// <inheritdoc />
 public override void Visit(Parameter parameter)
 {
     WriteVariable(parameter);
 }
コード例 #5
0
        /// <summary>
        /// Checks if a function needs to have a stream strucutre added in its declaration
        /// </summary>
        /// <param name="methodDefinition">the method definition</param>
        /// <param name="inputStream">The stage input structure stream.</param>
        /// <param name="intermediateStream">the stream structure</param>
        /// <param name="outputStream">The stage output stream structure.</param>
        /// <param name="visitedMethods">the list of already visited methods</param>
        /// <param name="methodsWithStreams">The list of methods that have a streams argument.</param>
        /// <returns>true if needed, false otherwise</returns>
        private bool PropagateStreamsParameter(MethodDefinition methodDefinition, StructType inputStream, StructType intermediateStream, StructType outputStream, HashSet<MethodDeclaration> visitedMethods, List<MethodDeclaration> methodsWithStreams)
        {
            var needStream = false;

            if (methodDefinition != null)
            {
                if (visitedMethods.Contains(methodDefinition))
                    return methodDefinition.Parameters.Count > 0 && methodDefinition.Parameters[0].Type == intermediateStream;

                List<StreamUsageInfo> streamUsageInfos;
                if (streamsUsages.TryGetValue(methodDefinition, out streamUsageInfos))
                {
                    needStream = streamUsageInfos.Any(x => x.CallType == StreamCallType.Member || x.CallType == StreamCallType.Direct);
                    visitedMethods.Add(methodDefinition);

                    List<MethodDeclaration> calls;
                    if (TryGetMethodCalls(methodDefinition, out calls))
                        needStream = calls.Aggregate(needStream, (res, calledmethod) => res | PropagateStreamsParameter(calledmethod as MethodDefinition, inputStream, intermediateStream, outputStream, visitedMethods, methodsWithStreams));

                    if (needStream && !entryPointMethods.Contains(methodDefinition))
                    {
                        var param = new Parameter(new TypeName(intermediateStream.Name), "streams");

                        foreach (var methodRef in mainModuleMixin.ClassReferences.MethodsReferences[methodDefinition])
                        {
                            var vre = new VariableReferenceExpression(param.Name) { TypeInference = { Declaration = param, TargetType = param.Type } };
                            methodRef.Arguments.Insert(0, vre);
                        }

                        param.Qualifiers |= ParameterQualifier.InOut;
                        methodDefinition.Parameters.Insert(0, param);

                        // If any parameters in the method are streams, then replace by using the intermediate stream
                        foreach (var parameter in methodDefinition.Parameters)
                        {
                            if (parameter.Type == StreamsType.Streams)
                            {
                                parameter.Type = new TypeName(intermediateStream.Name);
                            }
                        }

                        methodsWithStreams.Add(methodDefinition);
                    }
                }

                TransformStreamsAssignments(methodDefinition, inputStream, intermediateStream, outputStream);
            }
            return needStream;
        }