use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class Environment method __import.
/*public Memory __getConstant(String name, String lowerName, TraceInfo trace){
Memory constant = findConstant(name, lowerName);
if (constant == null){
error(trace, E_NOTICE, Messages.ERR_USE_UNDEFINED_CONSTANT, name, name);
int p = name.lastIndexOf(Information.NAMESPACE_SEP_CHAR);
if (p > -1) // for global scope
return StringMemory.valueOf(name.substring(p + 1));
else
return StringMemory.valueOf(name);
}
return constant;
}*/
private Memory __import(String path, ArrayMemory locals, TraceInfo trace, String funcName, boolean once, Callback<Void, Void> callback) throws Throwable {
synchronized (moduleManager) {
if (once && moduleManager.hasModule(path)) {
return Memory.TRUE;
}
ModuleEntity module = moduleManager.fetchCachedModule(path, path.endsWith(".phb"));
if (module == null) {
callback.call(null);
return Memory.FALSE;
}
pushCall(trace, null, new Memory[] { StringMemory.valueOf(path) }, funcName, null, null);
try {
if (locals == null) {
locals = new ArrayMemory();
}
return module.include(this, locals);
} finally {
popCall();
}
}
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class HttpClientExtension method cookieToArray.
public static ArrayMemory cookieToArray(HttpCookie cookie) {
ArrayMemory memory = new ArrayMemory();
memory.refOfIndex("value").assign(cookie.getValue());
memory.refOfIndex("name").assign(cookie.getName());
memory.refOfIndex("domain").assign(cookie.getDomain());
memory.refOfIndex("path").assign(cookie.getPath());
memory.refOfIndex("secure").assign(cookie.getSecure());
memory.refOfIndex("maxAge").assign(cookie.getMaxAge());
memory.refOfIndex("comment").assign(cookie.getComment());
memory.refOfIndex("discard").assign(cookie.getDiscard());
memory.refOfIndex("ports").assign(cookie.getPortlist());
memory.refOfIndex("version").assign(cookie.getVersion());
memory.refOfIndex("httpOnly").assign(cookie.isHttpOnly());
return memory;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class PHttpResponse method setRawCookies.
@Signature
public void setRawCookies(ArrayMemory rawCookies) {
this.rawCookies = rawCookies;
ArrayMemory cookies = new ArrayMemory();
ForeachIterator iterator = rawCookies.foreachIterator(false, false);
while (iterator.next()) {
cookies.putAsKeyString(iterator.getStringKey(), iterator.getValue().valueOfIndex("value").toImmutable());
}
this.cookies = cookies;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class Environment method __tick.
/***** UTILS *****/
public void __tick(TraceInfo trace, ArrayMemory locals) {
TickHandler tickHandler = scope.getTickHandler();
if (tickHandler != null) {
IObject $this = this.getLateObject();
if ($this != null) {
Memory value = ObjectMemory.valueOf($this);
if ($this instanceof Closure) {
value = ((Closure) $this).getSelf();
}
if (value.isObject()) {
locals.putAsKeyString("this", value);
}
}
tickHandler.onTick(this, trace, locals);
}
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ArrayFunctions method recursive_count.
private static int recursive_count(Environment env, TraceInfo trace, ArrayMemory array, Set<Integer> used) {
ForeachIterator iterator = array.foreachIterator(false, false);
int size = array.size();
while (iterator.next()) {
Memory el = iterator.getValue();
if (el.isArray()) {
if (used == null)
used = new HashSet<>();
int pointer = el.getPointer();
if (!used.add(pointer)) {
env.warning(trace, "recursion detected");
} else {
size += recursive_count(env, trace, array, used);
}
used.remove(pointer);
}
}
return size;
}
Aggregations