Search in sources :

Example 1 with ContextValueProvider

use of org.develnext.jphp.debug.impl.command.support.ContextValueProvider in project jphp by jphp-compiler.

the class ContextGetCommand method run.

@Override
public void run(Debugger context, CommandArguments args, Document result) {
    Element response = createResponse(args, result);
    String contextId = args.get("c");
    response.setAttribute("context", contextId);
    ContextValueProvider contextValueProvider = new ContextValueProvider(context, result);
    switch(contextId) {
        case "0":
            DebugTick tick = context.getRegisteredTick();
            ForeachIterator iterator = tick.getLocals().foreachIterator(true, false);
            while (iterator.next()) {
                Memory value = iterator.getValue().toValue();
                if (value.isUndefined()) {
                    continue;
                }
                response.appendChild(contextValueProvider.getProperty(iterator.getKey().toString(), value));
            }
            break;
    }
}
Also used : DebugTick(org.develnext.jphp.debug.impl.DebugTick) ForeachIterator(php.runtime.lang.ForeachIterator) ContextValueProvider(org.develnext.jphp.debug.impl.command.support.ContextValueProvider) Memory(php.runtime.Memory) Element(org.w3c.dom.Element)

Example 2 with ContextValueProvider

use of org.develnext.jphp.debug.impl.command.support.ContextValueProvider in project jphp by jphp-compiler.

the class EvalCommand method run.

@Override
public void run(Debugger context, CommandArguments args, Document result) {
    String content = args.getContent();
    Element response = createResponse(args, result);
    response.setAttribute("success", "1");
    ContextValueProvider valueProvider = new ContextValueProvider(context, result);
    valueProvider.setMaxData(0);
    Memory value = getValue(context, content);
    if (value == null) {
        response.setAttribute("success", "0");
    } else {
        response.appendChild(valueProvider.getProperty(null, value));
    }
}
Also used : ContextValueProvider(org.develnext.jphp.debug.impl.command.support.ContextValueProvider) Memory(php.runtime.Memory) Element(org.w3c.dom.Element)

Example 3 with ContextValueProvider

use of org.develnext.jphp.debug.impl.command.support.ContextValueProvider in project jphp by jphp-compiler.

the class PropertyGetCommand method run.

@Override
public void run(Debugger context, CommandArguments args, Document result) {
    DebugTick tick = context.getRegisteredTick();
    Element response = createResponse(args, result);
    response.setAttribute("encoding", "base64");
    String varName = args.get("n");
    if (varName.startsWith("$")) {
        varName = varName.substring(1);
    }
    ArrayMemory locals = tick.getLocals();
    if (!locals.containsKey(varName)) {
        return;
    }
    ContextValueProvider provider = getContextValueProvider(context, result);
    if (provider.getMaxData() != 0 && args.containsKey("m")) {
        try {
            provider.setMaxData(Integer.parseInt(args.get("m")));
        } catch (NumberFormatException e) {
            return;
        }
    }
    Element property = provider.getProperty(null, locals.valueOfIndex(varName));
    response.setAttribute("size", property.getAttribute("size"));
    response.appendChild(property.getFirstChild());
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) DebugTick(org.develnext.jphp.debug.impl.DebugTick) ContextValueProvider(org.develnext.jphp.debug.impl.command.support.ContextValueProvider) Element(org.w3c.dom.Element)

Example 4 with ContextValueProvider

use of org.develnext.jphp.debug.impl.command.support.ContextValueProvider in project jphp by jphp-compiler.

the class PropertyValueCommand method getContextValueProvider.

@Override
protected ContextValueProvider getContextValueProvider(Debugger debugger, Document document) {
    ContextValueProvider valueProvider = new ContextValueProvider(debugger, document);
    valueProvider.setMaxData(0);
    return valueProvider;
}
Also used : ContextValueProvider(org.develnext.jphp.debug.impl.command.support.ContextValueProvider)

Aggregations

ContextValueProvider (org.develnext.jphp.debug.impl.command.support.ContextValueProvider)4 Element (org.w3c.dom.Element)3 DebugTick (org.develnext.jphp.debug.impl.DebugTick)2 Memory (php.runtime.Memory)2 ForeachIterator (php.runtime.lang.ForeachIterator)1 ArrayMemory (php.runtime.memory.ArrayMemory)1