Exemple #1
0
        private DataType InferInvocationType(InvocationSyntax invocation)
        {
            // This could:
            // * Invoke a stand alone function
            // * Invoke a static function
            // * Invoke a method
            // * Invoke a function pointer
            var argumentTypes = invocation.Arguments.Select(InferArgumentType).ToFixedList();

            InferExpressionTypeInInvocation(invocation.Callee, argumentTypes);
            var callee = invocation.Callee.Type;

            if (callee is FunctionType functionType)
            {
                foreach (var(arg, type) in invocation.Arguments.Zip(functionType.ParameterTypes))
                {
                    InsertImplicitConversionIfNeeded(ref arg.Value, type);
                    CheckArgumentTypeCompatibility(type, arg);
                }

                return(invocation.Type = functionType.ReturnType);
            }

            // If it is unknown, we already reported an error
            if (callee == DataType.Unknown)
            {
                return(invocation.Type = DataType.Unknown);
            }

            diagnostics.Add(TypeError.MustBeCallable(file, invocation.Callee));
            return(invocation.Type = DataType.Unknown);
        }
        public static void Render(TypeError type, WebContext context, String info = "default")
        {
            var status = string.Empty;

            switch (type)
            {
            case TypeError._200: status = "200 OK";                 break;

            case TypeError._404: status = "404 Page Not Found";     break;

            case TypeError._405: status = "405 Method Not Allowed"; break;
            }

            var fullpath = Directory.GetCurrentDirectory() + "/../../Views/Error/" + (int)type;
            var file     = new FileInfo(fullpath);

            var fs     = file.OpenRead();
            var reader = new StreamReader(fs);
            var data   = reader.ReadToEnd();

            if (string.Compare(info, "default", true) != 0)
            {
                data = data.Replace("{{info}}", info);
            }
            else
            {
                data = data.Replace("{{info}}", "");
            }

            context.Response.Status = status;
            context.Response.Write(data);
        }
Exemple #3
0
        public AddEditTypeImageViewModel(Window window, ITypeImageService images, bool isAddMode)
        {
            Window = window;
            if (window != null)
            {
                window.Title = $"{(isAddMode ? "Edit" : "Add")} Image";
            }

            Window.DataContext = this;

            IsAddMode  = isAddMode;
            imageError = isAddMode ? ImageError.NotSpecified : ImageError.NoError;
            typeError  = isAddMode ? TypeError.NotSpecified : TypeError.NoError;

            Accept = new DelegateCommand(e => CloseDialog(true), c => IsValid);
            Reject = new DelegateCommand(e => CloseDialog(false));
            Browse = new DelegateCommand(BrowseForImageFiles);

            ImageService = images;

            UpdateErrorMessage(false);

            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "FileName")
                {
                    LoadImageFromFileName(FileName);
                }
            };
        }
Exemple #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence fn_round_half_to_even(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence fn_round_half_to_even(ICollection args)
        {
            if (args.Count > 2 || args.Count <= 1)
            {
                throw new DynamicError(TypeError.invalid_type(null));
            }

            IEnumerator argIt = args.GetEnumerator();

            argIt.MoveNext();
            ResultSequence rsArg1 = (ResultSequence)argIt.Current;

            argIt.MoveNext();
            ResultSequence rsPrecision = (ResultSequence)argIt.Current;

            NumericType nt = FnAbs.get_single_numeric_arg(rsArg1);

            // empty arg
            if (nt == null)
            {
                return(ResultBuffer.EMPTY);
            }

            NumericType ntPrecision = (NumericType)rsPrecision.first();

            return(nt.round_half_to_even(int.Parse(ntPrecision.StringValue)));
        }
        public AddEditTypeImageViewModel(Window window, ITypeImageService images, bool isAddMode)
        {
            this.window = window;
            if (window != null)
            {
                window.Title = string.Format("{0} Image", isAddMode ? "Edit" : "Add");
            }

            this.window.DataContext = this;

            _isAddMode = isAddMode;
            imageError = isAddMode ? ImageError.NotSpecified : ImageError.NoError;
            typeError = isAddMode ? TypeError.NotSpecified : TypeError.NoError;

            Accept = new DelegateCommand(e => CloseDialog(true), c => IsValid);
            Reject = new DelegateCommand(e => CloseDialog(false));
            Browse = new DelegateCommand(BrowseForImageFiles);

            ImageService = images;

            UpdateErrorMessage(false);

            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "FileName")
                {
                    LoadImageFromFileName(FileName);
                }
            };
        }
Exemple #6
0
        /// <summary>
        /// Prefix-from-QName operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:prefix-from-QName operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence inScopePrefixes(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence inScopePrefixes(ICollection args, DynamicContext dc)
        {
            //		Collection cargs = Function.convert_arguments(args, expected_args());
            ICollection cargs = args;
            var         i     = cargs.GetEnumerator();

            i.MoveNext();
            ResultSequence arg1 = (ResultSequence)i.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            ResultBuffer rs = new ResultBuffer();

            Item anytype = arg1.item(0);

            if (!(anytype is ElementType))
            {
                throw new DynamicError(TypeError.invalid_type(null));
            }

            ElementType element    = (ElementType)anytype;
            IList       prefixList = lookupPrefixes(element);

            createPrefixResultSet(rs, prefixList);
            return(rs.Sequence);
        }
Exemple #7
0
        /// <summary>
        /// Converts arguments to values.
        /// </summary>
        /// <param name="args">
        ///            Result from expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of conversion. </returns>
        private static ICollection value_convert_args(ICollection args)
        {
            var result = new ArrayList(args.Count);

            // atomize arguments
            for (IEnumerator i = args.GetEnumerator(); i.MoveNext();)
            {
                ResultSequence rs = (ResultSequence)i.Current;

                //FnData.fast_atomize(rs);
                rs = FnData.atomize(rs);

                if (rs.empty())
                {
                    return(new ArrayList());
                }

                if (rs.size() > 1)
                {
                    throw new DynamicError(TypeError.invalid_type(null));
                }

                Item arg = rs.first();

                if (arg is XSUntypedAtomic)
                {
                    arg = new XSString(arg.StringValue);
                }

                result.Add(arg);
            }

            return(result);
        }
Exemple #8
0
        public static void WriteLog(string logModule, string message, TypeError typeError)
        {
            try
            {
                switch (typeError)
                {
                case TypeError.Trace:
                    Logger.InfoFormat("{0} - {1}", logModule, message);
                    break;

                case TypeError.Warning:
                    Logger.WarnFormat("{0} - {1}", logModule, message);
                    break;

                case TypeError.Error:
                    Logger.ErrorFormat("{0} - {1}", logModule, message);
                    break;

                case TypeError.Debug:
                    Logger.DebugFormat("{0} - {1}", logModule, message);
                    break;
                }
            }
            catch
            {
            }
        }
Exemple #9
0
 public Package(Status status, T data, int code = 0, TypeError type = default)
 {
     Status = status;
     Data   = data;
     Code   = code;
     Type   = type.ToString();
 }
Exemple #10
0
        /// <summary>
        /// Insert-Before operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:insert-before operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence id(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence id(ICollection args, EvaluationContext context)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            ResultBuffer rs = new ResultBuffer();

            IEnumerator argIt = cargs.GetEnumerator();

            argIt.MoveNext();
            ResultSequence idrefRS = (ResultSequence)argIt.Current;

            string[] idrefst = idrefRS.first().StringValue.Split(" ", true);

            ArrayList      idrefs   = createIDRefs(idrefst);
            ResultSequence nodeArg  = null;
            NodeType       nodeType = null;

            if (argIt.MoveNext())
            {
                nodeArg  = (ResultSequence)argIt.Current;
                nodeType = (NodeType)nodeArg.first();
            }
            else
            {
                if (context.ContextItem == null)
                {
                    throw DynamicError.contextUndefined();
                }
                if (!(context.ContextItem is NodeType))
                {
                    throw new DynamicError(TypeError.invalid_type(null));
                }
                nodeType = (NodeType)context.ContextItem;
                if (nodeType.node_value().OwnerDocument == null)
                {
                    throw DynamicError.contextUndefined();
                }
            }

            Node node = nodeType.node_value();

            if (node.OwnerDocument == null)
            {
                // W3C Test suite seems to want XPDY0002
                throw DynamicError.contextUndefined();
                //throw DynamicError.noContextDoc();
            }

            if (hasIDREF(idrefs, node))
            {
                ElementType element = new ElementType((Element)node, context.StaticContext.TypeModel);
                rs.add(element);
            }

            processAttributes(node, idrefs, rs, context);
            processChildNodes(node, idrefs, rs, context);

            return(rs.Sequence);
        }
Exemple #11
0
        private DataType InferBinaryExpressionType(
            BinaryExpressionSyntax binaryExpression)
        {
            InferExpressionType(binaryExpression.LeftOperand);
            var leftType  = binaryExpression.LeftOperand.Type;
            var @operator = binaryExpression.Operator;

            InferExpressionType(binaryExpression.RightOperand);
            var rightType = binaryExpression.RightOperand.Type;

            // If either is unknown, then we can't know whether there is a a problem.
            // Note that the operator could be overloaded
            if (leftType == DataType.Unknown || rightType == DataType.Unknown)
            {
                return(binaryExpression.Type = DataType.Unknown);
            }

            bool compatible;

            switch (@operator)
            {
            case BinaryOperator.Plus:
            case BinaryOperator.Minus:
            case BinaryOperator.Asterisk:
            case BinaryOperator.Slash:
                compatible            = NumericOperatorTypesAreCompatible(ref binaryExpression.LeftOperand, ref binaryExpression.RightOperand, null);
                binaryExpression.Type = compatible ? leftType : DataType.Unknown;
                break;

            case BinaryOperator.EqualsEquals:
            case BinaryOperator.NotEqual:
            case BinaryOperator.LessThan:
            case BinaryOperator.LessThanOrEqual:
            case BinaryOperator.GreaterThan:
            case BinaryOperator.GreaterThanOrEqual:
                compatible = (leftType == DataType.Bool && rightType == DataType.Bool) ||
                             NumericOperatorTypesAreCompatible(ref binaryExpression.LeftOperand, ref binaryExpression.RightOperand, null);
                binaryExpression.Type = DataType.Bool;
                break;

            case BinaryOperator.And:
            case BinaryOperator.Or:
                compatible            = leftType == DataType.Bool && rightType == DataType.Bool;
                binaryExpression.Type = DataType.Bool;
                break;

            default:
                throw NonExhaustiveMatchException.ForEnum(@operator);
            }
            if (!compatible)
            {
                diagnostics.Add(TypeError.OperatorCannotBeAppliedToOperandsOfType(file,
                                                                                  binaryExpression.Span, @operator,
                                                                                  binaryExpression.LeftOperand.Type,
                                                                                  binaryExpression.RightOperand.Type));
            }

            return(binaryExpression.Type);
        }
Exemple #12
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string description)
 {
     _typeErreur  = typeErreur;
     _description = description;
     _severity    = severity;
     _codeMessage = string.Empty;
     _isCodeMessageFromFrameWork = false;
 }
Exemple #13
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string description)
 {
     _typeErreur = typeErreur;
     _description = description;
     _severity = severity;
     _codeMessage = string.Empty;
     _isCodeMessageFromFrameWork = false;
 }
Exemple #14
0
 public static KeyMsg GetError(TypeError key)
 {
     if (Error.All(_ => _.Key != (int)key))
     {
         throw new Exception($"Данного ключа:{key} нет в списке.");
     }
     return(Error.FirstOrDefault(_ => _.Key == (int)key));
 }
Exemple #15
0
    public void setError(TypeErrorKnownValues new_value)
    {
        TypeError new_full_value = new TypeError();

        Debug.Assert(new_value != TypeErrorKnownValues.Error__none);
        new_full_value.in_known_list = true;
        new_full_value.list_value    = new_value;
        setError(new_full_value);
    }
Exemple #16
0
        private void CheckArgumentTypeCompatibility(DataType type, ArgumentSyntax arg)
        {
            var fromType = arg.Value.Type;

            if (!IsAssignableFrom(type, fromType))
            {
                diagnostics.Add(TypeError.CannotConvert(file, arg.Value, fromType, type));
            }
        }
Exemple #17
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code de message de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si l'erreur provient du framework </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string codeMessage,
                      string description, bool isCodeMessageFromFrameWork)
 {
     _typeErreur  = typeErreur;
     _description = description;
     _severity    = severity;
     _codeMessage = codeMessage;
     _description = description;
     _isCodeMessageFromFrameWork = isCodeMessageFromFrameWork;
 }
Exemple #18
0
        public String GetMessageError(Int32?errorId, TypeError type)
        {
            String message = configuration.GetSection($"{type.ToString()}:{errorId}").Value;

            if (String.IsNullOrEmpty(message))
            {
                message = $"Unhandled error. {errorId}";
            }

            return(message);
        }
Exemple #19
0
 private static Responses.ErrorResponse DEFAULT(string pMessage = null, TypeError pTypeError = TypeError.DEFAULT)
 {
     return(new Responses.ErrorResponse()
     {
         error = true,
         type = pTypeError,
         message = new HashSet <string>()
         {
             BaseError.DEFAULT(pMessage)
         }
     });
 }
Exemple #20
0
        /// <summary>
        /// Devuelve un objeto con toda la info de un error sucedido para agregar a la lista de errores (traza de errores)
        /// </summary>
        /// <param name="infoEx"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        private ClassError GetInfoError(Exception infoEx, string action, TypeError error)
        {
            ClassError InfoError = new ClassError
            {
                Error         = error,
                Source        = infoEx.Source,
                ErrorMessage  = infoEx.Message,
                AditionalInfo = string.Format("Acción que ha provocado el error: {0}", action),
                DateError     = DateTime.Now
            };

            return(InfoError);
        }
Exemple #21
0
    public string  getErrorAsString()
    {
        TypeError result = getError();

        if (result.in_known_list)
        {
            return(stringFromError(result.list_value));
        }
        else
        {
            return(result.string_value);
        }
    }
Exemple #22
0
        public DataType CheckExpressionType(
            ExpressionSyntax expression,
            DataType expectedType)
        {
            var actualType = InferExpressionType(expression);

            // TODO check for type compatibility not equality
            if (!expectedType.Equals(actualType))
            {
                diagnostics.Add(TypeError.CannotConvert(file, expression, actualType, expectedType));
            }
            return(actualType);
        }
Exemple #23
0
        public static Form Alert(this Form Frm, string Message, TypeError Type = TypeError.Exclamation)
        {
            if (Type.Equals(TypeError.Exclamation))
            {
                MessageBox.Show(Message, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                MessageBox.Show(Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(Frm);
        }
Exemple #24
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code de message de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si l'erreur provient du framework </param>
 /// <param name="parameters"> Liste de paramètres qui se rattache à l'erreur </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string codeMessage,
                      string description, bool isCodeMessageFromFrameWork, params string[] parameters)
 {
     _typeErreur  = typeErreur;
     _description = description;
     _severity    = severity;
     _codeMessage = codeMessage;
     _description = description;
     _isCodeMessageFromFrameWork = isCodeMessageFromFrameWork;
     foreach (var t in parameters)
     {
         _parametersList.Add(t);
     }
 }
Exemple #25
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code de message de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si l'erreur provient du framework </param>
 /// <param name="parametersList"> Liste de paramètres qui se rattache à l'erreur </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string codeMessage, string description,
                      bool isCodeMessageFromFrameWork, IEnumerable <string> parametersList)
 {
     _typeErreur  = typeErreur;
     _description = description;
     _severity    = severity;
     _codeMessage = codeMessage;
     _description = description;
     _isCodeMessageFromFrameWork = isCodeMessageFromFrameWork;
     foreach (var x in parametersList)
     {
         _parametersList.Add(x);
     }
 }
Exemple #26
0
    // -----------------------------------------

    public static void showError(TypeError typeError, GameScene fromScene = GameScene.UNDEF)
    {
        //currentTypeError = typeError;
        switch (typeError)
        {
        case TypeError.ES_NEED_UPDATE: {
            //Ваша версия устарела, нужно обновится до последней версии
            var wnd = showError("Ваша версия не совместима, обновитесь до последней версии", typeError, "Выход");
            //wnd.setAction(0, () => { /* ЗДЕСЬ НУЖНО ОБНОВИТЬСЯ */ wnd.hideWindow(); });
            //wnd.setAction(1, exit);
            wnd.setAction(0, () => { MAIN.exit(); });
        } break;

        case TypeError.ES_SERVER_ERROR: { showErrorAndReAutification("Ошибка сервера", fromScene); }  break;

        case TypeError.ES_SESSION_EXPIRED: { showErrorAndReAutification("Время сессии истекло войдите заново", fromScene); }  break;

        case TypeError.ES_CONNECT_ERROR: { showConnectError("Ошибка связи", fromScene); } break;

        case TypeError.EP_ON_INITIALIZE_FAILED: buyError(); break;

        case TypeError.EP_ON_BUY_NOT_FIND: buyError(); break;

        case TypeError.EP_ON_FAILED_CONFIRM_PURCHASE: buyError("Ошибка покупки, обратитесь в техническую поддержку"); break;

        case TypeError.EC_NOT_ENOUGH_MONEY: {
            var wnd = show("Недостаточно денег!");
            wnd.setAction(0, () => {
                    if (!Tutorial.show(TutorialSubject.TS_BUY_GOLD_BTN))
                    {
                        WindowController.showPopUpWindow(WindowController.TypePopUpWindow.GOLD_EXCHANGE);
                        Tutorial.show();     // В этом месте обрывается обучения, для избежании этого вызвается команда показать без параметров, в ней внутри перепроверяется наличие списка сообщений которые нужно показать, и если список не пустой обучение продолжается
                    }
                });
        } break;

        case TypeError.EC_NOT_ENOUGH_RUBINS: {
            //WindowController.showPopUpWindow(WindowController.TypePopUpWindow.CRYSTALS_BUY);
            var wnd = show("Недостаточно рубинов!");
            wnd.setAction(0, () => {
                    WindowController.showPopUpWindow(WindowController.TypePopUpWindow.CRYSTALS_BUY);
                    Tutorial.show();     // В этом месте обрывается обучения, для избежании этого вызвается команда показать без параметров, в ней внутри перепроверяется наличие списка сообщений которые нужно показать, и если список не пустой обучение продолжается
                });
        } break;

        default: { show("Неизвестная ошибка"); } break;
        }
    }
Exemple #27
0
    public static ErrorWindow showError(string text, TypeError typeError_, params string[] btnText)
    {
        //Debug.Log("Error! \"" + text + "\", from game scene:" + typeError_.ToString() + Application.stackTraceLogType);
        //Application.RegisterLogCallback(HandleLog);
        //Application.logMessageReceived
        //var resourses = RESOURCES.getResources;
        var        errorWindowPrefab   = RESOURCES.getPrefab("ErrorWindow");
        GameObject errorWindowCanvasGO = GameObject.Instantiate(errorWindowPrefab) as GameObject;

        errorWindowCanvasGO.name = "ErrorWindowCanvas";
        errorWindow = errorWindowCanvasGO.transform.FindChild("ErrorWindow").GetComponent <ErrorWindow>();
        errorWindow.init(text, typeError_, btnText);
        Utils.screenShot("OnError.png"); // только в режиме тестировки
        SoundsSystem.play(Sound.S_ERROR);
        return(errorWindow);
    }
Exemple #28
0
            protected override void handle_result(string result)
            {
                TypeErrorKnownValues known     = stringToError(result);
                TypeError            new_value = new TypeError();

                if (known == TypeErrorKnownValues.Error__none)
                {
                    new_value.in_known_list = false;
                    new_value.string_value  = result;
                }
                else
                {
                    new_value.in_known_list = true;
                    new_value.list_value    = known;
                }
                handle_result(new_value);
            }
Exemple #29
0
    public void setError(string chars)
    {
        TypeErrorKnownValues known     = stringToError(chars);
        TypeError            new_value = new TypeError();

        if (known == TypeErrorKnownValues.Error__none)
        {
            new_value.in_known_list = false;
            new_value.string_value  = chars;
        }
        else
        {
            new_value.in_known_list = true;
            new_value.list_value    = known;
        }
        setError(new_value);
    }
Exemple #30
0
        private void ResolveTypesInVariableDeclaration(
            VariableDeclarationStatementSyntax variableDeclaration)
        {
            InferExpressionType(variableDeclaration.Initializer);

            DataType type;

            if (variableDeclaration.TypeExpression != null)
            {
                type = CheckAndEvaluateTypeExpression(variableDeclaration.TypeExpression);
            }
            else if (variableDeclaration.Initializer != null)
            {
                type = variableDeclaration.Initializer.Type;
                // Use the initializer type unless it is constant
                switch (type)
                {
                case IntegerConstantType integerConstant:
                    var value     = integerConstant.Value;
                    var byteCount = value.GetByteCount();
                    type = byteCount <= 4 ? DataType.Int : DataType.Int64;
                    break;

                case StringConstantType stringConstant:
                    throw new NotImplementedException();
                }
            }
            else
            {
                diagnostics.Add(TypeError.NotImplemented(file, variableDeclaration.NameSpan,
                                                         "Inference of local variable types not implemented"));
                type = DataType.Unknown;
            }

            variableDeclaration.Type = type;
            if (variableDeclaration.Initializer != null)
            {
                InsertImplicitConversionIfNeeded(ref variableDeclaration.Initializer, type);
                var initializerType = variableDeclaration.Initializer.Type;
                if (!IsAssignableFrom(type, initializerType))
                {
                    diagnostics.Add(TypeError.CannotConvert(file, variableDeclaration.Initializer, initializerType, type));
                }
            }
        }
Exemple #31
0
        /// <summary>
        /// Evaluates a type expression to the type it identifies
        /// </summary>
        public DataType CheckAndEvaluateTypeExpression(ExpressionSyntax typeExpression)
        {
            if (typeExpression == null)
            {
                return(DataType.Unknown);
            }

            var type = InferExpressionType(typeExpression);

            if (type is UnknownType)
            {
                return(DataType.Unknown);
            }
            if (!IsType(type))
            {
                diagnostics.Add(TypeError.MustBeATypeExpression(file, typeExpression.Span));
                return(DataType.Unknown);
            }

            return(TypeExpressionEvaluator.EvaluateExpression(typeExpression));
        }
Exemple #32
0
        /// <summary>
        /// Gets the error message for the property with the given name.
        /// </summary>
        /// <returns>
        /// The error message for the property. The default is an empty string ("").
        /// </returns>
        /// <param name="fieldName">The name of the property whose error message to get.
        /// </param>
        public string this[string fieldName]
        {
            get
            {
                string error = null;

                if (IsAddMode && (fieldName == "Type" || fieldName == "Size"))
                {
                    var oldTypeError = typeError;

                    var options = new ImageOptions
                    {
                        Quality            = (ImageQuality)Enum.Parse(typeof(ImageQuality), Size),
                        AcceptLowerQuality = true,
                    };
                    if (!string.IsNullOrEmpty(Type) && ImageService?.Get(Type, options) != null)
                    {
                        typeError = TypeError.Duplicate;
                    }
                    else if (fieldName == "Type" && string.IsNullOrEmpty(Type))
                    {
                        typeError = TypeError.NotSpecified;
                    }
                    else if (fieldName == "Type" || fieldName == "Size")
                    {
                        typeError = TypeError.NoError;
                    }

                    error = typeErrorMessages[typeError];

                    if (oldTypeError != typeError)
                    {
                        UpdateErrorMessage(false);
                    }
                }

                return(error);
            }
        }
Exemple #33
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code de message de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si l'erreur provient du framework </param>
 /// <param name="parametersList"> Liste de paramètres qui se rattache à l'erreur </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string codeMessage, string description,
     bool isCodeMessageFromFrameWork, IEnumerable<string> parametersList)
 {
     _typeErreur = typeErreur;
     _description = description;
     _severity = severity;
     _codeMessage = codeMessage;
     _description = description;
     _isCodeMessageFromFrameWork = isCodeMessageFromFrameWork;
     foreach (var x in parametersList)
     {
         _parametersList.Add(x);
     }
 }
Exemple #34
0
 /// <summary>
 ///     Constructeur de la classe. Ajoute automatiquement un message du type souhaité et de sévérité "Erreur"
 ///     à la liste.
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="codeMessage"> Code du message de l'erreur </param>
 /// <param name="description"> Informations de l'exception </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si le message provient du framework </param>
 public ProcessResults(TypeError typeErreur, string codeMessage, string description,
     bool isCodeMessageFromFrameWork)
 {
     _messageList.Add(new ReturnMessage(typeErreur, Severity.Error, codeMessage, description,
         isCodeMessageFromFrameWork));
 }
Exemple #35
0
 /// <summary>
 ///     Constructeur de la classe. Ajoute automatiquement un message du type souhaité et de sévérité souhaité
 ///     à la liste.
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code du message de l'erreur </param>
 /// <param name="description"> Informations de l'exception </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si le message provient du framework </param>
 /// <param name="parametres"> Tableau (array) de paramètres reliés à l'exception </param>
 public ProcessResults(TypeError typeErreur, Severity severity, string codeMessage,
     string description, bool isCodeMessageFromFrameWork, params string[] parametres)
 {
     _messageList.Add(new ReturnMessage(typeErreur, severity, codeMessage, description,
         isCodeMessageFromFrameWork, parametres));
 }
Exemple #36
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code de message de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si l'erreur provient du framework </param>
 /// <param name="parameters"> Liste de paramètres qui se rattache à l'erreur </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string codeMessage,
     string description, bool isCodeMessageFromFrameWork, params string[] parameters)
 {
     _typeErreur = typeErreur;
     _description = description;
     _severity = severity;
     _codeMessage = codeMessage;
     _description = description;
     _isCodeMessageFromFrameWork = isCodeMessageFromFrameWork;
     foreach (var t in parameters)
     {
         _parametersList.Add(t);
     }
 }
 assert_raises(TypeError, cval.train_test_split, range(3),
        /// <summary>
        /// Gets the error message for the property with the given name.
        /// </summary>
        /// <returns>
        /// The error message for the property. The default is an empty string ("").
        /// </returns>
        /// <param name="fieldName">The name of the property whose error message to get. 
        /// </param>
        public string this[string fieldName]
        {
            get
            {
                string error = null;

                if (_isAddMode && (fieldName == "Type" || fieldName == "Size"))
                {
                    var oldTypeError = typeError;

                    // TODO: need to be aware of the different qualities of images, using best available
                    var selectedSize = (ImageQuality)Enum.Parse(typeof(ImageQuality), Size);
                    if (!string.IsNullOrEmpty(Type)
                        && ImageService != null
                        && ImageService.Get(Type, selectedSize, false, false) != null)
                    {
                        typeError = TypeError.Duplicate;
                    }
                    else if (fieldName == "Type" && string.IsNullOrEmpty(Type))
                    {
                        typeError = TypeError.NotSpecified;
                    }
                    else if (fieldName == "Type" || fieldName == "Size")
                    {
                        typeError = TypeError.NoError;
                    }

                    error = typeErrorMessages[typeError];

                    if (oldTypeError != typeError)
                    {
                        UpdateErrorMessage(false);
                    }
                }

                return error;
            }
        }
Exemple #39
0
 /// <summary>
 ///     Constructeur de l'objet ReturnMessage
 /// </summary>
 /// <param name="typeErreur"> Type de l'erreur </param>
 /// <param name="severity"> Sévérité de l'erreur </param>
 /// <param name="codeMessage"> Code de message de l'erreur </param>
 /// <param name="description"> Informations de l'erreur </param>
 /// <param name="isCodeMessageFromFrameWork"> Booléen indiquant si l'erreur provient du framework </param>
 public ReturnMessage(TypeError typeErreur, Severity severity, string codeMessage,
     string description, bool isCodeMessageFromFrameWork)
 {
     _typeErreur = typeErreur;
     _description = description;
     _severity = severity;
     _codeMessage = codeMessage;
     _description = description;
     _isCodeMessageFromFrameWork = isCodeMessageFromFrameWork;
 }