Getting a Function Argument List?

Hello!

I am trying to get a list of arguments to the current function unit, as well as their types if possible. I thought I had figured out the rigtht way to do it, but it doesn't seem to be working. I created a new project in C# which is a phase right after typechecking. In the "Execute" method of this phase, I have the following code:

Code Snippet

protectedoverridevoid Execute(Phx.Unit unit)

{

if (!unit.IsFunctionUnit)

{

return;

}

Phx.FunctionUnit functionUnit = unit.AsFunctionUnit;

Phx.Collections.FunctionArgumentList args =

functionUnit.FunctionSymbol.FunctionArgumentList;

Phx.Types.FunctionType ftype = functionUnit.FunctionSymbol.Type.AsFunctionType;

Phx.Collections.FunctionArgumentList.Iterator iter =

new Phx.Collections.FunctionArgumentList.Iterator(args);

while ( iter.MoveNext() )

{

Phx.Symbols.FunctionArgument arg = iter.CurrentValue;

System.Console.WriteLine("\tFunction Arg: {0}", arg.NameString);

}

...

}

This type-checks, but doesn't work. It throws an assertion failure. But in particular, if I step through the execution, I see that the FunctionArgumentList, args, is always null (not an empty list) no matter how many arguments I have the in the function under analysis. Am I going about this the right way?

Thanks,

Nels

[2838 byte] By [NelsBeckman] at [2008-2-20]
# 1

Nels, what you may want to do is to access the destination operands passed to the FunctionUnit through the ENTERFUNCTION instruction (one of the first instructions in the IR).

Let me know if that does what you're looking for.

Thanks.

KangSuGatlin at 2007-10-2 > top of Msdn Tech,Visual Studio,Phoenix...

Visual Studio

Site Classified