public void RegisterMethod(string name, int signature, NativeMethod method, int frameSize) { _methods[HashMethod(name, signature)] = new NativeMethodInfo { Name = name, Signature = signature, FrameSize = frameSize, Method = method }; }
public virtual NativeMethod GetMethod(string name, int signature) { NativeMethodInfo result = null; if (!_methods.TryGetValue(HashMethod(name, signature), out result)) { return(null); } return(result.Method); }
public int GetFrameSize(string name, int signature) { return(40); NativeMethodInfo result = null; if (!_methods.TryGetValue(HashMethod(name, signature), out result)) { return(0); } return(result.FrameSize); }
//directly called only by native mathods implementation internal void PrepareMethodInvocation(MethodInfo methodToRun, JavaInstance instance, object[] parameters) { if (methodToRun.IsNative) { NativeMethodInfo nativeMethod = (NativeMethodInfo)methodToRun; object returnValue = nativeMethod.Implementation(instance, parameters, this); if (returnValue != null) { stack.Peek().PushToOperandStack(returnValue); } } else { StackFrame newFrame = new StackFrame(methodToRun, this); newFrame.InitLocals(instance, parameters); stack.Push(newFrame); } }
public void SignalException(string exceptionClassName, string ctorDescriptor = null, object[] parameters = null) { var exceptionInstance = CreateJavaInstance(exceptionClassName); NativeMethodInfo nativeCtor = null; if (ctorDescriptor == null) { nativeCtor = exceptionInstance.JavaClass.GetMethodInfo(ClassDefaults.ConstructorMethodName + ClassDefaults.VoidMethodDescriptor) as NativeMethodInfo; } else { nativeCtor = exceptionInstance.JavaClass.GetMethodInfo(ClassDefaults.ConstructorMethodName + ctorDescriptor) as NativeMethodInfo; } if (nativeCtor != null) { nativeCtor.Implementation(exceptionInstance, parameters ?? ClassDefaults.EmptyParameters, this); } SignalException(exceptionInstance); }
protected void AddMethod(NativeMethodInfo methodInfo) { base.Methods.Add(methodInfo.Key, methodInfo); }