public override void CheckSemantics(Scope scope, List <SemanticError> errors) { //-------------------------------------------------- // Buscar El FunctionInfo Correspondiente. //-------------------------------------------------- this.FunctionInfo = scope.FindFunctionInfo(ID.Name); //-------------------------------------------------- // Poner Por Defecto Que Hay Errores. //-------------------------------------------------- this.ExpressionType = PredefinedTypes.ErrorType; //-------------------------------------------------- // Si La Función No Existe, Reportar Error. //-------------------------------------------------- if (this.FunctionInfo == null) { errors.Add(SemanticError.FunctionDoesNotExist(this.ID.Name, this)); return; } //-------------------------------------------------- // Si La Cantidad De Argumentos Es Diferente A La // Cantidad De Parámetros, Reportar Error. //-------------------------------------------------- var parameters = this.FunctionInfo.Parameters; if (this.Arguments.Count() != parameters.Length) { errors.Add(SemanticError.WrongParameterNumber(this.ID.Name, parameters.Length, this.Arguments.Count(), this)); return; } //-------------------------------------------------- // Hacer 'CheckSemantics' A Cada Argumento. //-------------------------------------------------- bool IsOk = true; foreach (var argument in this.Arguments) { argument.CheckSemantics(scope, errors); if (argument.ExpressionType == PredefinedTypes.ErrorType) { IsOk = false; } } //-------------------------------------------------- // Si Hay Errores En Los Argumentos, Parar De // Reportar Errores. //-------------------------------------------------- if (!IsOk) { return; } //-------------------------------------------------- // Comprobar Que Los Tipos De Los Argumentos Son Iguales // A Los Tipos De Los Parámetros Correspondientes. //-------------------------------------------------- for (int i = 0; i < parameters.Length; i++) { var arg = this.Arguments.ElementAt(i); if (!SemanticError.CompatibleTypes(parameters[i].TypeNode, arg.ExpressionType)) { errors.Add(SemanticError.InvalidTypeConvertion(parameters[i].TypeNode, arg.ExpressionType, arg)); IsOk = false; } } if (IsOk) { this.ExpressionType = this.FunctionInfo.ReturnType; } }