Class< ? > thisClass = null;
if ( pattern.getObjectType() instanceof ClassObjectType ) {
thisClass = ((ClassObjectType) pattern.getObjectType()).getClassType();
}
final AnalysisResult analysis = context.getDialect().analyzeExpression( context,
predicateDescr,
predicateDescr.getContent(),
new BoundIdentifiers( declarations,
globals,
operators,
thisClass ) );
if ( analysis == null ) {
// something bad happened
return;
}
// this will return an array with 2 lists
// where first list is from rule local variables
// second list is from global variables
final BoundIdentifiers usedIdentifiers = analysis.getBoundIdentifiers();
final List tupleDeclarations = new ArrayList();
final List factDeclarations = new ArrayList();
for ( String id : usedIdentifiers.getDeclrClasses().keySet() ) {
final Declaration decl = context.getDeclarationResolver().getDeclaration( context.getRule(),
id );
if ( decl.getPattern() == pattern ) {
factDeclarations.add( decl );
} else {
tupleDeclarations.add( decl );
}
}
this.createImplicitBindings( context,
pattern,
analysis.getNotBoundedIdentifiers(),
analysis.getBoundIdentifiers(),
factDeclarations );
final Declaration[] previousDeclarations = (Declaration[]) tupleDeclarations.toArray( new Declaration[tupleDeclarations.size()] );
final Declaration[] localDeclarations = (Declaration[]) factDeclarations.toArray( new Declaration[factDeclarations.size()] );
final String[] requiredGlobals = usedIdentifiers.getGlobals().keySet().toArray( new String[usedIdentifiers.getGlobals().size()] );