/** * Comples and evaluates an expression. */ @UsesSymbolTable public Value eval(Env env, StringValue code) { try { if (log.isLoggable(Level.FINER)) log.finer("quercus eval: [[" + code + "]]"); QuercusContext quercus = env.getQuercus(); QuercusProgram program = quercus.parseCode(code); Value value = program.execute(env); if (value == null) value = NullValue.NULL; return value; } catch (IOException e) { throw new QuercusException(e); } }
/** * Returns the defined variables in the current scope. */ @UsesSymbolTable public static Value get_defined_vars(Env env) { ArrayValue result = new ArrayValueImpl(); Map<StringValue,EnvVar> map = env.getEnv(); for (Map.Entry<StringValue,EnvVar> entry : map.entrySet()) { result.append(entry.getKey(), entry.getValue().get()); } Map<StringValue,EnvVar> globalMap = env.getGlobalEnv(); if (map != globalMap) { for (Map.Entry<StringValue,EnvVar> entry : globalMap.entrySet()) { result.append(entry.getKey(), entry.getValue().get()); } } return result; }
/** * Inputs new variables into the symbol table from the passed array * * @param array the array contained the new variables * @return the number of new variables added from the array to the symbol * table */ @UsesSymbolTable(replace = true) public static Value extract(Env env, ArrayValue array) { if (array == null) return NullValue.NULL; int completedSymbols = 0; for (Value entryKey : array.keySet()) { Value entryValue; entryValue = array.get(entryKey); StringValue symbolName = entryKey.toStringValue(); if (validVariableName(symbolName)) { env.setValue(symbolName, entryValue); completedSymbols++; } } return LongValue.create(completedSymbols); }
/** * Parses the string as a query string. * * @param env the calling environment * @param str the query string * @param array the optional result array */ @UsesSymbolTable public static Value parse_str(Env env, StringValue str, @Optional @Reference Value ref) { boolean isRef = ref instanceof Var; ArrayValue result = null; if (isRef) { result = new ArrayValueImpl(); ref.set(result); } else if (ref instanceof ArrayValue) { result = (ArrayValue) ref; isRef = true; } else result = new ArrayValueImpl(); return StringUtility.parseStr(env, str, result, isRef, env.getHttpInputEncoding(), false); }
/** * Creates an array of corresponding values to variables in the symbol name. * The passed parameters are the names of the variables to be added to the * array. * * @param variables contains the names of variables to add to the array * @return an array with the values of variables that match those passed */ @UsesSymbolTable public static ArrayValue compact(Env env, Value[] variables) { ArrayValue compactArray = new ArrayValueImpl(); for (Value variableName : variables) { if (variableName.isString()) { Var var = env.getRef(variableName.toStringValue(), false); if (var != null) compactArray.put(variableName, var.toValue()); } else if (variableName instanceof ArrayValue) { ArrayValue array = (ArrayValue) variableName; ArrayValue innerArray = compact(env, array.valuesToArray()); compactArray.putAll(innerArray); } } return compactArray; }
@UsesSymbolTable public static Value preg_replace(Env env, Regexp[] regexpList,
@UsesSymbolTable private static Value preg_replace(Env env, Value pattern,
@UsesSymbolTable public static Value extract(Env env, ArrayValue array,
@UsesSymbolTable(replace = false) @Name("assert") public static Value q_assert(Env env,