public static string create_function(Context ctx, string args, string code) { // prepare function script var data = ScriptingContext.EnsureContext(ctx); var source = string.Format(_createFunctionTemplate, _lambdaFuncName, args, code); // create script that declares the lambda function var script = ctx.ScriptingProvider.CreateScript(new Context.ScriptOptions() { Context = ctx, EmitDebugInformation = Debugger.IsAttached, // CONSIDER Location = new Location(Path.Combine(ctx.RootPath, "runtime-created function"), 0, 0), // TODO: pass from calling script IsSubmission = true }, source); var methods = script.GetGlobalRoutineHandle(_lambdaFuncName).ToArray(); if (methods.Length == 0) { return(null); } var lambdaName = string.Format(_lambdaFormatString, ++data.LastLambdaIndex); var routine = RoutineInfo.CreateUserRoutine(lambdaName, methods); ctx.DeclareFunction(routine); return(lambdaName); }
Context.IScript Context.IScriptingProvider.CreateScript(Context.ScriptOptions options, string code) { var context = ScriptingContext.EnsureContext(options.Context); var script = TryGetOrCreateScript(code, options, context); Debug.Assert(script != null); // context.Submissions.Add(script); // return(script); }
Context.IScript Context.IScriptingProvider.CreateScript(Context.ScriptOptions options, string code) { var data = ScriptingContext.EnsureContext(options.Context); var script = CacheLookup(options, code, data); if (script == null) { // TODO: rwlock cache[code] script = Script.Create(options, code, _builder, data.Submissions); EnsureCache(code).Add(script); } Debug.Assert(script != null); // data.Submissions.Add(script); // return(script); }