示例#1
0
        public static Procedure getSupportProcedure(int index)
        {
            SObject support = Reg.globalValue("millicode-support");

            if (support is SVL)
            {
                SVL       procedures = (SVL)support;
                Procedure p          = procedures.elementAt(index) as Procedure;
                if (p != null)
                {
                    return(p);
                }
                else
                {
                    Exn.internalError("millicode support " + index + " not a procedure");
                    return(null);
                }
            }
            else if (support == Factory.Undefined)
            {
                Exn.internalError("millicode-support is not defined (index: " + index + ")");
                return(null);
            }
            else
            {
                Exn.internalError("millicode-support is not a vector");
                return(null);
            }
        }
示例#2
0
 public void checkPop(int lastslot, Procedure reg0)
 {
     if (this.lastslot != lastslot)
     {
         Exn.internalError("pop: wrong number of slots");
     }
     if (this.s0.entrypoint != reg0.entrypoint)
     {
         Exn.internalError("pop: can't pop someone else's frame!");
     }
 }
示例#3
0
        private static Stream fd2stream(int fd)
        {
            object s = open_files[fd];

            if (s is Stream)
            {
                return((Stream)s);
            }
            else
            {
                Exn.internalError("fd " + fd + " is not a stream: " + s);
                return(null);
            }
        }
示例#4
0
        private static Stream fd2output(int fd)
        {
            Stream s = fd2stream(fd);

            if (s == null || !s.CanWrite)
            {
                Exn.internalError("file descriptor " + fd + " not open for output");
                return(null);
            }
            else
            {
                return(s);
            }
        }
示例#5
0
        // Combines the effect of checkpop and pop.
        public void SafePop(int lastslot)
        {
            if (this.lastslot != lastslot)
            {
                Exn.internalError("pop: wrong number of slots.  Expected "
                                  + lastslot.ToString()
                                  + ", got "
                                  + this.lastslot.ToString());
            }

            if (this.s0.entrypoint != Reg.ProcRegister0.entrypoint)
            {
                Exn.internalError("pop: can't pop someone else's frame!");
            }

            Cont.pop();
        }
示例#6
0
        /* fillCache
         */
        public static void fillCache()
        {
#if HAS_PERFORMANCE_COUNTERS
            if (stackReloadCounter != null)
            {
                stackReloadCounter.Increment();
            }
#endif
            cont = ROOT;
            SVL h = heap as SVL;

            if (h == null)
            {
                Exn.internalError("fillCache: Cont.heap is not a vector");
            }
            else
            {
                heap = h.elements[Cont.HC_DYNLINK];
                cont.fillFromVector(h);
            }
        }
示例#7
0
        // file exists?
        private static void access()
        {
            string file      = ((SByteVL)Reg.Register2).asString();
            int    operation = ((SFixnum)Reg.Register3).value;
            int    result    = 2;  // WHY?

            if (operation == 0x01) // FILE EXISTS?
            {
                if (File.Exists(file) || Directory.Exists(file))
                {
                    result = 0;
                }
                else
                {
                    result = -1;
                }
            }
            else
            {
                Exn.internalError("access: read/write/execute checking not supported");
                return;
            }
            Reg.Result = Factory.makeNumber(result);
        }
示例#8
0
        // type checking is done in the scheme code that implements
        // the standard library.  if we get here, we can assume
        // that the parameters in the registers are all as expected.
        // (starting at register 2)
        public static void dispatch(int num_args, Sys num_proc)
        {
            switch (num_proc)
            {
            case Sys.open: open(); break;

            case Sys.unlink: unlink(); break;

            case Sys.close: close(); break;

            case Sys.read: read(); break;

            case Sys.write: write(); break;

            case Sys.get_resource_usage: get_resource_usage(); break;

            // case Sys.dump_heap :
            case Sys.exit: exit(); break;

            case Sys.mtime: mtime(); break;

            case Sys.access: access(); break;

            case Sys.rename: rename(); break;

            case Sys.pollinput: pollinput(); break;

            case Sys.getenv: getenv(); break;

            case Sys.setenv: setenv(); break;

            // case Sys.gc : gc(); break;
            case Sys.flonum_acos:  flonum_acos(); break;

            case Sys.flonum_asin:  flonum_asin(); break;

            case Sys.flonum_atan:  flonum_atan(); break;

            case Sys.flonum_atan2: flonum_atan2(); break;

            case Sys.flonum_cos:   flonum_cos(); break;

            case Sys.flonum_cosh:  flonum_cosh(); break;

            case Sys.flonum_exp:   flonum_exp(); break;

            case Sys.flonum_log:   flonum_log(); break;

            case Sys.flonum_sin:   flonum_sin(); break;

            case Sys.flonum_sinh:  flonum_sinh(); break;

            case Sys.flonum_sqrt:  flonum_sqrt(); break;

            case Sys.flonum_tan:   flonum_tan(); break;

            case Sys.system: system(); break;

            case Sys.c_ffi_dlsym: FFI.ffi_syscall(); break;

            case Sys.sro:         fake_sro(); break;

            case Sys.sys_feature: sys_feature(); break;

            case Sys.segment_code_address: segment_code_address(); break;

            case Sys.chdir: chdir(); break;

            case Sys.cwd: cwd(); break;

            case Sys.errno:    geterrno(); break;

            case Sys.seterrno: seterrno(); break;

            case Sys.time:     gettime();  break;

            case Sys.lseek:    lseek();    break;

            case Sys.sysglobal:
                SObject g = (SObject)Reg.globals[((SByteVL)Reg.Register2).asString()];
                if (g == null)
                {
                    Reg.Result = Factory.Undefined;
                }
                else
                {
                    Reg.Result = g;
                }
                break;

            default: Exn.internalError("unsupported syscall: " + num_proc); break;
            }
        }