Example #1
0
        public static object ParseReal(string s, bool exact)
        {
            if (exact)
            {
                Match m = expnum.Match(s);
                if (m.Success)
                {
                    string head = m.Groups["head"].Value;
                    string tail = m.Groups["tail"].Value;

                    if (tail == string.Empty)
                    {
                        tail = "0";
                    }

                    object hnum = Builtins.StringToNumber(head);
                    // this cant get bigger than 32 bit, else we would be dead already
                    int tnum = (int)Builtins.StringToNumber(tail);

                    if (hnum is double)
                    {
                        // get rid of decimal point
                        double h = (double)hnum;
                        int    i = 0;
                        do
                        {
                            h *= 10;
                            i++;
                        }while (h % 1 != 0);       // test is 'ok' but not really correct

                        hnum  = Builtins.Exact(h); // might be a bignum
                        tnum -= i;
                    }

                    return(Builtins.Multiply(hnum, Expt10(tnum)));
                }
            }
            return(null);
        }
Example #2
0
        static int Main(string[] args)
        {
#if !NETCOREAPP2_1_OR_GREATER
            if ((Array.IndexOf(args, "-profile")) >= 0)
            {
                const string PROFILER_GUID = "{9E2B38F2-7355-4C61-A54F-434B7AC266C0}";

                if (ExecuteRegsvr32(false, true))
                {
                    ProcessStartInfo psi = new ProcessStartInfo(typeof(Program).Assembly.Location);
                    psi.EnvironmentVariables["COR_PROFILER"]         = PROFILER_GUID;
                    psi.EnvironmentVariables["COR_ENABLE_PROFILING"] = "1";

                    // ----- RUN THE PROCESS -------------------
                    args = Array.FindAll(args, x => x != "-profile");

                    psi.Arguments       = string.Join(" ", args);
                    psi.UseShellExecute = false;

                    try
                    {
                        Process p = Process.Start(psi);

                        p.WaitForExit();

                        return(p.ExitCode);
                    }
                    finally
                    {
                        ExecuteRegsvr32(false, false);
                    }
                }
                else
                {
                    // remove -profile
                    args = Array.FindAll(args, x => x != "-profile");
                }
            }
#endif
            var exename = Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs()[0]);

            switch (exename)
            {
            case "isc":
            case "isc32":
            case "ironscheme":
                args = PrefixArgs(args, "-nologo");
                break;
            }

            args = Args(args, "--show-loaded-libraries", () => Builtins.ShowImports = true);
            args = ParseIncludes(args);

            Encoding oo = System.Console.OutputEncoding;
#if !NETCOREAPP2_1_OR_GREATER
            EnableMulticoreJIT();
#endif
            try
            {
                System.Console.OutputEncoding = Encoding.UTF8;
#if NETCOREAPP2_1_OR_GREATER
                Builtins.Exact(1);
#endif

                return(IronSchemeConsoleHost.Execute(args));
            }
            finally
            {
                System.Console.OutputEncoding = oo;
            }
        }