Exemple #1
0
        private static EvaluationResult ParseInt(Context context, ModuleLiteral env, EvaluationStackFrame args)
        {
            var str   = Args.AsString(args, 0);
            var radix = Args.AsIntOptional(args, 1);

            if (radix != null)
            {
                ValidateRadix(radix.Value);
                return(EvaluationResult.Create(Convert.ToInt32(str, radix.Value)));
            }

            if (int.TryParse(str, NumberStyles.Any, s_numberFormatInfo, out int intValue))
            {
                return(EvaluationResult.Create(intValue));
            }

            return(EvaluationResult.Undefined);
        }