X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Filasm%2Fparser%2FILParser.jay;h=523c5ffe1a236bcd21cfa40e6ab7fa0d7f998cb4;hb=4bf3aa7b3f52c3e7ff63813425c6fe97235e5673;hp=5fbdb1edf0de03fafb8c1d580227b33df97140b8;hpb=f95a20d10819d33ed8ddcfceed5a2ef340287da9;p=mono.git diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay index 5fbdb1edf0d..523c5ffe1a2 100644 --- a/mcs/ilasm/parser/ILParser.jay +++ b/mcs/ilasm/parser/ILParser.jay @@ -305,13 +305,14 @@ namespace Mono.ILASM { %token K_OUT %token K_OPT // %token K_LCID -%token K_RETVAL +//%token K_RETVAL %token K_STATIC %token K_PUBLIC %token K_PRIVATE %token K_FAMILY %token K_INITONLY %token K_RTSPECIALNAME +%token K_STRICT %token K_SPECIALNAME %token K_ASSEMBLY %token K_FAMANDASSEM @@ -768,6 +769,14 @@ formal_typar_attr : /* EMPTY */ { $$ = new PEAPI.GenericParamAttributes (); } + | formal_typar_attr PLUS + { + $$ = (PEAPI.GenericParamAttributes) $1 | PEAPI.GenericParamAttributes.Covariant; + } + | formal_typar_attr DASH + { + $$ = (PEAPI.GenericParamAttributes) $1 | PEAPI.GenericParamAttributes.Contravariant; + } | formal_typar_attr D_CTOR { $$ = (PEAPI.GenericParamAttributes) $1 | PEAPI.GenericParamAttributes.DefaultConstructorConstrait; @@ -907,8 +916,8 @@ class_decl : method_all (CallConv) $6, (string) $4, param_list, 0); // NOTICE: `owner' here might be wrong - string sig = MethodDef.CreateSignature (owner, (string) $10, - param_list, 0); + string sig = MethodDef.CreateSignature (owner, (CallConv) $6, (string) $10, + param_list, 0, false); codegen.CurrentTypeDef.AddOverride (sig, decl); } OPEN_PARENS sig_args CLOSE_PARENS @@ -1911,6 +1920,7 @@ meth_attr : /* EMPTY */ { $$ = new MethAttr (); } | meth_attr K_REQSECOBJ { $$ = (MethAttr) $1 | MethAttr.RequireSecObject; } | meth_attr K_SPECIALNAME { $$ = (MethAttr) $1 | MethAttr.SpecialName; } | meth_attr K_RTSPECIALNAME { $$ = (MethAttr) $1 | MethAttr.RTSpecialName; } + | meth_attr K_STRICT { $$ = (MethAttr) $1 | MethAttr.Strict; } | meth_attr K_COMPILERCONTROLLED { /* Do nothing */ } | meth_attr K_UNMANAGEDEXP | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring K_AS @@ -2067,6 +2077,11 @@ method_decls : /* EMPTY */ ; method_decl : D_EMITBYTE int32 + { + codegen.CurrentMethodDef.AddInstr (new + EmitByteInstr ((int) $2, tokenizer.Location)); + + } | D_MAXSTACK int32 { codegen.CurrentMethodDef.SetMaxStack ((int) $2); @@ -2143,9 +2158,7 @@ method_decl : D_EMITBYTE int32 if (param == null) { Report.Warning (tokenizer.Location, String.Format ("invalid param index ({0}) with .param", index)); - break; - } - if ($5 != null) + } else if ($5 != null) param.AddDefaultValue ((Constant) $5); } | param_type_decl @@ -2230,12 +2243,14 @@ scope_block : scope_block_begin method_decls CLOSE_BRACE { $$ = new HandlerBlock ((LabelInfo) $1, codegen.CurrentMethodDef.AddLabel ()); + codegen.CurrentMethodDef.EndLocalsScope (); } ; scope_block_begin : OPEN_BRACE { $$ = codegen.CurrentMethodDef.AddLabel (); + codegen.CurrentMethodDef.BeginLocalsScope (); } ; @@ -2285,12 +2300,12 @@ seh_clauses : seh_clause } ; -seh_clause : K_CATCH class_ref handler_block +seh_clause : K_CATCH type handler_block { if ($2.GetType () == typeof (PrimitiveTypeRef)) Report.Error ("Exception not be of a primitive type."); - BaseClassRef type = (BaseClassRef) $2; + BaseTypeRef type = (BaseTypeRef) $2; CatchBlock cb = new CatchBlock (type); cb.SetHandlerBlock ((HandlerBlock) $3); $$ = cb; @@ -2347,8 +2362,8 @@ handler_block : scope_block } | K_HANDLER int32 K_TO int32 { - LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2); - LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4); + LabelInfo from = codegen.CurrentMethodDef.AddLabel ((int) $2); + LabelInfo to = codegen.CurrentMethodDef.AddLabel ((int) $4); $$ = new HandlerBlock (from, to); } @@ -2367,6 +2382,8 @@ instr : INSTR_NONE | INSTR_LOCAL id { int slot = codegen.CurrentMethodDef.GetNamedLocalSlot ((string) $2); + if (slot < 0) + Report.Error (String.Format ("Undeclared identifier '{0}'", (string) $2)); codegen.CurrentMethodDef.AddInstr ( new IntInstr ((IntOp) $1, slot, tokenizer.Location)); } @@ -2392,6 +2409,8 @@ instr : INSTR_NONE | INSTR_I id { int slot = codegen.CurrentMethodDef.GetNamedLocalSlot ((string) $2); + if (slot < 0) + Report.Error (String.Format ("Undeclared identifier '{0}'", (string) $2)); codegen.CurrentMethodDef.AddInstr (new IntInstr ((IntOp) $1, slot, tokenizer.Location)); } @@ -2428,13 +2447,23 @@ instr : INSTR_NONE } | INSTR_R bytes_list { + byte[] fpdata; switch ((MiscInstr) $1) { case MiscInstr.ldc_r4: - float s = BitConverter.ToSingle ((byte []) $2, 0); + fpdata = (byte []) $2; + if (!BitConverter.IsLittleEndian) { + System.Array.Reverse (fpdata, 0, 4); + } + float s = BitConverter.ToSingle (fpdata, 0); codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, s, tokenizer.Location)); break; case MiscInstr.ldc_r8: - double d = BitConverter.ToDouble ((byte []) $2, 0); + fpdata = (byte []) $2; + if (!BitConverter.IsLittleEndian) { + // FIXME: handle the stupid ARM FPA format + System.Array.Reverse (fpdata, 0, 8); + } + double d = BitConverter.ToDouble (fpdata, 0); codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, d, tokenizer.Location)); break; } @@ -2584,7 +2613,7 @@ labels : /* EMPTY */ | id { ArrayList label_list = new ArrayList (); - label_list.Add ($1); + label_list.Add (codegen.CurrentMethodDef.AddLabelRef ((string) $1)); $$ = label_list; } | int32 @@ -2596,7 +2625,7 @@ labels : /* EMPTY */ | labels COMMA id { ArrayList label_list = (ArrayList) $1; - label_list.Add ($3); + label_list.Add (codegen.CurrentMethodDef.AddLabelRef ((string) $3)); } | labels COMMA int32 { @@ -2767,7 +2796,7 @@ customattr_decl : D_CUSTOM custom_type bytes_list ; -custom_type : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS type_list CLOSE_PARENS +custom_type : call_conv type type_spec DOUBLE_COLON method_name OPEN_PARENS type_list CLOSE_PARENS { BaseTypeRef owner = (BaseTypeRef) $3; ArrayList arg_list = (ArrayList) $7; @@ -2781,7 +2810,7 @@ custom_type : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS type_lis $$ = owner.GetMethodRef ((BaseTypeRef) $2, (CallConv) $1, (string) $5, param_list, 0); } - | call_conv type D_CTOR OPEN_PARENS type_list CLOSE_PARENS + | call_conv type method_name OPEN_PARENS type_list CLOSE_PARENS { ArrayList arg_list = (ArrayList) $5; BaseTypeRef[] param_list; @@ -3243,7 +3272,7 @@ float64 : FLOAT64 { int i = (int) $3; byte[] intb = BitConverter.GetBytes (i); - $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4); + $$ = (double) BitConverter.ToSingle (intb, 0); } | K_FLOAT32 OPEN_PARENS INT64 CLOSE_PARENS { @@ -3254,12 +3283,12 @@ float64 : FLOAT64 | K_FLOAT64 OPEN_PARENS INT64 CLOSE_PARENS { byte[] intb = BitConverter.GetBytes ((long) $3); - $$ = BitConverter.ToDouble (intb, BitConverter.IsLittleEndian ? 0 : 4); + $$ = BitConverter.ToDouble (intb, 0); } | K_FLOAT64 OPEN_PARENS INT32 CLOSE_PARENS { byte[] intb = BitConverter.GetBytes ((int) $3); - $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4); + $$ = (double) BitConverter.ToSingle (intb, 0); } ;