/// <summary> /// Create a bindings. </summary> /// <param name="fnMapper"> the function mapper to use </param> /// <param name="varMapper"> the variable mapper to use </param> /// <param name="converter"> custom type converter </param> /// <returns> tree bindings </returns> public virtual Bindings Bind(FunctionMapper fnMapper, VariableMapper varMapper, ITypeConverter converter) { MethodInfo[] methods = null; if (functions.Count > 0) { if (fnMapper == null) { throw new ELException(LocalMessages.Get("error.function.nomapper")); } methods = new MethodInfo[functions.Count]; foreach (IFunctionNode node in functions) { string image = node.Name; MethodInfo method = null; int colon = image.IndexOf(':'); if (colon < 0) { method = fnMapper.ResolveFunction("", image); } else { method = fnMapper.ResolveFunction(image.Substring(0, colon), image.Substring(colon + 1)); } if (method == null) { throw new ELException(LocalMessages.Get("{0} error.function.notfound", image)); } //if (node.VarArgs && method.VarArgs) //{ // if (method.ParameterTypes.length > node.ParamCount + 1) // { // throw new ELException(LocalMessages.Get("error.function.params", image)); // } //} //else //{ // if (method.ParameterTypes.length != node.ParamCount) // { // throw new ELException(LocalMessages.Get("error.function.params", image)); // } //} methods[node.Index] = method; } } ValueExpression[] expressions = null; if (identifiers.Count > 0) { expressions = new ValueExpression[identifiers.Count]; foreach (IIdentifierNode node in identifiers) { ValueExpression expression = null; if (varMapper != null) { expression = varMapper.ResolveVariable(node.Name); } expressions[node.Index] = expression; } } return(new Bindings(methods, expressions, converter)); }
public override MethodInfo ResolveFunction(string prefix, string localName) { var i = this.functionMappers.GetEnumerator(); MethodInfo method; do { if (!i.MoveNext()) //.hasNext()) { throw LOG.unknownFunction(prefix, localName); } FunctionMapper functionMapper = i.Current;//.next(); method = functionMapper.ResolveFunction(prefix, localName); } while (method == null); return(method); }