use of php.runtime.env.CallStackItem in project jphp by jphp-compiler.
the class UXNode method __isset.
@Signature
public Memory __isset(Environment env, String name) throws Throwable {
if (data("--property-" + name).isNotNull()) {
return Memory.TRUE;
}
// jphp hack
CallStackItem callStackItem = env.peekCall(0);
if (callStackItem != null) {
callStackItem.classEntity = callStackItem.staticClassEntity;
callStackItem.clazz = callStackItem.staticClazz;
}
Memory memory = getReflection().getProperty(env, env.trace(), this, name, null, 0);
return memory.isNotNull() ? Memory.TRUE : Memory.FALSE;
}
use of php.runtime.env.CallStackItem in project jphp by jphp-compiler.
the class StackGetCommand method run.
@Override
public void run(Debugger context, CommandArguments args, Document result) {
DebugTick tick = context.getRegisteredTick();
Element response = createResponse(args, result);
CallStack callStack = tick.getCallStack();
List<CallStackItem> list = new ArrayList<>();
Collections.addAll(list, callStack.getSnapshot());
CallStackItem last = list.get(list.size() - 1);
if (list.size() > 1) {
CallStackItem prevLast = list.get(list.size() - 2);
TraceInfo trace = prevLast.getTrace();
prevLast.setTrace(new TraceInfo(trace.getContext(), last.getTrace().getStartLine(), trace.getEndLine(), last.getTrace().getStartPosition(), trace.getEndLine()));
}
last.setTrace(tick.getTrace());
Collections.reverse(list);
int depth = args.containsKey("d") ? Integer.parseInt(args.get("d")) : -1;
if (depth > -1) {
list = list.subList(0, depth + 1);
}
int i = 0;
for (CallStackItem stackItem : list) {
Element stack = result.createElement("stack");
stack.setAttribute("level", String.valueOf(i));
stack.setAttribute("type", "file");
stack.setAttribute("filename", context.getFileName(stackItem.trace.getFileName()));
stack.setAttribute("lineno", String.valueOf(stackItem.trace.getStartLine() + 1));
stack.setAttribute("where", stackItem.getWhere());
response.appendChild(stack);
i++;
}
}
use of php.runtime.env.CallStackItem in project jphp by jphp-compiler.
the class BaseBaseException method getTraceAsString.
@Signature
public Memory getTraceAsString(Environment env, Memory... args) {
int i = 0;
StringBuilder sb = new StringBuilder();
if (callStack != null) {
for (CallStackItem e : getCallStack()) {
if (i != 0)
sb.append("\n");
sb.append("#").append(i).append(" ").append(e.toString(false));
i++;
}
if (i != 0)
sb.append("\n");
sb.append("#").append(i).append(" ").append(Messages.MSG_MAIN_SYMBOL);
}
return new StringMemory(sb.toString());
}
use of php.runtime.env.CallStackItem in project jphp by jphp-compiler.
the class StackTracer method toString.
public String toString(boolean withArgs) {
StringBuilder sb = new StringBuilder();
int i = 0;
for (CallStackItem el : this) {
sb.append("#").append(i).append(" ");
sb.append(el.toString(withArgs));
if (i != result.size() - 1)
sb.append("\n");
i++;
}
return sb.toString();
}
use of php.runtime.env.CallStackItem in project jphp by jphp-compiler.
the class Generator method _next.
protected Memory _next(Environment env) {
if (busy) {
env.error(env.trace(), "Cannot resume an already running generator");
}
boolean x2 = false;
if (callStackItem != null) {
env.pushCall(new CallStackItem(callStackItem));
x2 = true;
}
try {
counter += 1;
busy = true;
return iterator.next().getValue();
} catch (NoSuchElementException e) {
valid = false;
callStackItem = null;
} finally {
if (x2)
env.popCall();
busy = false;
checkThrow();
}
return null;
}
Aggregations