Search in sources :

Example 41 with StringMemory

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

the class Environment method exception.

public void exception(TraceInfo trace, BaseException e, String message, Object... args) {
    __clearSilent();
    if (args == null || args.length == 0) {
        e.__construct(this, new StringMemory(message));
    } else {
        e.__construct(this, new StringMemory(String.format(message, args)));
    }
    e.setTraceInfo(this, trace);
    throw e;
}
Also used : StringMemory(php.runtime.memory.StringMemory)

Example 42 with StringMemory

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

the class ErrorHandler method onError.

public boolean onError(Environment env, SystemMessage message) {
    if (ErrorType.check(errorHandlerFlags, message.getType())) {
        TraceInfo trace = message.getTrace().trace;
        int argCount = invoker.getArgumentCount();
        if (argCount < 4)
            argCount = 4;
        else if (argCount > 5)
            argCount = 5;
        Memory[] args = new Memory[argCount];
        args[0] = LongMemory.valueOf(message.getType().value);
        args[1] = new StringMemory(message.getMessage());
        args[2] = new StringMemory(trace.getFileName());
        args[3] = LongMemory.valueOf(trace.getStartLine() + 1);
        if (argCount > 4)
            args[4] = new ArrayMemory(false, message.getTrace().args);
        try {
            invoker.setTrace(null);
            return (invoker.call(args).toValue() != Memory.FALSE);
        } catch (ErrorException e) {
            throw e;
        } catch (BaseException e) {
            throw e;
        } catch (DieException e) {
            throw e;
        } catch (Throwable throwable) {
            throw new RuntimeException(throwable);
        }
    }
    return false;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) BaseException(php.runtime.lang.BaseException) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) StringMemory(php.runtime.memory.StringMemory) DieException(php.runtime.env.DieException) StringMemory(php.runtime.memory.StringMemory) TraceInfo(php.runtime.env.TraceInfo) ErrorException(php.runtime.exceptions.support.ErrorException)

Example 43 with StringMemory

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

the class InfoFunctions method print_r.

public static Memory print_r(Environment env, @Runtime.Reference Memory value, boolean returned) {
    StringWriter writer = new StringWriter();
    Printer printer = new PrintR(env, writer);
    printer.print(value);
    if (returned) {
        return new StringMemory(writer.toString());
    } else {
        env.echo(writer.toString());
        return Memory.TRUE;
    }
}
Also used : StringWriter(java.io.StringWriter) StringMemory(php.runtime.memory.StringMemory) Printer(php.runtime.memory.output.Printer) PrintR(php.runtime.memory.output.PrintR)

Example 44 with StringMemory

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

the class InfoFunctions method set_include_path.

public static String set_include_path(Environment env, String value) {
    String old = env.getConfigValue("include_path", Memory.CONST_EMPTY_STRING).toString();
    env.setConfigValue("include_path", new StringMemory(value));
    return old;
}
Also used : StringMemory(php.runtime.memory.StringMemory)

Example 45 with StringMemory

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

the class ClassEntity method emptyProperty.

public Memory emptyProperty(Environment env, TraceInfo trace, IObject object, String property) throws Throwable {
    ClassEntity contex = env.getLastClassOnStack();
    PropertyEntity entity = isInstanceOf(contex) ? contex.properties.get(property) : properties.get(property);
    int accessFlag = entity == null ? 0 : entity.canAccess(env);
    ArrayMemory props = object.getProperties();
    if (props != null && accessFlag == 0) {
        Memory tmp = props.getByScalar(entity == null ? property : entity.specificName);
        if (tmp != null) {
            return tmp.toBoolean() ? Memory.TRUE : Memory.NULL;
        } else
            return Memory.NULL;
    }
    if (methodMagicIsset != null) {
        Memory result;
        if (contex != null && contex.getId() == methodMagicIsset.getClazz().getId()) {
            if (env.peekCall(0).flags == FLAG_ISSET) {
                return object.getProperties().getByScalar(property) != null ? Memory.TRUE : Memory.NULL;
            }
        }
        try {
            Memory[] args = new Memory[] { new StringMemory(property) };
            env.pushCall(trace, object, args, methodMagicIsset.getName(), methodMagicIsset.getClazz().getName(), name);
            env.peekCall(0).flags = FLAG_ISSET;
            InvokeArgumentHelper.checkType(env, trace, methodMagicIsset, new StringMemory(property));
            result = methodMagicIsset.invokeDynamic(object, env, new StringMemory(property)).toBoolean() ? Memory.TRUE : Memory.NULL;
        } finally {
            env.popCall();
        }
        return result;
    }
    return Memory.NULL;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ArrayMemory(php.runtime.memory.ArrayMemory) Memory(php.runtime.Memory) ReferenceMemory(php.runtime.memory.ReferenceMemory) StringMemory(php.runtime.memory.StringMemory) StringMemory(php.runtime.memory.StringMemory)

Aggregations

StringMemory (php.runtime.memory.StringMemory)47 ArrayMemory (php.runtime.memory.ArrayMemory)14 Memory (php.runtime.Memory)11 ObjectMemory (php.runtime.memory.ObjectMemory)8 ReferenceMemory (php.runtime.memory.ReferenceMemory)7 BigDecimal (java.math.BigDecimal)5 Invoker (php.runtime.invoke.Invoker)4 ClassEntity (php.runtime.reflection.ClassEntity)4 TraceInfo (php.runtime.env.TraceInfo)3 IObject (php.runtime.lang.IObject)3 LongMemory (php.runtime.memory.LongMemory)3 StringWriter (java.io.StringWriter)2 ComponentProperties (org.develnext.jphp.swing.ComponentProperties)2 UIReader (org.develnext.jphp.swing.loader.UIReader)2 Signature (php.runtime.annotation.Reflection.Signature)2 CallStackItem (php.runtime.env.CallStackItem)2 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)2 CriticalException (php.runtime.exceptions.CriticalException)2 MethodEntity (php.runtime.reflection.MethodEntity)2 BigInteger (java.math.BigInteger)1