Beispiel #1
0
        public override void CheckSemantics(Scope scope, List <SemanticError> errors)
        {
            //--------------------------------------------------
            // Hacer 'CheckSemantics' A Los Hijos.
            //--------------------------------------------------
            this.LeftVariable.CheckSemantics(scope, errors);
            this.Value.CheckSemantics(scope, errors);

            //--------------------------------------------------
            // Poner Por Defecto Que Hay Errores.
            //--------------------------------------------------
            this.ExpressionType = PredefinedTypes.ErrorType;

            //--------------------------------------------------
            // Si Ha Ocurrido Un Error En Alguno De Los Hijos,
            // Parar De Reportar Errores.
            //--------------------------------------------------
            if (this.LeftVariable.ExpressionType == PredefinedTypes.ErrorType ||
                this.Value.ExpressionType == PredefinedTypes.ErrorType)
            {
                return;
            }

            if (this.LeftVariable.ReadOnly)
            {
                errors.Add(SemanticError.InvalidUseOfAssignmentToAReadonlyVariable(this.LeftVariable));
                return;
            }

            if (!SemanticError.CompatibleTypes(this.LeftVariable.ExpressionType, this.Value.ExpressionType))
            {
                errors.Add(SemanticError.ExpectedType(this.LeftVariable.ExpressionType,
                                                      this.Value.ExpressionType, this));
            }
            else
            {
                this.ExpressionType = PredefinedTypes.VoidType;
            }
        }