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 CompiledFunctionRef_2 extends CompiledFunctionRef { 43 private static final Logger log 44 = Logger.getLogger(CompiledFunctionRef_2.class.getName()); 45 private static final L10N L = new L10N(CompiledFunctionRef_2.class); 46 47 private String _name; 48 private Expr _default_0; 49 private Expr _default_1; 50 51 public CompiledFunctionRef_2(String name, Expr default_0, Expr default_1) 52 { 53 _name = name; 54 _default_0 = default_0; 55 _default_1 = default_1; 56 } 57 58 64 public Expr []bindArguments(Env env, Expr fun, Expr []args) 65 { 66 if (args.length > 2) 67 log.fine(L.l(env.getLocation().getMessagePrefix() + "incorrect number of arguments" + env.getFunctionLocation())); 68 69 return args; 70 } 71 72 public Value callRef(Env env, Value []argValues) 73 { 74 switch (argValues.length) { 75 case 0: 76 return callRef(env, _default_0.eval(env), _default_1.eval(env)); 77 case 1: 78 return callRef(env, argValues[0], _default_1.eval(env)); 79 case 2: 80 default: 81 return callRef(env, argValues[0], argValues[1]); 82 } 83 } 84 85 abstract public Value callRef(Env env, Value a1, Value a2); 86 87 public String toString() 88 { 89 return "CompiledFunction_1[" + _name + "]"; 90 } 91 } 92 93 | Popular Tags |