public static CScript CreateRunner(string[] srcs, ScriptConfig scriptConfig = null, RunConfig config = null) { if (srcs == null || srcs.Length == 0) { throw new ArgumentException(nameof(srcs)); } if (scriptConfig == null) { scriptConfig = ScriptConfig.Default; } if (config == null) { config = RunConfig.Default; } var r = new Runner(scriptConfig, config); var roots = new List <SyntaxNode>(); foreach (var src in srcs) { var root = ParseAndValidate(src, scriptConfig.PredefinedSymbols); r.LoadSyntax(root); roots.Add(root); } return(new CScript(r, roots.ToArray())); }
public static CScript CreateRunner(string[] srcs, ScriptConfig scriptConfig = null, RunConfig config = null) { if (srcs == null || srcs.Length == 0) { throw new ArgumentException(nameof(srcs)); } if (scriptConfig == null) { scriptConfig = ScriptConfig.Default; } if (config == null) { config = RunConfig.Default; } var r = new Runner(scriptConfig, config); foreach (var src in srcs) { var root = ParseAndValidate(src); r.LoadSyntax(root); } return(new CScript(r)); }
public static object Run(string src, ScriptConfig scriptConfig = null, RunConfig config = null) { var r = CreateRunner(src, scriptConfig, config); var ret = r.RunMain(); if (ret == null) { return(null); } return(ret.Unwrap()); }
public static object RunSimple(string src, ScriptConfig scriptConfig = null, RunConfig config = null) { return(Run(@" using System; class CScript__ { public static object Main() { return " + src + @"; } } ", scriptConfig, config)); }
public static CScript CreateRunner(ScriptConfig scriptConfig = null, RunConfig config = null) { if (scriptConfig == null) { scriptConfig = ScriptConfig.Default; } if (config == null) { config = RunConfig.Default; } var r = new Runner(scriptConfig, config); return(new CScript(r, new SyntaxNode[] { })); }
public Runner(ScriptConfig scriptConfig, RunConfig config) { this.Ctx = new RunContext(config); this.ScriptConfig = scriptConfig; this.Globals = new GlobalStorage(); var assemblies = AppDomain.CurrentDomain.GetAssemblies(); this.OptCache = new OptNodeCache(); this.Lookup = new IdLookup(assemblies); this.Catches = new Stack <CatchFrame>(); this.Frames = new Stack <VarFrame>(); this.ExtResolver = new ExtensionMethodResolver(assemblies); this.Resolver = new TypeResolver(Ctx, assemblies); AddDefaultUsings(); PrewarmTypes(); }
public static CScript CreateRunner(string src, ScriptConfig scriptConfig = null, RunConfig config = null) => CreateRunner(new string[] { src }, scriptConfig, config);