/// <summary>
        ///     Provides the changes performed by this statement
        /// </summary>
        /// <param name="context">The context on which the changes should be computed</param>
        /// <param name="changes">The list to fill with the changes</param>
        /// <param name="explanation">The explanatino to fill, if any</param>
        /// <param name="apply">Indicates that the changes should be applied immediately</param>
        /// <param name="runner"></param>
        public override void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation,
                                        bool apply, Runner runner)
        {
            IVariable var = VariableIdentification.GetVariable(context);

            if (var != null)
            {
                IValue value = Expression.GetExpressionValue(context, explanation);
                if (value != null)
                {
                    value = value.RightSide(var, true, true);
                }

                Range      range      = var.Type as Range;
                Collection collection = var.Type as Collection;
                if (range != null && range.convert(value) == null)
                {
                    AddError("Value " + value + " is outside range", RuleChecksEnum.ExecutionFailed);
                }
                else if (collection != null && collection.convert(value) == null)
                {
                    AddError("Value " + value + " cannot be assigned to variable", RuleChecksEnum.ExecutionFailed);
                }
                else
                {
                    Change change = new Change(var, var.Value, value);
                    changes.Add(change, apply, runner);
                    ExplanationPart.CreateSubExplanation(explanation, Root, change);
                }
            }
            else
            {
                AddError("Cannot find variable " + VariableIdentification, RuleChecksEnum.ExecutionFailed);
            }
        }
        /// <summary>
        ///     Checks the statement for semantical errors
        /// </summary>
        public override void CheckStatement()
        {
            VariableIdentification.CheckExpression();
            if (VariableIdentification.Ref is Parameter)
            {
                Root.AddError("Cannot assign a value to a parameter (" + VariableIdentification + ")");
            }

            if (VariableIdentification.Ref == null)
            {
                Root.AddError("Cannot assign a value to " + VariableIdentification);
            }

            Type targetType = VariableIdentification.GetExpressionType();

            if (targetType == null)
            {
                Root.AddError("Cannot determine type of target " + VariableIdentification);
            }
            else if (Expression != null)
            {
                Expression.CheckExpression();

                Type type = Expression.GetExpressionType();
                if (type != null)
                {
                    if (!targetType.Match(type))
                    {
                        UnaryExpression unaryExpression = Expression as UnaryExpression;
                        if (unaryExpression != null && unaryExpression.Term.LiteralValue != null)
                        {
                            Root.AddError("Expression " + Expression + " does not fit in variable " +
                                          VariableIdentification);
                        }
                        else
                        {
                            Root.AddError("Expression [" + Expression + "] type (" + type.FullName +
                                          ") does not match variable [" + VariableIdentification +
                                          "] type (" + targetType.FullName + ")");
                        }
                    }
                    else
                    {
                        Range rangeType = targetType as Range;
                        if (rangeType != null)
                        {
                            IValue value = Expression.Ref as IValue;
                            if (value != null)
                            {
                                if (rangeType.convert(value) == null)
                                {
                                    Root.AddError("Cannot set " + value.LiteralName + " in variable of type " +
                                                  rangeType.Name);
                                }
                            }
                        }
                    }

                    if (Expression.Ref == EfsSystem.Instance.EmptyValue)
                    {
                        if (targetType is Collection)
                        {
                            Root.AddError("Assignation of " + Expression.Ref.Name +
                                          " cannot be performed on variables of type collection. Use [] instead.");
                        }
                    }
                }
                else
                {
                    Root.AddError("Cannot determine expression type (3) for " + Expression);
                }
            }
            else
            {
                Root.AddError("Invalid expression in assignment");
            }
            // Check that the incoming variables are not modified
            if (EnclosingFinder <DataDictionary.Types.NameSpace> .find(Root, true) != null)
            {
                IVariable variable = VariableIdentification.Ref as IVariable;
                if (variable != null && variable.Mode == acceptor.VariableModeEnumType.aIncoming)
                {
                    Root.AddError("An incoming variable cannot be written");
                }
            }
        }