public override void CheckSemantics(Scope scope, List <SemanticError> errors) { //-------------------------------------------------- // Hacer 'CheckSemantics' A Los Hijos. //-------------------------------------------------- this.IfNode.CheckSemantics(scope, errors); this.ThenNode.CheckSemantics(scope, errors); this.ElseNode.CheckSemantics(scope, errors); //-------------------------------------------------- // Poner El Valor De Retorno De La Expresión A 'Error' // Por Default. //-------------------------------------------------- this.ExpressionType = PredefinedTypes.ErrorType; //-------------------------------------------------- // Si Ha Ocurrido Un Error En Alguno De Los Hijos, // Parar De Reportar Errores. //-------------------------------------------------- if (this.IfNode.ExpressionType == PredefinedTypes.ErrorType || this.ThenNode.ExpressionType == PredefinedTypes.ErrorType || this.ElseNode.ExpressionType == PredefinedTypes.ErrorType) { return; } //-------------------------------------------------- // La Condición Debe Ser De Tipo <int>. //-------------------------------------------------- if (this.IfNode.ExpressionType != PredefinedTypes.IntType) { errors.Add(SemanticError.InvalidTypeConvertion(PredefinedTypes.IntType, this.IfNode.ExpressionType, this.IfNode)); } else { //-------------------------------------------------- // Debe Haber Conversión Entre El Tipo Del 'Then' Y // Del 'Else'. //-------------------------------------------------- if (SemanticError.CompatibleTypes(this.ThenNode.ExpressionType, this.ElseNode.ExpressionType)) { this.ExpressionType = this.ThenNode.ExpressionType; } else if (SemanticError.CompatibleTypes(this.ElseNode.ExpressionType, this.ThenNode.ExpressionType)) { this.ExpressionType = this.ElseNode.ExpressionType; } else { errors.Add(SemanticError.IncompatibleTypesInIfThenElse(this)); } } }