Accessing current script line number from external functions

May 7, 2013 at 7:04 AM
Edited May 7, 2013 at 7:05 AM
Does anyone have an idea how the following scenario could be implemented:

whenever an external function (registered using SetFunction("Name", new Action<object>...)) I would like to allow the called function to write a log entry including the current line number.
One way to do this would be running the script in debug mode all the time and manually storing the current line from the OnStep event. But that's eating up performance. So ideally there would be something like a context that I can pass to the external function that holds all the current engine states including the SourceCodeDescriptor structure.

Any ideas welcome