* ILParser.jay: Define data, fix repeat_opt allways being set.
authorJackson Harper <jackson@novell.com>
Sun, 20 Apr 2003 09:08:49 +0000 (09:08 -0000)
committerJackson Harper <jackson@novell.com>
Sun, 20 Apr 2003 09:08:49 +0000 (09:08 -0000)
svn path=/trunk/mcs/; revision=13819

mcs/ilasm/parser/ChangeLog
mcs/ilasm/parser/ILParser.jay

index 1e16656a17092ca613292865161896ff7b7c0e40..1b5a6a7a3940a2ea80c1f5192515a7d4d88df59c 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+       * ILParser.jay: Define data, fix repeat_opt allways being set.
+               
 2003-04-17 Jackson Harper <jackson@latitudegeo.com>
 
        * ILParser.jay: Add external types to the extern type table.
index 38e840d5df29f5cd6c6f50a7f43cec7a9e300cdd..6fc2d4b3deceace5bbf5b6690da00dfdcded3155 100644 (file)
@@ -1006,10 +1006,10 @@ field_decl              : D_FIELD repeat_opt field_attr type id at_opt init_opt
                                 if ($6 != null) {\r
                                         field_def.AddDataValue ((DataConstant) $6);\r
                                 }\r
+                                */\r
                                 if ($7 != null) {\r
-                                        field_def.AddValue ((Constant) $7);\r
+                                        field_def.SetValue ((Constant) $7);\r
                                 }\r
-                                */\r
                           }\r
                        ;\r
 \r
@@ -1153,14 +1153,44 @@ field_init              : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
                        ;\r
 \r
 data_decl              : data_head data_body\r
+                          {\r
+                                /*\r
+                                Console.WriteLine ("Creating data decl: '{0}' '{1}'", $1, $2);\r
+\r
+                                DataDef datadef = (DataDef) $1;\r
+                                \r
+                                if ($2 is ArrayList) {\r
+                                        ArrayList const_list = (ArrayList) $2;\r
+                                        DataConstant[] const_arr = new DataConstant[const_list.Count];\r
+                                        \r
+                                        for (int i=0; i<const_arr.Length; i++)\r
+                                                const_arr[i] = (DataConstant) const_list[i];\r
+\r
+                                        datadef.PeapiConstant = new ArrayConstant (const_arr);\r
+                                } else {\r
+                                        datadef.PeapiConstant = (PEAPI.Constant) $2;\r
+                                }\r
+                                */\r
+                          }\r
                        ;\r
 \r
-data_head              : D_DATA tls id ASSIGN \r
+data_head              : D_DATA tls id ASSIGN\r
+                          {\r
+                                \r
+                                $$ = new DataDef ((string) $3, (bool)\r
+                          $2);\r
+                               \r
+                          } \r
                        | D_DATA tls\r
+                          {\r
+                                \r
+                                $$ = new DataDef (String.Empty, (bool) $2);\r
+                                \r
+                          }\r
                        ;\r
 \r
-tls                    : /* EMPTY */\r
-                       | K_TLS\r
+tls                    : /* EMPTY */   { $$ = false; }\r
+                       | K_TLS         { $$ = true; }\r
                        ;\r
 \r
 data_body              : OPEN_BRACE dataitem_list CLOSE_BRACE\r
@@ -1185,66 +1215,117 @@ dataitem               : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
                        | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt\r
                           {\r
                                 FloatConst float_const = new FloatConst ((float) $3);\r
-                                $$ = new RepeatedConstant (float_const, (int) $5);\r
+\r
+                                if ($5 != null)\r
+                                        $$ = new RepeatedConstant (float_const, (int) $5);\r
+                                else\r
+                                        $$ = float_const;\r
                           }\r
                        | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS repeat_opt\r
                           {\r
                                 DoubleConst double_const = new DoubleConst ((double) $3);\r
-                                $$ = new RepeatedConstant (double_const, (int) $5);\r
+\r
+                                if ($5 != null)\r
+                                        $$ = new RepeatedConstant (double_const, (int) $5);\r
+                                else\r
+                                        $$ = double_const;\r
                           }\r
                        | K_INT64 OPEN_PARENS int64 CLOSE_PARENS repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((long) $3);\r
-                                $$ = new RepeatedConstant (int_const, (int) $5);\r
+\r
+                                if ($5 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $5);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_INT32 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((int) $3);\r
-                                $$ = new RepeatedConstant (int_const, (int) $5);\r
+\r
+                                if ($5 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $5);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((short) $3);\r
-                                $$ = new RepeatedConstant (int_const, (int) $5);\r
+\r
+                                if ($5 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $5);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((sbyte) $3);\r
-                                $$ = new RepeatedConstant (int_const, (int) $5);\r
+\r
+                                if ($5 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $5);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_FLOAT32 repeat_opt\r
                           {\r
                                 FloatConst float_const = new FloatConst (0F);\r
-                                $$ = new RepeatedConstant (float_const, (int) $2);\r
+\r
+                                if ($2 != null)\r
+                                        $$ = new RepeatedConstant (float_const, (int) $2);\r
+                                else\r
+                                        $$ = float_const;\r
                           }\r
                        | K_FLOAT64 repeat_opt\r
                           {\r
                                 DoubleConst double_const = new DoubleConst (0);\r
-                                $$ = new RepeatedConstant (double_const, (int) $2);\r
+\r
+                                if ($2 != null)\r
+                                        $$ = new RepeatedConstant (double_const, (int) $2);\r
+                                else\r
+                                        $$ = double_const;\r
                           }\r
                        | K_INT64 repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((long) 0);\r
-                                $$ = new RepeatedConstant (int_const, (int) $2);\r
+\r
+                                if ($2 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $2);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_INT32 repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((int) 0);\r
-                                $$ = new RepeatedConstant (int_const, (int) $2);\r
+\r
+                                if ($2 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $2);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_INT16 repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((short) 0);\r
-                                $$ = new RepeatedConstant (int_const, (int) $2);\r
+\r
+                                if ($2 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $2);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        | K_INT8 repeat_opt\r
                           {\r
                                 IntConst int_const = new IntConst ((sbyte) 0);\r
-                                $$ = new RepeatedConstant (int_const, (int) $2);\r
+\r
+                                if ($2 != null)\r
+                                        $$ = new RepeatedConstant (int_const, (int) $2);\r
+                                else\r
+                                        $$ = int_const;\r
                           }\r
                        ;\r
 \r
 method_all             : method_head OPEN_BRACE method_decls CLOSE_BRACE\r
+                          {\r
+                                codegen.EndMethodDef ();\r
+                          }\r
                        ;\r
 \r
 method_head            : D_METHOD meth_attr call_conv param_attr type method_name\r