use of org.drools.compiler.lang.descr.OperatorDescr in project drools by kiegroup.
the class PatternBuilder method buildCcdDescr.
protected Constraint buildCcdDescr(RuleBuildContext context, PatternDescr patternDescr, Pattern pattern, BaseDescr d, ConstraintConnectiveDescr ccd, MVELDumper.MVELDumperContext mvelCtx) {
d.copyLocation(patternDescr);
mvelCtx.clear();
String expr = context.getCompilerFactory().getExpressionProcessor().dump(d, ccd, mvelCtx);
Map<String, OperatorDescr> aliases = mvelCtx.getAliases();
// create bindings
TypeDeclaration typeDeclaration = getTypeDeclaration(pattern, context);
for (BindingDescr bind : mvelCtx.getBindings()) {
buildRuleBindings(context, patternDescr, pattern, bind, typeDeclaration);
}
if (expr.length() == 0) {
return null;
}
// check if it is an atomic expression
Constraint constraint = processAtomicExpression(context, pattern, d, expr, aliases);
// otherwise check if it is a simple expression
return constraint != null ? constraint : buildExpression(context, pattern, d, expr, aliases);
}
use of org.drools.compiler.lang.descr.OperatorDescr in project drools by kiegroup.
the class PatternBuilder method buildOperators.
protected static Map<String, EvaluatorWrapper> buildOperators(RuleBuildContext context, Pattern pattern, BaseDescr predicateDescr, Map<String, OperatorDescr> aliases) {
if (aliases.isEmpty()) {
return Collections.emptyMap();
}
Map<String, EvaluatorWrapper> operators = new HashMap<String, EvaluatorWrapper>();
for (Map.Entry<String, OperatorDescr> entry : aliases.entrySet()) {
OperatorDescr op = entry.getValue();
Declaration leftDecl = createDeclarationForOperator(context, pattern, op.getLeftString());
Declaration rightDecl = createDeclarationForOperator(context, pattern, op.getRightString());
Target left = leftDecl != null && leftDecl.isPatternDeclaration() ? Target.HANDLE : Target.FACT;
Target right = rightDecl != null && rightDecl.isPatternDeclaration() ? Target.HANDLE : Target.FACT;
op.setLeftIsHandle(left == Target.HANDLE);
op.setRightIsHandle(right == Target.HANDLE);
Evaluator evaluator = getConstraintBuilder(context).getEvaluator(context, predicateDescr, ValueType.OBJECT_TYPE, op.getOperator(), // the rewrite takes care of negation
false, op.getParametersText(), left, right);
EvaluatorWrapper wrapper = getConstraintBuilder(context).wrapEvaluator(evaluator, leftDecl, rightDecl);
operators.put(entry.getKey(), wrapper);
}
return operators;
}
Aggregations