Search in sources :

Example 1 with StaticMethodInvoker

use of php.runtime.invoke.StaticMethodInvoker in project jphp by jphp-compiler.

the class ReflectionMethod method invokeArgs.

@Signature({ @Arg(value = "object", optional = @Optional, type = HintType.OBJECT), @Arg(value = "args", type = HintType.ARRAY) })
public Memory invokeArgs(Environment env, Memory... args) throws Throwable {
    Memory self = args[0];
    Memory[] arguments = args[1].toValue(ArrayMemory.class).values();
    Invoker invoker;
    if (self.isNull()) {
        invoker = new StaticMethodInvoker(env, env.trace(), methodEntity.getClazzName(), methodEntity);
    } else {
        invoker = new DynamicMethodInvoker(env, env.trace(), self.toObject(IObject.class), methodEntity);
    }
    return invoker.call(arguments);
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) StaticMethodInvoker(php.runtime.invoke.StaticMethodInvoker) StaticMethodInvoker(php.runtime.invoke.StaticMethodInvoker) DynamicMethodInvoker(php.runtime.invoke.DynamicMethodInvoker) Invoker(php.runtime.invoke.Invoker) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) ObjectMemory(php.runtime.memory.ObjectMemory) StringMemory(php.runtime.memory.StringMemory) DynamicMethodInvoker(php.runtime.invoke.DynamicMethodInvoker)

Example 2 with StaticMethodInvoker

use of php.runtime.invoke.StaticMethodInvoker in project jphp by jphp-compiler.

the class ReflectionMethod method invoke.

@Signature({ @Arg(value = "object", optional = @Optional, type = HintType.OBJECT) })
public Memory invoke(Environment env, Memory... args) throws Throwable {
    Memory self = args[0];
    Memory[] arguments = args.length == 1 ? Memory.CONST_EMPTY_ARRAY : Arrays.copyOfRange(args, 1, args.length - 1);
    Invoker invoker;
    if (self.isNull()) {
        invoker = new StaticMethodInvoker(env, env.trace(), methodEntity.getClazzName(), methodEntity);
    } else {
        invoker = new DynamicMethodInvoker(env, env.trace(), self.toObject(IObject.class), methodEntity);
    }
    return invoker.call(arguments);
}
Also used : StaticMethodInvoker(php.runtime.invoke.StaticMethodInvoker) StaticMethodInvoker(php.runtime.invoke.StaticMethodInvoker) DynamicMethodInvoker(php.runtime.invoke.DynamicMethodInvoker) Invoker(php.runtime.invoke.Invoker) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) ObjectMemory(php.runtime.memory.ObjectMemory) StringMemory(php.runtime.memory.StringMemory) DynamicMethodInvoker(php.runtime.invoke.DynamicMethodInvoker)

Aggregations

Memory (php.runtime.Memory)2 DynamicMethodInvoker (php.runtime.invoke.DynamicMethodInvoker)2 Invoker (php.runtime.invoke.Invoker)2 StaticMethodInvoker (php.runtime.invoke.StaticMethodInvoker)2 ArrayMemory (php.runtime.memory.ArrayMemory)2 LongMemory (php.runtime.memory.LongMemory)2 ObjectMemory (php.runtime.memory.ObjectMemory)2 StringMemory (php.runtime.memory.StringMemory)2