From: Jackson Harper Date: Sat, 11 Oct 2003 08:57:47 +0000 (-0000) Subject: * ILParser.jay: Create generic method refs. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=5cf9f721be18eee56497d3c761ff36019869b656;p=mono.git * ILParser.jay: Create generic method refs. svn path=/trunk/mcs/; revision=18875 --- diff --git a/mcs/ilasm/parser/ChangeLog b/mcs/ilasm/parser/ChangeLog index c429ef179ee..eab3387adb0 100644 --- a/mcs/ilasm/parser/ChangeLog +++ b/mcs/ilasm/parser/ChangeLog @@ -1,3 +1,7 @@ +2003-10-10 Jackson Harper + + * ILParser.jay: Create generic method refs. + 2003-10-08 Jackson Harper * ILParser.jay: Attach generic type parameters to methods. diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay index acd09867441..85d44f967e7 100644 --- a/mcs/ilasm/parser/ILParser.jay +++ b/mcs/ilasm/parser/ILParser.jay @@ -808,7 +808,8 @@ type : K_CLASS class_ref } | BANG BANG int32 { - // access method type parameter by number + MVar mvar = new MVar ((int) $3); + $$ = new GenericTypeRef (mvar, $3.ToString ()); } | K_CLASS slashed_name OPEN_ANGLE_BRACKET BANG int32 CLOSE_ANGLE_BRACKET { @@ -1975,25 +1976,28 @@ instr : INSTR_NONE } ; -method_ref : call_conv type type_spec DOUBLE_COLON method_name - OPEN_PARENS type_list CLOSE_PARENS +method_ref : call_conv type type_spec DOUBLE_COLON method_name + OPEN_PARENS type_list CLOSE_PARENS { ITypeRef owner = (ITypeRef) $3; ArrayList arg_list = (ArrayList) $7; ITypeRef[] param_list; - + IMethodRef methref; + if (arg_list != null) param_list = (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef)); else param_list = new ITypeRef[0]; if (owner.UseTypeSpec) { - $$ = new TypeSpecMethodRef (owner, (ITypeRef) $2, + methref = new TypeSpecMethodRef (owner, (ITypeRef) $2, (CallConv) $1, (string) $5, param_list); } else { - $$ = owner.GetMethodRef ((ITypeRef) $2, + methref = owner.GetMethodRef ((ITypeRef) $2, (CallConv) $1, (string) $5, param_list); } + + $$ = methref; } | call_conv type method_name OPEN_PARENS type_list CLOSE_PARENS @@ -2009,6 +2013,36 @@ method_ref : call_conv type type_spec DOUBLE_COLON method_name $$ = new GlobalMethodRef ((ITypeRef) $2, (CallConv) $1, (string) $3, param_list); } + | call_conv type type_spec DOUBLE_COLON method_name + typars_clause OPEN_PARENS type_list CLOSE_PARENS + { + ITypeRef owner = (ITypeRef) $3; + ArrayList arg_list = (ArrayList) $8; + ITypeRef[] param_list; + IMethodRef methref; + + if (arg_list != null) + param_list = (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef)); + else + param_list = new ITypeRef[0]; + + if (owner.UseTypeSpec) { + methref = new TypeSpecMethodRef (owner, (ITypeRef) $2, + (CallConv) $1, (string) $5, param_list); + } else { + methref = owner.GetMethodRef ((ITypeRef) $2, + (CallConv) $1, (string) $5, param_list); + } + + if ($6 != null) { + ArrayList tp = (ArrayList) $6; + ITypeRef[] ta = (ITypeRef[]) tp.ToArray (typeof (ITypeRef)); + + methref = new GenericMethodRef (methref, new GenericMethodSig (ta)); + } + Console.WriteLine ("methodref: {0}", methref); + $$ = methref; + } ; labels : /* EMPTY */