protected override void doRun(Assembly asm, out dynamic client) { if (_assembly != asm) { _assembly = asm; Type type = _assembly.GetType("ExtensionPlugin"); Injector result = (Injector)type.InvokeMember("Create", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, null); if (result == null) { throw new InvalidOperationException("Corrupted extension"); } _compiler = new RoslynCompiler(); result.apply(_compiler); } client = new { debuggerDlg = "/App/Main/dialogs/dslDebugger.html", debuggerCtrl = "dslDebuggerCtrl", debuggerData = new { keywords = keywordString(_compiler.Environment().keywords()) } }; }
public static void Apply(RoslynCompiler compiler, Options options = null, Scope scope = null) { scope?.AddKeywords("concurrent", "spawn", "await"); scope?.set <Options>(options); if (options == null) { options = new Options(); } var lexical = compiler.Lexical(); lexical .match() .token("concurrent", named: "keyword") .token("class", named: "ref") .then(lexical.transform() .remove("keyword") .then(CompileClass(options))) .match() .token("concurrent", named: "keyword") .token("object", named: "ref") .then(lexical.transform() .remove("keyword") .replace("ref", "class ") .then(CompileObject(options))) .match() .token("concurrent", named: "keyword") .token("app", named: "ref") .token("{") .then(lexical.transform() .replace("keyword", "class ") .replace("ref", "__app") .then(CompileApp(options))); compiler.Syntax() .match <MethodDeclarationSyntax>(IsConcurrentFunction, "after-syntax") .then(CompileFunction); compiler.Environment() .dependency(new[] { "System.Threading", "System.Threading.Tasks", }) .dependency <ConcurrentObject>("Excess.Concurrent.Runtime"); }
public static void Apply(RoslynCompiler compiler, Options options = null, Scope scope = null) { if (scope != null) { var keywords = scope.get("keywords") as List <string>; if (keywords != null) { keywords.AddRange(GetKeywords()); } } if (options == null) { options = new Options(); } var lexical = compiler.Lexical(); lexical .match() .token("concurrent", named: "keyword") .token("class", named: "ref") .then(lexical.transform() .remove("keyword") .then(CompileClass(options))) .match() .token("concurrent", named: "keyword") .token("object", named: "ref") .then(lexical.transform() .remove("keyword") .replace("ref", "class ") .then(CompileObject(options))) .match() .token("concurrent", named: "keyword") .token("app", named: "ref") .token("{") .then(lexical.transform() .replace("keyword", "class ") .replace("ref", "__app") .then(CompileApp(options))); compiler.Environment() .dependency(new[] { "System.Threading", "System.Threading.Tasks", }) .dependency <ConcurrentObject>("Excess.Concurrent.Runtime"); if (options.GenerateAppProgram /*&& compilation != null */) { throw new NotImplementedException(); //var compilation = compiler.Compilation(); ////app support //var Programs = new List<ClassDeclarationSyntax>(); //var Singletons = new List<ClassDeclarationSyntax>(); //compilation // .match<ClassDeclarationSyntax>((@class, model, scpe) => // @class.Identifier.ToString() == "Program" // && @class // .Members // .OfType<MethodDeclarationSyntax>() // .Any(method => method.Identifier.ToString() == "Main")) // .then((node, model, scpe) => Programs.Add((ClassDeclarationSyntax)node)) // .match<ClassDeclarationSyntax>((@class, model, scpe) => isSingleton(@class)) // .then((node, model, scpe) => Singletons.Add((ClassDeclarationSyntax)node)) // .after(AddAppProgram(Programs, Singletons)); } }