1 29 30 package com.caucho.quercus.expr; 31 32 import com.caucho.quercus.Location; 33 import com.caucho.quercus.env.Env; 34 import com.caucho.quercus.env.Value; 35 import com.caucho.quercus.parser.QuercusParser; 36 import com.caucho.util.L10N; 37 38 import java.util.ArrayList ; 39 40 43 public class VarFunctionExpr extends Expr { 44 private static final L10N L = new L10N(FunctionExpr.class); 45 46 protected final Expr _name; 47 protected final Expr []_args; 48 49 public VarFunctionExpr(Location location, Expr name, ArrayList <Expr> args) 50 { 51 super(location); 52 _name = name; 53 54 _args = new Expr[args.size()]; 55 args.toArray(_args); 56 } 57 58 public VarFunctionExpr(Location location, Expr name, Expr []args) 59 { 60 super(location); 61 _name = name; 62 63 _args = args; 64 } 65 66 public VarFunctionExpr(Expr name, ArrayList <Expr> args) 67 { 68 this(Location.UNKNOWN, name, args); 69 } 70 71 public VarFunctionExpr(Expr name, Expr []args) 72 { 73 this(Location.UNKNOWN, name, args); 74 } 75 76 80 public Expr createRef(QuercusParser parser) 81 { 82 return parser.getFactory().createRef(this); 83 } 84 85 89 public Expr createCopy(ExprFactory factory) 90 { 91 return this; 92 } 93 94 101 public Value eval(Env env) 102 { 103 return env.getFunction(_name.eval(env)).call(env, _args); 104 } 105 106 113 public Value evalRef(Env env) 114 { 115 return env.getFunction(_name.eval(env)).callRef(env, _args); 116 } 117 118 public String toString() 119 { 120 return _name + "()"; 121 } 122 } 123 124 | Popular Tags |