1 29 30 package com.caucho.quercus.program; 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.expr.Expr; 36 37 40 public class IfStatement extends Statement { 41 private final Expr _test; 42 private final Statement _trueBlock; 43 private final Statement _falseBlock; 44 45 public IfStatement(Location location, Expr test, Statement trueBlock, Statement falseBlock) 46 { 47 super(location); 48 49 _test = test; 50 _trueBlock = trueBlock; 51 _falseBlock = falseBlock; 52 } 53 54 protected Expr getTest() 55 { 56 return _test; 57 } 58 59 protected Statement getTrueBlock() 60 { 61 return _trueBlock; 62 } 63 64 protected Statement getFalseBlock() 65 { 66 return _falseBlock; 67 } 68 69 72 public Value execute(Env env) 73 { 74 if (_test.evalBoolean(env)) { 75 return _trueBlock.execute(env); 76 } 77 else if (_falseBlock != null) { 78 return _falseBlock.execute(env); 79 } 80 else 81 return null; 82 } 83 } 84 85 | Popular Tags |