Serializable expr = compiler.compile( parserContext );
return expr;
}
public ParserContext getParserContext(final Dialect.AnalysisResult analysis, final Map outerDeclarations, final RuleBuildContext context) {
final ParserContext parserContext = new ParserContext( this.imports,
null,
context.getPkg().getName()+"."+context.getRuleDescr().getClassName() );
for ( Iterator it = this.packageImports.values().iterator(); it.hasNext(); ) {
String packageImport = ( String ) it.next();
parserContext.addPackageImport( packageImport );
}
parserContext.setStrictTypeEnforcement( strictMode );
if ( interceptors != null ) {
parserContext.setInterceptors( interceptors );
}
//FIXME: analysis can be null, throws an NPE
List list[] = analysis.getBoundIdentifiers();
DeclarationScopeResolver resolver = context.getDeclarationResolver();
for ( Iterator it = list[0].iterator(); it.hasNext(); ) {
String identifier = (String) it.next();
Class cls = resolver.getDeclaration( identifier ).getExtractor().getExtractToClass();
parserContext.addInput( identifier,
cls );
}
Map globalTypes = context.getPkg().getGlobals();
for ( Iterator it = list[1].iterator(); it.hasNext(); ) {
String identifier = (String) it.next();
parserContext.addInput( identifier,
(Class) globalTypes.get( identifier ) );
}
Map mvelVars = ((MVELAnalysisResult) analysis).getMvelVariables();
if ( mvelVars != null ) {
for ( Iterator it = mvelVars.entrySet().iterator(); it.hasNext(); ) {
Entry entry = (Entry) it.next();
parserContext.addInput( (String) entry.getKey(),
(Class) entry.getValue() );
}
}
if ( outerDeclarations != null ) {
for ( Iterator it = outerDeclarations.entrySet().iterator(); it.hasNext(); ) {
Entry entry = (Entry) it.next();
parserContext.addInput( (String) entry.getKey(),
((Declaration) entry.getValue()).getExtractor().getExtractToClass() );
}
}
parserContext.addInput( "drools",
KnowledgeHelper.class );
return parserContext;
}