[ilasm] Custom attributes syntax with typeref expression
authorMarek Safar <marek.safar@gmail.com>
Wed, 24 Jun 2015 18:59:16 +0000 (20:59 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 24 Jun 2015 18:59:16 +0000 (20:59 +0200)
mcs/ilasm/parser/ILParser.jay

index 52edc8718398390a93b0c454806d2e4ad665f350..e4a980cb115832ec2fcfd7c24a6e4bde09536a35 100644 (file)
@@ -2801,24 +2801,27 @@ prop_decl               : D_SET method_ref
                        | language_decl\r
                        ;\r
 \r
-customattr_decl                : D_CUSTOM custom_type\r
+customattr_decl\r
+                       : D_CUSTOM customattr_owner_type_opt custom_type\r
                           {\r
-                                $$ = new CustomAttr ((BaseMethodRef) $2, null);\r
+                                $$ = new CustomAttr ((BaseMethodRef) $3, null);\r
                           }\r
-                       | D_CUSTOM custom_type ASSIGN comp_qstring\r
-                       | D_CUSTOM custom_type ASSIGN bytes_list\r
+                       | D_CUSTOM customattr_owner_type_opt custom_type ASSIGN comp_qstring\r
+                       | D_CUSTOM customattr_owner_type_opt custom_type ASSIGN bytes_list\r
                           {\r
-                                $$ = new CustomAttr ((BaseMethodRef) $2, new ByteArrConst ((byte[]) $4));\r
+                                $$ = new CustomAttr ((BaseMethodRef) $3, new ByteArrConst ((byte[]) $5));\r
                           }\r
-            | D_CUSTOM custom_type ASSIGN OPEN_BRACE customattr_values CLOSE_BRACE\r
+            | D_CUSTOM customattr_owner_type_opt custom_type ASSIGN OPEN_BRACE customattr_values CLOSE_BRACE\r
               {\r
-               $$ = new CustomAttr ((BaseMethodRef) $2, (PEAPI.Constant) $5);\r
+               $$ = new CustomAttr ((BaseMethodRef) $3, (PEAPI.Constant) $6);\r
               }\r
-                       | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type\r
-                       | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN comp_qstring\r
-                       | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN bytes_list\r
                        ;\r
 \r
+// TODO: unused for now\r
+customattr_owner_type_opt\r
+                       : /* empty */\r
+                       | OPEN_PARENS type CLOSE_PARENS\r
+                       ;\r
 \r
 customattr_values\r
                                : /* empty */\r
@@ -2845,8 +2848,8 @@ customattr_values
                                ;\r
 \r
 customattr_ctor_args\r
-                               : field_init_primitive\r
-                               | customattr_ctor_args field_init_primitive\r
+                               : customattr_ctor_arg\r
+                               | customattr_ctor_args customattr_ctor_arg\r
                                  {\r
                                        var l = $1 as List<DataConstant>;\r
                                        if (l == null) {\r
@@ -2860,6 +2863,14 @@ customattr_ctor_args
                                  }\r
                                ;\r
 \r
+customattr_ctor_arg\r
+                               : field_init_primitive\r
+                               | K_TYPE OPEN_PARENS type CLOSE_PARENS\r
+                                 {\r
+                                       $$ = new StringConst (((TypeRef) $3).FullName);\r
+                                 }\r
+                               ;\r
+\r
                        \r
 custom_type            : call_conv type type_spec DOUBLE_COLON method_name OPEN_PARENS type_list CLOSE_PARENS\r
                           {\r