public void ProcessRequest(HttpContext context) { if (lp == null) { lp = Helpers.Provider as IronSchemeLanguageProvider; se = lp.GetEngine(); RuntimeExtensions.Eval("(library-path (cons {0} (library-path)))", context.Server.MapPath("~/lib")); 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(); }
internal static void Initialize(IronSchemeLanguageProvider ironSchemeLanguageProvider) { lp = ironSchemeLanguageProvider; se = lp.GetEngine() as IronSchemeScriptEngine; scriptmodule = ScriptDomainManager.CurrentManager.Host.DefaultModule as ScriptModule; ModuleContext mc = new ModuleContext(scriptmodule); mc.CompilerContext = new CompilerContext(SourceUnit.CreateSnippet(se, "")); cc = new CodeContext(scriptmodule.Scope, se.GetLanguageContext(), mc); binder = new IronScheme.Actions.IronSchemeActionBinder(cc); Generator.initme = true; }