private void CallFunction(ScriptEngine engine, DynamicFunction f)
            {
                if (f == null)
                {
                    return;
                }

                try {
                    f.Invoke(engine);
                } catch (Exception e) {
                    if (!EngineHelper.ProcessRuntimeException(engine, e, ScriptVirtualPath))
                    {
                        throw;
                    }
                }
            }
        private void EnsureGlobalFileCompiled()
        {
            // This is done only once for all the HttpModule instances every time the file changes

            Debug.Assert(s_buildResult == null || s_globalFileCompiled);

            if (s_globalFileCompiled)
            {
                return;
            }

            lock (typeof(DynamicLanguageHttpModule)) {
                if (s_globalFileCompiled)
                {
                    return;
                }

                _globalScope        = null;
                s_globalVirtualPath = null;

                string globalVirtualPath;
                foreach (string extension in EngineHelper.FileExtensions)
                {
                    globalVirtualPath = s_globalVirtualPathWithoutExtension + extension;

                    if (HostingEnvironment.VirtualPathProvider.FileExists(globalVirtualPath))
                    {
                        // Fail if we had already found a global file
                        if (s_globalVirtualPath != null)
                        {
                            throw new Exception(String.Format("A web application can only have one global file. Found both '{0}' and '{1}'",
                                                              s_globalVirtualPath, globalVirtualPath));
                        }
                        s_globalVirtualPath = globalVirtualPath;
                    }
                }

                // If we found a global file, compile it
                if (s_globalVirtualPath != null)
                {
                    s_buildResult = (GlobalAsaxBuildResult)EngineHelper.GetBuildResult(s_globalVirtualPath, this);
                }

                // We set this even when there is no file to compile
                s_globalFileCompiled = true;
            }
        }
 ScriptEngine IBuildProvider.GetScriptEngine()
 {
     Debug.Assert(s_globalVirtualPath != null);
     return(EngineHelper.GetScriptEngineByExtension(VirtualPathUtility.GetExtension(s_globalVirtualPath)));
 }