private static EPCompiledManifest CompileToAssembly( FAFQueryMethodForge query, string classPostfix, CompilerOptions compilerOptions, ModuleCompileTimeServices compileTimeServices, out Assembly assembly) { string queryMethodProviderClassName; try { queryMethodProviderClassName = CompilerHelperFAFQuery.CompileQuery(query, classPostfix,compileTimeServices, out assembly); } catch (StatementSpecCompileException ex) { EPCompileExceptionItem first; if (ex is StatementSpecCompileSyntaxException) { first = new EPCompileExceptionSyntaxItem(ex.Message, ex.Expression, -1); } else { first = new EPCompileExceptionItem(ex.Message, ex.Expression, -1); } var items = Collections.SingletonList(first); throw new EPCompileException(ex.Message + " [" + ex.Expression + "]", ex, items); } // compile query provider var fafProviderClassName = MakeFAFProvider( queryMethodProviderClassName, classPostfix, compileTimeServices, out assembly); // create manifest return new EPCompiledManifest(COMPILER_VERSION, null, fafProviderClassName, false); }
private static void AssertItem( EPCompileExceptionItem item, string expression, int lineNumber, string expectedMsg) { Assert.AreEqual(expression, item.Expression); Assert.AreEqual(lineNumber, item.LineNumber); AssertMessage(item.InnerException.Message, expectedMsg); }
private static EPCompiledManifest CompileToModules( ICollection<Assembly> assemblies, IList<Compilable> compilables, string optionalModuleName, IDictionary<ModuleProperty, object> moduleProperties, ModuleCompileTimeServices compileTimeServices, CompilerOptions compilerOptions, out Assembly assembly) { var moduleAssignedName = optionalModuleName ?? Guid.NewGuid().ToString(); var moduleIdentPostfix = IdentifierUtil.GetIdentifierMayStartNumeric(moduleAssignedName); // compile each statement var statementNumber = 0; IList<string> statementClassNames = new List<string>(); ISet<string> statementNames = new HashSet<string>(); IList<EPCompileExceptionItem> exceptions = new List<EPCompileExceptionItem>(); IList<EPCompileExceptionItem> postLatchExceptions = new List<EPCompileExceptionItem>(); foreach (var compilable in compilables) { string className = null; EPCompileExceptionItem exception = null; try { CompilableItem compilableItem = CompilerHelperStatementProvider.CompileItem( compilable, optionalModuleName, moduleIdentPostfix, statementNumber, statementNames, compileTimeServices, compilerOptions, out assembly); assemblies.Add(assembly); className = compilableItem.ProviderClassName; compilableItem.PostCompileLatch.Completed(assemblies); // there can be a post-compile step, which may block submitting further compilables try { compilableItem.PostCompileLatch.AwaitAndRun(); } catch (Exception e) { postLatchExceptions.Add( new EPCompileExceptionItem( e.Message, e, compilable.ToEPL(), -1)); } } catch (StatementSpecCompileException ex) { if (ex is StatementSpecCompileSyntaxException) { exception = new EPCompileExceptionSyntaxItem(ex.Message, ex.Expression, -1); } else { exception = new EPCompileExceptionItem( ex.Message, ex, ex.Expression, -1); } exceptions.Add(exception); } if (exception == null) { statementClassNames.Add(className); statementNumber++; } } exceptions.AddAll(postLatchExceptions); if (!exceptions.IsEmpty()) { var ex = exceptions[0]; throw new EPCompileException( "Error during compilation: " + ex.Message + " [" + ex.Expression + "]", ex, exceptions); } // compile module resource var moduleProviderClassName = CompileModule( optionalModuleName, moduleProperties, statementClassNames, moduleIdentPostfix, compileTimeServices, out assembly); #if TBD // revisit // remove path create-class class-provided byte code compileTimeServices.ClassProvidedCompileTimeResolver.RemoveFrom(moduleBytes); // add class-provided create-class classes to module bytes foreach (var entry in compileTimeServices.ClassProvidedCompileTimeRegistry.Classes) { moduleBytes.Put(entry.Value.Assembly); } #endif // create module XML return new EPCompiledManifest(COMPILER_VERSION, moduleProviderClassName, null, compileTimeServices.SerdeResolver.IsTargetHA); }