Example #1
0
        public override void CheckSemantics(Scope scope, List <SemanticError> errors)
        {
            //--------------------------------------------------
            // Hacer 'CheckSemantics' Al Hijo.
            //--------------------------------------------------
            this.LeftVariable.CheckSemantics(scope, errors);

            //--------------------------------------------------
            // ...
            //--------------------------------------------------
            this.ReadOnly = this.LeftVariable.ReadOnly;

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

            //--------------------------------------------------
            // Si Ha Ocurrido Un Error, Parar De Reportar Errores.
            //--------------------------------------------------
            if (LeftVariable.ExpressionType == PredefinedTypes.ErrorType)
            {
                return;
            }

            var RT = this.LeftVariable.ExpressionType as RecordTypeNode;

            //--------------------------------------------------
            // Si La Variable No Es Un Record, Reportar Error.
            //--------------------------------------------------
            if (RT == null)
            {
                errors.Add(SemanticError.InvalidAccessToAField(this.Field.Text,
                                                               this.LeftVariable.ExpressionType, this));
                return;
            }

            //--------------------------------------------------
            // Buscar El Nombre Del Campo ...
            //--------------------------------------------------
            var FT = RT.Fields.FirstOrDefault(x => x.ID.Name == this.Field.Name);

            if (FT == null)
            {
                errors.Add(SemanticError.InvalidAccessToAField(this.Field.Text,
                                                               this.LeftVariable.ExpressionType, this
                                                               ));
            }
            else
            {
                this.ExpressionType = FT.VariableInfo.TypeNode;
            }
        }