X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Filasm%2Fparser%2FILParser.jay;h=1c4c9c40deca3fc71985ef52110d8cdcd1a4bd1b;hb=ba2604940e0dcfe116c44eea72932326aabaa8ff;hp=b0ac8dab7ddb6c51b773a12612b6f832e9f2ff73;hpb=01a00d3020acef8b08cbb21088b6921f0e47ff86;p=mono.git diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay index b0ac8dab7dd..1c4c9c40dec 100644 --- a/mcs/ilasm/parser/ILParser.jay +++ b/mcs/ilasm/parser/ILParser.jay @@ -6,6 +6,7 @@ using PEAPI; using System; using System.Collections; +using System.Globalization; namespace Mono.ILASM { @@ -67,7 +68,8 @@ namespace Mono.ILASM { %token BANG "!" %token ELLIPSIS "..." %token DASH "-" - +%token OPEN_ANGLE_BRACKET "<" +%token CLOSE_ANGLE_BRACKET ">" @@ -97,7 +99,6 @@ namespace Mono.ILASM { - /* Mechanically generated - DO NOT EDIT! */ @@ -401,7 +402,6 @@ vtfixup_decl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET ; vtfixup_attr : /* EMPTY */ - | vtfixup_attr int32 | vtfixup_attr int64 | vtfixup_attr K_FROMUNMANAGED | vtfixup_attr K_CALLMOSTDERIVED @@ -419,29 +419,30 @@ namespace_head : D_NAMESPACE comp_name } ; -class_all : class_head OPEN_BRACE class_decls - CLOSE_BRACE +class_all : class_head OPEN_BRACE class_decls CLOSE_BRACE { - codegen.CompleteClass (); + codegen.EndTypeDef (); } - ; -class_head : D_CLASS class_attr id extends_clause +class_head : D_CLASS class_attr id typars_clause extends_clause impl_clause { + codegen.BeginTypeDef ((TypeAttr) $2, (string) $3, + $5 as IClassRef, $6 as ArrayList, null); + + /* + // Lets not worry about generics for now :p if ($4 != null) { - codegen.AddClass ((TypeAttr) $2, (string) $3, - ((TypeRef)$4).Type as Class, null); - } else { - codegen.AddClass ((TypeAttr)$2, (string) $3, null); - } - - ArrayList impl_list = (ArrayList) $5; - if (impl_list != null) { - foreach (TypeRef type_ref in impl_list) - codegen.CurrentClass.AddImplementedInterface (type_ref.Type as Class); - } + ArrayList typars_list = (ArrayList) $4; + int index = 0; + foreach (DictionaryEntry entry in typars_list) { + TypeRef type = (TypeRef) entry.Key; + string name = (string) entry.Value; + codegen.CurrentClass.AddGenericParameter ((short) index++, type.Type, name); + } + } + */ } ; @@ -489,6 +490,46 @@ impl_clause : /* EMPTY */ } ; +typars_clause : /* EMPTY */ + | OPEN_ANGLE_BRACKET formal_typars CLOSE_ANGLE_BRACKET + { + $$ = $2; + } + ; + +typars : type + { + ArrayList typars_list = new ArrayList (); + typars_list.Add ($1); + $$ = typars_list; + } + | typars COMMA type + { + ArrayList typars_list = (ArrayList) $1; + typars_list.Add ($3); + $$ = typars_list; + } + ; + +formal_typars : formal_typar + { + ArrayList formal_list = new ArrayList (); + formal_list.Add ($1); + $$ = formal_list; + } + | formal_typars COMMA formal_typar + { + ArrayList formal_list = (ArrayList) $1; + formal_list.Add ($3); + $$ = formal_list; + } + ; + + +formal_typar : type { $$ = new DictionaryEntry ($1, null); } + | type id { $$ = new DictionaryEntry ($1, $2); } + ; + class_refs : class_ref { ArrayList class_list = new ArrayList (); @@ -511,14 +552,13 @@ slashed_name : comp_name class_ref : OPEN_BRACKET comp_name CLOSE_BRACKET slashed_name { - PEAPI.Type type = codegen.ExternTable.GetClass ((string) $2, (string)$4); - $$ = new TypeRef (type, (string) $4); + ClassRef klass = codegen.ExternTable.GetClass ((string) $2, (string)$4); + $$ = new ExternTypeRef (klass, (string) $4); } | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET slashed_name | slashed_name { - $$ = new TypeRef (codegen.ClassTable.GetReference ((string) $1, null), - (string) $1); + $$ = new TypeRef ((string) $1, null); } ; @@ -536,6 +576,9 @@ class_decl : method_all | extsource_spec | customattr_decl | D_SIZE int32 + { + + } | D_PACK int32 | D_OVERRIDE type_spec DOUBLE_COLON method_name K_WITH call_conv type type_spec DOUBLE_COLON method_name @@ -549,11 +592,11 @@ type : K_CLASS class_ref } | K_OBJECT { - $$ = new TypeRef (PrimitiveType.Object, "System.Object"); + $$ = new PrimitiveTypeRef (PrimitiveType.Object, "System.Object"); } | K_STRING { - $$ = new TypeRef (PrimitiveType.String, "System.String"); + $$ = new PrimitiveTypeRef (PrimitiveType.String, "System.String"); } | K_VALUE K_CLASS class_ref { @@ -565,151 +608,125 @@ type : K_CLASS class_ref } | type OPEN_BRACKET CLOSE_BRACKET { - TypeRef base_type = (TypeRef) $1; - PEAPI.Type arr_type = new ZeroBasedArray (base_type.Type); - $$ = new TypeRef (arr_type, base_type.FullName + "[]"); + ITypeRef base_type = (ITypeRef) $1; + base_type.MakeArray (); } | type OPEN_BRACKET bounds CLOSE_BRACKET { - TypeRef base_type = (TypeRef) $1; + ITypeRef base_type = (ITypeRef) $1; ArrayList bound_list = (ArrayList) $3; - int dimen = bound_list.Count; - int[] lower_array = new int[dimen]; - int[] size_array = new int[dimen]; - bool lower_set = false; - bool size_set = false; - bool prev_lower_set = true; - bool prev_size_set = true; - - // TODO: There should probably be an error reported if - // something like [3...,3...5] is done - for (int i=0; i Int32.MaxValue) + $$ = Int32.MaxValue; + else if (int64 < Int32.MinValue) + $$ = Int32.MinValue; + } ; -int64 : INT32 - | INT64 +int64 : INT64 + | INT32 ; float64 : FLOAT64 @@ -1371,16 +1926,32 @@ float64 : FLOAT64 ; hexbyte : HEXBYTE - | INT32 // ******** ADDED - | ID // ******** ADDED + | INT32 { $$ = Convert.ToByte ($1); } + | ID + { + $$ = Byte.Parse ((string) $1, NumberStyles.HexNumber); + } ; -bytes : /* EMPTY */ +bytes : /* EMPTY */ { $$ = new byte[0]; } | hexbytes + { + ArrayList byte_list = (ArrayList) $1; + $$ = byte_list.ToArray (typeof (byte)); + } ; hexbytes : hexbyte + { + ArrayList byte_list = new ArrayList (); + byte_list.Add (Convert.ToByte ($1)); + $$ = byte_list; + } | hexbytes hexbyte + { + ArrayList byte_list = (ArrayList) $1; + byte_list.Add (Convert.ToByte ($2)); + } ; truefalse : K_TRUE @@ -1392,11 +1963,10 @@ id : ID ; comp_name : id - | dotted_name - ; - -dotted_name : id - | dotted_name DOT id + | comp_name DOT id + { + $$ = (string) $1 + '.' + (string) $3; + } ;