private void Visit(AssignmentExpression assignmentExpression) { if (currentAssignmentOperatorStatus != AssignmentOperatorStatus.Read) { errorWarningLog.Error(XenkoMessageCode.ErrorNestedAssignment, assignmentExpression.Span, assignmentExpression, shaderName); } var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; assignmentExpression.Value = (Expression)VisitDynamic(assignmentExpression.Value); currentAssignmentOperatorStatus = (assignmentExpression.Operator != AssignmentOperator.Default) ? AssignmentOperatorStatus.ReadWrite : AssignmentOperatorStatus.Write; currentStreamUsage = StreamUsage.Write; assignmentExpression.Target = (Expression)VisitDynamic(assignmentExpression.Target); currentAssignmentOperatorStatus = AssignmentOperatorStatus.Read; currentStreamUsage = prevStreamUsage; var parentBlock = this.NodeStack.OfType <StatementList>().LastOrDefault(); if (assignmentExpression.Operator == AssignmentOperator.Default && parentBlock != null) { if (assignmentExpression.Target is VariableReferenceExpression && (assignmentExpression.Target as VariableReferenceExpression).Name == StreamsType.ThisStreams.Name) // "streams = ...;" { StreamAssignations.Add(assignmentExpression, parentBlock); } else if (assignmentExpression.Value is VariableReferenceExpression && (assignmentExpression.Value as VariableReferenceExpression).Name == StreamsType.ThisStreams.Name) // "... = streams;" { AssignationsToStream.Add(assignmentExpression, parentBlock); } } }
private void Visit(AssignmentExpression assignmentExpression) { if (currentAssignmentOperatorStatus != AssignmentOperatorStatus.Read) { errorWarningLog.Error(ParadoxMessageCode.ErrorNestedAssignment, assignmentExpression.Span, assignmentExpression, shaderName); } var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; assignmentExpression.Value = (Expression)VisitDynamic(assignmentExpression.Value); currentAssignmentOperatorStatus = (assignmentExpression.Operator != AssignmentOperator.Default) ? AssignmentOperatorStatus.ReadWrite : AssignmentOperatorStatus.Write; currentStreamUsage = StreamUsage.Write; assignmentExpression.Target = (Expression)VisitDynamic(assignmentExpression.Target); currentAssignmentOperatorStatus = AssignmentOperatorStatus.Read; currentStreamUsage = prevStreamUsage; if (assignmentExpression.Operator == AssignmentOperator.Default) { if (assignmentExpression.Target is VariableReferenceExpression && (assignmentExpression.Target as VariableReferenceExpression).Name.Text == "streams") // "streams = ...;" { StreamAssignations.Add(assignmentExpression); } else if (assignmentExpression.Value is VariableReferenceExpression && (assignmentExpression.Value as VariableReferenceExpression).Name.Text == "streams") // "... = streams;" { AssignationsToStream.Add(assignmentExpression); } } }
protected void Visit(UnaryExpression expression) { var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; Visit((Node)expression); currentStreamUsage = prevStreamUsage; }
public override void Visit(UnaryExpression expression) { var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; base.Visit(expression); currentStreamUsage = prevStreamUsage; }
protected void Visit(MemberReferenceExpression memberReferenceExpression) { var usageCopy = currentStreamUsage; currentStreamUsage |= StreamUsage.Partial; Visit((Node)memberReferenceExpression); currentStreamUsage = usageCopy; // check if it is a stream if (IsStreamMember(memberReferenceExpression)) { AddStreamUsage(memberReferenceExpression.TypeInference.Declaration as Variable, memberReferenceExpression, currentStreamUsage); } }
/// <summary> /// Adds a stream usage to the current method /// </summary> /// <param name="variable">the stream Variable</param> /// <param name="expression">the calling expression</param> /// <param name="usage">the encountered usage</param> private void AddStreamUsage(Variable variable, SiliconStudio.Shaders.Ast.Expression expression, StreamUsage usage) { currentStreamUsageList.Add(new StreamUsageInfo { CallType = StreamCallType.Member, Variable = variable, Expression = expression, Usage = usage }); }
/// <summary> /// Adds a stream usage to the current method /// </summary> /// <param name="variable">the stream Variable</param> /// <param name="expression">the calling expression</param> /// <param name="usage">the encountered usage</param> private void AddStreamUsage(Variable variable, SiliconStudio.Shaders.Ast.Expression expression, StreamUsage usage) { currentStreamUsageList.Add(new StreamUsageInfo { CallType = StreamCallType.Member, Variable = variable, Expression = expression, Usage = usage }); }
/// <summary> /// Analyse the AssignmentExpression to correctly infer the potential stream usage /// </summary> /// <param name="assignmentExpression">the AssignmentExpression</param> public override void Visit(AssignmentExpression assignmentExpression) { if (currentAssignmentOperatorStatus != AssignmentOperatorStatus.Read) errorWarningLog.Error(XenkoMessageCode.ErrorNestedAssignment, assignmentExpression.Span, assignmentExpression, shaderName); var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; assignmentExpression.Value = (Expression)VisitDynamic(assignmentExpression.Value); currentAssignmentOperatorStatus = (assignmentExpression.Operator != AssignmentOperator.Default) ? AssignmentOperatorStatus.ReadWrite : AssignmentOperatorStatus.Write; currentStreamUsage = StreamUsage.Write; assignmentExpression.Target = (Expression)VisitDynamic(assignmentExpression.Target); currentAssignmentOperatorStatus = AssignmentOperatorStatus.Read; currentStreamUsage = prevStreamUsage; var parentBlock = this.NodeStack.OfType<StatementList>().LastOrDefault(); if (assignmentExpression.Operator == AssignmentOperator.Default && parentBlock != null) { if (assignmentExpression.Target is VariableReferenceExpression && (assignmentExpression.Target as VariableReferenceExpression).Name == StreamsType.ThisStreams.Name) // "streams = ...;" StreamAssignations.Add(assignmentExpression, parentBlock); else if (assignmentExpression.Value is VariableReferenceExpression && (assignmentExpression.Value as VariableReferenceExpression).Name == StreamsType.ThisStreams.Name) // "... = streams;" AssignationsToStream.Add(assignmentExpression, parentBlock); } }
public override void Visit(UnaryExpression expression) { var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; base.Visit(expression); currentStreamUsage = prevStreamUsage; }
public override void Visit(MemberReferenceExpression memberReferenceExpression) { var usageCopy = currentStreamUsage; currentStreamUsage |= StreamUsage.Partial; base.Visit(memberReferenceExpression); currentStreamUsage = usageCopy; // check if it is a stream if (IsStreamMember(memberReferenceExpression)) AddStreamUsage(memberReferenceExpression.TypeInference.Declaration as Variable, memberReferenceExpression, currentStreamUsage); }
public static bool IsPartial(this StreamUsage usage) { return((usage & StreamUsage.Partial) != 0); }
public static bool IsWrite(this StreamUsage usage) { return((usage & StreamUsage.Write) != 0); }
public static bool IsRead(this StreamUsage usage) { return((usage & StreamUsage.Read) != 0); }
protected void Visit(UnaryExpression expression) { var prevStreamUsage = currentStreamUsage; currentStreamUsage = StreamUsage.Read; Visit((Node)expression); currentStreamUsage = prevStreamUsage; }