Search in sources :

Example 41 with ArrayMemory

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;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 42 with ArrayMemory

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);
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) DebugTick(org.develnext.jphp.debug.impl.DebugTick) DoubleMemory(php.runtime.memory.DoubleMemory) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) StringMemory(php.runtime.memory.StringMemory) Element(org.w3c.dom.Element)

Example 43 with ArrayMemory

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

Example 44 with ArrayMemory

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

Example 45 with ArrayMemory

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();
    }
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ArrayList(java.util.ArrayList) OutputBuffer(php.runtime.output.OutputBuffer)

Aggregations

ArrayMemory (php.runtime.memory.ArrayMemory)148 Memory (php.runtime.Memory)60 ForeachIterator (php.runtime.lang.ForeachIterator)41 ObjectMemory (php.runtime.memory.ObjectMemory)35 LongMemory (php.runtime.memory.LongMemory)31 StringMemory (php.runtime.memory.StringMemory)29 ReferenceMemory (php.runtime.memory.ReferenceMemory)25 KeyValueMemory (php.runtime.memory.KeyValueMemory)17 Invoker (php.runtime.invoke.Invoker)9 ClassEntity (php.runtime.reflection.ClassEntity)9 Signature (php.runtime.annotation.Reflection.Signature)6 IObject (php.runtime.lang.IObject)6 Map (java.util.Map)4 Test (org.junit.Test)4 DoubleMemory (php.runtime.memory.DoubleMemory)4 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)3 TraceInfo (php.runtime.env.TraceInfo)3 ModuleEntity (php.runtime.reflection.ModuleEntity)3 ParameterEntity (php.runtime.reflection.ParameterEntity)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2