xxx.pushRefArg(myStr);(my imaginary function)
xxx.pushValueArg(5);(my imaginary function)
yyy.call(printIntAndString);(also my imaginary function)
anyone could tell me does C# or mono support calling function in this way?
I want to have some knowledge of the very low level code…
if it does, what are xxx and yyy.
and is it supported in mobile platform…
Actually if you aren’t after this for performance and instead simply want to manipulate methods on a very low level the you can do this sort of thing with reflection.
It will be slower then calling a method directly, but it gives you incredible flexibility to invoke a method however you choose.
the question is: it not C#, the code is a string interpreted by an interpreter
I want to know how the interpreter works…like lua interpreter
it finds a parameter, push it, and push and push, and finally call that function which is binded with a C# function.
reflection is too slow for a call
I want to know how the interpreter function works…like lua interpreter
function callThis(arg1, arg2)
printArg(arg1, arg2)
end
in this imaginary interpreter, printArg is actually connected to a C# function.I can index it by a Dictionary<string, Action> or anything like. in order to make a quick call, I think pushing arg1 and arg2 and then invoking C#printArg is faster than delegate or whichever way …
Well, aside from basic reflection you can look into Reflection.Emit, Expression Trees, or CodeDOM. These will let you dynamically compile code at runtime, but I don’t know if they are available in Unity’s Mono.