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); } } }
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); } } }
/// <summary> /// Analyse the AssignmentExpression to correctly infer the potential stream usage /// </summary> /// <param name="assignmentExpression">the AssignmentExpression</param> public override Node Visit(AssignmentExpression assignmentExpression) { if (currentAssignmentOperatorStatus != AssignmentOperatorStatus.Read) Error(XenkoMessageCode.ErrorNestedAssignment, assignmentExpression.Span, assignmentExpression, analyzedModuleMixin.MixinName); assignmentExpression.Value = (Expression)VisitDynamic(assignmentExpression.Value); currentAssignmentOperatorStatus = (assignmentExpression.Operator != AssignmentOperator.Default) ? AssignmentOperatorStatus.ReadWrite : AssignmentOperatorStatus.Write; assignmentExpression.Target = (Expression)VisitDynamic(assignmentExpression.Target); currentAssignmentOperatorStatus = AssignmentOperatorStatus.Read; return assignmentExpression; }
/// <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); } }
protected override void Visit(AssignmentExpression assignmentExpression) { if (currentAssignmentOperatorStatus != AssignmentOperatorStatus.Read) Error(ParadoxMessageCode.ErrorNestedAssignment, assignmentExpression.Span, assignmentExpression, analyzedModuleMixin.MixinName); assignmentExpression.Value = (Expression)VisitDynamic(assignmentExpression.Value); currentAssignmentOperatorStatus = (assignmentExpression.Operator != AssignmentOperator.Default) ? AssignmentOperatorStatus.ReadWrite : AssignmentOperatorStatus.Write; assignmentExpression.Target = (Expression)VisitDynamic(assignmentExpression.Target); currentAssignmentOperatorStatus = AssignmentOperatorStatus.Read; }