PDA

View Full Version : Call structure?


projectigi
12-30-2007, 12:50 PM
Hi,

is there any way to get the call structure without function profiling?
like


function onCreated()
{
test1();
}

function test1()
{
test2();
}

function test2()
{
}



would be onCreated=>test1=>test2

cbk1994
12-30-2007, 04:19 PM
What is the call structure? aka what does it mean? Never heard the term before.

Novo
12-30-2007, 05:46 PM
What I think about that is using a global variable...


function thing()
{
stack.add( "thing" );
test1();
stack.delete( stack.size() - 1 );
}

function test1()
{
stack.add( "test1" );
test2();
stack.delete( stack.size() - 1 );
}

function test2()
{
stack.add( "test2" );
echo( stack );
stack.delete( stack.size() - 1 );
}


I do believe that temp.name returns the name of the function... But I can't verify this right now... But if you'll be using this, I would recommend you try it out.

What you want, however, isn't currently available in Graal, nor do I believe that it will be.

Inverness
12-31-2007, 04:47 PM
What is the call structure? aka what does it mean? Never heard the term before.Basically you're finding out what functions are called and the order they're called in.

cbk1994
12-31-2007, 05:48 PM
Basically you're finding out what functions are called and the order they're called in.

So, you could get the same result by calling something like


function storeFunction( f )
{
this.functionsCalled.add( f );
}


and then at the end you would have the same result?

EDIT: I realize this isn't what you're asking, I'm just trying to understand this.

Skyld
12-31-2007, 05:54 PM
What is the call structure? aka what does it mean? Never heard the term before.
It is probably more accurately named "call stack access"; typically call stacks are used internally in a lot of languages so that a function knows where to send it's return value, however call stack access also means that the programmer can read the order of executed functions (and also sometimes identify where the function was called from).

It's something that Stefan has thought about adding into GScript but hasn't got to yet; it would greatly improve script security if functions could tell where they were being called from.

Admins
01-02-2008, 12:24 PM
Yes will try to work on that soon.