Search in sources :

Example 1 with CallStackItem

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;
}
Also used : CallStackItem(php.runtime.env.CallStackItem) Memory(php.runtime.Memory)

Example 2 with CallStackItem

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++;
    }
}
Also used : DebugTick(org.develnext.jphp.debug.impl.DebugTick) CallStackItem(php.runtime.env.CallStackItem) CallStack(php.runtime.env.CallStack) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) TraceInfo(php.runtime.env.TraceInfo)

Example 3 with CallStackItem

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());
}
Also used : CallStackItem(php.runtime.env.CallStackItem) StringMemory(php.runtime.memory.StringMemory) Signature(php.runtime.annotation.Reflection.Signature)

Example 4 with CallStackItem

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();
}
Also used : CallStackItem(php.runtime.env.CallStackItem)

Example 5 with CallStackItem

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;
}
Also used : CallStackItem(php.runtime.env.CallStackItem) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

CallStackItem (php.runtime.env.CallStackItem)6 Memory (php.runtime.Memory)2 StringMemory (php.runtime.memory.StringMemory)2 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1 DebugTick (org.develnext.jphp.debug.impl.DebugTick)1 Element (org.w3c.dom.Element)1 Signature (php.runtime.annotation.Reflection.Signature)1 CallStack (php.runtime.env.CallStack)1 TraceInfo (php.runtime.env.TraceInfo)1 ArrayMemory (php.runtime.memory.ArrayMemory)1