Search in sources :

Example 1 with PlainPrinter

use of php.runtime.memory.output.PlainPrinter in project jphp by jphp-compiler.

the class CallStackItem method toString.

public String toString(boolean withArgs) {
    StringBuilder sb = new StringBuilder();
    if (object instanceof Closure)
        sb.append("{closure}");
    else if (clazz != null) {
        sb.append(clazz);
        if (object == null)
            sb.append("::");
        else
            sb.append("->");
        sb.append(function);
    } else if (function != null) {
        sb.append(function);
    } else
        sb.append("<internal>");
    sb.append("(");
    if (withArgs) {
        StringWriter writer = new StringWriter();
        PlainPrinter printer = new PlainPrinter(null, writer);
        int i = 0;
        if (args != null)
            for (Memory arg : args) {
                printer.print(arg);
                if (i != args.length - 1)
                    writer.append(", ");
                i++;
            }
        sb.append(writer.toString());
    }
    sb.append(")");
    if (trace != null && trace != TraceInfo.UNKNOWN) {
        sb.append(" called at [");
        sb.append(trace.getFileName());
        sb.append(":");
        sb.append(trace.getStartLine() + 1);
        sb.append("]");
    }
    return sb.toString();
}
Also used : Closure(php.runtime.lang.Closure) StringWriter(java.io.StringWriter) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) ObjectMemory(php.runtime.memory.ObjectMemory) PlainPrinter(php.runtime.memory.output.PlainPrinter)

Aggregations

StringWriter (java.io.StringWriter)1 Memory (php.runtime.Memory)1 Closure (php.runtime.lang.Closure)1 ArrayMemory (php.runtime.memory.ArrayMemory)1 ObjectMemory (php.runtime.memory.ObjectMemory)1 PlainPrinter (php.runtime.memory.output.PlainPrinter)1