Пример #1
0
	public void Init() {
		"(import (racr core) (racr testing))".Eval();

		// extend library path
		"(library-path (cons {0} (library-path)))".Eval(racrPath + "examples");

		// siple
		"(import (siple main) (siple exception-api))".Eval();
		interpretCorrect = "siple-interpret".Eval<Callable>();
		interpretIncorrect = @"
		(lambda (x)
		  (assert-exception
		    siple-exception?
			(siple-interpret x)))
		".Eval<Callable>();
	}
Пример #2
0
    public void ProcessRequest(HttpContext context)
    {
      if (lp == null)
      {
        lp = Helpers.Provider as IronSchemeLanguageProvider;
        se = lp.GetEngine();
        compiled.Clear();
      }

      if (!File.Exists(context.Request.PhysicalPath))
      {
        if (context.Request.AppRelativeCurrentExecutionFilePath == "~/process-routes.ss")
        {
          if (process_routes == null)
          {
            Callable eval = Builtins.SymbolValue(SymbolTable.StringToObject("eval-r6rs")) as Callable;
            StringReader r = new StringReader("(eval 'process-request (environment '(ironscheme web routing)))");

            process_routes = eval.Call(Builtins.Read(r)) as Callable;
          }
          process_routes.Call();
        }
        else
        {
          context.Response.StatusCode = 404;
        }
        return;
      }


      Compiled cc;

      lock (GLOBALLOCK)
      {
        if (!compiled.TryGetValue(context.Request.PhysicalPath, out cc) || cc.Time < File.GetLastWriteTime(context.Request.PhysicalPath) || cc.Closure == null)
        {
          Callable ccc = se.Evaluate(string.Format("(compile->closure \"{0}\")", context.Request.PhysicalPath.Replace('\\', '/'))) as Callable;
          cc = new Compiled();
          cc.Time = DateTime.Now;
          cc.Closure = ccc;

          compiled[context.Request.PhysicalPath] = cc;
        }
      }

      cc.Closure.Call();
    }
Пример #3
0
 public SchemeDebugger(Callable callback)
 {
     this.callback = callback;
 }
Пример #4
0
 public VarArgClosure(Delegate target, int paramcount)
     : base(target, -1)
 {
     pcount = paramcount;
     realtarget = Create(target) as Callable;
 }
Пример #5
0
 public static Callable CreateTypedCase(Callable[] targets, int[] arities)
 {
     return new CaseClosure(targets, arities);
 }
Пример #6
0
 public CaseClosure(Callable[] targets, int[] arities)
     : base(null, -1)
 {
     this.arities = arities;
     for (int i = 0; i < targets.Length; i++)
     {
       this.targets.Add(targets[i]);
     }
 }
Пример #7
0
 public SchemeDebugger(Callable callback)
 {
     this.callback = callback;
 }
Пример #8
0
        public override object Call(object[] args)
        {
            try
            {
                object ppo;

                if (Builtins.cc.Scope.TryLookupName(SymbolTable.StringToId("trace-printer"), out ppo))
                {
                    ppo = (ppo as Callable).Call();
                }
                else
                {
                    ppo = "write".Eval();
                }
                Callable pp = ppo as Callable;

                depth++;

                Cons c = Runtime.Cons.FromArray(args), u = c;

                if (filter != null)
                {
                    while (c != null)
                    {
                        c.car = filter.Call(c.car);
                        c     = c.cdr as Cons;
                    }
                }


                object a = args.Length == 1 ? Builtins.Car(u) : u;

                StringWriter pre = new StringWriter();

                pp.Call(a, pre);

                string prefix = new string('|', depth);

                if ((Console.LargestWindowWidth | Console.LargestWindowHeight) == 0)
                {
                    Console.WriteLine("{0} -> {1}", prefix, name);
                    Console.WriteLine(pre.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray()));

                    object result = realtarget.Call(args);

                    StringWriter p = new StringWriter();

                    pp.Call(filter == null ? result : filter.Call(result), p);

                    Console.WriteLine("{0} <- {1}", prefix, name);
                    Console.WriteLine(p.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray()));
                    return(result);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("{0} -> {1}", prefix, name);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(pre.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray()));
                    Console.ForegroundColor = ConsoleColor.Gray;

                    object result = realtarget.Call(args);

                    StringWriter p = new StringWriter();

                    pp.Call(filter == null ? result : filter.Call(result), p);

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("{0} <- {1}", prefix, name);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(p.GetBuffer().TrimEnd(Environment.NewLine.ToCharArray()));
                    Console.ForegroundColor = ConsoleColor.Gray;
                    return(result);
                }
            }
            finally
            {
                depth--;
            }
        }
Пример #9
0
 public TraceClosure(Callable realtarget, SymbolId name, object filter)
 {
     this.realtarget = realtarget;
     this.filter     = filter as Callable;
     this.name       = name;
 }
Пример #10
0
 public VarArgClosure(Delegate target, int paramcount)
     : base(target, -1)
 {
     pcount     = paramcount;
     realtarget = Create(target) as Callable;
 }
Пример #11
0
 public TraceClosure(Callable realtarget,  SymbolId name, object filter)
 {
     this.realtarget = realtarget;
       this.filter = filter as Callable;
       this.name = name;
 }