Example #1
0
        public static SObject findCode(string module, string ns, int id, int number)
        {
            // First look in programAssembly

            CodeVector cv = findCodeInAssembly(Reg.programAssembly, ns, number);

            if (cv != null)
            {
                return(cv);
            }

            // Then look in external Assembly via module in name

            Assembly moduleAssembly;

            try {
                moduleAssembly = Assembly.LoadFrom(module + ".exe");
            }
            catch {
                try {
                    moduleAssembly = Assembly.LoadFrom(module + ".dll");
                }
                catch {
                    Exn.error("code not found (no EXE or DLL file): " + module);
                    return(Factory.Impossible);
                }
            }
            cv = findCodeInAssembly(moduleAssembly, ns, number);
            if (cv != null)
            {
                return(cv);
            }
            Exn.error("code not found: " + module + " " + ns + " " + number);
            return(Factory.False);
        }
Example #2
0
        public static CodeAddress call (CodeVector code, int jumpIndex)
        {
#if HAS_PERFORMANCE_COUNTERS
           if (Call.bounceCounter != null) Call.bounceCounter.Increment();
#endif
#if ALWAYS_THROW_TO_TRAMPOLINE
           throw new CodeVectorCallException (code, jumpIndex);
#else
           return code.Address (jumpIndex);
#endif
        }
Example #3
0
        public static CodeAddress call(CodeVector code, int jumpIndex)
        {
#if HAS_PERFORMANCE_COUNTERS
            if (Call.bounceCounter != null)
            {
                Call.bounceCounter.Increment();
            }
#endif
#if ALWAYS_THROW_TO_TRAMPOLINE
            throw new CodeVectorCallException(code, jumpIndex);
#else
            return(code.Address(jumpIndex));
#endif
        }
Example #4
0
 public CodeVectorCallException (CodeVector rtn, int j)
     : base (rtn.Address (j))
 {}
Example #5
0
 public static void setrtn (CodeVector code, int index)
 {
   if (code != Cont.cont.Slot0.entrypoint) {
       Exn.internalError("setrtn: different codevector from slot0");
       }
   Cont.cont.returnIndex = index;
 }
Example #6
0
 public CodeVectorCallException(CodeVector rtn, int j)
     : base(rtn.Address(j))
 {
 }
Example #7
0
 public CodeAddress(Procedure p)
 {
     this.code  = p.entrypoint;
     this.label = 0;
 }
Example #8
0
  /* ===================================================== */
  /*   Closures                                            */
  /* ===================================================== */


  /** lambda
   * Create a new Procedure based on current Procedure (Register 0),
   * given CodeVector, and given number of registers to close over
   */
  public static void lambda (CodeVector codevector, int constIndex, int numRegs)
  {
    Procedure thisProc = Reg.ProcRegister0;

    if (numRegs < Reg.LASTREG) {
        Reg.Result = new Procedure (codevector,
				    (SVL) thisProc.constants[constIndex],
				    thisProc,
				    Reg.Close (numRegs));
        }
    else {
        SObject[] environment = new SObject[numRegs+1];
        for (int i = 0; i <= Reg.LASTREG -1; ++i) {
            environment[i] = Reg.getRegister(i);
            }
        SObject restlist = Reg.getRegister (Reg.LASTREG);
        for (int i = Reg.LASTREG; i < numRegs+1; ++i) {
            SPair restpair = (SPair) restlist;
            environment[i] = restpair.first;
            restlist = restpair.rest;
            }
        Reg.Result = new Procedure (codevector,
				    (SVL) thisProc.constants[constIndex],
				    thisProc,
				    environment);
        }
  }
Example #9
0
 public CodeAddress(CodeVector code, int label)
 {
     this.code  = code;
     this.label = label;
 }
Example #10
0
 public CodeAddress(CodeVector code)
 {
     this.code  = code;
     this.label = 0;
 }
Example #11
0
 public CodeAddress (Procedure p)
 {
   this.code = p.entrypoint;
   this.label = 0;
 }
Example #12
0
 public CodeAddress (CodeVector code, int label)
 {
   this.code = code;
   this.label = label;
 }
Example #13
0
 public CodeAddress (CodeVector code)
 {
   this.code = code;
   this.label = 0;
 }