[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
AW: [cdt-dev] Reading formal parameters from AST
|
Hi Markus,
thanks for your comments!
> It'd be easier to resolve the binding for the function main:
> IFunction f= (IFunction) declarator.getName().resolveBinding();
> From there you have access to the function type:
> IFunctionType ft= f.getType();
> Then you can check return type and parameter types:
> ft.getReturnType(); ft.getParameterTypes(); // or similar
But I don't see any simplification. getParameterTypes() returns IType s
This is just the same as in my code that applies "getType()" to the parameters.
IVariable argCount = (IVariable)argCountParam.resolveBinding();
String argcType = ASTTypeUtil.getType(argCount.getType());
if(!"int".equals(argcType))
status.addFatalError("First parameter of 'main' function is expected to be of type 'int'.");
With your proposition I still need ASTTypeUtil.getType(...) to generate a String representation
of the IType and compare to what I want to see. Your code even needs the same exceptions to be handled.
Is there any simpler way like
MagicTypeUtil.compare(argCount.getType(), IType.type_int);
Mit freundlichen Grüßen / Best regards
Dr. Nils Hagge
Projektleiter Vorfeld
Siemens AG
Industry Sector, I IA&DT ATS 13
Telefon +49 911 895-3484
Telefax +49 911 895-153484
mailto:nils.hagge@xxxxxxxxxxx
http://www.siemens.com/automation
Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme
Managing Board: Peter Loescher, Chairman, President and Chief Executive Officer;
Wolfgang Dehen, Heinrich Hiesinger, Joe Kaeser, Jim Reid-Anderson, Hermann Requardt,
Siegfried Russwurm, Peter Y. Solmssen
Registered offices: Berlin and Munich;
Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684
WEEE-Reg.-No. DE 23691322
-----Ursprüngliche Nachricht-----
Von: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] Im Auftrag von Schorn, Markus
Gesendet: Mittwoch, 20. Januar 2010 10:01
An: CDT General developers list.
Be