1 29 30 package com.caucho.quercus.program; 31 32 import com.caucho.quercus.env.Env; 33 import com.caucho.quercus.env.Value; 34 import com.caucho.quercus.expr.Expr; 35 import com.caucho.util.L10N; 36 37 import java.util.logging.Logger ; 38 39 42 abstract public class CompiledFunction_N extends CompiledFunction { 43 private static final Logger log 44 = Logger.getLogger(CompiledFunction_N.class.getName()); 45 private static final L10N L = new L10N(CompiledFunction_N.class); 46 47 private final String _name; 48 private final Expr []_defaultArgs; 49 50 public CompiledFunction_N(String name, Expr []defaultArgs) 51 { 52 _name = name; 53 _defaultArgs = defaultArgs; 54 } 55 56 62 public Expr []bindArguments(Env env, Expr fun, Expr []args) 63 { 64 return args; 65 } 66 67 public final Value call(Env env, Value []argValues) 68 { 69 Value []args = argValues; 70 71 if (_defaultArgs.length != argValues.length) { 72 int len = _defaultArgs.length; 73 74 if (len < argValues.length) 75 len = argValues.length; 76 77 args = new Value[len]; 78 79 System.arraycopy(argValues, 0, args, 0, argValues.length); 80 81 for (int i = argValues.length; i < _defaultArgs.length; i++) { 82 args[i] = _defaultArgs[i].eval(env); 83 } 84 } 85 86 return callImpl(env, args); 87 } 88 89 abstract public Value callImpl(Env env, Value []args); 90 91 public String toString() 92 { 93 return "CompiledFunction_N[" + _name + "]"; 94 } 95 } 96 97 | Popular Tags |