1 29 30 package com.caucho.quercus.program; 31 32 import com.caucho.quercus.Quercus; 33 import com.caucho.quercus.expr.VarInfo; 34 35 import java.util.ArrayList ; 36 import java.util.Collection ; 37 import java.util.HashMap ; 38 39 42 public class FunctionInfo { 43 private final Quercus _quercus; 44 45 private final String _name; 46 47 private final HashMap <String ,VarInfo> _varMap 48 = new HashMap <String ,VarInfo>(); 49 50 private final ArrayList <String > _tempVarList 51 = new ArrayList <String >(); 52 53 private ClassDef _classDef; 54 private Function _fun; 55 56 private boolean _isGlobal; 57 58 private boolean _isPageMain; 59 private boolean _isPageStatic; 60 61 private boolean _isReturnsReference; 62 private boolean _isVariableVar; 63 private boolean _isOutUsed; 64 65 private boolean _isVariableArgs; 66 private boolean _isUsesSymbolTable; 67 68 private boolean _isReadOnly = true; 69 70 public FunctionInfo(Quercus quercus, String name) 71 { 72 _quercus = quercus; 73 _name = name; 74 } 75 76 79 public Quercus getPhp() 80 { 81 return _quercus; 82 } 83 84 public String getName() 85 { 86 return _name; 87 } 88 89 92 public void setFunction(Function fun) 93 { 94 _fun = fun; 95 } 96 97 100 public boolean isGlobal() 101 { 102 return _isGlobal; 103 } 104 105 108 public void setGlobal(boolean isGlobal) 109 { 110 _isGlobal = isGlobal; 111 } 112 113 116 public boolean isPageMain() 117 { 118 return _isPageMain; 119 } 120 121 124 public void setPageMain(boolean isPageMain) 125 { 126 _isPageMain = isPageMain; 127 } 128 129 132 public boolean isPageStatic() 133 { 134 return _isPageStatic; 135 } 136 137 140 public void setPageStatic(boolean isPageStatic) 141 { 142 _isPageStatic = isPageStatic; 143 } 144 145 148 public void setDeclaringClass(ClassDef classDef) 149 { 150 _classDef = classDef; 151 } 152 153 156 public ClassDef getDeclaringClass() 157 { 158 return _classDef; 159 } 160 161 164 public boolean isMethod() 165 { 166 return _classDef != null && ! _fun.isStatic(); 167 } 168 169 172 public boolean isReturnsReference() 173 { 174 return _isReturnsReference; 175 } 176 177 180 public void setReturnsReference(boolean isReturnsReference) 181 { 182 _isReturnsReference = isReturnsReference; 183 } 184 185 188 public boolean isVariableVar() 189 { 190 return _isVariableVar; 191 } 192 193 196 public void setVariableVar(boolean isVariableVar) 197 { 198 _isVariableVar = isVariableVar; 199 } 200 201 204 public boolean isVariableArgs() 205 { 206 return _isVariableArgs; 207 } 208 209 212 public void setVariableArgs(boolean isVariableArgs) 213 { 214 _isVariableArgs = isVariableArgs; 215 } 216 217 220 public boolean isUsesSymbolTable() 221 { 222 return _isUsesSymbolTable; 223 } 224 225 228 public void setUsesSymbolTable(boolean isUsesSymbolTable) 229 { 230 _isUsesSymbolTable = isUsesSymbolTable; 231 } 232 233 236 public boolean isOutUsed() 237 { 238 return _isOutUsed; 239 } 240 241 244 public void setOutUsed() 245 { 246 _isOutUsed = true; 247 } 248 249 252 public boolean isReadOnly() 253 { 254 return _isReadOnly; 255 } 256 257 260 public void setModified() 261 { 262 _isReadOnly = false; 263 } 264 265 268 public VarInfo createVar(String name) 269 { 270 VarInfo var = _varMap.get(name); 271 272 if (var == null) { 273 var = new VarInfo(name, this); 274 275 if (_isGlobal) 276 var.setGlobal(); 277 278 if (Quercus.isSuperGlobal(name)) 279 var.setGlobal(); 280 281 _varMap.put(name, var); 282 } 283 284 return var; 285 } 286 287 290 public Collection <VarInfo> getVariables() 291 { 292 return _varMap.values(); 293 } 294 295 298 public void addTempVar(String name) 299 { 300 if (! _tempVarList.contains(name)) 301 _tempVarList.add(name); 302 } 303 304 307 public Collection <String > getTempVariables() 308 { 309 return _tempVarList; 310 } 311 312 public int getTempIndex() 313 { 314 return _tempVarList.size(); 315 } 316 317 public String toString() 318 { 319 return "FunctionInfo[" + _name + "]"; 320 } 321 } 322 323 | Popular Tags |