* ILParser.jay: Set size and packing information for types
[mono.git] / mcs / ilasm / parser / ILParser.jay
index 25efab48b12550e90723fd60483d009444b6fed2..28f06c9a581f483eec25eefb6722b69654e29646 100644 (file)
@@ -577,9 +577,12 @@ class_decl         : method_all
                        | customattr_decl\r
                        | D_SIZE int32\r
                           {\r
-                                \r
+                                codegen.CurrentTypeDef.SetSize ((int) $2);\r
                           }\r
                        | D_PACK int32\r
+                          {\r
+                                codegen.CurrentTypeDef.SetPack ((int) $2);\r
+                          }\r
                        | D_OVERRIDE type_spec DOUBLE_COLON method_name\r
                          K_WITH call_conv type type_spec DOUBLE_COLON method_name\r
                          OPEN_PARENS sig_args CLOSE_PARENS\r
@@ -1175,16 +1178,11 @@ data_decl               : data_head data_body
 \r
 data_head              : D_DATA tls id ASSIGN\r
                           {\r
-                                \r
-                                $$ = new DataDef ((string) $3, (bool)\r
-                          $2);\r
-                               \r
+                                $$ = new DataDef ((string) $3, (bool) $2);    \r
                           } \r
                        | D_DATA tls\r
                           {\r
-                                \r
                                 $$ = new DataDef (String.Empty, (bool) $2);\r
-                                \r
                           }\r
                        ;\r
 \r
@@ -1432,15 +1430,41 @@ sig_arg                 : param_attr type
                        | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id\r
                        ;\r
 \r
+type_list               : /* EMPTY */   { $$ = new ArrayList (); }\r
+                        | type\r
+                          {\r
+                                ArrayList type_list = new ArrayList ();\r
+                                type_list.Add ($1);\r
+                                $$ = type_list;\r
+                          }\r
+                        | type_list COMMA type\r
+                          {\r
+                                ArrayList type_list = (ArrayList) $1;\r
+                                type_list.Add ($3);\r
+                          }\r
+                        ;\r
+\r
 method_decls           : /* EMPTY */\r
                        | method_decls method_decl\r
                        ;\r
 \r
 method_decl            : D_EMITBYTE int32\r
                        | D_MAXSTACK int32\r
-                       | D_LOCALS OPEN_PARENS sig_args CLOSE_PARENS\r
-                       | D_LOCALS K_INIT OPEN_PARENS sig_args CLOSE_PARENS\r
+                       | D_LOCALS OPEN_PARENS local_list CLOSE_PARENS\r
+                          {\r
+                                codegen.CurrentMethodDef.AddLocals (\r
+                                        (ArrayList) $3);\r
+                          }\r
+                       | D_LOCALS K_INIT OPEN_PARENS local_list CLOSE_PARENS\r
+                          {\r
+                                codegen.CurrentMethodDef.AddLocals (\r
+                                        (ArrayList) $4);\r
+                                codegen.CurrentMethodDef.InitLocals ();\r
+                          }\r
                        | D_ENTRYPOINT\r
+                          {\r
+                                codegen.CurrentMethodDef.EntryPoint ();\r
+                          }\r
                        | D_ZEROINIT\r
                        | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET\r
                        | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id\r
@@ -1461,6 +1485,38 @@ method_decl              : D_EMITBYTE int32
                        | data_decl\r
                        ;\r
 \r
+local_list              : /* EMPTY */\r
+                        | local\r
+                          {\r
+                                ArrayList local_list = new ArrayList ();\r
+                                local_list.Add ($1);\r
+                                $$ = local_list;\r
+                          }\r
+                        | local_list COMMA local\r
+                          {\r
+                                ArrayList local_list = (ArrayList) $1;\r
+                                local_list.Add ($3);\r
+                          }\r
+                        ;\r
+\r
+local                   : type\r
+                          {\r
+                                $$ = new Local (-1, (ITypeRef) $1);\r
+                          }\r
+                        | type id\r
+                          {\r
+                                $$ = new Local (-1, (string) $2, (ITypeRef) $1);\r
+                          }\r
+                        | OPEN_BRACKET int32 CLOSE_BRACKET type\r
+                          {\r
+                                $$ = new Local ((int) $2, (ITypeRef) $4);\r
+                          }\r
+                        | OPEN_BRACKET int32 CLOSE_BRACKET type id\r
+                          {\r
+                                $$ = new Local ((int) $2, (string) $5, (ITypeRef) $4);\r
+                          }\r
+                        ;\r
+\r
 type_spec              : class_ref\r
                        | OPEN_BRACKET comp_name CLOSE_BRACKET\r
                        | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET\r
@@ -1504,6 +1560,9 @@ instr                     : INSTR_NONE
                                         new SimpInstr ((Op) $1));\r
                           }\r
                        | INSTR_VAR int32\r
+                          {\r
+                               \r
+                          }\r
                        | INSTR_I int32\r
                           {\r
                                 codegen.CurrentMethodDef.AddInstr (new\r
@@ -1544,11 +1603,27 @@ instr                   : INSTR_NONE
                           }\r
                        | INSTR_METHOD method_ref\r
                           {\r
-                                \r
+                                codegen.CurrentMethodDef.AddInstr (new MethodInstr ((MethodOp) $1,\r
+                                        (IMethodRef) $2));\r
                           }\r
                        | INSTR_FIELD type type_spec DOUBLE_COLON id\r
+                          {\r
+                                IClassRef owner = (IClassRef) $3;\r
+                                IFieldRef fieldref = owner.GetFieldRef ((ITypeRef) $2, (string) $5);\r
+\r
+                                codegen.CurrentMethodDef.AddInstr (new FieldInstr ((FieldOp) $1, fieldref));\r
+                          }\r
                        | INSTR_FIELD type id\r
+                          {\r
+                                GlobalFieldRef fieldref = new GlobalFieldRef ((ITypeRef) $2, (string) $3);\r
+\r
+                                codegen.CurrentMethodDef.AddInstr (new FieldInstr ((FieldOp) $1, fieldref));\r
+                          }\r
                        | INSTR_TYPE type_spec\r
+                          {\r
+                                codegen.CurrentMethodDef.AddInstr (new TypeInstr ((TypeOp) $1,\r
+                                        (ITypeRef) $2));\r
+                          }\r
                        | INSTR_STRING comp_qstring\r
                           {\r
                                 if ((MiscInstr) $1 == MiscInstr.ldstr)\r
@@ -1566,9 +1641,22 @@ instr                    : INSTR_NONE
                        ;\r
 \r
 method_ref             : call_conv type type_spec DOUBLE_COLON method_name \r
-                         OPEN_PARENS sig_args CLOSE_PARENS\r
+                         OPEN_PARENS type_list CLOSE_PARENS\r
+                          {\r
+                                IClassRef owner = (IClassRef) $3;\r
+                                ArrayList arg_list = (ArrayList) $7;\r
+                                \r
+                                $$ = owner.GetMethodRef ((ITypeRef) $2, (string) $5,\r
+                                        (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef)));\r
+                          }\r
                        | call_conv type method_name \r
-                         OPEN_PARENS sig_args CLOSE_PARENS\r
+                         OPEN_PARENS type_list CLOSE_PARENS\r
+                          {\r
+                                ArrayList arg_list = (ArrayList) $5;\r
+\r
+                                $$ = new GlobalMethodRef ((ITypeRef) $2, (string) $3,\r
+                                        (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef)));\r
+                          }\r
                        ;\r
 \r
 labels                 : /* EMPTY */\r