예제 #1
0
파일: CScript.cs 프로젝트: ru-ace/SlowSharp
        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()));
        }
예제 #2
0
        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));
        }
예제 #3
0
파일: CScript.cs 프로젝트: ru-ace/SlowSharp
        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());
        }
예제 #4
0
파일: CScript.cs 프로젝트: ru-ace/SlowSharp
        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));
        }
예제 #5
0
파일: CScript.cs 프로젝트: ru-ace/SlowSharp
        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[] { }));
        }
예제 #6
0
        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();
        }
예제 #7
0
파일: CScript.cs 프로젝트: ru-ace/SlowSharp
 public static CScript CreateRunner(string src, ScriptConfig scriptConfig = null, RunConfig config = null)
 => CreateRunner(new string[] { src }, scriptConfig, config);