示例#1
0
文件: Factory.cs 项目: zen3d/larceny
        public static SByteVL makeUString(int length, int fill)
        {
            SByteVL ustring = new SByteVL(Tags.UStringTag, length * 4, 0);
            SChar   c       = makeChar(fill);

            for (int i = 0; i < length; ++i)
            {
                makeFixnum(i).op_reversed_ustring_set(ustring, c);
            }
            return(ustring);
        }
示例#2
0
文件: Factory.cs 项目: zen3d/larceny
        // ===================
        //   Characters
        // ===================

        public static SChar makeChar(int val)
        {
            return(SChar.makeChar(val));
        }
示例#3
0
        // MainHelper takes the argument vector, executes the body of the caller's
        // assembly (should be the assembly corresponding to the compiled scheme
        // code) and then executes the "go" procedure, if available.

        public static void MainHelper(string[] args)
        {
            Console.WriteLine("CommonLarceny");
            Console.WriteLine("CLR, Version={0}", System.Environment.Version);
            Console.WriteLine("{0}",
                              System.Reflection.Assembly.GetExecutingAssembly());
            Console.WriteLine("{0}", System.Reflection.Assembly.GetCallingAssembly());
            Console.WriteLine("");

            Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            //  Debug.WriteLine ("CLR Version:  {0}", System.Environment.Version);
            Debug.WriteLine("DEBUG version of Scheme runtime.");
            Debug.WriteLine(test_checked()
                     ? "CHECKED arithmetic"
                     : "UNCHECKED arithmetic");

            { // Establish invariant that LARCENY_ROOT has been set before we
              // invoke (interactive-entry-point ...)

                string lar_root = Environment.GetEnvironmentVariable("LARCENY_ROOT");
                if (lar_root == null)
                {
                    Type[]     argtypes = { typeof(string), typeof(string) };
                    MethodInfo method;

                    string location = Assembly.GetCallingAssembly().Location;
                    lar_root = System.IO.Path.GetDirectoryName(location);

                    // By reflection:
                    // Environment.SetEnvironmentVariable("LARCENY_ROOT", lar_root);

                    try {
                        method = typeof(Environment).GetMethod("SetEnvironmentVariable",
                                                               argtypes);
                        method.Invoke(null, new Object[] { "LARCENY_ROOT", lar_root });
                    }
                    catch (Exception e) {
                        throw new Exception("Couldn't set LARCENY_ROOT; please "
                                            + "set it and try again: ", e);
                    }
                }
            }

            // Mono throws a not implemented exception here.

            try {
                InitializePerformanceCounters();
            }  catch (Exception) {};
            Debug.WriteLine("Initializing fixnum pool.");
            SFixnum.Initialize();
            Debug.WriteLine("Initializing immediates.");
            SImmediate.Initialize();
            Debug.WriteLine("Initializing char pool.");
            SChar.Initialize();
            Debug.WriteLine("Initializing registers.");
            Reg.Initialize(Assembly.GetCallingAssembly());
            Cont.Initialize();

            bool keepRunning = handleAssembly(Reg.programAssembly);

            if (keepRunning)
            {
                handleGo(args);
            }
        }