예제 #1
0
        protected virtual void Visit(AssignmentExpression assignmentExpression)
        {
            Visit((Node)assignmentExpression);

            // An assignment expression get the
            assignmentExpression.TypeInference = (TypeInference)assignmentExpression.Target.TypeInference.Clone();

            // TODO: check if types are compatible?
        }
예제 #2
0
        /// <summary>
        /// Visits the specified assignement expression.
        /// </summary>
        /// <param name="assignmentExpression">The assignement expression.</param>
        public override Node Visit(AssignmentExpression assignmentExpression)
        {
            base.Visit(assignmentExpression);

            // An assignment expression get the
            assignmentExpression.TypeInference = (TypeInference)assignmentExpression.Target.TypeInference.Clone();

            // TODO: check if types are compatible?
            return assignmentExpression;
        }
        /// <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;
        }
예제 #4
0
파일: ShaderWriter.cs 프로젝트: cg123/xenko
 public virtual void Visit(AssignmentExpression assignmentExpression)
 {
     VisitDynamic(assignmentExpression.Target);
     WriteSpace().Write(assignmentExpression.Operator.ConvertToString()).WriteSpace();
     VisitDynamic(assignmentExpression.Value);
 }
예제 #5
0
파일: CastAnalysis.cs 프로젝트: cg123/xenko
        protected void Visit(AssignmentExpression expression)
        {
            // First, dispatch to resolve type of node at deeper level
            Visit((Node)expression);

            var expressionType = expression.Target.TypeInference.TargetType;
            var targetType = expression.Target.TypeInference.ExpectedType ?? expressionType;
            expression.Value = Cast(expression.Value.TypeInference.TargetType, targetType, expression.Value);
        }
        /// <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);
            }
        }
예제 #7
0
        protected void Visit(AssignmentExpression assignmentExpression)
        {
            var variable = GetUniform(assignmentExpression.Target);
            bool isMemberExpression = assignmentExpression.Target is MemberReferenceExpression;
            if (variable != null)
            {
                // Default == operator is the only write only operators
                if (assignmentExpression.Operator == AssignmentOperator.Default && !uniformReadList.Contains(variable) && !this.UniformUsedWriteFirstList.Contains(variable))
                {
                    // Handle the case where the assignment operator is partial like vect.xy = 5; and later vect.zw += 6;
                    // In this case, the variable is considered as read and write (and not only write first)
                    if (isMemberExpression)
                    {
                        var variableType = variable.Type.ResolveType();

                        if (variableType is VectorType || variableType is MatrixType)
                        {
                            var dim = Math.Max(TypeBase.GetDimensionSize(variableType, 0), TypeBase.GetDimensionSize(variableType, 1));

                            var memberRef = assignmentExpression.Target as MemberReferenceExpression;
                            var numberOfMembers = memberRef.Member.Text.Length;

                            // If the variable is a global uniform, non static/const and is not already in the list used then
                            if (numberOfMembers < dim)
                            {
                                if (!uniformReadList.Contains(variable))
                                {
                                    uniformReadList.Add(variable);
                                }
                            }
                            else
                            {
                                UniformUsedWriteFirstList.Add(variable);
                            }
                        }
                    }
                    else
                    {
                        UniformUsedWriteFirstList.Add(variable);
                    }
                }
                if (assignmentExpression.Operator != AssignmentOperator.Default)
                {
                    if (!UniformReadWriteList.Contains(variable))
                        UniformReadWriteList.Add(variable);
                }
            }
        }
예제 #8
0
        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;
        }
예제 #9
0
 public override void Visit(AssignmentExpression assignmentExpression)
 {
     Identifier typeTarget;
     Identifier typeMember;
     if (TryParameters(assignmentExpression.Target, out typeTarget, out typeMember))
     {
         Write("context.SetParam(").Write(typeTarget).Write(".").Write(typeMember).Write(", ");
         VisitDynamic(assignmentExpression.Value);
         Write(")");
     }
     else
     {
         base.Visit(assignmentExpression);
     }
 }
예제 #10
0
        public override Node Visit(AssignmentExpression expression)
        {
            // First, dispatch to resolve type of node at deeper level
            base.Visit(expression);

            var expressionType = expression.Target.TypeInference.TargetType;
            var targetType = expression.Target.TypeInference.ExpectedType ?? expressionType;
            expression.Value = Cast(expression.Value.TypeInference.TargetType, targetType, expression.Value);

            return expression;
        }