CreateNumber() приватный Метод

Creates an instance of the number primitive.
private CreateNumber ( double value ) : SNumber
value double
Результат Pokemon3D.Scripting.Types.SNumber
Пример #1
0
        public static SObject ToPrimitive(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            if (parameters.Length == 0)
            {
                return(processor.Undefined);
            }

            if (parameters[0] is SString)
            {
                return(processor.CreateString(((SString)parameters[0]).Value));
            }
            else if (parameters[0] is SNumber)
            {
                return(processor.CreateNumber(((SNumber)parameters[0]).Value));
            }
            else if (parameters[0] is SBool)
            {
                return(processor.CreateBool(((SBool)parameters[0]).Value));
            }
            else
            {
                return(parameters[0]); // returns the input object, if no conversion was conducted.
            }
        }
Пример #2
0
        public static SObject ToPrimitive(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            if (parameters.Length == 0)
                return processor.Undefined;

            if (parameters[0] is SString)
                return processor.CreateString(((SString)parameters[0]).Value);
            else if (parameters[0] is SNumber)
                return processor.CreateNumber(((SNumber)parameters[0]).Value);
            else if (parameters[0] is SBool)
                return processor.CreateBool(((SBool)parameters[0]).Value);
            else
                return parameters[0]; // returns the input object, if no conversion was conducted.
        }
Пример #3
0
 public static SObject SizeOf(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters) =>
     parameters.Length == 0 ? processor.Undefined : processor.CreateNumber(parameters[0].SizeOf());
Пример #4
0
 public static SObject SizeOf(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters) =>
 parameters.Length == 0 ? processor.Undefined : processor.CreateNumber(parameters[0].SizeOf());
Пример #5
0
        /// <summary>
        /// Throws an error with the given <see cref="ErrorType"/> and error message.
        /// </summary>
        public SObject ThrowError(ErrorType errorType, string message, params object[] messageArgs)
        {
            var strErrorType     = errorType.ToString();
            var formattedMessage = string.Format(message, messageArgs);

            var errorObject = _processor.Context.CreateInstance("Error", new SObject[] { _processor.CreateString(formattedMessage),
                                                                                         _processor.CreateString(errorType.ToString()),
                                                                                         _processor.CreateNumber(_processor.GetLineNumber()) });

            return(ThrowError(errorObject));
        }