* ILParser.jay: Add module refs, allow them to be referenced.
[mono.git] / mcs / ilasm / parser / ILParser.jay
index dbeaef0e958ffd554ed8f624d1e6427fa667d4a5..886f47990a93a1012a8fbb9d239ca671e07883d8 100644 (file)
@@ -610,6 +610,13 @@ class_ref          : OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name
                                 }\r
                           }\r
                        | OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET slashed_name\r
+                          {\r
+                                if (codegen.IsThisModule ((string) $3)) {\r
+                                        $$ = new TypeRef ((string) $5, false, null);\r
+                                } else {\r
+                                        $$ = codegen.ExternTable.GetModuleTypeRef ((string) $3, (string) $5, false);\r
+                                }\r
+                          }\r
                        | slashed_name\r
                           {\r
                                 PrimitiveTypeRef prim = PrimitiveTypeRef.GetPrimitiveType ((string) $1);\r
@@ -1136,11 +1143,11 @@ field_decl              : D_FIELD repeat_opt field_attr type id at_opt init_opt
                                 if ($2 != null) {\r
                                         field_def.SetOffset ((uint) $2);\r
                                 }\r
-                                \r
+\r
                                 if ($6 != null) {\r
                                         field_def.AddDataValue ((string) $6);\r
                                 }\r
-                                \r
+\r
                                 if ($7 != null) {\r
                                         field_def.SetValue ((Constant) $7);\r
                                 }\r
@@ -1363,7 +1370,8 @@ dataitem          : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
                           }\r
                        | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt\r
                           {\r
-                                FloatConst float_const = new FloatConst ((float) $3);\r
+                                double d = (double) $3;\r
+                                FloatConst float_const = new FloatConst ((float) d);\r
 \r
                                 if ($5 != null)\r
                                         $$ = new RepeatedConstant (float_const, (int) $5);\r
@@ -1399,7 +1407,8 @@ dataitem          : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
                           }\r
                        | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
-                                IntConst int_const = new IntConst ((short) $3);\r
+                                int i = (int) $3;\r
+                                IntConst int_const = new IntConst ((short) i);\r
 \r
                                 if ($5 != null)\r
                                         $$ = new RepeatedConstant (int_const, (int) $5);\r
@@ -1408,7 +1417,8 @@ dataitem          : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
                           }\r
                        | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
-                                IntConst int_const = new IntConst ((sbyte) $3);\r
+                                int i = (int) $3;\r
+                                IntConst int_const = new IntConst ((sbyte) i);\r
 \r
                                 if ($5 != null)\r
                                         $$ = new RepeatedConstant (int_const, (int) $5);\r
@@ -1757,6 +1767,9 @@ type_spec         : class_ref
                                 // assembly. This is not supported in the MS version of ilasm\r
                           }\r
                        | OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET\r
+                          {\r
+\r
+                          }\r
                        | type\r
                        ;\r
 \r
@@ -2352,8 +2365,16 @@ sec_action               : K_REQUEST
                        ;\r
 \r
 module_head            : D_MODULE\r
+                          {\r
+                          }\r
                        | D_MODULE comp_name\r
+                          {\r
+                                codegen.SetModuleName ((string) $2);\r
+                          }\r
                        | D_MODULE K_EXTERN comp_name\r
+                          {\r
+                                codegen.ExternTable.AddModule ((string) $3);                         \r
+                          }\r
                        ;\r
 \r
 file_decl              : D_FILE file_attr comp_name file_entry D_HASH ASSIGN\r