use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class CallStackItem method toArray.
public ArrayMemory toArray(boolean provideObject, boolean ignoreArgs) {
ArrayMemory el = new ArrayMemory();
if (trace != null) {
if (trace.getFile() != null)
el.refOfIndex("file").assign(trace.getFileName());
el.refOfIndex("line").assign(trace.getStartLine() + 1);
}
el.refOfIndex("function").assign(function);
if (clazz != null) {
el.refOfIndex("class").assign(clazz);
el.refOfIndex("type").assign("::");
}
if (object != null) {
if (provideObject) {
el.refOfIndex("object").assign(new ObjectMemory(object));
}
el.refOfIndex("type").assign("->");
}
if (!ignoreArgs) {
el.refOfIndex("args").assign(ArrayMemory.of(args));
}
if (trace != null)
el.refOfIndex("position").assign(trace.getStartPosition() + 1);
return el;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class PropertySetCommand method run.
@Override
public void run(Debugger context, CommandArguments args, Document result) {
DebugTick tick = context.getRegisteredTick();
Element response = createResponse(args, result);
response.setAttribute("success", "1");
String varName = args.get("n");
if (varName.startsWith("$")) {
varName = varName.substring(1);
}
Memory data = EvalCommand.getValue(context, args.getContent());
ArrayMemory locals = tick.getLocals();
if (!locals.containsKey(varName) || data == null) {
response.setAttribute("success", "0");
return;
}
Memory memory = locals.refOfIndex(varName);
Memory.Type type = null;
if (args.containsKey("t")) {
switch(args.get("t")) {
case "boolean":
case "bool":
type = Memory.Type.BOOL;
break;
case "int":
case "integer":
type = Memory.Type.INT;
break;
case "float":
case "double":
type = Memory.Type.DOUBLE;
break;
case "string":
type = Memory.Type.STRING;
break;
case "array":
type = Memory.Type.ARRAY;
break;
case "null":
type = Memory.Type.NULL;
break;
}
}
if (type != null) {
switch(type) {
case BOOL:
data = data.toBoolean() ? Memory.TRUE : Memory.FALSE;
break;
case INT:
data = LongMemory.valueOf(data.toLong());
break;
case DOUBLE:
data = DoubleMemory.valueOf(data.toDouble());
break;
case NULL:
data = Memory.NULL;
break;
case ARRAY:
data = new ArrayMemory();
break;
}
}
memory.assign(data);
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class FileObject method __debugInfo.
@Signature
public Memory __debugInfo(Environment env, Memory... args) {
ArrayMemory r = new ArrayMemory();
r.refOfIndex("*path").assign(file.getPath());
return r.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class OutputFunctions method _get_status.
private static ArrayMemory _get_status(OutputBuffer buffer) {
ArrayMemory result = new ArrayMemory();
result.refOfIndex("name").assign(buffer.getName());
result.refOfIndex("type").assign(buffer.getInvoker() == null ? 0 : 1);
result.refOfIndex("flags").assign(buffer.getStatus());
result.refOfIndex("level").assign(buffer.getLevel() - 1);
result.refOfIndex("chunk_size").assign(buffer.getChunkSize());
result.refOfIndex("buffer_used").assign(buffer.getBufferSize());
return result;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class OutputFunctions method ob_get_status.
public static Memory ob_get_status(Environment env, boolean fullStatus) {
if (fullStatus) {
ArrayMemory result = new ArrayMemory();
OutputBuffer peek = env.peekOutputBuffer();
ArrayList<OutputBuffer> list = new ArrayList<OutputBuffer>();
while (peek != null && !peek.isRoot()) {
list.add(0, peek);
peek = peek.getParentOutput();
}
for (OutputBuffer e : list) {
result.add(_get_status(e));
}
return result;
} else {
OutputBuffer buffer = env.peekOutputBuffer();
if (buffer == null || buffer.isRoot())
return new ArrayMemory().toConstant();
return _get_status(buffer).toConstant();
}
}
Aggregations