/// <summary> /// method creates Bindings from the bound constraint and adds them to /// the Rule. /// </summary> /// <param name="cnstr">The CNSTR.</param> /// <param name="templ">The templ.</param> /// <param name="rule">The rule.</param> /// <param name="position">The position.</param> /// <returns></returns> public virtual BaseAlpha2 compileConstraint(BoundConstraint cnstr, ITemplate templ, Rule.IRule rule, int position) { BaseAlpha2 current = null; if (rule.getBinding(cnstr.VariableName) == null) { // if the HashMap doesn't already contain the binding, we create // a new one if (cnstr.IsObjectBinding) { Binding bind = new Binding(); bind.VarName = cnstr.VariableName; bind.LeftRow = position; bind.LeftIndex = -1; bind.IsObjectVar = true; rule.addBinding(cnstr.VariableName, bind); } else { Binding bind = new Binding(); bind.VarName = cnstr.VariableName; bind.LeftRow = position; bind.LeftIndex = templ.getSlot(cnstr.Name).Id; bind.RowDeclared = position; cnstr.FirstDeclaration = true; rule.addBinding(cnstr.VariableName, bind); } } return(current); }
/// <summary> the paramList should be clean and /// other codes surrounding this method in subclass may be removed into this method. /// Houzhanbin 10/16/2007 /// </summary> /// <param name="">condition /// </param> /// <param name="">rule /// </param> /// <param name="">Constraints /// </param> /// <param name="">position /// </param> /// <param name="">hasNotEqual /// </param> /// <param name="">hasPredicateJoin /// </param> /// <returns> /// /// </returns> internal Binding[] getBindings(ICondition condition, Rule.IRule rule, int position) { ObjectCondition oc = getObjectCondition(condition); IList Constraints = oc.BindConstraints; Deftemplate tmpl = oc.Deftemplate; Binding[] binds = new Binding[Constraints.Count]; for (int idz = 0; idz < Constraints.Count; idz++) { Object cst = Constraints[idz]; if (cst is BoundConstraint) { BoundConstraint bc = (BoundConstraint)cst; Binding cpy = rule.copyBinding(bc.VariableName); if (cpy.LeftRow >= position) { binds = new Binding[0]; break; } else { binds[idz] = cpy; int rinx = tmpl.getColumnIndex(bc.Name); // we increment the count to make sure the // template isn't removed if it is being used tmpl.incrementColumnUseCount(bc.Name); binds[idz].RightIndex = rinx; binds[idz].Negated = bc.Negated; if (bc.Negated) { oc.HasNotEqual = true; } } } else if (cst is PredicateConstraint) { PredicateConstraint pc = (PredicateConstraint)cst; if (pc.Value is BoundParam) { oc.HasPredicateJoin = true; BoundParam bpm = (BoundParam)pc.Value; String var = bpm.VariableName; int op = ConversionUtils.getOperatorCode(pc.FunctionName); // check and make sure the function isn't user defined if (op != Constants.USERDEFINED) { // if the first binding in the function is from the object type // we reverse the operator if (pc.Parameters[0] != bpm) { op = ConversionUtils.getOppositeOperatorCode(op); } binds[idz] = rule.copyPredicateBinding(var, op); ((Binding2)binds[idz]).RightVariable = pc.VariableName; } else { binds[idz] = rule.copyPredicateBinding(var, op); } binds[idz].PredJoin = true; int rinx = tmpl.getColumnIndex(pc.Name); // we increment the count to make sure the // template isn't removed if it is being used tmpl.incrementColumnUseCount(pc.Name); binds[idz].RightIndex = rinx; } else if (pc.Value is FunctionParam) { // this means there is a nested function } } } return(binds); }