Ejemplo n.º 1
0
		public override DynamicMetaObject FallbackInvoke (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
			expr = new Compiler.Invocation (expr, c_args);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			return binder.Bind (callingContext, target);
		}
Ejemplo n.º 2
0
		public override DynamicMetaObject FallbackInvokeMember (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
			var t_args = typeArguments == null ?
				null :
				new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (TypeImporter.Import (l), Compiler.Location.Null)).ToArray ());

			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo[0], target);

			//
			// Simple name invocation is actually member access invocation
 			// to capture original this argument. This  brings problem when
			// simple name is resolved as a static invocation and member access
			// has to be reduced back to simple name without reporting an error
			//
			if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
				var value = expr as Compiler.RuntimeValueExpression;
				if (value != null)
					value.IsSuggestionOnly = true;
			}

			expr = new Compiler.MemberAccess (expr, Name, t_args, Compiler.Location.Null);
			expr = new Compiler.Invocation (expr, c_args);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
				binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;

			return binder.Bind (callingContext, target);
		}
Ejemplo n.º 3
0
        public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
        {
            var ctx    = DynamicContext.Create();
            var expr   = ctx.CreateCompilerExpression(argumentInfo [0], target);
            var c_args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), args);

            expr = new Compiler.Invocation(expr, c_args);

            if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
            {
                expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
            }
            else
            {
                expr = new Compiler.DynamicResultCast(ctx.ImportType(ReturnType), expr);
            }

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);
            binder.AddRestrictions(args);

            return(binder.Bind(ctx, callingContext));
        }
Ejemplo n.º 4
0
		void DoEmitStringSwitch (LocalTemporary value, EmitContext ec)
		{
			Label l_initialized = ec.DefineLabel ();

			//
			// Skip initialization when value is null
			//
			value.EmitBranchable (ec, null_target, false);

			//
			// Check if string dictionary is initialized and initialize
			//
			switch_cache_field.EmitBranchable (ec, l_initialized, true);
			string_dictionary.EmitStatement (ec);
			ec.MarkLabel (l_initialized);

			LocalTemporary string_switch_variable = new LocalTemporary (TypeManager.int32_type);

			ResolveContext rc = new ResolveContext (ec.MemberContext);

			if (TypeManager.generic_ienumerable_type != null) {
				Arguments get_value_args = new Arguments (2);
				get_value_args.Add (new Argument (value));
				get_value_args.Add (new Argument (string_switch_variable, Argument.AType.Out));
				Expression get_item = new Invocation (new MemberAccess (switch_cache_field, "TryGetValue", loc), get_value_args).Resolve (rc);
				if (get_item == null)
					return;

				//
				// A value was not found, go to default case
				//
				get_item.EmitBranchable (ec, default_target, false);
			} else {
				Arguments get_value_args = new Arguments (1);
				get_value_args.Add (new Argument (value));

				Expression get_item = new ElementAccess (switch_cache_field, get_value_args, loc).Resolve (rc);
				if (get_item == null)
					return;

				LocalTemporary get_item_object = new LocalTemporary (TypeManager.object_type);
				get_item_object.EmitAssign (ec, get_item, true, false);
				ec.Emit (OpCodes.Brfalse, default_target);

				ExpressionStatement get_item_int = (ExpressionStatement) new SimpleAssign (string_switch_variable,
					new Cast (new TypeExpression (TypeManager.int32_type, loc), get_item_object, loc)).Resolve (rc);

				get_item_int.EmitStatement (ec);
				get_item_object.Release (ec);
			}

			TableSwitchEmit (ec, string_switch_variable);
			string_switch_variable.Release (ec);
		}
Ejemplo n.º 5
0
			public override bool Resolve (BlockContext ec)
			{
				bool is_dynamic = expr.Type == InternalType.Dynamic;
				if (is_dynamic)
					expr = Convert.ImplicitConversionRequired (ec, expr, TypeManager.ienumerable_type, loc);

				var get_enumerator_mg = ResolveGetEnumerator (ec);
				if (get_enumerator_mg == null) {
					return false;
				}

				var get_enumerator = get_enumerator_mg.BestCandidate;
				var enumerator = new TemporaryVariable (get_enumerator.ReturnType, loc);
				enumerator.Resolve (ec);

				// Prepare bool MoveNext ()
				var move_next_mg = ResolveMoveNext (ec, get_enumerator);
				if (move_next_mg == null) {
					return false;
				}

				move_next_mg.InstanceExpression = enumerator;

				// Prepare ~T~ Current { get; }
				var current_prop = ResolveCurrent (ec, get_enumerator);
				if (current_prop == null) {
					return false;
				}

				var current_pe = new PropertyExpr (current_prop, loc) { InstanceExpression = enumerator }.Resolve (ec);
				if (current_pe == null)
					return false;

				VarExpr ve = var_type as VarExpr;
				if (ve != null) {
					// Infer implicitly typed local variable from foreach enumerable type
					var_type = new TypeExpression (current_pe.Type, var_type.Location);
				}

				var_type = var_type.ResolveAsTypeTerminal (ec, false);
				if (var_type == null)
					return false;

				var init = new Invocation (get_enumerator_mg, null);
				init.Resolve (ec);

				statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)),
					new Body (var_type.Type, variable, current_pe, statement, loc), loc);

				var enum_type = enumerator.Type;

				//
				// Add Dispose method call when enumerator can be IDisposable
				//
				if (!enumerator.Type.ImplementsInterface (TypeManager.idisposable_type)) {
					if (!enum_type.IsSealed && !TypeManager.IsValueType (enum_type)) {
						//
						// Runtime Dispose check
						//
						var tv = new LocalTemporary (TypeManager.idisposable_type);
						statement = new Dispose (enumerator, tv, init, statement, loc);
					} else {
						//
						// No Dispose call needed
						//
						this.init = new SimpleAssign (enumerator, init);
						this.init.Resolve (ec);
					}
				} else {
					//
					// Static Dispose check
					//
					statement = new Dispose (enumerator, null, init, statement, loc);
				}

				return statement.Resolve (ec);
			}
Ejemplo n.º 6
0
  /** the generated parser.
      Maintains a state and a value stack, currently with fixed maximum size.
      @param yyLex scanner.
      @return result of the last reduction, if any.
      @throws yyException on irrecoverable parse error.
    */
  internal Object yyparse (yyParser.yyInput yyLex)
  {
    if (yyMax <= 0) yyMax = 256;		// initial size
    int yyState = 0;                   // state stack ptr
    int [] yyStates;               	// state stack 
    Object yyVal = null;                // value stack ptr
    Object [] yyVals;					// value stack
    int yyToken = -1;					// current input
    int yyErrorFlag = 0;				// #tks to shift
	if (use_global_stacks && global_yyStates != null) {
		yyVals = global_yyVals;
		yyStates = global_yyStates;
   } else {
		yyVals = new object [yyMax];
		yyStates = new int [yyMax];
		if (use_global_stacks) {
			global_yyVals = yyVals;
			global_yyStates = yyStates;
		}
	}

    /*yyLoop:*/ for (int yyTop = 0;; ++ yyTop) {
      if (yyTop >= yyStates.Length) {			// dynamically increase
        global::System.Array.Resize (ref yyStates, yyStates.Length+yyMax);
        global::System.Array.Resize (ref yyVals, yyVals.Length+yyMax);
      }
      yyStates[yyTop] = yyState;
      yyVals[yyTop] = yyVal;
      if (debug != null) debug.push(yyState, yyVal);

      /*yyDiscarded:*/ for (;;) {	// discarding a token does not change stack
        int yyN;
        if ((yyN = yyDefRed[yyState]) == 0) {	// else [default] reduce (yyN)
          if (yyToken < 0) {
            yyToken = yyLex.advance() ? yyLex.token() : 0;
            if (debug != null)
              debug.lex(yyState, yyToken, yyname(yyToken), yyLex.value());
          }
          if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0)
              && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) {
            if (debug != null)
              debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
            yyState = yyTable[yyN];		// shift to yyN
            yyVal = yyLex.value();
            yyToken = -1;
            if (yyErrorFlag > 0) -- yyErrorFlag;
            goto continue_yyLoop;
          }
          if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
              && yyN < yyTable.Length && yyCheck[yyN] == yyToken)
            yyN = yyTable[yyN];			// reduce (yyN)
          else
            switch (yyErrorFlag) {
  
            case 0:
              yyExpectingState = yyState;
              // yyerror(String.Format ("syntax error, got token `{0}'", yyname (yyToken)), yyExpecting(yyState));
              if (debug != null) debug.error("syntax error");
              if (yyToken == 0 /*eof*/ || yyToken == eof_token) throw new yyParser.yyUnexpectedEof ();
              goto case 1;
            case 1: case 2:
              yyErrorFlag = 3;
              do {
                if ((yyN = yySindex[yyStates[yyTop]]) != 0
                    && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length
                    && yyCheck[yyN] == Token.yyErrorCode) {
                  if (debug != null)
                    debug.shift(yyStates[yyTop], yyTable[yyN], 3);
                  yyState = yyTable[yyN];
                  yyVal = yyLex.value();
                  goto continue_yyLoop;
                }
                if (debug != null) debug.pop(yyStates[yyTop]);
              } while (-- yyTop >= 0);
              if (debug != null) debug.reject();
              throw new yyParser.yyException("irrecoverable syntax error");
  
            case 3:
              if (yyToken == 0) {
                if (debug != null) debug.reject();
                throw new yyParser.yyException("irrecoverable syntax error at end-of-file");
              }
              if (debug != null)
                debug.discard(yyState, yyToken, yyname(yyToken),
  							yyLex.value());
              yyToken = -1;
              goto continue_yyDiscarded;		// leave stack alone
            }
        }
        int yyV = yyTop + 1-yyLen[yyN];
        if (debug != null)
          debug.reduce(yyState, yyStates[yyV-1], yyN, YYRules.getRule (yyN), yyLen[yyN]);
        yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
        switch (yyN) {
case 5:
#line 379 "cs-parser.jay"
  { Lexer.CompleteOnEOF = false; }
  break;
case 7:
#line 384 "cs-parser.jay"
  {
		Lexer.check_incorrect_doc_comment ();
	  }
  break;
case 8:
#line 388 "cs-parser.jay"
  {
		Lexer.check_incorrect_doc_comment ();
	  }
  break;
case 16:
#line 411 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		string s = lt.Value;
		if (s != "alias"){
			syntax_error (lt.Location, "`alias' expected");
		} else if (RootContext.Version == LanguageVersion.ISO_1) {
			Report.FeatureIsNotAvailable (lt.Location, "external alias");
		} else {
			lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; 
			current_namespace.AddUsingExternalAlias (lt.Value, lt.Location, Report);
		}
	  }
  break;
case 17:
#line 424 "cs-parser.jay"
  {
	  	syntax_error (GetLocation (yyVals[-1+yyTop]), "`alias' expected");   /* TODO: better*/
	  }
  break;
case 20:
#line 436 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 21:
#line 441 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 22:
#line 449 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		current_namespace.AddUsingAlias (lt.Value, (MemberName) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 23:
#line 453 "cs-parser.jay"
  {
		CheckIdentifierToken (yyToken, GetLocation (yyVals[0+yyTop]));
		yyVal = null;
	  }
  break;
case 24:
#line 461 "cs-parser.jay"
  {
		current_namespace.AddUsing ((MemberName) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 25:
#line 473 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[0+yyTop];

		if (yyVals[-2+yyTop] != null) {
			Report.Error(1671, name.Location, "A namespace declaration cannot have modifiers or attributes");
		}

		current_namespace = new NamespaceEntry (
			current_namespace, file, name.GetName ());
		current_class = current_namespace.SlaveDeclSpace;
		current_container = current_class.PartialContainer;
	  }
  break;
case 26:
#line 486 "cs-parser.jay"
  { 
		current_namespace = current_namespace.Parent;
		current_class = current_namespace.SlaveDeclSpace;
		current_container = current_class.PartialContainer;
	  }
  break;
case 27:
#line 495 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = new MemberName (lt.Value, lt.Location);
	  }
  break;
case 28:
#line 500 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, lt.Location);		
	  }
  break;
case 29:
#line 505 "cs-parser.jay"
  {
		syntax_error (lexer.Location, "`.' expected");
		yyVal = new MemberName ("<invalid>", lexer.Location);
	  }
  break;
case 34:
#line 523 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[0+yyTop];

		if (name.TypeArguments != null)
			syntax_error (lexer.Location, "namespace name expected");

		yyVal = name;
	  }
  break;
case 35:
#line 535 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 38:
#line 548 "cs-parser.jay"
  {
		Report.Error (1518, lexer.Location, "Expected `class', `delegate', `enum', `interface', or `struct'");
	  }
  break;
case 40:
#line 556 "cs-parser.jay"
  {
		Report.Error (1513, lexer.Location, "Expected `}'");
	  }
  break;
case 49:
#line 583 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null) {
			DeclSpace ds = (DeclSpace)yyVals[0+yyTop];

			if ((ds.ModFlags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){
				Report.Error (1527, ds.Location, 
				"Namespace elements cannot be explicitly declared as private, protected or protected internal");
			}
		}
		current_namespace.DeclarationFound = true;
	  }
  break;
case 50:
#line 594 "cs-parser.jay"
  {
		current_namespace.DeclarationFound = true;
	  }
  break;
case 51:
#line 598 "cs-parser.jay"
  {
		Report.Error (116, ((MemberCore) yyVals[0+yyTop]).Location, "A namespace can only contain types and namespace declarations");
	  }
  break;
case 52:
#line 601 "cs-parser.jay"
  {
		Report.Error (116, ((MemberCore) yyVals[0+yyTop]).Location, "A namespace can only contain types and namespace declarations");
	  }
  break;
case 58:
#line 627 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null) {
			Attributes attrs = (Attributes)yyVals[0+yyTop];
			if (global_attrs_enabled) {
				CodeGen.Assembly.AddAttributes (attrs.Attrs, current_namespace);
			} else {
				foreach (Attribute a in attrs.Attrs) {
					Report.Error (1730, a.Location, "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations");
				}
			}
		}
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 59:
#line 644 "cs-parser.jay"
  {
		global_attrs_enabled = false;
		yyVal = null;
      }
  break;
case 60:
#line 649 "cs-parser.jay"
  { 
		global_attrs_enabled = false;
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 61:
#line 658 "cs-parser.jay"
  {
		if (current_attr_target != String.Empty) {
			var sect = (List<Attribute>) yyVals[0+yyTop];

			if (global_attrs_enabled) {
				if (current_attr_target == "module") {
					current_container.Module.Compiled.AddAttributes (sect);
					yyVal = null;
				} else if (current_attr_target != null && current_attr_target.Length > 0) {
					CodeGen.Assembly.AddAttributes (sect, current_namespace);
					yyVal = null;
				} else {
					yyVal = new Attributes (sect);
				}
				if (yyVal == null) {
					if (RootContext.Documentation != null) {
						Lexer.check_incorrect_doc_comment ();
						Lexer.doc_state =
							XmlCommentState.Allowed;
					}
				}
			} else {
				yyVal = new Attributes (sect);
			}		
		}
		else
			yyVal = null;
		current_attr_target = null;
	  }
  break;
case 62:
#line 688 "cs-parser.jay"
  {
		if (current_attr_target != String.Empty) {
			Attributes attrs = yyVals[-1+yyTop] as Attributes;
			var sect = (List<Attribute>) yyVals[0+yyTop];

			if (global_attrs_enabled) {
				if (current_attr_target == "module") {
					current_container.Module.Compiled.AddAttributes (sect);
					yyVal = null;
				} else if (current_attr_target == "assembly") {
					CodeGen.Assembly.AddAttributes (sect, current_namespace);
					yyVal = null;
				} else {
					if (attrs == null)
						attrs = new Attributes (sect);
					else
						attrs.AddAttributes (sect);			
				}
			} else {
				if (attrs == null)
					attrs = new Attributes (sect);
				else
					attrs.AddAttributes (sect);
			}		
			yyVal = attrs;
		}
		else
			yyVal = null;
		current_attr_target = null;
	  }
  break;
case 63:
#line 722 "cs-parser.jay"
  {
		yyVal = yyVals[-2+yyTop];
 	  }
  break;
case 64:
#line 726 "cs-parser.jay"
  {
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 65:
#line 733 "cs-parser.jay"
  {
		current_attr_target = (string)yyVals[-1+yyTop];
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 66:
#line 741 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = CheckAttributeTarget (lt.Value, lt.Location);
	  }
  break;
case 67:
#line 745 "cs-parser.jay"
  { yyVal = "event"; }
  break;
case 68:
#line 746 "cs-parser.jay"
  { yyVal = "return"; }
  break;
case 69:
#line 748 "cs-parser.jay"
  {
		string name = GetTokenName (yyToken);
		yyVal = CheckAttributeTarget (name, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 70:
#line 756 "cs-parser.jay"
  {
		yyVal = new List<Attribute> (4) { (Attribute) yyVals[0+yyTop] };
	  }
  break;
case 71:
#line 760 "cs-parser.jay"
  {
		var attrs = (List<Attribute>) yyVals[-2+yyTop];
		attrs.Add ((Attribute) yyVals[0+yyTop]);

		yyVal = attrs;
	  }
  break;
case 72:
#line 770 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 73:
#line 774 "cs-parser.jay"
  {
		--lexer.parsing_block;
		MemberName mname = (MemberName) yyVals[-2+yyTop];
		if (mname.IsGeneric) {
			Report.Error (404, lexer.Location,
				      "'<' unexpected: attributes cannot be generic");
		}

		Arguments [] arguments = (Arguments []) yyVals[0+yyTop];
		ATypeNameExpression expr = mname.GetTypeExpression ();

		if (current_attr_target == String.Empty)
			yyVal = null;
		else if (global_attrs_enabled && (current_attr_target == "assembly" || current_attr_target == "module"))
			/* FIXME: supply "nameEscaped" parameter here.*/
			yyVal = new GlobalAttribute (current_namespace, current_attr_target,
						  expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname.Location));
		else
			yyVal = new Attribute (current_attr_target, expr, arguments, mname.Location, lexer.IsEscapedIdentifier (mname.Location));
	  }
  break;
case 74:
#line 797 "cs-parser.jay"
  { /* reserved attribute name or identifier: 17.4 */ }
  break;
case 75:
#line 801 "cs-parser.jay"
  { yyVal = null; }
  break;
case 76:
#line 803 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 77:
#line 810 "cs-parser.jay"
  { yyVal = null; }
  break;
case 78:
#line 812 "cs-parser.jay"
  {
	  	Arguments a = new Arguments (4);
		a.Add ((Argument) yyVals[0+yyTop]);
		yyVal = new Arguments [] { a, null };
	  }
  break;
case 79:
#line 818 "cs-parser.jay"
  {
	  	Arguments a = new Arguments (4);
		a.Add ((Argument) yyVals[0+yyTop]);  
		yyVal = new Arguments [] { null, a };
	  }
  break;
case 80:
#line 824 "cs-parser.jay"
  {
		Arguments[] o = (Arguments[]) yyVals[-2+yyTop];
		if (o [1] != null) {
			Report.Error (1016, ((Argument) yyVals[0+yyTop]).Expr.Location, "Named attribute arguments must appear after the positional arguments");
			o [0] = new Arguments (4);
		}
		
		Arguments args = ((Arguments) o [0]);
		if (args.Count > 0 && !(yyVals[0+yyTop] is NamedArgument) && args [args.Count - 1] is NamedArgument)
			Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]);
		
		args.Add ((Argument) yyVals[0+yyTop]);
	  }
  break;
case 81:
#line 838 "cs-parser.jay"
  {
		Arguments[] o = (Arguments[]) yyVals[-2+yyTop];
		if (o [1] == null) {
			o [1] = new Arguments (4);
		}

		((Arguments) o [1]).Add ((Argument) yyVals[0+yyTop]);
	  }
  break;
case 82:
#line 850 "cs-parser.jay"
  {
	  	yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 84:
#line 858 "cs-parser.jay"
  {
	  	var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new NamedArgument (lt.Value, lt.Location, (Expression) yyVals[0+yyTop]);	  
	  }
  break;
case 85:
#line 866 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.V_3)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument");
			
		/* Avoid boxing in common case (no modifier)*/
		var arg_mod = yyVals[-1+yyTop] == null ? Argument.AType.None : (Argument.AType) yyVals[-1+yyTop];
			
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		yyVal = new NamedArgument (lt.Value, lt.Location, (Expression) yyVals[0+yyTop], arg_mod);
	  }
  break;
case 86:
#line 879 "cs-parser.jay"
  { yyVal = null; }
  break;
case 87:
#line 881 "cs-parser.jay"
  { 
		yyVal = Argument.AType.Ref;
	  }
  break;
case 88:
#line 885 "cs-parser.jay"
  { 
		yyVal = Argument.AType.Out;
	  }
  break;
case 104:
#line 917 "cs-parser.jay"
  {
		Report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration",
			GetSymbolName (yyToken));
		yyVal = null;
		lexer.parsing_generic_declaration = false;
	  }
  break;
case 105:
#line 930 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = true;
	  }
  break;
case 106:
#line 934 "cs-parser.jay"
  { 
		MemberName name = MakeName ((MemberName) yyVals[0+yyTop]);
		push_current_class (new Struct (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]);
	  }
  break;
case 107:
#line 940 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;

		current_class.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);

		if (RootContext.Documentation != null)
			current_container.DocComment = Lexer.consume_doc_comment ();
	  }
  break;
case 108:
#line 949 "cs-parser.jay"
  {
		--lexer.parsing_declaration;	  
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 109:
#line 955 "cs-parser.jay"
  {
		yyVal = pop_current_class ();
	  }
  break;
case 110:
#line 958 "cs-parser.jay"
  {
		CheckIdentifierToken (yyToken, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 111:
#line 965 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 127:
#line 1007 "cs-parser.jay"
  {
		var modflags = (Modifiers) yyVals[-4+yyTop];
		foreach (VariableDeclaration constant in (List<object>) yyVals[-1+yyTop]){
			Location l = constant.Location;
			if ((modflags & Modifiers.STATIC) != 0) {
				Report.Error (504, l, "The constant `{0}' cannot be marked static", current_container.GetSignatureForError () + "." + (string) constant.identifier);
				continue;
			}

			Const c = new Const (
				current_class, (FullNamedExpression) yyVals[-2+yyTop], (string) constant.identifier, 
				constant.GetInitializer ((FullNamedExpression) yyVals[-2+yyTop]), modflags, 
				(Attributes) yyVals[-5+yyTop], l);

			if (RootContext.Documentation != null) {
				c.DocComment = Lexer.consume_doc_comment ();
				Lexer.doc_state = XmlCommentState.Allowed;
			}
			current_container.AddConstant (c);
		}
	  }
  break;
case 128:
#line 1032 "cs-parser.jay"
  {
  	  	variables_bucket.Clear ();
		if (yyVals[0+yyTop] != null)
			variables_bucket.Add (yyVals[0+yyTop]);
		yyVal = variables_bucket;
	  }
  break;
case 129:
#line 1039 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null) {
			var constants = (List<object>) yyVals[-2+yyTop];
			constants.Add (yyVals[0+yyTop]);
		}
	  }
  break;
case 130:
#line 1049 "cs-parser.jay"
  {
	  	++lexer.parsing_block;
	  }
  break;
case 131:
#line 1053 "cs-parser.jay"
  {
	  	--lexer.parsing_block;
		yyVal = new VariableDeclaration ((Tokenizer.LocatedToken) yyVals[-3+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 132:
#line 1058 "cs-parser.jay"
  {
		/* A const field requires a value to be provided*/
		Report.Error (145, GetLocation (yyVals[0+yyTop]), "A const field requires a value to be provided");
		yyVal = null;
	  }
  break;
case 135:
#line 1076 "cs-parser.jay"
  { 
		FullNamedExpression type = (FullNamedExpression) yyVals[-2+yyTop];
		if (type == TypeManager.system_void_expr)
			Report.Error (670, GetLocation (yyVals[-2+yyTop]), "Fields cannot have void type");
		
		var mod = (Modifiers) yyVals[-3+yyTop];

		foreach (VariableMemberDeclaration var in (List<object>) yyVals[-1+yyTop]){
			Field field = new Field (current_class, type, mod, var.MemberName, (Attributes) yyVals[-4+yyTop]);

			field.Initializer = var.GetInitializer (type);

			if (RootContext.Documentation != null) {
				field.DocComment = Lexer.consume_doc_comment ();
				Lexer.doc_state = XmlCommentState.Allowed;
			}
			current_container.AddField (field);
			yyVal = field; /* FIXME: might be better if it points to the top item*/
		}
	  }
  break;
case 136:
#line 1102 "cs-parser.jay"
  { 
			FullNamedExpression type = (FullNamedExpression) yyVals[-2+yyTop];
			
			var mod = (Modifiers) yyVals[-4+yyTop];

			foreach (VariableDeclaration var in (List<VariableDeclaration>) yyVals[-1+yyTop]) {
				FixedField field = new FixedField (current_class, type, mod, var.identifier,
					var.GetInitializer (type), (Attributes) yyVals[-5+yyTop], var.Location);
					
				if (RootContext.Version < LanguageVersion.ISO_2)
					Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "fixed size buffers");

				if (RootContext.Documentation != null) {
					field.DocComment = Lexer.consume_doc_comment ();
					Lexer.doc_state = XmlCommentState.Allowed;
				}
				current_container.AddField (field);
				yyVal = field; /* FIXME: might be better if it points to the top item*/
			}
	  }
  break;
case 137:
#line 1127 "cs-parser.jay"
  {
		Report.Error (1641, GetLocation (yyVals[-1+yyTop]), "A fixed size buffer field must have the array size specifier after the field name");
	  }
  break;
case 138:
#line 1134 "cs-parser.jay"
  {
		var decl = new List<VariableDeclaration> (2);
		decl.Add ((VariableDeclaration)yyVals[0+yyTop]);
		yyVal = decl;
  	  }
  break;
case 139:
#line 1140 "cs-parser.jay"
  {
		var decls = (List<VariableDeclaration>) yyVals[-2+yyTop];
		decls.Add ((VariableDeclaration)yyVals[0+yyTop]);
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 140:
#line 1149 "cs-parser.jay"
  {
		yyVal = new VariableDeclaration ((Tokenizer.LocatedToken) yyVals[-3+yyTop], (Expression) yyVals[-1+yyTop]);
	  }
  break;
case 141:
#line 1153 "cs-parser.jay"
  {
		Report.Error (443, lexer.Location, "Value or constant expected");
		yyVal = new VariableDeclaration ((Tokenizer.LocatedToken) yyVals[-2+yyTop], null);
	  }
  break;
case 142:
#line 1162 "cs-parser.jay"
  {
		variables_bucket.Clear ();
		if (yyVals[0+yyTop] != null)
			variables_bucket.Add (yyVals[0+yyTop]);
		yyVal = variables_bucket;
	  }
  break;
case 143:
#line 1169 "cs-parser.jay"
  {
		var decls = (List<object>) yyVals[-2+yyTop];
		decls.Add (yyVals[0+yyTop]);
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 144:
#line 1178 "cs-parser.jay"
  {
		yyVal = new VariableDeclaration ((Tokenizer.LocatedToken) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 145:
#line 1182 "cs-parser.jay"
  {
		yyVal = new VariableDeclaration ((Tokenizer.LocatedToken) yyVals[0+yyTop], null);
	  }
  break;
case 146:
#line 1186 "cs-parser.jay"
  {
		yyVal = null;
	  }
  break;
case 149:
#line 1195 "cs-parser.jay"
  {
		yyVal = new StackAlloc ((Expression) yyVals[-3+yyTop], (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 150:
#line 1199 "cs-parser.jay"
  {
		yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 151:
#line 1203 "cs-parser.jay"
  {
		Report.Error (1575, GetLocation (yyVals[-1+yyTop]), "A stackalloc expression requires [] after type");
		yyVal = new StackAlloc ((Expression) yyVals[0+yyTop], null, GetLocation (yyVals[-1+yyTop]));		
	  }
  break;
case 152:
#line 1211 "cs-parser.jay"
  {
		variables_bucket.Clear ();
		if (yyVals[0+yyTop] != null)
			variables_bucket.Add (yyVals[0+yyTop]);
		yyVal = variables_bucket;
	  }
  break;
case 153:
#line 1218 "cs-parser.jay"
  {
		var decls = (List<object>) yyVals[-2+yyTop];
		decls.Add (yyVals[0+yyTop]);
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 154:
#line 1227 "cs-parser.jay"
  {
	  	++lexer.parsing_block;
	  	lexer.parsing_generic_declaration = false;
	  }
  break;
case 155:
#line 1232 "cs-parser.jay"
  {
	  	--lexer.parsing_block;
		yyVal = new VariableMemberDeclaration ((MemberName) yyVals[-3+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 156:
#line 1237 "cs-parser.jay"
  {
	  	lexer.parsing_generic_declaration = false;
		yyVal = new VariableMemberDeclaration ((MemberName) yyVals[0+yyTop], null);
	  }
  break;
case 157:
#line 1242 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = false;	  
		yyVal = null;
	  }
  break;
case 158:
#line 1250 "cs-parser.jay"
  {
		Report.Error (650, GetLocation (yyVals[-2+yyTop]), "Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. " +
			"To declare a fixed size buffer field, use the fixed keyword before the field type");
	  }
  break;
case 161:
#line 1262 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.NotAllowed;
	  }
  break;
case 162:
#line 1267 "cs-parser.jay"
  {
		Method method = (Method) yyVals[-2+yyTop];
		method.Block = (ToplevelBlock) yyVals[0+yyTop];
		current_container.AddMethod (method);
		
		if (current_container.Kind == MemberKind.Interface && method.Block != null) {
			Report.Error (531, method.Location, "`{0}': interface members cannot have a definition", method.GetSignatureForError ());
		}

		current_generic_method = null;
		current_local_parameters = null;

		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 163:
#line 1289 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.All;
	  }
  break;
case 164:
#line 1293 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = true;
	  }
  break;
case 165:
#line 1297 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;
		valid_param_mod = 0;
		MemberName name = (MemberName) yyVals[-6+yyTop];
		current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop];

		GenericMethod generic = null;
		if (name.TypeArguments != null) {
			generic = new GenericMethod (current_namespace, current_class, name,
						     (FullNamedExpression) yyVals[-7+yyTop], current_local_parameters);

			generic.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);
		} else if (yyVals[0+yyTop] != null) {
			Report.Error (80, GetLocation (yyVals[0+yyTop]),
				"Constraints are not allowed on non-generic declarations");
		}

		Method method = new Method (current_class, generic, (FullNamedExpression) yyVals[-7+yyTop], (Modifiers) yyVals[-8+yyTop],
				     name, current_local_parameters, (Attributes) yyVals[-9+yyTop]);
				     
		if (yyVals[0+yyTop] != null && ((method.ModFlags & Modifiers.OVERRIDE) != 0 || method.IsExplicitImpl)) {
			Report.Error (460, method.Location,
				"`{0}': Cannot specify constraints for overrides and explicit interface implementation methods",
				method.GetSignatureForError ());
		}

		current_generic_method = generic;

		if (RootContext.Documentation != null)
			method.DocComment = Lexer.consume_doc_comment ();

		yyVal = method;
	  }
  break;
case 166:
#line 1335 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.All;
	  }
  break;
case 167:
#line 1339 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = true;
	  }
  break;
case 168:
#line 1343 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;
		valid_param_mod = 0;

		MemberName name = (MemberName) yyVals[-6+yyTop];
		current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop];

		if (yyVals[-1+yyTop] != null && name.TypeArguments == null)
			Report.Error (80, lexer.Location,
				      "Constraints are not allowed on non-generic declarations");

		Method method;
		GenericMethod generic = null;
		if (name.TypeArguments != null) {
			generic = new GenericMethod (current_namespace, current_class, name,
						     TypeManager.system_void_expr, current_local_parameters);

			generic.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);
		}

		var modifiers = (Modifiers) yyVals[-9+yyTop];


		const Modifiers invalid_partial_mod = Modifiers.AccessibilityMask | Modifiers.ABSTRACT | Modifiers.EXTERN |
			Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.SEALED | Modifiers.VIRTUAL;

		if ((modifiers & invalid_partial_mod) != 0) {
			Report.Error (750, name.Location, "A partial method cannot define access modifier or " +
       			"any of abstract, extern, new, override, sealed, or virtual modifiers");
			modifiers &= ~invalid_partial_mod;
		}

		if ((current_class.ModFlags & Modifiers.PARTIAL) == 0) {
			Report.Error (751, name.Location, "A partial method must be declared within a " +
       			"partial class or partial struct");
		}
		
		modifiers |= Modifiers.PARTIAL | Modifiers.PRIVATE;
		
		method = new Method (current_class, generic, TypeManager.system_void_expr,
				     modifiers, name, current_local_parameters, (Attributes) yyVals[-10+yyTop]);

		current_generic_method = generic;

		if (RootContext.Documentation != null)
			method.DocComment = Lexer.consume_doc_comment ();

		yyVal = method;
	  }
  break;
case 169:
#line 1396 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[-3+yyTop];
		Report.Error (1585, name.Location, 
			"Member modifier `{0}' must precede the member type and name", ModifiersExtensions.Name ((Modifiers) yyVals[-4+yyTop]));

		Method method = new Method (current_class, null, TypeManager.system_void_expr,
					    0, name, (ParametersCompiled) yyVals[-1+yyTop], (Attributes) yyVals[-7+yyTop]);

		current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop];

		if (RootContext.Documentation != null)
			method.DocComment = Lexer.consume_doc_comment ();

		yyVal = method;
	  }
  break;
case 171:
#line 1415 "cs-parser.jay"
  { yyVal = null; }
  break;
case 172:
#line 1419 "cs-parser.jay"
  { yyVal = ParametersCompiled.EmptyReadOnlyParameters; }
  break;
case 174:
#line 1425 "cs-parser.jay"
  { 
		var pars_list = (List<Parameter>) yyVals[0+yyTop];
	  	yyVal = new ParametersCompiled (compiler, pars_list.ToArray ());
	  }
  break;
case 175:
#line 1430 "cs-parser.jay"
  {
		var pars_list = (List<Parameter>) yyVals[-2+yyTop];
		pars_list.Add ((Parameter) yyVals[0+yyTop]);

		yyVal = new ParametersCompiled (compiler, pars_list.ToArray ()); 
	  }
  break;
case 176:
#line 1437 "cs-parser.jay"
  {
		var pars_list = (List<Parameter>) yyVals[-2+yyTop];
		pars_list.Add (new ArglistParameter (GetLocation (yyVals[0+yyTop])));
		yyVal = new ParametersCompiled (compiler, pars_list.ToArray (), true);
	  }
  break;
case 177:
#line 1443 "cs-parser.jay"
  {
		if (yyVals[-2+yyTop] != null)
			Report.Error (231, ((Parameter) yyVals[-2+yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list");

		yyVal = new ParametersCompiled (compiler, new Parameter[] { (Parameter) yyVals[-2+yyTop] } );			
	  }
  break;
case 178:
#line 1450 "cs-parser.jay"
  {
		if (yyVals[-2+yyTop] != null)
			Report.Error (231, ((Parameter) yyVals[-2+yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list");

		var pars_list = (List<Parameter>) yyVals[-4+yyTop];
		pars_list.Add (new ArglistParameter (GetLocation (yyVals[-2+yyTop])));

		yyVal = new ParametersCompiled (compiler, pars_list.ToArray (), true);
	  }
  break;
case 179:
#line 1460 "cs-parser.jay"
  {
		Report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list");

		yyVal = new ParametersCompiled (compiler, new Parameter [] { new ArglistParameter (GetLocation (yyVals[-2+yyTop])) }, true);
	  }
  break;
case 180:
#line 1466 "cs-parser.jay"
  {
		Report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list");

		var pars_list = (List<Parameter>) yyVals[-4+yyTop];
		pars_list.Add (new ArglistParameter (GetLocation (yyVals[-2+yyTop])));

		yyVal = new ParametersCompiled (compiler, pars_list.ToArray (), true);
	  }
  break;
case 181:
#line 1475 "cs-parser.jay"
  {
		yyVal = new ParametersCompiled (compiler, new Parameter[] { (Parameter) yyVals[0+yyTop] } );
	  }
  break;
case 182:
#line 1479 "cs-parser.jay"
  {
		yyVal = new ParametersCompiled (compiler, new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true);
	  }
  break;
case 183:
#line 1486 "cs-parser.jay"
  {
		parameters_bucket.Clear ();
		Parameter p = (Parameter) yyVals[0+yyTop];
		parameters_bucket.Add (p);
		
		default_parameter_used = p.HasDefaultValue;
		yyVal = parameters_bucket;
	  }
  break;
case 184:
#line 1495 "cs-parser.jay"
  {
		var pars = (List<Parameter>) yyVals[-2+yyTop];
		Parameter p = (Parameter) yyVals[0+yyTop];
		if (p != null) {
			if (p.HasExtensionMethodModifier)
				Report.Error (1100, p.Location, "The parameter modifier `this' can only be used on the first parameter");
			else if (!p.HasDefaultValue && default_parameter_used)
				Report.Error (1737, p.Location, "Optional parameter cannot precede required parameters");

			default_parameter_used |= p.HasDefaultValue;
			pars.Add (p);
		}
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 185:
#line 1516 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Parameter.Modifier) yyVals[-2+yyTop], (Attributes) yyVals[-3+yyTop], lt.Location);
	  }
  break;
case 186:
#line 1524 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		Report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name");
		yyVal = new Parameter ((FullNamedExpression) yyVals[-3+yyTop], lt.Value, (Parameter.Modifier) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop], lt.Location);
	  }
  break;
case 187:
#line 1533 "cs-parser.jay"
  {
	  	Location l = GetLocation (yyVals[0+yyTop]);
		CheckIdentifierToken (yyToken, l);
		yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], "NeedSomeGeneratorHere", (Parameter.Modifier) yyVals[-2+yyTop], (Attributes) yyVals[-3+yyTop], l);
	  }
  break;
case 188:
#line 1544 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.V_3) {
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "optional parameter");
		}
		
		Parameter.Modifier mod = (Parameter.Modifier) yyVals[-4+yyTop];
		if (mod != Parameter.Modifier.NONE) {
			switch (mod) {
			case Parameter.Modifier.REF:
			case Parameter.Modifier.OUT:
				Report.Error (1741, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for the `{0}' parameter",
					Parameter.GetModifierSignature (mod));
				break;
				
			case Parameter.Modifier.This:
				Report.Error (1743, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for the `{0}' parameter",
					Parameter.GetModifierSignature (mod));
				break;
			default:
				throw new NotImplementedException (mod.ToString ());
			}
				
			mod = Parameter.Modifier.NONE;
		}
		
		if ((valid_param_mod & ParameterModifierType.DefaultValue) == 0)
			Report.Error (1065, GetLocation (yyVals[0+yyTop]), "Optional parameter is not valid in this context");
		
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new Parameter ((FullNamedExpression) yyVals[-3+yyTop], lt.Value, mod, (Attributes) yyVals[-5+yyTop], lt.Location);
		if (yyVals[0+yyTop] != null)
			((Parameter) yyVal).DefaultValue = (Expression) yyVals[0+yyTop];
	  }
  break;
case 189:
#line 1580 "cs-parser.jay"
  { yyVal = Parameter.Modifier.NONE; }
  break;
case 191:
#line 1586 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 192:
#line 1590 "cs-parser.jay"
  {
		Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop];
  		Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2;
  		if (((Parameter.Modifier)yyVals[-1+yyTop] & p2) == p2) {
  			Error_DuplicateParameterModifier (lexer.Location, p2);
  		} else {
	  		switch (mod & ~Parameter.Modifier.This) {
  				case Parameter.Modifier.REF:
					Report.Error (1101, lexer.Location, "The parameter modifiers `this' and `ref' cannot be used altogether");
  					break;
   				case Parameter.Modifier.OUT:
					Report.Error (1102, lexer.Location, "The parameter modifiers `this' and `out' cannot be used altogether");
  					break;
  				default:
 					Report.Error (1108, lexer.Location, "A parameter cannot have specified more than one modifier");
 					break;
 			}
  		}
  		yyVal = mod;
	  }
  break;
case 193:
#line 1614 "cs-parser.jay"
  {
	  	if ((valid_param_mod & ParameterModifierType.Ref) == 0)
	  		Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop]));
	  		
	  	yyVal = Parameter.Modifier.REF;
	  }
  break;
case 194:
#line 1621 "cs-parser.jay"
  {
	  	if ((valid_param_mod & ParameterModifierType.Out) == 0)
	  		Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop]));
	  
	  	yyVal = Parameter.Modifier.OUT;
	  }
  break;
case 195:
#line 1628 "cs-parser.jay"
  {
		if ((valid_param_mod & ParameterModifierType.This) == 0)
	  		Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop]));

	  	if (RootContext.Version <= LanguageVersion.ISO_2)
	  		Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "extension methods");
	  			
		yyVal = Parameter.Modifier.This;
	  }
  break;
case 196:
#line 1641 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = new ParamsParameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Attributes) yyVals[-3+yyTop], lt.Location);
	  }
  break;
case 197:
#line 1646 "cs-parser.jay"
  {
		Report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array");
		
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new ParamsParameter ((FullNamedExpression) yyVals[-3+yyTop], lt.Value, (Attributes) yyVals[-5+yyTop], lt.Location);		
	  }
  break;
case 198:
#line 1652 "cs-parser.jay"
  {
		CheckIdentifierToken (yyToken, GetLocation (yyVals[0+yyTop]));
		yyVal = null;
	  }
  break;
case 199:
#line 1660 "cs-parser.jay"
  {
		if ((valid_param_mod & ParameterModifierType.Params) == 0)
			Report.Error (1670, (GetLocation (yyVals[0+yyTop])), "The `params' modifier is not allowed in current context");
	  }
  break;
case 200:
#line 1665 "cs-parser.jay"
  {
		Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop];
		if ((mod & Parameter.Modifier.This) != 0) {
			Report.Error (1104, GetLocation (yyVals[-1+yyTop]), "The parameter modifiers `this' and `params' cannot be used altogether");
		} else {
			Report.Error (1611, GetLocation (yyVals[-1+yyTop]), "The params parameter cannot be declared as ref or out");
		}	  
	  }
  break;
case 201:
#line 1674 "cs-parser.jay"
  {
		Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS);
	  }
  break;
case 202:
#line 1681 "cs-parser.jay"
  {
	  	if ((valid_param_mod & ParameterModifierType.Arglist) == 0)
	  		Report.Error (1669, GetLocation (yyVals[0+yyTop]), "__arglist is not valid in this context");
	  }
  break;
case 203:
#line 1692 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			tmpComment = Lexer.consume_doc_comment ();
	  }
  break;
case 204:
#line 1697 "cs-parser.jay"
  {
		implicit_value_parameter_type = (FullNamedExpression) yyVals[-3+yyTop];
		lexer.PropertyParsing = true;
	  }
  break;
case 205:
#line 1702 "cs-parser.jay"
  {
		lexer.PropertyParsing = false;
		has_get = has_set = false;
	  }
  break;
case 206:
#line 1707 "cs-parser.jay"
  { 
		Property prop;
		Accessors accessors = (Accessors) yyVals[-2+yyTop];
		Accessor get_block = accessors != null ? accessors.get_or_add : null;
		Accessor set_block = accessors != null ? accessors.set_or_remove : null;
		bool order = accessors != null ? accessors.declared_in_reverse : false;

		MemberName name = (MemberName) yyVals[-6+yyTop];
		FullNamedExpression ptype = (FullNamedExpression) yyVals[-7+yyTop];

		prop = new Property (current_class, ptype, (Modifiers) yyVals[-8+yyTop],
				     name, (Attributes) yyVals[-9+yyTop], get_block, set_block, order, current_block);

		if (ptype == TypeManager.system_void_expr)
			Report.Error (547, name.Location, "`{0}': property or indexer cannot have void type", prop.GetSignatureForError ());
			
		if (accessors == null)
			Report.Error (548, prop.Location, "`{0}': property or indexer must have at least one accessor", prop.GetSignatureForError ());

		if (current_container.Kind == MemberKind.Interface) {
			if (prop.Get.Block != null)
				Report.Error (531, prop.Location, "`{0}.get': interface members cannot have a definition", prop.GetSignatureForError ());

			if (prop.Set.Block != null)
				Report.Error (531, prop.Location, "`{0}.set': interface members cannot have a definition", prop.GetSignatureForError ());
		}

		current_container.AddProperty (prop);
		implicit_value_parameter_type = null;

		if (RootContext.Documentation != null)
			prop.DocComment = ConsumeStoredComment ();

	  }
  break;
case 207:
#line 1745 "cs-parser.jay"
  {
		yyVal = new Accessors ((Accessor) yyVals[0+yyTop], null);
	 }
  break;
case 208:
#line 1749 "cs-parser.jay"
  { 
		Accessors accessors = (Accessors) yyVals[0+yyTop];
		accessors.get_or_add = (Accessor) yyVals[-1+yyTop];
		yyVal = accessors;
	 }
  break;
case 209:
#line 1755 "cs-parser.jay"
  {
		yyVal = new Accessors (null, (Accessor) yyVals[0+yyTop]);
	 }
  break;
case 210:
#line 1759 "cs-parser.jay"
  { 
		Accessors accessors = (Accessors) yyVals[0+yyTop];
		accessors.set_or_remove = (Accessor) yyVals[-1+yyTop];
		accessors.declared_in_reverse = true;
		yyVal = accessors;
	 }
  break;
case 211:
#line 1766 "cs-parser.jay"
  {
	  	if (yyToken == Token.CLOSE_BRACE) {
	  		yyVal = null;
		} else {
			if (yyToken == Token.SEMICOLON)
				Report.Error (1597, lexer.Location, "Semicolon after method or accessor block is not valid");
			else
				Report.Error (1014, GetLocation (yyVals[0+yyTop]), "A get or set accessor expected");

			yyVal = new Accessors (null, null);
		}
	  }
  break;
case 212:
#line 1782 "cs-parser.jay"
  {
		/* If this is not the case, then current_local_parameters has already*/
		/* been set in indexer_declaration*/
		if (parsing_indexer == false)
			current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
		else 
			current_local_parameters = indexer_parameters;
		lexer.PropertyParsing = false;
	  }
  break;
case 213:
#line 1792 "cs-parser.jay"
  {
		if (has_get) {
			Report.Error (1007, GetLocation (yyVals[-2+yyTop]), "Property accessor already defined");
			break;
		}
		Accessor accessor = new Accessor ((ToplevelBlock) yyVals[0+yyTop], (Modifiers) yyVals[-3+yyTop], (Attributes) yyVals[-4+yyTop], current_local_parameters, GetLocation (yyVals[-2+yyTop]));
		has_get = true;
		current_local_parameters = null;
		lexer.PropertyParsing = true;

		if (RootContext.Documentation != null)
			if (Lexer.doc_state == XmlCommentState.Error)
				Lexer.doc_state = XmlCommentState.NotAllowed;

		yyVal = accessor;
	  }
  break;
case 214:
#line 1812 "cs-parser.jay"
  {
		Parameter implicit_value_parameter = new Parameter (
			implicit_value_parameter_type, "value", 
			Parameter.Modifier.NONE, null, GetLocation (yyVals[0+yyTop]));

		if (!parsing_indexer) {
			current_local_parameters = new ParametersCompiled (compiler, new Parameter [] { implicit_value_parameter });
		} else {
			current_local_parameters = ParametersCompiled.MergeGenerated (compiler,
				indexer_parameters, true, implicit_value_parameter, null);
		}
		
		lexer.PropertyParsing = false;
	  }
  break;
case 215:
#line 1827 "cs-parser.jay"
  {
		if (has_set) {
			Report.Error (1007, GetLocation (yyVals[-2+yyTop]), "Property accessor already defined");
			break;
		}
		Accessor accessor = new Accessor ((ToplevelBlock) yyVals[0+yyTop], (Modifiers) yyVals[-3+yyTop], (Attributes) yyVals[-4+yyTop], current_local_parameters, GetLocation (yyVals[-2+yyTop]));
		has_set = true;
		current_local_parameters = null;
		lexer.PropertyParsing = true;

		if (RootContext.Documentation != null
			&& Lexer.doc_state == XmlCommentState.Error)
			Lexer.doc_state = XmlCommentState.NotAllowed;

		yyVal = accessor;
	  }
  break;
case 217:
#line 1848 "cs-parser.jay"
  {
	  	yyVal = null;
	  }
  break;
case 218:
#line 1852 "cs-parser.jay"
  {
	  	Error_SyntaxError (1043, yyToken, "Invalid accessor body");
	  	yyVal = null;
	  }
  break;
case 219:
#line 1863 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = true;
	  }
  break;
case 220:
#line 1867 "cs-parser.jay"
  {
		MemberName name = MakeName ((MemberName) yyVals[0+yyTop]);
		push_current_class (new Interface (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]);
	  }
  break;
case 221:
#line 1873 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;

		current_class.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);

		if (RootContext.Documentation != null) {
			current_container.DocComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}
	  }
  break;
case 222:
#line 1884 "cs-parser.jay"
  {
		--lexer.parsing_declaration;	  
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 223:
#line 1890 "cs-parser.jay"
  {
		yyVal = pop_current_class ();
	  }
  break;
case 224:
#line 1893 "cs-parser.jay"
  {
		CheckIdentifierToken (yyToken, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 230:
#line 1916 "cs-parser.jay"
  {
		Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
	  }
  break;
case 231:
#line 1920 "cs-parser.jay"
  {
		Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
	  }
  break;
case 236:
#line 1928 "cs-parser.jay"
  {
	  	Report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators");
	  }
  break;
case 237:
#line 1932 "cs-parser.jay"
  {
	  	Report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors");
	  }
  break;
case 238:
#line 1936 "cs-parser.jay"
  {
	  	Report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations");
	  }
  break;
case 239:
#line 1943 "cs-parser.jay"
  {
	  }
  break;
case 240:
#line 1946 "cs-parser.jay"
  {
		if (yyVals[-2+yyTop] == null)
			break;

		OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop];
		Operator op = new Operator (
			current_class, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop], 
			current_local_parameters,
			(ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location);

		if (RootContext.Documentation != null) {
			op.DocComment = tmpComment;
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		/* Note again, checking is done in semantic analysis*/
		current_container.AddOperator (op);

		current_local_parameters = null;
	  }
  break;
case 242:
#line 1970 "cs-parser.jay"
  { yyVal = null; }
  break;
case 244:
#line 1976 "cs-parser.jay"
  {
		Report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void");
		yyVal = TypeManager.system_void_expr;		
	  }
  break;
case 245:
#line 1984 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
  break;
case 246:
#line 1988 "cs-parser.jay"
  {
		valid_param_mod = 0;

		Location loc = GetLocation (yyVals[-5+yyTop]);
		Operator.OpType op = (Operator.OpType) yyVals[-4+yyTop];
		current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop];
		
		int p_count = current_local_parameters.Count;
		if (p_count == 1) {
			if (op == Operator.OpType.Addition)
				op = Operator.OpType.UnaryPlus;
			else if (op == Operator.OpType.Subtraction)
				op = Operator.OpType.UnaryNegation;
		}
		
		if (IsUnaryOperator (op)) {
			if (p_count == 2) {
				Report.Error (1020, loc, "Overloadable binary operator expected");
			} else if (p_count != 1) {
				Report.Error (1535, loc, "Overloaded unary operator `{0}' takes one parameter",
					Operator.GetName (op));
			}
		} else {
			if (p_count > 2) {
				Report.Error (1534, loc, "Overloaded binary operator `{0}' takes two parameters",
					Operator.GetName (op));
			} else if (p_count != 2) {
				Report.Error (1019, loc, "Overloadable unary operator expected");
			}
		}
		
		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}

		yyVal = new OperatorDeclaration (op, (FullNamedExpression) yyVals[-6+yyTop], loc);
	  }
  break;
case 248:
#line 2031 "cs-parser.jay"
  { yyVal = Operator.OpType.LogicalNot; }
  break;
case 249:
#line 2032 "cs-parser.jay"
  { yyVal = Operator.OpType.OnesComplement; }
  break;
case 250:
#line 2033 "cs-parser.jay"
  { yyVal = Operator.OpType.Increment; }
  break;
case 251:
#line 2034 "cs-parser.jay"
  { yyVal = Operator.OpType.Decrement; }
  break;
case 252:
#line 2035 "cs-parser.jay"
  { yyVal = Operator.OpType.True; }
  break;
case 253:
#line 2036 "cs-parser.jay"
  { yyVal = Operator.OpType.False; }
  break;
case 254:
#line 2038 "cs-parser.jay"
  { yyVal = Operator.OpType.Addition; }
  break;
case 255:
#line 2039 "cs-parser.jay"
  { yyVal = Operator.OpType.Subtraction; }
  break;
case 256:
#line 2041 "cs-parser.jay"
  { yyVal = Operator.OpType.Multiply; }
  break;
case 257:
#line 2042 "cs-parser.jay"
  {  yyVal = Operator.OpType.Division; }
  break;
case 258:
#line 2043 "cs-parser.jay"
  { yyVal = Operator.OpType.Modulus; }
  break;
case 259:
#line 2044 "cs-parser.jay"
  { yyVal = Operator.OpType.BitwiseAnd; }
  break;
case 260:
#line 2045 "cs-parser.jay"
  { yyVal = Operator.OpType.BitwiseOr; }
  break;
case 261:
#line 2046 "cs-parser.jay"
  { yyVal = Operator.OpType.ExclusiveOr; }
  break;
case 262:
#line 2047 "cs-parser.jay"
  { yyVal = Operator.OpType.LeftShift; }
  break;
case 263:
#line 2048 "cs-parser.jay"
  { yyVal = Operator.OpType.RightShift; }
  break;
case 264:
#line 2049 "cs-parser.jay"
  { yyVal = Operator.OpType.Equality; }
  break;
case 265:
#line 2050 "cs-parser.jay"
  { yyVal = Operator.OpType.Inequality; }
  break;
case 266:
#line 2051 "cs-parser.jay"
  { yyVal = Operator.OpType.GreaterThan; }
  break;
case 267:
#line 2052 "cs-parser.jay"
  { yyVal = Operator.OpType.LessThan; }
  break;
case 268:
#line 2053 "cs-parser.jay"
  { yyVal = Operator.OpType.GreaterThanOrEqual; }
  break;
case 269:
#line 2054 "cs-parser.jay"
  { yyVal = Operator.OpType.LessThanOrEqual; }
  break;
case 270:
#line 2059 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
  break;
case 271:
#line 2063 "cs-parser.jay"
  {
		valid_param_mod = 0;

		Location loc = GetLocation (yyVals[-5+yyTop]);
		current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop];  
		  
		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}

		yyVal = new OperatorDeclaration (Operator.OpType.Implicit, (FullNamedExpression) yyVals[-4+yyTop], loc);
	  }
  break;
case 272:
#line 2077 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
  break;
case 273:
#line 2081 "cs-parser.jay"
  {
		valid_param_mod = 0;
		
		Location loc = GetLocation (yyVals[-5+yyTop]);
		current_local_parameters = (ParametersCompiled)yyVals[-1+yyTop];  
		  
		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}

		yyVal = new OperatorDeclaration (Operator.OpType.Explicit, (FullNamedExpression) yyVals[-4+yyTop], loc);
	  }
  break;
case 274:
#line 2095 "cs-parser.jay"
  {
	  	Error_SyntaxError (yyToken);
		current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
		yyVal = new OperatorDeclaration (Operator.OpType.Implicit, null, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 275:
#line 2101 "cs-parser.jay"
  {
	  	Error_SyntaxError (yyToken);
		current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
	  	yyVal = new OperatorDeclaration (Operator.OpType.Explicit, null, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 276:
#line 2111 "cs-parser.jay"
  { 
		Constructor c = (Constructor) yyVals[-1+yyTop];
		c.Block = (ToplevelBlock) yyVals[0+yyTop];
		
		if (RootContext.Documentation != null)
			c.DocComment = ConsumeStoredComment ();

		current_container.AddConstructor (c);

		current_local_parameters = null;
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 277:
#line 2130 "cs-parser.jay"
  {
		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}
		
		valid_param_mod = ParameterModifierType.All;
	  }
  break;
case 278:
#line 2139 "cs-parser.jay"
  {
		valid_param_mod = 0;
		current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop];  
		
		/**/
		/* start block here, so possible anonymous methods inside*/
		/* constructor initializer can get correct parent block*/
		/**/
	  	start_block (lexer.Location);
	  }
  break;
case 279:
#line 2150 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-6+yyTop];
		var mods = (Modifiers) yyVals[-7+yyTop];
		ConstructorInitializer ci = (ConstructorInitializer) yyVals[0+yyTop];

		Constructor c = new Constructor (current_class, lt.Value, mods,
			(Attributes) yyVals[-8+yyTop], current_local_parameters, ci, lt.Location);
		
		if (lt.Value != current_container.MemberName.Name) {
			Report.Error (1520, c.Location, "Class, struct, or interface method must have a return type");
		} else if ((mods & Modifiers.STATIC) != 0) {
			if ((mods & Modifiers.AccessibilityMask) != 0){
				Report.Error (515, c.Location,
					"`{0}': static constructor cannot have an access modifier",
					c.GetSignatureForError ());
			}
			if (ci != null) {
				Report.Error (514, c.Location,
					"`{0}': static constructor cannot have an explicit `this' or `base' constructor call",
					c.GetSignatureForError ());
			
			}
		}
		
		yyVal = c;
	  }
  break;
case 281:
#line 2180 "cs-parser.jay"
  { current_block = null; yyVal = null; }
  break;
case 284:
#line 2190 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 285:
#line 2194 "cs-parser.jay"
  {
	  	--lexer.parsing_block;
		yyVal = new ConstructorBaseInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 286:
#line 2199 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 287:
#line 2203 "cs-parser.jay"
  {
	  	--lexer.parsing_block;
		yyVal = new ConstructorThisInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 288:
#line 2207 "cs-parser.jay"
  {
		Report.Error (1018, GetLocation (yyVals[-1+yyTop]), "Keyword `this' or `base' expected");
		yyVal = null;
	  }
  break;
case 289:
#line 2215 "cs-parser.jay"
  {
		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}
		
		current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
	  }
  break;
case 290:
#line 2224 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		if (lt.Value != current_container.MemberName.Name){
			Report.Error (574, lt.Location, "Name of destructor must match name of class");
		} else if (current_container.Kind != MemberKind.Class){
			Report.Error (575, lt.Location, "Only class types can contain destructor");
		} else {
			Destructor d = new Destructor (current_class, (Modifiers) yyVals[-6+yyTop],
				ParametersCompiled.EmptyReadOnlyParameters, (Attributes) yyVals[-7+yyTop], lt.Location);
			if (RootContext.Documentation != null)
				d.DocComment = ConsumeStoredComment ();
		  
			d.Block = (ToplevelBlock) yyVals[0+yyTop];
			current_container.AddMethod (d);
		}

		current_local_parameters = null;
	  }
  break;
case 291:
#line 2248 "cs-parser.jay"
  {
		foreach (VariableMemberDeclaration var in (List<object>) yyVals[-1+yyTop]) {

			EventField e = new EventField (
				current_class, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-4+yyTop], var.MemberName, (Attributes) yyVals[-5+yyTop]);
				
			e.Initializer = var.GetInitializer ((FullNamedExpression) yyVals[-2+yyTop]);
			if (current_container.Kind == MemberKind.Interface && e.Initializer != null) {
				Report.Error (68, e.Location, "`{0}': event in interface cannot have initializer", e.GetSignatureForError ());
			}
			
			if (var.MemberName.Left != null) {
				Report.Error (71, e.Location,
					"`{0}': An explicit interface implementation of an event must use property syntax",
					e.GetSignatureForError ());
			}

			current_container.AddEvent (e);

			if (RootContext.Documentation != null) {
				e.DocComment = Lexer.consume_doc_comment ();
				Lexer.doc_state = XmlCommentState.Allowed;
			}
		}
	  }
  break;
case 292:
#line 2277 "cs-parser.jay"
  {
		implicit_value_parameter_type = (FullNamedExpression) yyVals[-2+yyTop];  
		current_local_parameters = new ParametersCompiled (compiler,
			new Parameter (implicit_value_parameter_type, "value", 
			Parameter.Modifier.NONE, null, GetLocation (yyVals[-3+yyTop])));

		lexer.EventParsing = true;
	  }
  break;
case 293:
#line 2286 "cs-parser.jay"
  {
		lexer.EventParsing = false;  
	  }
  break;
case 294:
#line 2290 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[-5+yyTop];
		
		if (current_container.Kind == MemberKind.Interface) {
			Report.Error (69, GetLocation (yyVals[-7+yyTop]), "Event in interface cannot have add or remove accessors");
			yyVals[-2+yyTop] = new Accessors (null, null);
		} else if (yyVals[-2+yyTop] == null) {
			Report.Error (65, GetLocation (yyVals[-7+yyTop]), "`{0}.{1}': event property must have both add and remove accessors",
				current_container.GetSignatureForError (), name.GetSignatureForError ());
			yyVals[-2+yyTop] = new Accessors (null, null);
		}
		
		Accessors accessors = (Accessors) yyVals[-2+yyTop];

		if (accessors.get_or_add == null || accessors.set_or_remove == null)
			/* CS0073 is already reported, so no CS0065 here.*/
			yyVal = null;
		else {
			Event e = new EventProperty (
				current_class, (FullNamedExpression) yyVals[-6+yyTop], (Modifiers) yyVals[-8+yyTop], name,
				(Attributes) yyVals[-9+yyTop], accessors.get_or_add, accessors.set_or_remove);
			if (RootContext.Documentation != null) {
				e.DocComment = Lexer.consume_doc_comment ();
				Lexer.doc_state = XmlCommentState.Allowed;
			}

			current_container.AddEvent (e);
			implicit_value_parameter_type = null;
		}
		current_local_parameters = null;
	  }
  break;
case 295:
#line 2322 "cs-parser.jay"
  {
		MemberName mn = (MemberName) yyVals[-1+yyTop];
		if (mn.Left != null)
			Report.Error (71, mn.Location, "An explicit interface implementation of an event must use property syntax");

		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;

		Error_SyntaxError (yyToken);
		yyVal = null;
	  }
  break;
case 296:
#line 2337 "cs-parser.jay"
  {
		yyVal = new Accessors ((Accessor) yyVals[-1+yyTop], (Accessor) yyVals[0+yyTop]);
	  }
  break;
case 297:
#line 2341 "cs-parser.jay"
  {
		Accessors accessors = new Accessors ((Accessor) yyVals[0+yyTop], (Accessor) yyVals[-1+yyTop]);
		accessors.declared_in_reverse = true;
		yyVal = accessors;
	  }
  break;
case 298:
#line 2346 "cs-parser.jay"
  { yyVal = null; }
  break;
case 299:
#line 2347 "cs-parser.jay"
  { yyVal = null; }
  break;
case 300:
#line 2349 "cs-parser.jay"
  { 
		Report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected");
		yyVal = null;
	  }
  break;
case 301:
#line 2353 "cs-parser.jay"
  { yyVal = null; }
  break;
case 302:
#line 2358 "cs-parser.jay"
  {
		lexer.EventParsing = false;
	  }
  break;
case 303:
#line 2362 "cs-parser.jay"
  {
		Accessor accessor = new Accessor ((ToplevelBlock) yyVals[0+yyTop], 0, (Attributes) yyVals[-3+yyTop], null, GetLocation (yyVals[-2+yyTop]));
		lexer.EventParsing = true;
		yyVal = accessor;
	  }
  break;
case 304:
#line 2367 "cs-parser.jay"
  {
		Report.Error (73, GetLocation (yyVals[-1+yyTop]), "An add or remove accessor must have a body");
		yyVal = null;
	  }
  break;
case 305:
#line 2371 "cs-parser.jay"
  {
		Report.Error (1609, GetLocation (yyVals[0+yyTop]), "Modifiers cannot be placed on event accessor declarations");
		yyVal = null;
	  }
  break;
case 306:
#line 2379 "cs-parser.jay"
  {
		lexer.EventParsing = false;
	  }
  break;
case 307:
#line 2383 "cs-parser.jay"
  {
		yyVal = new Accessor ((ToplevelBlock) yyVals[0+yyTop], 0, (Attributes) yyVals[-3+yyTop], null, GetLocation (yyVals[-2+yyTop]));
		lexer.EventParsing = true;
	  }
  break;
case 308:
#line 2387 "cs-parser.jay"
  {
		Report.Error (73, GetLocation (yyVals[-1+yyTop]), "An add or remove accessor must have a body");
		yyVal = null;
	  }
  break;
case 309:
#line 2391 "cs-parser.jay"
  {
		Report.Error (1609, GetLocation (yyVals[0+yyTop]), "Modifiers cannot be placed on event accessor declarations");
		yyVal = null;
	  }
  break;
case 310:
#line 2400 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue;
	  }
  break;
case 311:
#line 2405 "cs-parser.jay"
  {
		valid_param_mod = 0;
		implicit_value_parameter_type = (FullNamedExpression) yyVals[-6+yyTop];
		indexer_parameters = (ParametersCompiled) yyVals[-2+yyTop];
		
		if (indexer_parameters.IsEmpty) {
			Report.Error (1551, GetLocation (yyVals[-4+yyTop]), "Indexers must have at least one parameter");
		}

		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		lexer.PropertyParsing = true;
		parsing_indexer  = true;
		
	  }
  break;
case 312:
#line 2424 "cs-parser.jay"
  {
		  lexer.PropertyParsing = false;
		  has_get = has_set = false;
		  parsing_indexer  = false;
	  }
  break;
case 313:
#line 2430 "cs-parser.jay"
  { 
		Accessors accessors = (Accessors) yyVals[-2+yyTop];
		Accessor get_block = accessors != null ? accessors.get_or_add : null;
		Accessor set_block = accessors != null ? accessors.set_or_remove : null;
		bool order = accessors != null ? accessors.declared_in_reverse : false;

		Indexer indexer = new Indexer (current_class, (FullNamedExpression) yyVals[-10+yyTop],
			(MemberName)yyVals[-9+yyTop], (Modifiers) yyVals[-11+yyTop], (ParametersCompiled) yyVals[-6+yyTop], (Attributes) yyVals[-12+yyTop],
			get_block, set_block, order);
				       
		if (yyVals[-10+yyTop] == TypeManager.system_void_expr)
			Report.Error (620, GetLocation (yyVals[-10+yyTop]), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError ());
			
		if (accessors == null)
			Report.Error (548, indexer.Location, "`{0}': property or indexer must have at least one accessor", indexer.GetSignatureForError ());

		if (current_container.Kind == MemberKind.Interface) {
			if (indexer.Get.Block != null)
				Report.Error (531, indexer.Location, "`{0}.get': interface members cannot have a definition", indexer.GetSignatureForError ());

			if (indexer.Set.Block != null)
				Report.Error (531, indexer.Location, "`{0}.set': interface members cannot have a definition", indexer.GetSignatureForError ());
		}

		if (RootContext.Documentation != null)
			indexer.DocComment = ConsumeStoredComment ();

		current_container.AddIndexer (indexer);
		
		current_local_parameters = null;
		implicit_value_parameter_type = null;
		indexer_parameters = null;
	  }
  break;
case 314:
#line 2469 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			enumTypeComment = Lexer.consume_doc_comment ();
	  }
  break;
case 315:
#line 2475 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[-4+yyTop];
		if (name.IsGeneric) {
			Report.Error (1675, name.Location, "Enums cannot have type parameters");
		}

		name = MakeName (name);
		Enum e = new Enum (current_namespace, current_class, (TypeExpr) yyVals[-3+yyTop], (Modifiers) yyVals[-6+yyTop],
				   name, (Attributes) yyVals[-7+yyTop]);
		
		if (RootContext.Documentation != null)
			e.DocComment = enumTypeComment;


		EnumMember em = null;
		foreach (VariableDeclaration ev in (IList<VariableDeclaration>) yyVals[-1+yyTop]) {
			em = new EnumMember (
				e, em, ev.identifier, ev.GetInitializer ((FullNamedExpression) yyVals[-3+yyTop]),
				ev.OptAttributes, ev.Location);

/*			if (RootContext.Documentation != null)*/
				em.DocComment = ev.DocComment;

			e.AddEnumMember (em);
		}
		if (RootContext.EvalMode)
			undo.AddTypeContainer (current_container, e);

		current_container.AddTypeContainer (e);

		yyVal = e;

	  }
  break;
case 316:
#line 2512 "cs-parser.jay"
  {
		yyVal = TypeManager.system_int32_expr;
	  }
  break;
case 317:
#line 2516 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != TypeManager.system_int32_expr && yyVals[0+yyTop] != TypeManager.system_uint32_expr &&
			yyVals[0+yyTop] != TypeManager.system_int64_expr && yyVals[0+yyTop] != TypeManager.system_uint64_expr &&
			yyVals[0+yyTop] != TypeManager.system_int16_expr && yyVals[0+yyTop] != TypeManager.system_uint16_expr &&
			yyVals[0+yyTop] != TypeManager.system_byte_expr && yyVals[0+yyTop] != TypeManager.system_sbyte_expr) {
			Enum.Error_1008 (GetLocation (yyVals[0+yyTop]), Report);
			yyVals[0+yyTop] = TypeManager.system_int32_expr;
		}
	 
		yyVal = yyVals[0+yyTop];
	 }
  break;
case 318:
#line 2528 "cs-parser.jay"
  {
	 	Error_TypeExpected (GetLocation (yyVals[-1+yyTop]));
		yyVal = TypeManager.system_int32_expr;
	 }
  break;
case 319:
#line 2536 "cs-parser.jay"
  {
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 320:
#line 2541 "cs-parser.jay"
  {
	  	/* here will be evaluated after CLOSE_BLACE is consumed.*/
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 321:
#line 2547 "cs-parser.jay"
  {
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 322:
#line 2553 "cs-parser.jay"
  { yyVal = new VariableDeclaration [0]; }
  break;
case 323:
#line 2554 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 324:
#line 2559 "cs-parser.jay"
  {
		var l = new List<VariableDeclaration> (4);
		l.Add ((VariableDeclaration) yyVals[0+yyTop]);
		yyVal = l;
	  }
  break;
case 325:
#line 2565 "cs-parser.jay"
  {
		var l = (List<VariableDeclaration>) yyVals[-2+yyTop];
		l.Add ((VariableDeclaration) yyVals[0+yyTop]);
		yyVal = l;
	  }
  break;
case 326:
#line 2574 "cs-parser.jay"
  {
		VariableDeclaration vd = new VariableDeclaration (
			(Tokenizer.LocatedToken) yyVals[0+yyTop], null, (Attributes) yyVals[-1+yyTop]);

		if (RootContext.Documentation != null) {
			vd.DocComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		yyVal = vd;
	  }
  break;
case 327:
#line 2586 "cs-parser.jay"
  {
	  	++lexer.parsing_block;
		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.NotAllowed;
		}
	  }
  break;
case 328:
#line 2594 "cs-parser.jay"
  { 
		--lexer.parsing_block;	  
		VariableDeclaration vd = new VariableDeclaration (
			(Tokenizer.LocatedToken) yyVals[-3+yyTop], (Expression) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop]);

		if (RootContext.Documentation != null)
			vd.DocComment = ConsumeStoredComment ();

		yyVal = vd;
	  }
  break;
case 329:
#line 2612 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue;
	  }
  break;
case 330:
#line 2616 "cs-parser.jay"
  {
		valid_param_mod = 0;

		MemberName name = MakeName ((MemberName) yyVals[-4+yyTop]);
		ParametersCompiled p = (ParametersCompiled) yyVals[-1+yyTop];

		Delegate del = new Delegate (current_namespace, current_class, (FullNamedExpression) yyVals[-5+yyTop],
					     (Modifiers) yyVals[-7+yyTop], name, p, (Attributes) yyVals[-8+yyTop]);

		if (RootContext.Documentation != null) {
			del.DocComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		current_container.AddDelegate (del);
		current_delegate = del;
		lexer.ConstraintsParsing = true;
	  }
  break;
case 331:
#line 2635 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;
	  }
  break;
case 332:
#line 2639 "cs-parser.jay"
  {
		current_delegate.SetParameterInfo ((List<Constraints>) yyVals[-2+yyTop]);
		yyVal = current_delegate;

		current_delegate = null;
	  }
  break;
case 333:
#line 2649 "cs-parser.jay"
  {
		yyVal = null;
	  }
  break;
case 334:
#line 2653 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (GetLocation (yyVals[0+yyTop]), "nullable types");
		else if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types");
	  
	  	yyVal = this;
	  }
  break;
case 336:
#line 2666 "cs-parser.jay"
  {
		var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		
		yyVal = new MemberName (lt1.Value, lt2.Value, (TypeArguments) yyVals[0+yyTop], lt1.Location);
	  }
  break;
case 338:
#line 2677 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberName ((MemberName) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
	  }
  break;
case 339:
#line 2685 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location);	  
	  }
  break;
case 340:
#line 2695 "cs-parser.jay"
  { yyVal = null; }
  break;
case 341:
#line 2697 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (GetLocation (yyVals[-2+yyTop]), "generics");
		else if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics");	  
	  
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 342:
#line 2706 "cs-parser.jay"
  {
		Error_TypeExpected (lexer.Location);
		yyVal = new TypeArguments ();
	  }
  break;
case 343:
#line 2714 "cs-parser.jay"
  {
		TypeArguments type_args = new TypeArguments ();
		type_args.Add ((FullNamedExpression) yyVals[0+yyTop]);
		yyVal = type_args;
	  }
  break;
case 344:
#line 2720 "cs-parser.jay"
  {
		TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop];
		type_args.Add ((FullNamedExpression) yyVals[0+yyTop]);
		yyVal = type_args;
	  }
  break;
case 345:
#line 2732 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = true;
	  }
  break;
case 346:
#line 2736 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = false;
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new MemberName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location);	  
	  }
  break;
case 347:
#line 2745 "cs-parser.jay"
  {
	  	MemberName mn = (MemberName)yyVals[0+yyTop];
	  	if (mn.TypeArguments != null)
	  		syntax_error (mn.Location, string.Format ("Member `{0}' cannot declare type arguments",
	  			mn.GetSignatureForError ()));
	  }
  break;
case 349:
#line 2756 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = false;	  
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
	  }
  break;
case 350:
#line 2765 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = false;	  
		yyVal = new MemberName (TypeContainer.DefaultIndexerName, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 351:
#line 2770 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = false;
		yyVal = new MemberName ((MemberName) yyVals[-1+yyTop], TypeContainer.DefaultIndexerName, null, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 352:
#line 2778 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new MemberName (lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location);
	  }
  break;
case 353:
#line 2783 "cs-parser.jay"
  {
		var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		
		yyVal = new MemberName (lt1.Value, lt2.Value, (TypeArguments) yyVals[-1+yyTop], lt1.Location);
	  }
  break;
case 354:
#line 2790 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new MemberName ((MemberName) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location);
	  }
  break;
case 355:
#line 2797 "cs-parser.jay"
  { yyVal = null; }
  break;
case 356:
#line 2799 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (GetLocation (yyVals[-2+yyTop]), "generics");
		else if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics");
	  
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 357:
#line 2811 "cs-parser.jay"
  {
		TypeArguments type_args = new TypeArguments ();
		type_args.Add ((FullNamedExpression)yyVals[0+yyTop]);
		yyVal = type_args;
	  }
  break;
case 358:
#line 2817 "cs-parser.jay"
  {
		TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop];
		type_args.Add ((FullNamedExpression)yyVals[0+yyTop]);
		yyVal = type_args;
	  }
  break;
case 359:
#line 2826 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop];
		yyVal = new TypeParameterName (lt.Value, (Attributes)yyVals[-2+yyTop], (Variance) yyVals[-1+yyTop], lt.Location);
  	  }
  break;
case 360:
#line 2831 "cs-parser.jay"
  {
  	  	if (GetTokenName (yyToken) == "type")
			Report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type");
		else
			Error_SyntaxError (yyToken);
			
  	  	yyVal = new TypeParameterName ("", null, lexer.Location);
  	  }
  break;
case 362:
#line 2847 "cs-parser.jay"
  {
		yyVal = TypeManager.system_void_expr;
	  }
  break;
case 363:
#line 2854 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = true;
	  }
  break;
case 365:
#line 2865 "cs-parser.jay"
  {
	  	Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), Report);
		yyVal = TypeManager.system_void_expr;
	  }
  break;
case 367:
#line 2874 "cs-parser.jay"
  {
	  	Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), Report);
		yyVal = TypeManager.system_void_expr;
	  }
  break;
case 369:
#line 2883 "cs-parser.jay"
  {
	  	Report.Error (1536, GetLocation (yyVals[0+yyTop]), "Invalid parameter type `void'");
		yyVal = TypeManager.system_void_expr;
	  }
  break;
case 371:
#line 2892 "cs-parser.jay"
  {
		string rank_specifiers = (string) yyVals[0+yyTop];
		yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], rank_specifiers);
	  }
  break;
case 372:
#line 2900 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[-1+yyTop];

		if (yyVals[0+yyTop] != null) {
			yyVal = new ComposedCast (name.GetTypeExpression (), "?", lexer.Location);
		} else {
			if (name.Left == null && name.Name == "var")
				yyVal = new VarExpr (name.Location);
			else
				yyVal = name.GetTypeExpression ();
		}
	  }
  break;
case 373:
#line 2913 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null)
			yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], "?", lexer.Location);
	  }
  break;
case 374:
#line 2918 "cs-parser.jay"
  {
		/**/
		/* Note that here only unmanaged types are allowed but we*/
		/* can't perform checks during this phase - we do it during*/
		/* semantic analysis.*/
		/**/
		yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], "*", Lexer.Location);
	  }
  break;
case 375:
#line 2927 "cs-parser.jay"
  {
		yyVal = new ComposedCast (TypeManager.system_void_expr, "*", GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 376:
#line 2934 "cs-parser.jay"
  {
		var types = new List<FullNamedExpression> (2);
		types.Add ((FullNamedExpression) yyVals[0+yyTop]);
		yyVal = types;
	  }
  break;
case 377:
#line 2940 "cs-parser.jay"
  {
		var types = (List<FullNamedExpression>) yyVals[-2+yyTop];
		types.Add ((FullNamedExpression) yyVals[0+yyTop]);
		yyVal = types;
	  }
  break;
case 378:
#line 2949 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] is ComposedCast) {
			Report.Error (1521, GetLocation (yyVals[0+yyTop]), "Invalid base type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ());
		}
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 379:
#line 2956 "cs-parser.jay"
  {
	  	Error_TypeExpected (lexer.Location);
		yyVal = null;
	  }
  break;
case 380:
#line 2967 "cs-parser.jay"
  { yyVal = TypeManager.system_object_expr; }
  break;
case 381:
#line 2968 "cs-parser.jay"
  { yyVal = TypeManager.system_string_expr; }
  break;
case 382:
#line 2969 "cs-parser.jay"
  { yyVal = TypeManager.system_boolean_expr; }
  break;
case 383:
#line 2970 "cs-parser.jay"
  { yyVal = TypeManager.system_decimal_expr; }
  break;
case 384:
#line 2971 "cs-parser.jay"
  { yyVal = TypeManager.system_single_expr; }
  break;
case 385:
#line 2972 "cs-parser.jay"
  { yyVal = TypeManager.system_double_expr; }
  break;
case 387:
#line 2977 "cs-parser.jay"
  { yyVal = TypeManager.system_sbyte_expr; }
  break;
case 388:
#line 2978 "cs-parser.jay"
  { yyVal = TypeManager.system_byte_expr; }
  break;
case 389:
#line 2979 "cs-parser.jay"
  { yyVal = TypeManager.system_int16_expr; }
  break;
case 390:
#line 2980 "cs-parser.jay"
  { yyVal = TypeManager.system_uint16_expr; }
  break;
case 391:
#line 2981 "cs-parser.jay"
  { yyVal = TypeManager.system_int32_expr; }
  break;
case 392:
#line 2982 "cs-parser.jay"
  { yyVal = TypeManager.system_uint32_expr; }
  break;
case 393:
#line 2983 "cs-parser.jay"
  { yyVal = TypeManager.system_int64_expr; }
  break;
case 394:
#line 2984 "cs-parser.jay"
  { yyVal = TypeManager.system_uint64_expr; }
  break;
case 395:
#line 2985 "cs-parser.jay"
  { yyVal = TypeManager.system_char_expr; }
  break;
case 397:
#line 2991 "cs-parser.jay"
  {
		yyVal = TypeManager.system_void_expr;	
	  }
  break;
case 401:
#line 3009 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location);	  
	  }
  break;
case 402:
#line 3013 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
	       yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location);
	  }
  break;
case 422:
#line 3039 "cs-parser.jay"
  { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); }
  break;
case 423:
#line 3043 "cs-parser.jay"
  { yyVal = new BoolLiteral (true, GetLocation (yyVals[0+yyTop])); }
  break;
case 424:
#line 3044 "cs-parser.jay"
  { yyVal = new BoolLiteral (false, GetLocation (yyVals[0+yyTop])); }
  break;
case 429:
#line 3070 "cs-parser.jay"
  {
		yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]);
	  }
  break;
case 430:
#line 3074 "cs-parser.jay"
  {
		yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]);
	  }
  break;
case 431:
#line 3081 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
	  }
  break;
case 432:
#line 3086 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		/* TODO: Location is wrong as some predefined types doesn't hold a location*/
		yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
	  }
  break;
case 433:
#line 3092 "cs-parser.jay"
  {
		var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop];

		yyVal = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) yyVals[0+yyTop], lt1.Location);
	  }
  break;
case 434:
#line 3098 "cs-parser.jay"
  {
		yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 435:
#line 3101 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location);
	  }
  break;
case 436:
#line 3106 "cs-parser.jay"
  {
		/* TODO: Location is wrong as some predefined types doesn't hold a location*/
		yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location);
	  }
  break;
case 437:
#line 3110 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location);
 	  }
  break;
case 438:
#line 3118 "cs-parser.jay"
  {
		yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
	  }
  break;
case 439:
#line 3124 "cs-parser.jay"
  { yyVal = null; }
  break;
case 441:
#line 3130 "cs-parser.jay"
  {
	  	if (yyVals[-1+yyTop] == null)
	  		yyVal = CollectionOrObjectInitializers.Empty;
	  	else
	  		yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 442:
#line 3137 "cs-parser.jay"
  {
	  	yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 443:
#line 3143 "cs-parser.jay"
  { yyVal = null; }
  break;
case 444:
#line 3145 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	}
  break;
case 445:
#line 3152 "cs-parser.jay"
  {
	  	var a = new List<Expression> ();
	  	a.Add ((Expression) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 446:
#line 3158 "cs-parser.jay"
  {
	  	var a = (List<Expression>)yyVals[-2+yyTop];
	  	a.Add ((Expression) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 447:
#line 3163 "cs-parser.jay"
  {
	  	Error_SyntaxError (yyToken);
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 448:
#line 3171 "cs-parser.jay"
  {
	  	var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
	  	yyVal = new ElementInitializer (lt.Value, (Expression)yyVals[0+yyTop], lt.Location);
	  }
  break;
case 449:
#line 3176 "cs-parser.jay"
  {
		yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 450:
#line 3179 "cs-parser.jay"
  {
		CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName;
		if (csn == null)
			yyVal = new CollectionElementInitializer ((Expression)yyVals[-1+yyTop]);
		else
			yyVal = new CompletionElementInitializer (csn.Prefix, csn.Location);
	  }
  break;
case 451:
#line 3187 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] == null)
			yyVal = null;
		else
	  		yyVal = new CollectionElementInitializer ((List<Expression>)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 452:
#line 3194 "cs-parser.jay"
  {
	  	Report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty");
		yyVal = null;
	  }
  break;
case 455:
#line 3206 "cs-parser.jay"
  { yyVal = null; }
  break;
case 457:
#line 3212 "cs-parser.jay"
  { 
		Arguments list = new Arguments (4);
		list.Add ((Argument) yyVals[0+yyTop]);
		yyVal = list;
	  }
  break;
case 458:
#line 3218 "cs-parser.jay"
  {
		Arguments list = (Arguments) yyVals[-2+yyTop];
		if (list [list.Count - 1] is NamedArgument)
			Error_NamedArgumentExpected ((NamedArgument) list [list.Count - 1]);
		
		list.Add ((Argument) yyVals[0+yyTop]);
		yyVal = list;
	  }
  break;
case 459:
#line 3227 "cs-parser.jay"
  {
		Arguments list = (Arguments) yyVals[-2+yyTop];
		NamedArgument a = (NamedArgument) yyVals[0+yyTop];
		for (int i = 0; i < list.Count; ++i) {
			NamedArgument na = list [i] as NamedArgument;
			if (na != null && na.Name == a.Name)
				Report.Error (1740, na.Location, "Named argument `{0}' specified multiple times",
					na.Name);
		}
		
		list.Add (a);
		yyVal = list;
	  }
  break;
case 460:
#line 3241 "cs-parser.jay"
  {
	  	Report.Error (839, GetLocation (yyVals[0+yyTop]), "An argument is missing");
	  	yyVal = yyVals[-1+yyTop];
	  }
  break;
case 461:
#line 3246 "cs-parser.jay"
  {
	  	Report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing");
	  	yyVal = yyVals[-1+yyTop];
	  }
  break;
case 462:
#line 3254 "cs-parser.jay"
  {
		yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 466:
#line 3267 "cs-parser.jay"
  { 
		yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref);
	  }
  break;
case 467:
#line 3271 "cs-parser.jay"
  { 
		yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out);
	  }
  break;
case 468:
#line 3275 "cs-parser.jay"
  {
		yyVal = new Argument (new Arglist ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])));
	  }
  break;
case 469:
#line 3279 "cs-parser.jay"
  {
		yyVal = new Argument (new Arglist (GetLocation (yyVals[-2+yyTop])));
	  }
  break;
case 470:
#line 3283 "cs-parser.jay"
  {
		yyVal = new Argument (new ArglistAccess (GetLocation (yyVals[0+yyTop])));
	  }
  break;
case 472:
#line 3294 "cs-parser.jay"
  {
		yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
	  }
  break;
case 473:
#line 3298 "cs-parser.jay"
  {
	  	/* LAMESPEC: Not allowed according to specification*/
		yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
	  }
  break;
case 474:
#line 3303 "cs-parser.jay"
  {
		/* So the super-trick is that primary_expression*/
		/* can only be either a SimpleName or a MemberAccess. */
		/* The MemberAccess case arises when you have a fully qualified type-name like :*/
		/* Foo.Bar.Blah i;*/
		/* SimpleName is when you have*/
		/* Blah i;*/
		  
		Expression expr = (Expression) yyVals[-1+yyTop];  
		if (expr is ComposedCast){
			yyVal = new ComposedCast ((ComposedCast)expr, (string) yyVals[0+yyTop]);
		} else if (expr is ATypeNameExpression){
			/**/
			/* So we extract the string corresponding to the SimpleName*/
			/* or MemberAccess*/
			/* */
			yyVal = new ComposedCast ((ATypeNameExpression)expr, (string) yyVals[0+yyTop]);
		} else {
			Error_ExpectingTypeName (expr);
			yyVal = TypeManager.system_object_expr;
		}
	  }
  break;
case 475:
#line 3329 "cs-parser.jay"
  {
		var list = new List<Expression> (4);
		list.Add ((Expression) yyVals[0+yyTop]);
		yyVal = list;
	  }
  break;
case 476:
#line 3335 "cs-parser.jay"
  {
		var list = (List<Expression>) yyVals[-2+yyTop];
		list.Add ((Expression) yyVals[0+yyTop]);
		yyVal = list;
	  }
  break;
case 477:
#line 3340 "cs-parser.jay"
  {
	  	Error_SyntaxError (yyToken);
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 478:
#line 3348 "cs-parser.jay"
  {
		Arguments args = new Arguments (4);
		args.Add ((Argument) yyVals[0+yyTop]);
		yyVal = args;
	  }
  break;
case 479:
#line 3354 "cs-parser.jay"
  {
		Arguments args = (Arguments) yyVals[-2+yyTop];
		args.Add ((Argument) yyVals[0+yyTop]);
		yyVal = args;	  
	  }
  break;
case 480:
#line 3363 "cs-parser.jay"
  {
	  	yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 482:
#line 3371 "cs-parser.jay"
  {
		yyVal = new This (current_block, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 483:
#line 3378 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new BaseAccess (lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
	  }
  break;
case 484:
#line 3383 "cs-parser.jay"
  {
		yyVal = new BaseIndexerAccess ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 485:
#line 3387 "cs-parser.jay"
  {
	  	Error_SyntaxError (yyToken);
		yyVal = new BaseAccess (null, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 486:
#line 3395 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 487:
#line 3402 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 488:
#line 3409 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null) {
			if (RootContext.Version <= LanguageVersion.ISO_2)
				Report.FeatureIsNotAvailable (GetLocation (yyVals[-4+yyTop]), "object initializers");
				
			yyVal = new NewInitialize ((Expression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
		}
		else
			yyVal = new New ((Expression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 489:
#line 3420 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "collection initializers");
	  
		yyVal = new NewInitialize ((Expression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 490:
#line 3432 "cs-parser.jay"
  {
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List<Expression>) yyVals[-3+yyTop], (string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
	  }
  break;
case 491:
#line 3436 "cs-parser.jay"
  {
	  	if (yyVals[0+yyTop] == null)
	  		Report.Error (1586, GetLocation (yyVals[-2+yyTop]), "Array creation must have array size or array initializer");

		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 492:
#line 3443 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays");
	  
		yyVal = new ImplicitlyTypedArrayCreation ((string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 493:
#line 3450 "cs-parser.jay"
  {
		Report.Error (1526, GetLocation (yyVals[-1+yyTop]), "A new expression requires () or [] after type");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], "[]", null, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 494:
#line 3458 "cs-parser.jay"
  {
		++lexer.parsing_type;
	  }
  break;
case 495:
#line 3462 "cs-parser.jay"
  {
		--lexer.parsing_type;
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 496:
#line 3470 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (GetLocation (yyVals[-3+yyTop]), "anonymous types");
	  	else if (RootContext.Version <= LanguageVersion.ISO_2)
	  		Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types");

		yyVal = new NewAnonymousType ((List<AnonymousTypeParameter>) yyVals[-1+yyTop], current_container, GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 499:
#line 3486 "cs-parser.jay"
  { yyVal = null; }
  break;
case 501:
#line 3492 "cs-parser.jay"
  {
	  	var a = new List<AnonymousTypeParameter> (4);
	  	a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 502:
#line 3498 "cs-parser.jay"
  {
	  	var a = (List<AnonymousTypeParameter>) yyVals[-2+yyTop];
	  	a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 503:
#line 3507 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop];
	  	yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location);
	  }
  break;
case 504:
#line 3512 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location),
	  		lt.Value, lt.Location);
	  }
  break;
case 505:
#line 3518 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		BaseAccess ba = new BaseAccess (lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
	  	yyVal = new AnonymousTypeParameter (ba, lt.Value, lt.Location);		
	  }
  break;
case 506:
#line 3524 "cs-parser.jay"
  {
	  	MemberAccess ma = (MemberAccess) yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location);
	  }
  break;
case 507:
#line 3529 "cs-parser.jay"
  {
		Report.Error (746, lexer.Location,
			"Invalid anonymous type member declarator. Anonymous type members must be a member assignment, simple name or member access expression");
		yyVal = null;
	  }
  break;
case 508:
#line 3538 "cs-parser.jay"
  {
		yyVal = "";
	  }
  break;
case 509:
#line 3542 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 510:
#line 3549 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null)
			yyVal = "?";
		else
			yyVal = string.Empty;
	  }
  break;
case 511:
#line 3556 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] != null)
			yyVal = "?" + (string) yyVals[0+yyTop];
		else
			yyVal = yyVals[0+yyTop];
	  }
  break;
case 513:
#line 3567 "cs-parser.jay"
  {
		yyVal = (string) yyVals[-1+yyTop] + (string) yyVals[0+yyTop];
	  }
  break;
case 514:
#line 3574 "cs-parser.jay"
  {
		yyVal = "[]";
	  }
  break;
case 515:
#line 3578 "cs-parser.jay"
  {
		yyVal = "[" + (string) yyVals[-1+yyTop] + "]";
	  }
  break;
case 516:
#line 3582 "cs-parser.jay"
  {
	  	Error_SyntaxError (178, yyToken, "Invalid rank specifier");
		yyVal = "[]";
	  }
  break;
case 517:
#line 3590 "cs-parser.jay"
  {
		yyVal = ",";
	  }
  break;
case 518:
#line 3594 "cs-parser.jay"
  {
		yyVal = (string) yyVals[-1+yyTop] + ",";
	  }
  break;
case 519:
#line 3601 "cs-parser.jay"
  {
		yyVal = null;
	  }
  break;
case 520:
#line 3605 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 521:
#line 3612 "cs-parser.jay"
  {
		yyVal = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 522:
#line 3616 "cs-parser.jay"
  {
		yyVal = new ArrayInitializer ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 523:
#line 3623 "cs-parser.jay"
  {
		var list = new List<Expression> (4);
		list.Add ((Expression) yyVals[0+yyTop]);
		yyVal = list;
	  }
  break;
case 524:
#line 3629 "cs-parser.jay"
  {
		var list = (List<Expression>) yyVals[-2+yyTop];
		list.Add ((Expression) yyVals[0+yyTop]);
		yyVal = list;
	  }
  break;
case 525:
#line 3635 "cs-parser.jay"
  {
	  	Error_SyntaxError (yyToken);
	  	yyVal = new List<Expression> ();
	  }
  break;
case 526:
#line 3643 "cs-parser.jay"
  {
	  	lexer.TypeOfParsing = true;
	  }
  break;
case 527:
#line 3647 "cs-parser.jay"
  {
	  	lexer.TypeOfParsing = false;
		Expression type = (Expression)yyVals[-1+yyTop];
		if (type == TypeManager.system_void_expr)
			yyVal = new TypeOfVoid (GetLocation (yyVals[-4+yyTop]));
		else
			yyVal = new TypeOf (type, GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 530:
#line 3661 "cs-parser.jay"
  {
	 	Error_TypeExpected (lexer.Location);
	 	yyVal = null;
	 }
  break;
case 531:
#line 3669 "cs-parser.jay"
  {  
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];

		yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location);
	  }
  break;
case 532:
#line 3675 "cs-parser.jay"
  {
		var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop];

		yyVal = new QualifiedAliasMember (lt1.Value, lt2.Value, (int) yyVals[0+yyTop], lt1.Location);
	  }
  break;
case 533:
#line 3682 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		
		yyVal = new MemberAccess ((Expression) yyVals[-2+yyTop], lt.Value, lt.Location);		
	  }
  break;
case 534:
#line 3688 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		
		yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (int) yyVals[0+yyTop], lt.Location);		
	  }
  break;
case 535:
#line 3694 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		MemberName name = (MemberName) yyVals[-3+yyTop];

		yyVal = new MemberAccess (name.GetTypeExpression (), lt.Value, (int) yyVals[0+yyTop], lt.Location);		
	  }
  break;
case 536:
#line 3704 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (GetLocation (yyVals[0+yyTop]), "generics");
		else if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics");

		yyVal = yyVals[0+yyTop];
	  }
  break;
case 537:
#line 3716 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		if (RootContext.Version == LanguageVersion.ISO_1)
			Report.FeatureIsNotAvailable (lt.Location, "namespace alias qualifier");

		yyVal = lt;		
	  }
  break;
case 538:
#line 3726 "cs-parser.jay"
  { 
		yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 539:
#line 3733 "cs-parser.jay"
  {
		yyVal = new CheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 540:
#line 3740 "cs-parser.jay"
  {
		yyVal = new UnCheckedExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 541:
#line 3747 "cs-parser.jay"
  {
		Expression deref;
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];

		deref = new Indirection ((Expression) yyVals[-2+yyTop], lt.Location);
		yyVal = new MemberAccess (deref, lt.Value);
	  }
  break;
case 542:
#line 3758 "cs-parser.jay"
  {
		start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 543:
#line 3762 "cs-parser.jay"
  {
		yyVal = end_anonymous ((ToplevelBlock) yyVals[0+yyTop]);
	}
  break;
case 544:
#line 3769 "cs-parser.jay"
  {
		yyVal = ParametersCompiled.Undefined;
	  }
  break;
case 546:
#line 3777 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 547:
#line 3781 "cs-parser.jay"
  {
		valid_param_mod = 0;
	  	yyVal = yyVals[-1+yyTop];
	  }
  break;
case 548:
#line 3789 "cs-parser.jay"
  {
		if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 550:
#line 3800 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 551:
#line 3804 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 553:
#line 3812 "cs-parser.jay"
  {
		yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 554:
#line 3816 "cs-parser.jay"
  {
		yyVal = new Cast ((FullNamedExpression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 556:
#line 3828 "cs-parser.jay"
  { 
	  	yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 557:
#line 3832 "cs-parser.jay"
  { 
		yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 558:
#line 3836 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 559:
#line 3840 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 560:
#line 3844 "cs-parser.jay"
  {
		yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 561:
#line 3848 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 563:
#line 3856 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Multiply, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 564:
#line 3861 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Division, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 565:
#line 3866 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Modulus, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 567:
#line 3875 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Addition, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 568:
#line 3880 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 569:
#line 3884 "cs-parser.jay"
  {
	  	/* Shift/Reduce conflict*/
		yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
  	  }
  break;
case 570:
#line 3889 "cs-parser.jay"
  {
		yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 571:
#line 3893 "cs-parser.jay"
  {
		yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 573:
#line 3901 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.LeftShift, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 574:
#line 3906 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.RightShift, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 576:
#line 3915 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.LessThan, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 577:
#line 3920 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.GreaterThan, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 578:
#line 3925 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.LessThanOrEqual, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 579:
#line 3930 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 581:
#line 3939 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Equality, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 582:
#line 3944 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.Inequality, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 584:
#line 3953 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.BitwiseAnd, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 586:
#line 3962 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.ExclusiveOr, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 588:
#line 3971 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.BitwiseOr, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 590:
#line 3980 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.LogicalAnd, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 592:
#line 3989 "cs-parser.jay"
  {
		yyVal = new Binary (Binary.Operator.LogicalOr, 
			         (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 594:
#line 3998 "cs-parser.jay"
  {
		if (RootContext.Version < LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator");
			
		yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 596:
#line 4009 "cs-parser.jay"
  {
		yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 597:
#line 4016 "cs-parser.jay"
  {
		yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 598:
#line 4020 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 599:
#line 4025 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 600:
#line 4030 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 601:
#line 4035 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 602:
#line 4040 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 603:
#line 4045 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 604:
#line 4050 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 605:
#line 4055 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 606:
#line 4060 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 607:
#line 4065 "cs-parser.jay"
  {
		yyVal = new CompoundAssign (
			Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
	  }
  break;
case 608:
#line 4073 "cs-parser.jay"
  {
		var pars = new List<Parameter> (4);
		pars.Add ((Parameter) yyVals[0+yyTop]);

		yyVal = pars;
	  }
  break;
case 609:
#line 4080 "cs-parser.jay"
  {
		var pars = (List<Parameter>) yyVals[-2+yyTop];
		Parameter p = (Parameter)yyVals[0+yyTop];
		if (pars[0].GetType () != p.GetType ()) {
			Report.Error (748, p.Location, "All lambda parameters must be typed either explicitly or implicitly");
		}
		
		pars.Add (p);
		yyVal = pars;
	  }
  break;
case 610:
#line 4094 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];

		yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, (Parameter.Modifier) yyVals[-2+yyTop], null, lt.Location);
	  }
  break;
case 611:
#line 4100 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];

		yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, Parameter.Modifier.NONE, null, lt.Location);
	  }
  break;
case 612:
#line 4106 "cs-parser.jay"
  {
	  	var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location);
	  }
  break;
case 613:
#line 4113 "cs-parser.jay"
  { yyVal = ParametersCompiled.EmptyReadOnlyParameters; }
  break;
case 614:
#line 4114 "cs-parser.jay"
  { 
		var pars_list = (List<Parameter>) yyVals[0+yyTop];
		yyVal = new ParametersCompiled (compiler, pars_list.ToArray ());
	  }
  break;
case 615:
#line 4121 "cs-parser.jay"
  {
		start_block (lexer.Location);
	  }
  break;
case 616:
#line 4125 "cs-parser.jay"
  {
		Block b = end_block (lexer.Location);
		b.AddStatement (new ContextualReturn ((Expression) yyVals[0+yyTop]));
		yyVal = b;
	  }
  break;
case 617:
#line 4130 "cs-parser.jay"
  { 
	  	yyVal = yyVals[0+yyTop]; 
	  }
  break;
case 618:
#line 4137 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
		start_anonymous (true, new ParametersCompiled (compiler, p), GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 619:
#line 4143 "cs-parser.jay"
  {
		yyVal = end_anonymous ((ToplevelBlock) yyVals[0+yyTop]);
	  }
  break;
case 620:
#line 4147 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "lambda expressions");
	  
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 621:
#line 4154 "cs-parser.jay"
  {
	  	valid_param_mod = 0;
		start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 622:
#line 4159 "cs-parser.jay"
  {
		yyVal = end_anonymous ((ToplevelBlock) yyVals[0+yyTop]);
	  }
  break;
case 629:
#line 4181 "cs-parser.jay"
  {
		yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 630:
#line 4194 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = true;
	  }
  break;
case 631:
#line 4198 "cs-parser.jay"
  {
		MemberName name = MakeName ((MemberName) yyVals[0+yyTop]);
		push_current_class (new Class (current_namespace, current_class, name, (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]);
	  }
  break;
case 632:
#line 4204 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;

		current_class.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);

		if (RootContext.Documentation != null) {
			current_container.DocComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}
	  }
  break;
case 633:
#line 4215 "cs-parser.jay"
  {
		--lexer.parsing_declaration;	  
		if (RootContext.Documentation != null)
			Lexer.doc_state = XmlCommentState.Allowed;
	  }
  break;
case 634:
#line 4221 "cs-parser.jay"
  {
		yyVal = pop_current_class ();
	  }
  break;
case 635:
#line 4228 "cs-parser.jay"
  { yyVal = null; }
  break;
case 636:
#line 4230 "cs-parser.jay"
  { yyVal = yyVals[0+yyTop]; }
  break;
case 637:
#line 4234 "cs-parser.jay"
  { yyVal = (int) 0; }
  break;
case 640:
#line 4241 "cs-parser.jay"
  { 
		var m1 = (Modifiers) yyVals[-1+yyTop];
		var m2 = (Modifiers) yyVals[0+yyTop];

		if ((m1 & m2) != 0) {
			Location l = lexer.Location;
			Report.Error (1004, l, "Duplicate `{0}' modifier", ModifiersExtensions.Name (m2));
		}
		yyVal = m1 | m2;
	  }
  break;
case 641:
#line 4255 "cs-parser.jay"
  {
		yyVal = Modifiers.NEW;
		if (current_container == RootContext.ToplevelTypes)
			Report.Error (1530, GetLocation (yyVals[0+yyTop]), "Keyword `new' is not allowed on namespace elements");
	  }
  break;
case 642:
#line 4260 "cs-parser.jay"
  { yyVal = Modifiers.PUBLIC; }
  break;
case 643:
#line 4261 "cs-parser.jay"
  { yyVal = Modifiers.PROTECTED; }
  break;
case 644:
#line 4262 "cs-parser.jay"
  { yyVal = Modifiers.INTERNAL; }
  break;
case 645:
#line 4263 "cs-parser.jay"
  { yyVal = Modifiers.PRIVATE; }
  break;
case 646:
#line 4264 "cs-parser.jay"
  { yyVal = Modifiers.ABSTRACT; }
  break;
case 647:
#line 4265 "cs-parser.jay"
  { yyVal = Modifiers.SEALED; }
  break;
case 648:
#line 4266 "cs-parser.jay"
  { yyVal = Modifiers.STATIC; }
  break;
case 649:
#line 4267 "cs-parser.jay"
  { yyVal = Modifiers.READONLY; }
  break;
case 650:
#line 4268 "cs-parser.jay"
  { yyVal = Modifiers.VIRTUAL; }
  break;
case 651:
#line 4269 "cs-parser.jay"
  { yyVal = Modifiers.OVERRIDE; }
  break;
case 652:
#line 4270 "cs-parser.jay"
  { yyVal = Modifiers.EXTERN; }
  break;
case 653:
#line 4271 "cs-parser.jay"
  { yyVal = Modifiers.VOLATILE; }
  break;
case 654:
#line 4272 "cs-parser.jay"
  { yyVal = Modifiers.UNSAFE; }
  break;
case 657:
#line 4282 "cs-parser.jay"
  {
		current_container.AddBasesForPart (current_class, (List<FullNamedExpression>) yyVals[0+yyTop]);
	 }
  break;
case 658:
#line 4288 "cs-parser.jay"
  { yyVal = null; }
  break;
case 659:
#line 4290 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 660:
#line 4297 "cs-parser.jay"
  {
		var constraints = new List<Constraints> (1);
		constraints.Add ((Constraints) yyVals[0+yyTop]);
		yyVal = constraints;
	  }
  break;
case 661:
#line 4303 "cs-parser.jay"
  {
		var constraints = (List<Constraints>) yyVals[-1+yyTop];
		Constraints new_constraint = (Constraints)yyVals[0+yyTop];

		foreach (Constraints c in constraints) {
			if (new_constraint.TypeParameter.Value == c.TypeParameter.Value) {
				Report.Error (409, new_constraint.Location,
					"A constraint clause has already been specified for type parameter `{0}'",
					new_constraint.TypeParameter.Value);
			}
		}

		constraints.Add (new_constraint);
		yyVal = constraints;
	  }
  break;
case 662:
#line 4322 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List<FullNamedExpression>) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 663:
#line 4330 "cs-parser.jay"
  {
		var constraints = new List<FullNamedExpression> (1);
		constraints.Add ((FullNamedExpression) yyVals[0+yyTop]);
		yyVal = constraints;
	  }
  break;
case 664:
#line 4336 "cs-parser.jay"
  {
		var constraints = (List<FullNamedExpression>) yyVals[-2+yyTop];
		var prev = constraints [constraints.Count - 1] as SpecialContraintExpr;
		if (prev != null && (prev.Constraint & SpecialConstraint.Constructor) != 0) {			
			Report.Error (401, GetLocation (yyVals[-1+yyTop]), "The `new()' constraint must be the last constraint specified");
		}
		
		prev = yyVals[0+yyTop] as SpecialContraintExpr;
		if (prev != null) {
			if ((prev.Constraint & (SpecialConstraint.Class | SpecialConstraint.Struct)) != 0) {
				Report.Error (449, prev.Location, "The `class' or `struct' constraint must be the first constraint specified");			
			} else {
			 	prev = constraints [0] as SpecialContraintExpr;
			 	if (prev != null && (prev.Constraint & SpecialConstraint.Struct) != 0) {			
					Report.Error (451, GetLocation (yyVals[0+yyTop]), "The `new()' constraint cannot be used with the `struct' constraint");
				}
			}
		}

		constraints.Add ((FullNamedExpression) yyVals[0+yyTop]);
		yyVal = constraints;
	  }
  break;
case 665:
#line 4362 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] is ComposedCast)
			Report.Error (706, GetLocation (yyVals[0+yyTop]), "Invalid constraint type `{0}'", ((ComposedCast)yyVals[0+yyTop]).GetSignatureForError ());
	  
	  	yyVal = yyVals[0+yyTop];
	  }
  break;
case 666:
#line 4369 "cs-parser.jay"
  {
		yyVal = new SpecialContraintExpr (SpecialConstraint.Constructor, GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 667:
#line 4373 "cs-parser.jay"
  {
		yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 668:
#line 4377 "cs-parser.jay"
  {
		yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 669:
#line 4384 "cs-parser.jay"
  {
		yyVal = Variance.None;
	  }
  break;
case 670:
#line 4388 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (lexer.Location, "generic type variance");
		else if (RootContext.Version <= LanguageVersion.V_3)
			Report.FeatureIsNotAvailable (lexer.Location, "generic type variance");

		yyVal = yyVals[0+yyTop];
	  }
  break;
case 671:
#line 4400 "cs-parser.jay"
  {
		yyVal = Variance.Covariant;
	  }
  break;
case 672:
#line 4404 "cs-parser.jay"
  {
		yyVal = Variance.Contravariant;
	  }
  break;
case 673:
#line 4424 "cs-parser.jay"
  {
		++lexer.parsing_block;
		start_block (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 674:
#line 4429 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 675:
#line 4436 "cs-parser.jay"
  {
	 	--lexer.parsing_block;
		yyVal = end_block (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 676:
#line 4441 "cs-parser.jay"
  {
	 	--lexer.parsing_block;
		yyVal = end_block (lexer.Location);
	  }
  break;
case 677:
#line 4450 "cs-parser.jay"
  {
		++lexer.parsing_block;
		current_block.StartLocation = GetLocation (yyVals[0+yyTop]);
	  }
  break;
case 678:
#line 4455 "cs-parser.jay"
  {
		--lexer.parsing_block;
		yyVal = end_block (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 683:
#line 4473 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null && (Block) yyVals[0+yyTop] != current_block){
			current_block.AddStatement ((Statement) yyVals[0+yyTop]);
			current_block = (Block) yyVals[0+yyTop];
		}
	  }
  break;
case 684:
#line 4480 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 688:
#line 4499 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null && (Block) yyVals[0+yyTop] != current_block){
			current_block.AddStatement ((Statement) yyVals[0+yyTop]);
			current_block = (Block) yyVals[0+yyTop];
		}
	  }
  break;
case 689:
#line 4506 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 718:
#line 4547 "cs-parser.jay"
  {
		  Report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement");
		  yyVal = null;
	  }
  break;
case 719:
#line 4552 "cs-parser.jay"
  {
		  Report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement");
		  yyVal = null;
	  }
  break;
case 720:
#line 4560 "cs-parser.jay"
  {
		yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 721:
#line 4567 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		LabeledStatement labeled = new LabeledStatement (lt.Value, lt.Location);

		if (current_block.AddLabel (labeled))
			current_block.AddStatement (labeled);
	  }
  break;
case 723:
#line 4579 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] != null){
			var de = (Tuple<FullNamedExpression, List<object>>) yyVals[-1+yyTop];
			yyVal = declare_local_variables (de.Item1, de.Item2, de.Item1.Location);
		}
	  }
  break;
case 724:
#line 4587 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] != null){
			var de = (Tuple<FullNamedExpression, List<object>>) yyVals[-1+yyTop];

			yyVal = declare_local_constants (de.Item1, de.Item2);
		}
	  }
  break;
case 725:
#line 4604 "cs-parser.jay"
  { 
		/* FIXME: Do something smart here regarding the composition of the type.*/

		/* Ok, the above "primary_expression" is there to get rid of*/
		/* both reduce/reduce and shift/reduces in the grammar, it should*/
		/* really just be "type_name".  If you use type_name, a reduce/reduce*/
		/* creeps up.  If you use namespace_or_type_name (which is all we need*/
		/* really) two shift/reduces appear.*/
		/* */

		/* So the super-trick is that primary_expression*/
		/* can only be either a SimpleName or a MemberAccess. */
		/* The MemberAccess case arises when you have a fully qualified type-name like :*/
		/* Foo.Bar.Blah i;*/
		/* SimpleName is when you have*/
		/* Blah i;*/
		
		Expression expr = (Expression) yyVals[-1+yyTop];
		string rank_or_nullable = (string) yyVals[0+yyTop];
		
		if (expr is ComposedCast){
			yyVal = new ComposedCast ((ComposedCast)expr, rank_or_nullable);
		} else if (expr is ATypeNameExpression){
			/**/
			/* So we extract the string corresponding to the SimpleName*/
			/* or MemberAccess*/
			/**/
			if (rank_or_nullable.Length == 0) {
				SimpleName sn = expr as SimpleName;
				if (sn != null && sn.Name == "var")
					yyVal = new VarExpr (sn.Location);
				else
					yyVal = yyVals[-1+yyTop];
			} else {
				yyVal = new ComposedCast ((ATypeNameExpression)expr, rank_or_nullable);
			}
		} else {
			Error_ExpectingTypeName (expr);
			yyVal = TypeManager.system_object_expr;
		}
	  }
  break;
case 726:
#line 4646 "cs-parser.jay"
  {
		if ((string) yyVals[0+yyTop] == "")
			yyVal = yyVals[-1+yyTop];
		else
			yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (string) yyVals[0+yyTop], lexer.Location);
	  }
  break;
case 727:
#line 4653 "cs-parser.jay"
  {
		Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[-1+yyTop]), Report);
		yyVal = TypeManager.system_void_expr;
	  }
  break;
case 728:
#line 4661 "cs-parser.jay"
  {
		ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression;

		if (expr != null) {
			yyVal = new ComposedCast (expr, "*");
		} else {
			Error_ExpectingTypeName ((Expression)yyVals[-1+yyTop]);
			yyVal = expr;
		}
	  }
  break;
case 729:
#line 4672 "cs-parser.jay"
  {
		yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], "*", GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 730:
#line 4676 "cs-parser.jay"
  {
		yyVal = new ComposedCast (TypeManager.system_void_expr, "*", GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 731:
#line 4680 "cs-parser.jay"
  {
		yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], "*");
	  }
  break;
case 733:
#line 4688 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] != null){
			string rank = (string)yyVals[0+yyTop];

			if (rank == "")
				yyVal = yyVals[-1+yyTop];
			else
				yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], rank);
		} else {
			yyVal = null;
		}
	  }
  break;
case 734:
#line 4704 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] != null) {
			VarExpr ve = yyVals[-1+yyTop] as VarExpr;
			if (ve != null) {
				if (!((VariableDeclaration) ((List<object>)yyVals[0+yyTop]) [0]).HasInitializer)
					ve.VariableInitializersCount = 0;
				else
					ve.VariableInitializersCount = ((List<object>)yyVals[0+yyTop]).Count;
			}
				
			yyVal = new Tuple<FullNamedExpression, List<object>> ((FullNamedExpression) yyVals[-1+yyTop], (List<object>) yyVals[0+yyTop]);
		} else
			yyVal = null;
	  }
  break;
case 735:
#line 4722 "cs-parser.jay"
  {
		if (yyVals[-1+yyTop] != null)
			yyVal = new Tuple<FullNamedExpression, List<object>> ((FullNamedExpression) yyVals[-1+yyTop], (List<object>) yyVals[0+yyTop]);
		else
			yyVal = null;
	  }
  break;
case 736:
#line 4731 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 737:
#line 4732 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 738:
#line 4736 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 739:
#line 4737 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 740:
#line 4746 "cs-parser.jay"
  {
		ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
		if (s == null) {
			Expression.Error_InvalidExpressionStatement (Report, GetLocation (yyVals[0+yyTop]));
			s = EmptyExpressionStatement.Instance;
		}

		yyVal = new StatementExpression (s);
	  }
  break;
case 741:
#line 4756 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
		yyVal = null;
	  }
  break;
case 742:
#line 4764 "cs-parser.jay"
  {
		Expression expr = (Expression) yyVals[0+yyTop];
		ExpressionStatement s;

	        s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
		yyVal = new StatementExpression (s);
	  }
  break;
case 743:
#line 4772 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
		yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 746:
#line 4786 "cs-parser.jay"
  { 
		if (yyVals[0+yyTop] is EmptyStatement)
			Report.Warning (642, 3, GetLocation (yyVals[0+yyTop]), "Possible mistaken empty statement");
		
		yyVal = new If ((BooleanExpression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 747:
#line 4794 "cs-parser.jay"
  {
		yyVal = new If ((BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));

		if (yyVals[-2+yyTop] is EmptyStatement)
			Report.Warning (642, 3, GetLocation (yyVals[-2+yyTop]), "Possible mistaken empty statement");
		if (yyVals[0+yyTop] is EmptyStatement)
			Report.Warning (642, 3, GetLocation (yyVals[0+yyTop]), "Possible mistaken empty statement");
	  }
  break;
case 748:
#line 4806 "cs-parser.jay"
  { 
		if (switch_stack == null)
			switch_stack = new Stack<Block> (2);
		switch_stack.Push (current_block);
	  }
  break;
case 749:
#line 4813 "cs-parser.jay"
  {
		yyVal = new Switch ((Expression) yyVals[-2+yyTop], (List<SwitchSection>) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
		current_block = (Block) switch_stack.Pop ();
	  }
  break;
case 750:
#line 4823 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 751:
#line 4830 "cs-parser.jay"
  {
	  	Report.Warning (1522, 1, lexer.Location, "Empty switch block"); 
		yyVal = new List<SwitchSection> ();
	  }
  break;
case 753:
#line 4839 "cs-parser.jay"
  {
		var sections = new List<SwitchSection> (4);

		sections.Add ((SwitchSection) yyVals[0+yyTop]);
		yyVal = sections;
	  }
  break;
case 754:
#line 4846 "cs-parser.jay"
  {
		var sections = (List<SwitchSection>) yyVals[-1+yyTop];

		sections.Add ((SwitchSection) yyVals[0+yyTop]);
		yyVal = sections;
	  }
  break;
case 755:
#line 4856 "cs-parser.jay"
  {
		current_block = current_block.CreateSwitchBlock (lexer.Location);
	  }
  break;
case 756:
#line 4860 "cs-parser.jay"
  {
		yyVal = new SwitchSection ((List<SwitchLabel>) yyVals[-2+yyTop], current_block.Explicit);
	  }
  break;
case 757:
#line 4867 "cs-parser.jay"
  {
		var labels = new List<SwitchLabel> (4);

		labels.Add ((SwitchLabel) yyVals[0+yyTop]);
		yyVal = labels;
	  }
  break;
case 758:
#line 4874 "cs-parser.jay"
  {
		var labels = (List<SwitchLabel>) (yyVals[-1+yyTop]);
		labels.Add ((SwitchLabel) yyVals[0+yyTop]);

		yyVal = labels;
	  }
  break;
case 759:
#line 4884 "cs-parser.jay"
  {
	 	yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	 }
  break;
case 760:
#line 4888 "cs-parser.jay"
  {
		yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 765:
#line 4902 "cs-parser.jay"
  {
		Location l = GetLocation (yyVals[-4+yyTop]);
		yyVal = new While ((BooleanExpression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], l);
	  }
  break;
case 766:
#line 4911 "cs-parser.jay"
  {
		Location l = GetLocation (yyVals[-6+yyTop]);

		yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], l);
	  }
  break;
case 767:
#line 4920 "cs-parser.jay"
  {
		Location l = lexer.Location;
		start_block (l);  
		Block assign_block = current_block;

		if (yyVals[-1+yyTop] is Tuple<FullNamedExpression, List<object>>){
			var de = (Tuple<FullNamedExpression, List<object>>) yyVals[-1+yyTop];
			
			var type = de.Item1;

			foreach (VariableDeclaration decl in de.Item2){

				LocalInfo vi;

				vi = current_block.AddVariable (type, decl.identifier, decl.Location);
				if (vi == null)
					continue;

				Expression expr = decl.GetInitializer (type);
					
				LocalVariableReference var;
				var = new LocalVariableReference (assign_block, decl.identifier, l);

				if (expr != null) {
					Assign a = new SimpleAssign (var, expr, decl.Location);
					
					assign_block.AddStatement (new StatementExpression (a));
				}
			}
			
			/* Note: the $$ below refers to the value of this code block, not of the LHS non-terminal.*/
			/* This can be referred to as $5 below.*/
			yyVal = null;
		} else {
			yyVal = yyVals[-1+yyTop];
		}
	  }
  break;
case 768:
#line 4960 "cs-parser.jay"
  {
		Location l = GetLocation (yyVals[-9+yyTop]);

		For f = new For ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], l);

		current_block.AddStatement (f);

		yyVal = end_block (lexer.Location);
	  }
  break;
case 769:
#line 4972 "cs-parser.jay"
  { yyVal = new EmptyStatement (lexer.Location); }
  break;
case 773:
#line 4982 "cs-parser.jay"
  { yyVal = null; }
  break;
case 775:
#line 4987 "cs-parser.jay"
  { yyVal = new EmptyStatement (lexer.Location); }
  break;
case 778:
#line 4997 "cs-parser.jay"
  {
		/* CHANGE: was `null'*/
		Statement s = (Statement) yyVals[0+yyTop];
		Block b = new Block (current_block, s.loc, lexer.Location);   

		b.AddStatement (s);
		yyVal = b;
	  }
  break;
case 779:
#line 5006 "cs-parser.jay"
  {
		Block b = (Block) yyVals[-2+yyTop];

		b.AddStatement ((Statement) yyVals[0+yyTop]);
		yyVal = yyVals[-2+yyTop];
	  }
  break;
case 780:
#line 5016 "cs-parser.jay"
  {
		Report.Error (230, GetLocation (yyVals[-5+yyTop]), "Type and identifier are both required in a foreach statement");
		yyVal = null;
	  }
  break;
case 781:
#line 5022 "cs-parser.jay"
  {
		start_block (lexer.Location);
		Block foreach_block = current_block;

		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		Location l = lt.Location;
		LocalInfo vi = foreach_block.AddVariable ((Expression) yyVals[-4+yyTop], lt.Value, l);
		if (vi != null) {
			vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Foreach);

			/* Get a writable reference to this read-only variable.*/
			/**/
			/* Note that the $$ here refers to the value of _this_ code block,*/
			/* not the value of the LHS non-terminal.  This can be referred to as $8 below.*/
			yyVal = new LocalVariableReference (foreach_block, lt.Value, l, vi, false);
		} else {
			yyVal = null;
		}
	  }
  break;
case 782:
#line 5042 "cs-parser.jay"
  {
		LocalVariableReference v = (LocalVariableReference) yyVals[-1+yyTop];
		Location l = GetLocation (yyVals[-8+yyTop]);

		if (v != null) {
			Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], v, (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], l);
			current_block.AddStatement (f);
		}

		yyVal = end_block (lexer.Location);
	  }
  break;
case 789:
#line 5066 "cs-parser.jay"
  {
		yyVal = new Break (GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 790:
#line 5073 "cs-parser.jay"
  {
		yyVal = new Continue (GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 791:
#line 5080 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
		yyVal = new Goto (lt.Value, lt.Location);
	  }
  break;
case 792:
#line 5085 "cs-parser.jay"
  {
		yyVal = new GotoCase ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 793:
#line 5089 "cs-parser.jay"
  {
		yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 794:
#line 5096 "cs-parser.jay"
  {
		yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 795:
#line 5103 "cs-parser.jay"
  {
		yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 796:
#line 5110 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		string s = lt.Value;
		if (s != "yield"){
			Report.Error (1003, lt.Location, "; expected");
			yyVal = null;
		}
		if (RootContext.Version == LanguageVersion.ISO_1){
			Report.FeatureIsNotAvailable (lt.Location, "yield statement");
			yyVal = null;
		}
		current_block.Toplevel.IsIterator = true;
		yyVal = new Yield ((Expression) yyVals[-1+yyTop], lt.Location); 
	  }
  break;
case 797:
#line 5125 "cs-parser.jay"
  {
		Report.Error (1627, GetLocation (yyVals[-1+yyTop]), "Expression expected after yield return");
		yyVal = null;
	  }
  break;
case 798:
#line 5130 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		string s = lt.Value;
		if (s != "yield"){
			Report.Error (1003, lt.Location, "; expected");
			yyVal = null;
		}
		if (RootContext.Version == LanguageVersion.ISO_1){
			Report.FeatureIsNotAvailable (lt.Location, "yield statement");
			yyVal = null;
		}
		
		current_block.Toplevel.IsIterator = true;
		yyVal = new YieldBreak (lt.Location);
	  }
  break;
case 801:
#line 5154 "cs-parser.jay"
  {
		yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List<Catch>) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false);
	  }
  break;
case 802:
#line 5158 "cs-parser.jay"
  {
		yyVal = new TryFinally ((Statement) yyVals[-2+yyTop], (Block) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 803:
#line 5162 "cs-parser.jay"
  {
		yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List<Catch>) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]), true), (Block) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 804:
#line 5166 "cs-parser.jay"
  {
		Report.Error (1524, GetLocation (yyVals[-2+yyTop]), "Expected catch or finally");
		yyVal = null;
	  }
  break;
case 805:
#line 5174 "cs-parser.jay"
  {
		var l = new List<Catch> (2);

		l.Add ((Catch) yyVals[0+yyTop]);
		yyVal = l;
	  }
  break;
case 806:
#line 5181 "cs-parser.jay"
  {
		var l = (List<Catch>) yyVals[-1+yyTop];
		
		Catch c = (Catch) yyVals[0+yyTop];
		if (l [0].IsGeneral) {
			Report.Error (1017, c.loc, "Try statement already has an empty catch block");
		} else {
			if (c.IsGeneral)
				l.Insert (0, c);
			else
				l.Add (c);
		}
		
		yyVal = l;
	  }
  break;
case 807:
#line 5199 "cs-parser.jay"
  { yyVal = null; }
  break;
case 809:
#line 5205 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null) {
			var cc = (Tuple<FullNamedExpression, Tokenizer.LocatedToken>) yyVals[0+yyTop];
			var lt = cc.Item2;

			if (lt != null){
				List<object> one = new List<object> (1);

				one.Add (new VariableDeclaration (lt, null));

				start_block (lexer.Location);
				current_block = declare_local_variables (cc.Item1, one, lt.Location);
			}
		}
	  }
  break;
case 810:
#line 5219 "cs-parser.jay"
  {
		Expression type = null;
		string id = null;
		Block var_block = null;

		if (yyVals[-2+yyTop] != null){
			var cc = (Tuple<FullNamedExpression, Tokenizer.LocatedToken>) yyVals[-2+yyTop];
			type = cc.Item1;
			var lt = cc.Item2;

			if (lt != null){
				id = lt.Value;
				var_block = end_block (lexer.Location);
			}
		}

		yyVal = new Catch (type, id, (Block) yyVals[0+yyTop], var_block, ((Block) yyVals[0+yyTop]).loc);
	  }
  break;
case 811:
#line 5240 "cs-parser.jay"
  { yyVal = null; }
  break;
case 813:
#line 5246 "cs-parser.jay"
  {
		yyVal = new Tuple<FullNamedExpression, Tokenizer.LocatedToken> ((FullNamedExpression)yyVals[-2+yyTop], (Tokenizer.LocatedToken) yyVals[-1+yyTop]);
	  }
  break;
case 814:
#line 5250 "cs-parser.jay"
  {
		Report.Error (1015, GetLocation (yyVals[-1+yyTop]), "A type that derives from `System.Exception', `object', or `string' expected");
		yyVal = null;
	  }
  break;
case 815:
#line 5258 "cs-parser.jay"
  {
		yyVal = new Checked ((Block) yyVals[0+yyTop]);
	  }
  break;
case 816:
#line 5265 "cs-parser.jay"
  {
		yyVal = new Unchecked ((Block) yyVals[0+yyTop]);
	  }
  break;
case 817:
#line 5272 "cs-parser.jay"
  {
		RootContext.CheckUnsafeOption (GetLocation (yyVals[0+yyTop]), Report);
	  }
  break;
case 818:
#line 5274 "cs-parser.jay"
  {
		yyVal = new Unsafe ((Block) yyVals[0+yyTop]);
	  }
  break;
case 819:
#line 5283 "cs-parser.jay"
  {
		start_block (lexer.Location);
	  }
  break;
case 820:
#line 5287 "cs-parser.jay"
  {
		Expression type = (Expression) yyVals[-4+yyTop];
	  	var list = (List<KeyValuePair<Tokenizer.LocatedToken, Expression>>) yyVals[-3+yyTop];
		Fixed f = new Fixed (type,
			list.ConvertAll (i => {
				var v = new KeyValuePair<LocalInfo, Expression> (current_block.AddVariable (type, i.Key.Value, i.Key.Location), i.Value);
				if (v.Key != null) {
					v.Key.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Fixed);
					v.Key.Pinned = true;
				}
				return v;
			}), (Statement) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));

		current_block.AddStatement (f);

		yyVal = end_block (lexer.Location);
	  }
  break;
case 821:
#line 5307 "cs-parser.jay"
  { 
	   	var declarators = new List<KeyValuePair<Tokenizer.LocatedToken, Expression>> (2);
	   	if (yyVals[0+yyTop] != null)
			declarators.Add ((KeyValuePair<Tokenizer.LocatedToken, Expression>)yyVals[0+yyTop]);
		yyVal = declarators;
	  }
  break;
case 822:
#line 5314 "cs-parser.jay"
  {
		var declarators = (List<KeyValuePair<Tokenizer.LocatedToken, Expression>>) yyVals[-2+yyTop];
		if (yyVals[0+yyTop] != null)
			declarators.Add ((KeyValuePair<Tokenizer.LocatedToken, Expression>)yyVals[0+yyTop]);
		yyVal = declarators;
	  }
  break;
case 823:
#line 5324 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new KeyValuePair<Tokenizer.LocatedToken, Expression> (lt, (Expression) yyVals[0+yyTop]);
	  }
  break;
case 824:
#line 5329 "cs-parser.jay"
  {
		Report.Error (210, ((Tokenizer.LocatedToken) yyVals[0+yyTop]).Location, "You must provide an initializer in a fixed or using statement declaration");
		yyVal = null;
	  }
  break;
case 825:
#line 5337 "cs-parser.jay"
  {
		/**/
 	  }
  break;
case 826:
#line 5341 "cs-parser.jay"
  {
		yyVal = new Lock ((Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
	  }
  break;
case 827:
#line 5348 "cs-parser.jay"
  {
		start_block (lexer.Location);
		Block assign_block = current_block;

		var de = (Tuple<FullNamedExpression, List<object>>) yyVals[-1+yyTop];
		Location l = GetLocation (yyVals[-3+yyTop]);

		var vars = new Stack<Tuple<LocalVariableReference, Expression>> ();

		foreach (VariableDeclaration decl in de.Item2) {
			LocalInfo vi = current_block.AddVariable (de.Item1, decl.identifier, decl.Location);
			if (vi == null)
				continue;
			vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Using);

			Expression expr = decl.GetInitializer (de.Item1);
			if (expr == null) {
				Report.Error (210, l, "You must provide an initializer in a fixed or using statement declaration");
				continue;
			}
			LocalVariableReference var;

			/* Get a writable reference to this read-only variable.*/
			var = new LocalVariableReference (assign_block, decl.identifier, l, vi, false);

			/* This is so that it is not a warning on using variables*/
			vi.Used = true;

			vars.Push (new Tuple<LocalVariableReference, Expression> (var, expr));

			/* Assign a = new SimpleAssign (var, expr, decl.Location);*/
			/* assign_block.AddStatement (new StatementExpression (a));*/
		}

		/* Note: the $$ here refers to the value of this code block and not of the LHS non-terminal.*/
		/* It can be referred to as $5 below.*/
		yyVal = vars;
	  }
  break;
case 828:
#line 5387 "cs-parser.jay"
  {
		Statement stmt = (Statement) yyVals[0+yyTop];
		var vars = (Stack<Tuple<LocalVariableReference, Expression>>) yyVals[-1+yyTop];
		Location l = GetLocation (yyVals[-5+yyTop]);

		while (vars.Count > 0) {
			  var de = vars.Pop ();
			  stmt = new Using (de.Item1, de.Item2, stmt, l);
		}
		current_block.AddStatement (stmt);
		yyVal = end_block (lexer.Location);
	  }
  break;
case 829:
#line 5400 "cs-parser.jay"
  {
		start_block (lexer.Location);
	  }
  break;
case 830:
#line 5404 "cs-parser.jay"
  {
		current_block.AddStatement (new UsingTemporary ((Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])));
		yyVal = end_block (lexer.Location);
	  }
  break;
case 831:
#line 5415 "cs-parser.jay"
  {
		lexer.query_parsing = false;
			
		Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause;
			
		from.Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop];
		yyVal = from;
		
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 832:
#line 5427 "cs-parser.jay"
  {
		Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause;
			
		from.Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop];
		yyVal = from;
		
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 833:
#line 5438 "cs-parser.jay"
  {
	        lexer.query_parsing = false;
		yyVal = yyVals[-1+yyTop];

		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 834:
#line 5445 "cs-parser.jay"
  {
	        yyVal = yyVals[-1+yyTop];
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 835:
#line 5454 "cs-parser.jay"
  {
		yyVal = new Linq.QueryExpression (current_block, new Linq.QueryStartClause ((Expression)yyVals[0+yyTop]));
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 836:
#line 5460 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		yyVal = new Linq.QueryExpression (current_block, new Linq.Cast ((FullNamedExpression)yyVals[-3+yyTop], (Expression)yyVals[0+yyTop]));
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 837:
#line 5469 "cs-parser.jay"
  {
		yyVal = new Linq.QueryExpression (current_block, new Linq.QueryStartClause ((Expression)yyVals[0+yyTop]));
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 838:
#line 5475 "cs-parser.jay"
  {
		yyVal = new Linq.QueryExpression (current_block, new Linq.Cast ((FullNamedExpression)yyVals[-3+yyTop], (Expression)yyVals[0+yyTop]));
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 839:
#line 5484 "cs-parser.jay"
  {
		current_block = new Linq.QueryBlock (compiler, current_block, GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 840:
#line 5488 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		var sn = new SimpleMemberName (lt.Value, lt.Location);
		yyVal = new Linq.SelectMany (current_block.Toplevel, sn, (Expression)yyVals[0+yyTop]);
		
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
		
		((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn);
	  }
  break;
case 841:
#line 5499 "cs-parser.jay"
  {
		current_block = new Linq.QueryBlock (compiler, current_block, GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 842:
#line 5503 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		var sn = new SimpleMemberName (lt.Value, lt.Location);

		FullNamedExpression type = (FullNamedExpression)yyVals[-4+yyTop];
		
		yyVal = new Linq.SelectMany (current_block.Toplevel, sn, new Linq.Cast (type, (FullNamedExpression)yyVals[0+yyTop]));
		
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
		
		((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn);
	  }
  break;
case 843:
#line 5520 "cs-parser.jay"
  {
	  	Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop];
		
		if (yyVals[0+yyTop] != null)
			head.Next = (Linq.AQueryClause)yyVals[0+yyTop];
				
		if (yyVals[-2+yyTop] != null) {
			Linq.AQueryClause clause = (Linq.AQueryClause)yyVals[-2+yyTop];
			clause.Tail.Next = head;
			head = clause;
		}
		
		yyVal = head;
	  }
  break;
case 845:
#line 5539 "cs-parser.jay"
  {
	  	current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
	  }
  break;
case 846:
#line 5543 "cs-parser.jay"
  {
		yyVal = new Linq.Select (current_block.Toplevel, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));

		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 847:
#line 5550 "cs-parser.jay"
  {
	  	if (linq_clause_blocks == null)
	  		linq_clause_blocks = new Stack<Block> ();
	  		
	  	current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
	  	linq_clause_blocks.Push (current_block);
	  }
  break;
case 848:
#line 5558 "cs-parser.jay"
  {
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  
		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
	  }
  break;
case 849:
#line 5565 "cs-parser.jay"
  {
		yyVal = new Linq.GroupBy (current_block.Toplevel, (Expression)yyVals[-3+yyTop], (ToplevelBlock) linq_clause_blocks.Pop (), (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
		
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 853:
#line 5581 "cs-parser.jay"
  {
		((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop];
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 859:
#line 5597 "cs-parser.jay"
  {
	  	current_block = new Linq.QueryBlock (compiler, current_block, GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 860:
#line 5601 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
		var sn = new SimpleMemberName (lt.Value, lt.Location);
	  	yyVal = new Linq.Let (current_block.Toplevel, current_container, sn, (Expression)yyVals[0+yyTop]);
	  	
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
		
		((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn);
	  }
  break;
case 861:
#line 5615 "cs-parser.jay"
  {
	  	current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
	  }
  break;
case 862:
#line 5619 "cs-parser.jay"
  {
		yyVal = new Linq.Where (current_block.Toplevel, (BooleanExpression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));

		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  }
  break;
case 863:
#line 5629 "cs-parser.jay"
  {
		if (linq_clause_blocks == null)
			linq_clause_blocks = new Stack<Block> ();
	  		
		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
		linq_clause_blocks.Push (current_block);
	  }
  break;
case 864:
#line 5637 "cs-parser.jay"
  {
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;

		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
		linq_clause_blocks.Push (current_block);
	  }
  break;
case 865:
#line 5645 "cs-parser.jay"
  {
		current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;

		var lt = (Tokenizer.LocatedToken) yyVals[-7+yyTop];
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), lexer.Location);
	  }
  break;
case 866:
#line 5654 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-10+yyTop];
		var sn = new SimpleMemberName (lt.Value, lt.Location);
		SimpleMemberName sn2 = null;
		
		ToplevelBlock outer_selector = (ToplevelBlock) linq_clause_blocks.Pop ();
		ToplevelBlock block = (ToplevelBlock) linq_clause_blocks.Pop ();

		if (yyVals[0+yyTop] == null) {
	  		yyVal = new Linq.Join (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, current_block.Toplevel, GetLocation (yyVals[-11+yyTop]));
		} else {
			var lt2 = (Tokenizer.LocatedToken) yyVals[0+yyTop];
			sn2 = new SimpleMemberName (lt2.Value, lt2.Location);
			yyVal = new Linq.GroupJoin (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, current_block.Toplevel,
				sn2, GetLocation (yyVals[-11+yyTop]));
		}

		current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
			
		if (sn2 == null)
			((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn);
		else
			((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn2);
	  }
  break;
case 867:
#line 5681 "cs-parser.jay"
  {
		if (linq_clause_blocks == null)
			linq_clause_blocks = new Stack<Block> ();
	  		
		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
		linq_clause_blocks.Push (current_block);
	  }
  break;
case 868:
#line 5689 "cs-parser.jay"
  {
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;

		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
		linq_clause_blocks.Push (current_block);
	  }
  break;
case 869:
#line 5697 "cs-parser.jay"
  {
		current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;

		var lt = (Tokenizer.LocatedToken) yyVals[-7+yyTop];
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), lexer.Location);
	  }
  break;
case 870:
#line 5706 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-10+yyTop];
		var sn = new SimpleMemberName (lt.Value, lt.Location);
		SimpleMemberName sn2 = null;
		ToplevelBlock outer_selector = (ToplevelBlock) linq_clause_blocks.Pop ();
		ToplevelBlock block = (ToplevelBlock) linq_clause_blocks.Pop ();
		
		Linq.Cast cast = new Linq.Cast ((FullNamedExpression)yyVals[-11+yyTop], (Expression)yyVals[-7+yyTop]);
		if (yyVals[0+yyTop] == null) {
	  		yyVal = new Linq.Join (block, sn, cast, outer_selector, current_block.Toplevel, GetLocation (yyVals[-12+yyTop]));
		} else {
			var lt2 = (Tokenizer.LocatedToken) yyVals[0+yyTop];
			sn2 = new SimpleMemberName (lt2.Value, lt2.Location);
			yyVal = new Linq.GroupJoin (block, sn, cast, outer_selector, current_block.Toplevel,
				sn2, GetLocation (yyVals[-12+yyTop]));
		}
		
		current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
			
		if (sn2 == null)
			((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn);
		else
			((Linq.QueryBlock)current_block).AddTransparentParameter (compiler, sn2);
	  }
  break;
case 872:
#line 5737 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 873:
#line 5744 "cs-parser.jay"
  {
		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
	  }
  break;
case 874:
#line 5748 "cs-parser.jay"
  {
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 876:
#line 5759 "cs-parser.jay"
  {
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  
		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);
	  }
  break;
case 877:
#line 5766 "cs-parser.jay"
  {
		((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop];
		yyVal = yyVals[-3+yyTop];
	  }
  break;
case 879:
#line 5775 "cs-parser.jay"
  {
		current_block.SetEndLocation (lexer.Location);
		current_block = current_block.Parent;
	  
		current_block = new Linq.QueryBlock (compiler, current_block, lexer.Location);	 
	 }
  break;
case 880:
#line 5782 "cs-parser.jay"
  {
		((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[-1+yyTop];
		yyVal = yyVals[-3+yyTop];
	 }
  break;
case 881:
#line 5790 "cs-parser.jay"
  {
		yyVal = new Linq.OrderByAscending (current_block.Toplevel, (Expression)yyVals[0+yyTop]);	
	  }
  break;
case 882:
#line 5794 "cs-parser.jay"
  {
		yyVal = new Linq.OrderByAscending (current_block.Toplevel, (Expression)yyVals[-1+yyTop]);	
	  }
  break;
case 883:
#line 5798 "cs-parser.jay"
  {
		yyVal = new Linq.OrderByDescending (current_block.Toplevel, (Expression)yyVals[-1+yyTop]);	
	  }
  break;
case 884:
#line 5805 "cs-parser.jay"
  {
		yyVal = new Linq.ThenByAscending (current_block.Toplevel, (Expression)yyVals[0+yyTop]);	
	  }
  break;
case 885:
#line 5809 "cs-parser.jay"
  {
		yyVal = new Linq.ThenByAscending (current_block.Toplevel, (Expression)yyVals[-1+yyTop]);	
	  }
  break;
case 886:
#line 5813 "cs-parser.jay"
  {
		yyVal = new Linq.ThenByDescending (current_block.Toplevel, (Expression)yyVals[-1+yyTop]);	
	  }
  break;
case 888:
#line 5822 "cs-parser.jay"
  {
		/* query continuation block is not linked with query block but with block*/
		/* before. This means each query can use same range variable names for*/
		/* different identifiers.*/

		current_block.SetEndLocation (GetLocation (yyVals[-1+yyTop]));
		current_block = current_block.Parent;

		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		
		current_block = new Linq.QueryBlock (compiler, current_block, new SimpleMemberName (lt.Value, lt.Location), GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 889:
#line 5835 "cs-parser.jay"
  {
  		yyVal = new Linq.QueryExpression (current_block, (Linq.AQueryClause)yyVals[0+yyTop]);
	  }
  break;
case 892:
#line 5856 "cs-parser.jay"
  { 
	        Evaluator.LoadAliases (current_namespace);

		push_current_class (new Class (current_namespace, current_class, new MemberName ("Class" + class_count++),
			Modifiers.PUBLIC, null), null);

		var baseclass_list = new List<FullNamedExpression> ();
		baseclass_list.Add (new TypeExpression (Evaluator.InteractiveBaseClass, lexer.Location));
		current_container.AddBasesForPart (current_class, baseclass_list);

		/* (ref object retval)*/
		Parameter [] mpar = new Parameter [1];
		mpar [0] = new Parameter (TypeManager.system_object_expr, "$retval", Parameter.Modifier.REF, null, Location.Null);

		ParametersCompiled pars = new ParametersCompiled (compiler, mpar);
		current_local_parameters = pars;
		Method method = new Method (
			current_class,
			null, /* generic*/
			TypeManager.system_void_expr,
			Modifiers.PUBLIC | Modifiers.STATIC,
			new MemberName ("Host"),
			pars,
			null /* attributes */);

		oob_stack.Push (method);
	        ++lexer.parsing_block;
		start_block (lexer.Location);
	  }
  break;
case 893:
#line 5886 "cs-parser.jay"
  {
		--lexer.parsing_block;
		Method method = (Method) oob_stack.Pop ();

		method.Block = (ToplevelBlock) end_block(lexer.Location);
		current_container.AddMethod (method);

		--lexer.parsing_declaration;
		InteractiveResult = pop_current_class ();
		current_local_parameters = null;
	  }
  break;
case 894:
#line 5897 "cs-parser.jay"
  {
	        Evaluator.LoadAliases (current_namespace);
	  }
  break;
#line default
        }
        yyTop -= yyLen[yyN];
        yyState = yyStates[yyTop];
        int yyM = yyLhs[yyN];
        if (yyState == 0 && yyM == 0) {
          if (debug != null) debug.shift(0, yyFinal);
          yyState = yyFinal;
          if (yyToken < 0) {
            yyToken = yyLex.advance() ? yyLex.token() : 0;
            if (debug != null)
               debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value());
          }
          if (yyToken == 0) {
            if (debug != null) debug.accept(yyVal);
            return yyVal;
          }
          goto continue_yyLoop;
        }
        if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0)
            && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState))
          yyState = yyTable[yyN];
        else
          yyState = yyDgoto[yyM];
        if (debug != null) debug.shift(yyStates[yyTop], yyState);
	 goto continue_yyLoop;
      continue_yyDiscarded: continue;	// implements the named-loop continue: 'continue yyDiscarded'
      }
    continue_yyLoop: continue;		// implements the named-loop continue: 'continue yyLoop'
    }
Ejemplo n.º 7
0
		public Expression TryInline(ResolveContext rc) {
			if (!(Expr is Invocation)) {
				return Expr;
			}

			invocation = (Expr as Invocation);
			if (invocation.MethodGroup.BestCandidate == null) {
				return Expr;
			}

			methodSpec = invocation.MethodGroup.BestCandidate;
			if (!(methodSpec.MemberDefinition is MethodCore)) {
				return Expr;
			}

			method = methodSpec.MemberDefinition as MemberCore;
			methodData = method as IMethodData;

			if (methodData.IsInlinable) {
				return Expr;
			}

			TypeSpec returnType = methodData.ReturnType;

			ToplevelBlock block = methodData.Block;
			if (block.Parameters.Count > 0 || block.TopBlock.NamesCount > 0 && block.TopBlock.LabelsCount > 0) {
				return Expr;
			}

			if (returnType != rc.BuiltinTypes.Void && 
			    block.Statements.Count == 1 && block.Statements [0] is Return) {
				inlineExpr = ((Return)block.Statements [0]).Expr.Clone (new CloneContext());
			} else if (returnType == rc.BuiltinTypes.Void) {
				Block newBlock = new Block (rc.CurrentBlock, block.StartLocation, block.EndLocation);
				foreach (var st in block.Statements) {
					newBlock.AddStatement (st.Clone (new CloneContext()));
				}
//				inlineExpr = newBlock;
			}

			this.rc = rc;
			this.inlineFailed = false;

			Expression ret;

			inlineExpr.Accept (this);
			ret = inlineExpr;

			if (inlineFailed) {
				return Expr;
			}

			return ret;
		}
Ejemplo n.º 8
0
		private Expression CreateDynamicBinaryOperation(ResolveContext rc)
		{
			// strip dynamic from all arguments
			Arguments.CastDynamicArgs(rc);

			TypeSpec binary = rc.Module.PredefinedTypes.PsBinaryOperation.Resolve();

			// perform numeric or other type conversion
			string binaryMethod = null;
			switch (oper)
			{
				case Binary.Operator.Multiply:
					binaryMethod = "Multiply";
					break;
				case Binary.Operator.Division:
					binaryMethod = "Division";
					break;
				case Binary.Operator.Modulus:
					binaryMethod = "Modulus";
					break;
				case Binary.Operator.Addition:
					binaryMethod = "Addition";
					break;
				case Binary.Operator.Subtraction:
					binaryMethod = "Subtraction";
					break;
				case Binary.Operator.LeftShift:
					binaryMethod = "LeftShift";
					break;
				case Binary.Operator.RightShift:
					binaryMethod = "RightShift";
					break;
				case Binary.Operator.AsURightShift:
					binaryMethod = "AsURightShift";
					break;
				case Binary.Operator.LessThan:
					binaryMethod = "LessThan";
					break;
				case Binary.Operator.GreaterThan:
					binaryMethod = "GreaterThan";
					break;
				case Binary.Operator.LessThanOrEqual:
					binaryMethod = "LessThanOrEqual";
					break;
				case Binary.Operator.GreaterThanOrEqual:
					binaryMethod = "GreaterThanOrEqual";
					break;
				case Binary.Operator.Equality:
					binaryMethod = "Equality";
					break;
				case Binary.Operator.Inequality:
					binaryMethod = "Inequality";
					break;
				case Binary.Operator.AsStrictEquality:
					binaryMethod = "AsStrictEquality";
					break;
				case Binary.Operator.AsStrictInequality:
					binaryMethod = "AsStrictInequality";
					break;
				case Binary.Operator.BitwiseAnd:
					binaryMethod = "BitwiseAnd";
					break;
				case Binary.Operator.ExclusiveOr:
					binaryMethod = "ExclusiveOr";
					break;
				case Binary.Operator.BitwiseOr:
					binaryMethod = "BitwiseOr";
					break;
					// we should never support these
//				case Binary.Operator.LogicalAnd:
//					binaryMethod = "LogicalAnd";
//					break;
//				case Binary.Operator.LogicalOr:
//					binaryMethod = "LogicalOr";
//					break;
				case Binary.Operator.AsE4xChild:
					binaryMethod = "AsE4xChild";
					break;
				case Binary.Operator.AsE4xDescendant:
					binaryMethod = "AsE4xDescendant";
					break;
				case Binary.Operator.AsE4xChildAttribute:
					binaryMethod = "AsE4xChildAttribute";
					break;
				case Binary.Operator.AsE4xDescendantAttribute:
					binaryMethod = "AsE4xDescendantAttribute";
					break;
				default:
					throw new InvalidOperationException("Unknown binary operation: " + oper);
			}

			string leftType = GetDynamicBinaryTypeName(Arguments[0].Type);
			string rightType = GetDynamicBinaryTypeName(Arguments[1].Type);

			// for strict equality checks, just use a single method and check
			// types at runtime
			if (oper == Binary.Operator.AsStrictEquality ||
				oper == Binary.Operator.AsStrictInequality) {
				leftType = rightType = "Obj";
			}

			// append to binary method instead of using overloads
			binaryMethod += leftType + rightType;

			var ret = new Invocation(new MemberAccess(new TypeExpression(binary, loc), binaryMethod, loc), Arguments).Resolve(rc);
			if (ret.Type == rc.BuiltinTypes.Object) {
				// cast object to dynamic for return types
				ret = new Cast (new TypeExpression (rc.BuiltinTypes.Dynamic, loc), ret, loc).Resolve (rc);
			} 
			return ret;
		}
Ejemplo n.º 9
0
		//
		// Creates a proxy base method call inside this container for hoisted base member calls
		//
		public MethodSpec CreateHoistedBaseCallProxy (ResolveContext rc, MethodSpec method)
		{
			Method proxy_method;

			//
			// One proxy per base method is enough
			//
			if (hoisted_base_call_proxies == null) {
				hoisted_base_call_proxies = new Dictionary<MethodSpec, Method> ();
				proxy_method = null;
			} else {
				hoisted_base_call_proxies.TryGetValue (method, out proxy_method);
			}

			if (proxy_method == null) {
				string name = CompilerGeneratedContainer.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);

				MemberName member_name;
				TypeArguments targs = null;
				TypeSpec return_type = method.ReturnType;
				var local_param_types = method.Parameters.Types;

				if (method.IsGeneric) {
					//
					// Copy all base generic method type parameters info
					//
					var hoisted_tparams = method.GenericDefinition.TypeParameters;
					var tparams = new TypeParameters ();

					targs = new TypeArguments ();
					targs.Arguments = new TypeSpec[hoisted_tparams.Length];
					for (int i = 0; i < hoisted_tparams.Length; ++i) {
						var tp = hoisted_tparams[i];
						var local_tp = new TypeParameter (tp, null, new MemberName (tp.Name, Location), null);
						tparams.Add (local_tp);

						targs.Add (new SimpleName (tp.Name, Location));
						targs.Arguments[i] = local_tp.Type;
					}

					member_name = new MemberName (name, tparams, Location);

					//
					// Mutate any method type parameters from original
					// to newly created hoisted version
					//
					var mutator = new TypeParameterMutator (hoisted_tparams, tparams);
					return_type = mutator.Mutate (return_type);
					local_param_types = mutator.Mutate (local_param_types);
				} else {
					member_name = new MemberName (name);
				}

				var base_parameters = new Parameter[method.Parameters.Count];
				for (int i = 0; i < base_parameters.Length; ++i) {
					var base_param = method.Parameters.FixedParameters[i];
					base_parameters[i] = new Parameter (new TypeExpression (local_param_types [i], Location),
						base_param.Name, base_param.ModFlags, null, Location);
					base_parameters[i].Resolve (this, i);
				}

				var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
				if (method.Parameters.HasArglist) {
					cloned_params.FixedParameters[0] = new Parameter (null, "__arglist", Parameter.Modifier.NONE, null, Location);
					cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve ();
				}

				// Compiler generated proxy
				proxy_method = new Method (this, new TypeExpression (return_type, Location),
					Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
					member_name, cloned_params, null);

				var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location) {
					IsCompilerGenerated = true
				};

				var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
				mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);
				if (targs != null)
					mg.SetTypeArguments (rc, targs);

				// Get all the method parameters and pass them as arguments
				var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
				Statement statement;
				if (method.ReturnType.Kind == MemberKind.Void)
					statement = new StatementExpression (real_base_call);
				else
					statement = new Return (real_base_call, Location);

				block.AddStatement (statement);
				proxy_method.Block = block;

				members.Add (proxy_method);
				proxy_method.Define ();
				proxy_method.PrepareEmit ();

				hoisted_base_call_proxies.Add (method, proxy_method);
			}

			return proxy_method.Spec;
		}
Ejemplo n.º 10
0
 public static bool IsIntrnsic(Invocation invoke)
 {
     return(false);
 }
Ejemplo n.º 11
0
        public override bool Resolve(BlockContext bc)
        {
            if (bc.CurrentBlock is Linq.QueryBlock)
            {
                bc.Report.Error(1995, loc,
                                "The `await' operator may only be used in a query expression within the first collection expression of the initial `from' clause or within the collection expression of a `join' clause");
                return(false);
            }

            if (!base.Resolve(bc))
            {
                return(false);
            }

            Arguments args = new Arguments(0);

            type = expr.Type;

            //
            // The await expression is of dynamic type
            //
            if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
            {
                result_type = type;
                expr        = new Invocation(new MemberAccess(expr, "GetAwaiter"), args).Resolve(bc);
                return(true);
            }

            //
            // Check whether the expression is awaitable
            //
            Expression ama = new AwaitableMemberAccess(expr).Resolve(bc);

            if (ama == null)
            {
                return(false);
            }

            var errors_printer = new SessionReportPrinter();
            var old            = bc.Report.SetPrinter(errors_printer);

            ama = new Invocation(ama, args).Resolve(bc);
            bc.Report.SetPrinter(old);

            if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(ama.Type))
            {
                bc.Report.Error(1986, expr.Location,
                                "The `await' operand type `{0}' must have suitable GetAwaiter method",
                                expr.Type.GetSignatureForError());

                return(false);
            }

            var awaiter_type = ama.Type;

            expr = ama;

            //
            // Predefined: bool IsCompleted { get; }
            //
            is_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Property("IsCompleted", bc.Module.Compiler.BuiltinTypes.Bool),
                                                  BindingRestriction.InstanceOnly) as PropertySpec;

            if (is_completed == null || !is_completed.HasGet)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: GetResult ()
            //
            // The method return type is also result type of await expression
            //
            get_result = MemberCache.FindMember(awaiter_type, MemberFilter.Method("GetResult", 0,
                                                                                  ParametersCompiled.EmptyReadOnlyParameters, null),
                                                BindingRestriction.InstanceOnly) as MethodSpec;

            if (get_result == null)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: INotifyCompletion.OnCompleted (System.Action)
            //
            var nc = bc.Module.PredefinedTypes.INotifyCompletion;

            if (nc.Define() && !awaiter_type.ImplementsInterface(nc.TypeSpec, false))
            {
                bc.Report.Error(4027, loc, "The awaiter type `{0}' must implement interface `{1}'",
                                awaiter_type.GetSignatureForError(), nc.GetSignatureForError());
                return(false);
            }

            result_type = get_result.ReturnType;

            return(true);
        }
Ejemplo n.º 12
0
void case_439()
{
		Error_SyntaxError (yyToken);

		yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
Ejemplo n.º 13
0
void case_438()
{
		yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
Ejemplo n.º 14
0
        protected override Expression DoResolve(ResolveContext ec)
        {
            if (ec.Target == Target.JavaScript)
            {
                type   = ec.BuiltinTypes.Dynamic;
                eclass = ExprClass.Value;
                return(this);
            }

            if (Expr is ElementAccess)
            {
                var elem_access = Expr as ElementAccess;

                if (elem_access.Arguments.Count != 1)
                {
                    ec.Report.Error(7021, loc, "delete statement must have only one index argument.");
                    return(null);
                }

                var expr = elem_access.Expr.Resolve(ec);
                if (expr.Type == null)
                {
                    return(null);
                }

                if (expr.Type.IsArray)
                {
                    ec.Report.Error(7021, loc, "delete statement not allowed on arrays.");
                    return(null);
                }

                if (ec.Target == Target.JavaScript)
                {
                    Expr = Expr.Resolve(ec);
                    return(this);
                }

                if (!expr.Type.IsAsDynamicClass && (expr.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic))
                {
                    ec.Report.Error(7021, loc, "delete statement only allowed on dynamic types or dynamic classes");
                    return(null);
                }

                // cast expression to IDynamicClass and invoke __DeleteDynamicValue
                var dynClass = new Cast(new MemberAccess(new SimpleName("PlayScript", loc), "IDynamicClass", loc), expr, loc);
                removeExpr = new Invocation(new MemberAccess(dynClass, "__DeleteDynamicValue", loc), elem_access.Arguments);
                return(removeExpr.Resolve(ec));
            }
            else if (Expr is MemberAccess)
            {
                if (ec.Target == Target.JavaScript)
                {
                    Expr = Expr.Resolve(ec);
                    return(this);
                }

                var memb_access = Expr as MemberAccess;

                var expr = memb_access.LeftExpression.Resolve(ec);
                if (expr.Type == null)
                {
                    return(null);
                }

                if (!expr.Type.IsAsDynamicClass && (expr.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic))
                {
                    ec.Report.Error(7021, loc, "delete statement only allowed on dynamic types or dynamic classes");
                    return(null);
                }

                // cast expression to IDynamicClass and invoke __DeleteDynamicValue
                var dynClass = new Cast(new MemberAccess(new SimpleName("PlayScript", loc), "IDynamicClass", loc), expr, loc);
                var args     = new Arguments(1);
                args.Add(new Argument(new StringLiteral(ec.BuiltinTypes, memb_access.Name, loc)));
                removeExpr = new Invocation(new MemberAccess(dynClass, "__DeleteDynamicValue", loc), args);
                return(removeExpr.Resolve(ec));
            }
            else
            {
                // Error is reported elsewhere.
                return(null);
            }
        }
Ejemplo n.º 15
0
        public override bool Resolve(BlockContext bc)
        {
            if (!base.Resolve(bc))
            {
                return(false);
            }

            type = expr.Type;

            //
            // The task result is of dynamic type
            //
            if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
            {
                throw new NotImplementedException("dynamic await");
            }

            //
            // Check whether the expression is awaitable
            //
            Expression ama = new AwaitableMemberAccess(expr).Resolve(bc);

            if (ama == null)
            {
                return(false);
            }

            Arguments args = new Arguments(0);

            var errors_printer = new SessionReportPrinter();
            var old            = bc.Report.SetPrinter(errors_printer);

            ama = new Invocation(ama, args).Resolve(bc);

            if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(ama.Type))
            {
                bc.Report.SetPrinter(old);
                Error_WrongGetAwaiter(bc, loc, expr.Type);
                return(false);
            }

            var awaiter_type = ama.Type;

            awaiter = ((AsyncTaskStorey)machine_initializer.Storey).AddAwaiter(awaiter_type, loc);
            expr    = ama;

            //
            // Predefined: bool IsCompleted { get; }
            //
            var is_completed_ma = new MemberAccess(expr, "IsCompleted").Resolve(bc);

            if (is_completed_ma != null)
            {
                is_completed = is_completed_ma as PropertyExpr;
                if (is_completed != null && is_completed.Type.BuiltinType == BuiltinTypeSpec.Type.Bool && is_completed.IsInstance && is_completed.Getter != null)
                {
                    // valid
                }
                else
                {
                    bc.Report.SetPrinter(old);
                    Error_WrongAwaiterPattern(bc, awaiter_type);
                    return(false);
                }
            }

            bc.Report.SetPrinter(old);

            if (errors_printer.ErrorsCount > 0)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: OnCompleted (Action)
            //
            if (bc.Module.PredefinedTypes.Action.Define())
            {
                on_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Method("OnCompleted", 0,
                                                                                        ParametersCompiled.CreateFullyResolved(bc.Module.PredefinedTypes.Action.TypeSpec), bc.Module.Compiler.BuiltinTypes.Void),
                                                      BindingRestriction.InstanceOnly) as MethodSpec;

                if (on_completed == null)
                {
                    Error_WrongAwaiterPattern(bc, awaiter_type);
                    return(false);
                }
            }

            //
            // Predefined: GetResult ()
            //
            // The method return type is also result type of await expression
            //
            get_result = MemberCache.FindMember(awaiter_type, MemberFilter.Method("GetResult", 0,
                                                                                  ParametersCompiled.EmptyReadOnlyParameters, null),
                                                BindingRestriction.InstanceOnly) as MethodSpec;

            if (get_result == null)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 16
0
        public override Expression CreateExpressionTree(ResolveContext ec)
        {
            var invoke = new Invocation(expr, arguments);

            return(invoke.CreateExpressionTree(ec));
        }
Ejemplo n.º 17
0
			public override bool Resolve (BlockContext ec)
			{
				bool is_dynamic = expr.Type == InternalType.Dynamic;

				if (is_dynamic) {
					expr = Convert.ImplicitConversionRequired (ec, expr, TypeManager.ienumerable_type, loc);
				} else if (TypeManager.IsNullableType (expr.Type)) {
					expr = new Nullable.UnwrapCall (expr).Resolve (ec);
				}

				var get_enumerator_mg = ResolveGetEnumerator (ec);
				if (get_enumerator_mg == null) {
					return false;
				}

				var get_enumerator = get_enumerator_mg.BestCandidate;
				enumerator_variable = TemporaryVariableReference.Create (get_enumerator.ReturnType, variable.Block, loc);
				enumerator_variable.Resolve (ec);

				// Prepare bool MoveNext ()
				var move_next_mg = ResolveMoveNext (ec, get_enumerator);
				if (move_next_mg == null) {
					return false;
				}

				move_next_mg.InstanceExpression = enumerator_variable;

				// Prepare ~T~ Current { get; }
				var current_prop = ResolveCurrent (ec, get_enumerator);
				if (current_prop == null) {
					return false;
				}

				var current_pe = new PropertyExpr (current_prop, loc) { InstanceExpression = enumerator_variable }.Resolve (ec);
				if (current_pe == null)
					return false;

				VarExpr ve = var_type as VarExpr;
				if (ve != null) {
					if (is_dynamic) {
						// Source type is dynamic, set element type to dynamic too
						var_type = new TypeExpression (InternalType.Dynamic, var_type.Location);
					} else {
						// Infer implicitly typed local variable from foreach enumerable type
						var_type = new TypeExpression (current_pe.Type, var_type.Location);
					}
				} else if (is_dynamic) {
					// Explicit cast of dynamic collection elements has to be done at runtime
					current_pe = EmptyCast.Create (current_pe, InternalType.Dynamic);
				}

				var_type = var_type.ResolveAsTypeTerminal (ec, false);
				if (var_type == null)
					return false;

				variable.Type = var_type.Type;

				var init = new Invocation (get_enumerator_mg, null);

				statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)),
					new Body (var_type.Type, variable, current_pe, statement, loc), loc);

				var enum_type = enumerator_variable.Type;

				//
				// Add Dispose method call when enumerator can be IDisposable
				//
				if (!enum_type.ImplementsInterface (TypeManager.idisposable_type, false)) {
					if (!enum_type.IsSealed && !TypeManager.IsValueType (enum_type)) {
						//
						// Runtime Dispose check
						//
						var vd = new RuntimeDispose (enumerator_variable.LocalInfo, loc);
						vd.Initializer = init;
						statement = new Using (vd, statement, loc);
					} else {
						//
						// No Dispose call needed
						//
						this.init = new SimpleAssign (enumerator_variable, init);
						this.init.Resolve (ec);
					}
				} else {
					//
					// Static Dispose check
					//
					var vd = new Using.VariableDeclaration (enumerator_variable.LocalInfo, loc);
					vd.Initializer = init;
					statement = new Using (vd, statement, loc);
				}

				return statement.Resolve (ec);
			}
Ejemplo n.º 18
0
				public RuntimeDynamicInvocation (Invocation invoke, Compiler.Expression memberExpr)
					: base (memberExpr)
				{
					this.invoke = invoke;
				}
Ejemplo n.º 19
0
			public override bool Resolve (EmitContext ec)
			{
				enumerator_type = TypeManager.ienumerator_type;

				if (!ProbeCollectionType (ec, expr.Type)) {
					Error_Enumerator ();
					return false;
				}

				bool is_disposable = !enumerator_type.IsSealed ||
					TypeManager.ImplementsInterface (enumerator_type, TypeManager.idisposable_type);

				VarExpr ve = var_type as VarExpr;
				if (ve != null) {
					// Infer implicitly typed local variable from foreach enumerable type
					var_type = new TypeExpression (get_current.PropertyInfo.PropertyType, var_type.Location);
				}

				var_type = var_type.ResolveAsTypeTerminal (ec, false);
				if (var_type == null)
					return false;
								
				enumerator = new TemporaryVariable (enumerator_type, loc);
				enumerator.Resolve (ec);

				init = new Invocation (get_enumerator, null);
				init = init.Resolve (ec);
				if (init == null)
					return false;

				Expression move_next_expr;
				{
					MemberInfo[] mi = new MemberInfo[] { move_next };
					MethodGroupExpr mg = new MethodGroupExpr (mi, var_type.Type, loc);
					mg.InstanceExpression = enumerator;

					move_next_expr = new Invocation (mg, null);
				}

				get_current.InstanceExpression = enumerator;

				Statement block = new CollectionForeachStatement (
					var_type.Type, variable, get_current, statement, loc);

				loop = new While (move_next_expr, block, loc);

				wrapper = is_disposable ?
					(Statement) new DisposableWrapper (this) :
					(Statement) new NonDisposableWrapper (this);
				return wrapper.Resolve (ec);
			}
Ejemplo n.º 20
0
		//
		// Creates a proxy base method call inside this container for hoisted base member calls
		//
		public MethodSpec CreateHoistedBaseCallProxy (ResolveContext rc, MethodSpec method)
		{
			Method proxy_method;

			//
			// One proxy per base method is enough
			//
			if (hoisted_base_call_proxies == null) {
				hoisted_base_call_proxies = new Dictionary<MethodSpec, Method> ();
				proxy_method = null;
			} else {
				hoisted_base_call_proxies.TryGetValue (method, out proxy_method);
			}

			if (proxy_method == null) {
				string name = CompilerGeneratedClass.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
				var base_parameters = new Parameter[method.Parameters.Count];
				for (int i = 0; i < base_parameters.Length; ++i) {
					var base_param = method.Parameters.FixedParameters[i];
					base_parameters[i] = new Parameter (new TypeExpression (method.Parameters.Types[i], Location),
						base_param.Name, base_param.ModFlags, null, Location);
					base_parameters[i].Resolve (this, i);
				}

				var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
				if (method.Parameters.HasArglist) {
					cloned_params.FixedParameters[0] = new Parameter (null, "__arglist", Parameter.Modifier.NONE, null, Location);
					cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve (Location);
				}

				GenericMethod generic_method;
				MemberName member_name;
				if (method.IsGeneric) {
					//
					// Copy all base generic method type parameters info
					//
					var hoisted_tparams = method.GenericDefinition.TypeParameters;
					var targs = new TypeArguments ();
					var type_params = new TypeParameter[hoisted_tparams.Length];
					for (int i = 0; i < type_params.Length; ++i) {
						var tp = hoisted_tparams[i];
						targs.Add (new TypeParameterName (tp.Name, null, Location));
						type_params[i] = new TypeParameter (tp, this, null, new MemberName (tp.Name), null);
					}

					member_name = new MemberName (name, targs, Location);
					generic_method = new GenericMethod (NamespaceEntry, this, member_name, type_params,
						new TypeExpression (method.ReturnType, Location), cloned_params);
				} else {
					member_name = new MemberName (name);
					generic_method = null;
				}

				// Compiler generated proxy
				proxy_method = new Method (this, generic_method, new TypeExpression (method.ReturnType, Location),
					Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
					member_name, cloned_params, null);

				var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location);

				var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
				mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);

				// Get all the method parameters and pass them as arguments
				var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
				Statement statement;
				if (method.ReturnType == TypeManager.void_type)
					statement = new StatementExpression (real_base_call);
				else
					statement = new Return (real_base_call, Location);

				block.AddStatement (statement);
				proxy_method.Block = block;

				methods.Add (proxy_method);
				proxy_method.Define ();

				hoisted_base_call_proxies.Add (method, proxy_method);
			}

			return proxy_method.Spec;
		}
Ejemplo n.º 21
0
        public override Expression DoResolve(ResolveContext ec)
        {
            constructor_method = Delegate.GetConstructor(ec.Compiler, ec.CurrentType, type);

            MethodInfo invoke_method = Delegate.GetInvokeMethod(ec.Compiler, ec.CurrentType, type);

            method_group.DelegateType       = type;
            method_group.CustomErrorHandler = this;

            Arguments arguments = CreateDelegateMethodArguments(TypeManager.GetParameterData(invoke_method), loc);

            method_group = method_group.OverloadResolve(ec, ref arguments, false, loc);
            if (method_group == null)
            {
                return(null);
            }

            delegate_method = (MethodInfo)method_group;

            if (TypeManager.IsNullableType(delegate_method.DeclaringType))
            {
                ec.Report.Error(1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
                                TypeManager.GetFullNameSignature(delegate_method));
                return(null);
            }

            Invocation.IsSpecialMethodInvocation(ec, delegate_method, loc);

            ExtensionMethodGroupExpr emg = method_group as ExtensionMethodGroupExpr;

            if (emg != null)
            {
                delegate_instance_expression = emg.ExtensionExpression;
                Type e_type = delegate_instance_expression.Type;
                if (TypeManager.IsValueType(e_type))
                {
                    ec.Report.Error(1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates",
                                    TypeManager.CSharpSignature(delegate_method), TypeManager.CSharpName(e_type));
                }
            }

            Type       rt       = TypeManager.TypeToCoreType(delegate_method.ReturnType);
            Expression ret_expr = new TypeExpression(rt, loc);

            if (!Delegate.IsTypeCovariant(ret_expr, (TypeManager.TypeToCoreType(invoke_method.ReturnType))))
            {
                Error_ConversionFailed(ec, delegate_method, ret_expr);
            }

            if (Invocation.IsMethodExcluded(delegate_method, loc))
            {
                ec.Report.SymbolRelatedToPreviousError(delegate_method);
                MethodOrOperator m = TypeManager.GetMethod(delegate_method) as MethodOrOperator;
                if (m != null && m.IsPartialDefinition)
                {
                    ec.Report.Error(762, loc, "Cannot create delegate from partial method declaration `{0}'",
                                    TypeManager.CSharpSignature(delegate_method));
                }
                else
                {
                    ec.Report.Error(1618, loc, "Cannot create delegate with `{0}' because it has a Conditional attribute",
                                    TypeManager.CSharpSignature(delegate_method));
                }
            }

            DoResolveInstanceExpression(ec);
            eclass = ExprClass.Value;
            return(this);
        }
Ejemplo n.º 22
0
        public void EmitPrologue(EmitContext ec)
        {
            var fe_awaiter = new FieldExpr(awaiter, loc);

            fe_awaiter.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc);

            //
            // awaiter = expr.GetAwaiter ();
            //
            fe_awaiter.EmitAssign(ec, expr, false, false);

            Label skip_continuation = ec.DefineLabel();

            Expression completed_expr;

            if (IsDynamic)
            {
                var rc = new ResolveContext(ec.MemberContext);

                Arguments dargs = new Arguments(1);
                dargs.Add(new Argument(fe_awaiter));
                completed_expr = new DynamicMemberBinder("IsCompleted", dargs, loc).Resolve(rc);
            }
            else
            {
                var pe = PropertyExpr.CreatePredefined(is_completed, loc);
                pe.InstanceExpression = fe_awaiter;
                completed_expr        = pe;
            }

            completed_expr.EmitBranchable(ec, skip_continuation, true);

            base.DoEmit(ec);

            //
            // The stack has to be empty before calling await continuation. We handle this
            // by lifting values which would be left on stack into class fields. The process
            // is quite complicated and quite hard to test because any expression can possibly
            // leave a value on the stack.
            //
            // Following assert fails when some of expression called before is missing EmitToField
            // or parent expression fails to find await in children expressions
            //
            ec.AssertEmptyStack();

            var args    = new Arguments(1);
            var storey  = (AsyncTaskStorey)machine_initializer.Storey;
            var fe_cont = new FieldExpr(storey.Continuation, loc);

            fe_cont.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc);

            args.Add(new Argument(fe_cont));

            if (IsDynamic)
            {
                var rc      = new ResolveContext(ec.MemberContext);
                var mg_expr = new Invocation(new MemberAccess(fe_awaiter, "OnCompleted"), args).Resolve(rc);

                ExpressionStatement es = (ExpressionStatement)mg_expr;
                es.EmitStatement(ec);
            }
            else
            {
                var mg_completed = MethodGroupExpr.CreatePredefined(on_completed, fe_awaiter.Type, loc);
                mg_completed.InstanceExpression = fe_awaiter;

                //
                // awaiter.OnCompleted (continuation);
                //
                mg_completed.EmitCall(ec, args);
            }

            // Return ok
            machine_initializer.EmitLeave(ec, unwind_protect);

            ec.MarkLabel(resume_point);
            ec.MarkLabel(skip_continuation);
        }
Ejemplo n.º 23
0
            private Method GenerateNumberMatcher()
            {
                var loc        = Location;
                var parameters = ParametersCompiled.CreateFullyResolved(
                    new[] {
                    new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc),
                    new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, loc), "value", 0, null, loc),
                    new Parameter(new TypeExpression(Compiler.BuiltinTypes.Bool, loc), "enumType", 0, null, loc),
                },
                    new[] {
                    Compiler.BuiltinTypes.Object,
                    Compiler.BuiltinTypes.Object,
                    Compiler.BuiltinTypes.Bool
                });

                var m = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Bool, loc),
                                   Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName("NumberMatcher", loc),
                                   parameters, null);

                parameters[0].Resolve(m, 0);
                parameters[1].Resolve(m, 1);
                parameters[2].Resolve(m, 2);

                ToplevelBlock top_block = new ToplevelBlock(Compiler, parameters, loc);

                m.Block = top_block;

                //
                // if (enumType)
                //		return Equals (obj, value);
                //
                var equals_args = new Arguments(2);

                equals_args.Add(new Argument(top_block.GetParameterReference(0, loc)));
                equals_args.Add(new Argument(top_block.GetParameterReference(1, loc)));

                var if_type = new If(
                    top_block.GetParameterReference(2, loc),
                    new Return(new Invocation(new SimpleName("Equals", loc), equals_args), loc),
                    loc);

                top_block.AddStatement(if_type);

                //
                // if (obj is Enum || obj == null)
                //		return false;
                //

                var if_enum = new If(
                    new Binary(Binary.Operator.LogicalOr,
                               new Is(top_block.GetParameterReference(0, loc), new TypeExpression(Compiler.BuiltinTypes.Enum, loc), loc),
                               new Binary(Binary.Operator.Equality, top_block.GetParameterReference(0, loc), new NullLiteral(loc))),
                    new Return(new BoolLiteral(Compiler.BuiltinTypes, false, loc), loc),
                    loc);

                top_block.AddStatement(if_enum);

                var system_convert = new MemberAccess(new QualifiedAliasMember("global", "System", loc), "Convert", loc);

                //
                // var converted = System.Convert.ChangeType (obj, System.Convert.GetTypeCode (value));
                //
                var lv_converted = LocalVariable.CreateCompilerGenerated(Compiler.BuiltinTypes.Object, top_block, loc);

                var arguments_gettypecode = new Arguments(1);

                arguments_gettypecode.Add(new Argument(top_block.GetParameterReference(1, loc)));

                var gettypecode = new Invocation(new MemberAccess(system_convert, "GetTypeCode", loc), arguments_gettypecode);

                var arguments_changetype = new Arguments(1);

                arguments_changetype.Add(new Argument(top_block.GetParameterReference(0, loc)));
                arguments_changetype.Add(new Argument(gettypecode));

                var changetype = new Invocation(new MemberAccess(system_convert, "ChangeType", loc), arguments_changetype);

                top_block.AddStatement(new StatementExpression(new SimpleAssign(new LocalVariableReference(lv_converted, loc), changetype, loc)));

                //
                // return converted.Equals (value)
                //
                var equals_arguments = new Arguments(1);

                equals_arguments.Add(new Argument(top_block.GetParameterReference(1, loc)));
                var equals_invocation = new Invocation(new MemberAccess(new LocalVariableReference(lv_converted, loc), "Equals"), equals_arguments);

                top_block.AddStatement(new Return(equals_invocation, loc));

                m.Define();
                m.PrepareEmit();
                AddMember(m);

                return(m);
            }
Ejemplo n.º 24
0
		static Expression DoImplicitConversionStandard (ResolveContext ec, Expression expr, TypeSpec target_type, Location loc, bool explicit_cast, bool upconvert_only)
		{
			if (expr.eclass == ExprClass.MethodGroup){
				if (!target_type.IsDelegate){
					if (ec.FileType == SourceFileType.PlayScript && 
					    (target_type == ec.BuiltinTypes.Dynamic || target_type == ec.BuiltinTypes.Delegate)) {
						MethodGroupExpr mg = expr as MethodGroupExpr;
						if (mg != null) {
							if (mg.Candidates.Count != 1) {
								ec.Report.Error (7021, loc, "Ambiguous overloaded methods `{0}' when assigning to Function or Object type", mg.Name);
								return null;
							}
							var ms = (MethodSpec)mg.Candidates[0];
							var del_type = Delegate.CreateDelegateTypeFromMethodSpec(ec, ms, loc);

							// If return is "Delegate", we create a var args anonymous method which calls the target method..
							if (del_type == ec.BuiltinTypes.Delegate) {
								var objArrayType = new ComposedCast (
									new TypeExpression(ec.BuiltinTypes.Object, loc),  
									ComposedTypeSpecifier.CreateArrayDimension (1, loc));
								var parameters = new ParametersCompiled(new Parameter[] {
									new ParamsParameter(objArrayType, "args", null, loc) }, false);
								var dynCall = new AnonymousMethodExpression(expr.Location, parameters, new TypeExpression(ms.ReturnType, loc));
								var block = new ParametersBlock (ec.CurrentBlock, parameters, expr.Location);
								dynCall.Block = block;
								var args = new Arguments (3);
								args.Add (new Argument(new TypeOf(new TypeExpression(ms.DeclaringType, loc), loc)));
								args.Add (new Argument(new StringLiteral(ec.BuiltinTypes, ms.Name, loc)));
								args.Add (new Argument(new SimpleName("args", loc)));
								var call = new Invocation (new MemberAccess(new MemberAccess(new SimpleName("PlayScript", loc), "Support", loc), "VarArgCall", loc), args);
								if (ms.ReturnType == ec.BuiltinTypes.Void) {
									block.AddStatement (new StatementExpression(call));
								} else {
									block.AddStatement (new Return(call, loc));
								}
								return dynCall.Resolve (ec);
							} else { 
								// Otherwise cast to the specific delegate type
								return new ImplicitDelegateCreation (del_type, mg, loc).Resolve (ec);
							}
						}
					}
					return null;
				}

				//
				// Only allow anonymous method conversions on post ISO_1
				//
				if (ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1){
					MethodGroupExpr mg = expr as MethodGroupExpr;
					if (mg != null)
						return new ImplicitDelegateCreation (target_type, mg, loc).Resolve (ec);
				}
			}

			TypeSpec expr_type = expr.Type;
			Expression e;

			if (expr_type == target_type) {
				if (expr_type != InternalType.NullLiteral && expr_type != InternalType.AnonymousMethod)
					return expr;
				return null;
			}

			// Auto convert types to type objects..
			if (ec.FileType == SourceFileType.PlayScript && target_type.BuiltinType == BuiltinTypeSpec.Type.Type && expr is FullNamedExpression) {
				FullNamedExpression type_expr = (FullNamedExpression)expr;
				if (expr_type != null) {
					if (expr_type.MemberDefinition.Namespace == PsConsts.PsRootNamespace) {
						switch (expr_type.Name) {
						case "String":
							type_expr = new TypeExpression (ec.BuiltinTypes.String, type_expr.Location);
							break;
						case "Number":
							type_expr = new TypeExpression (ec.BuiltinTypes.Double, type_expr.Location);
							break;
						case "Boolean":
							type_expr = new TypeExpression (ec.BuiltinTypes.Double, type_expr.Location);
							break;
						}
					} else if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
						type_expr = new TypeExpression (ec.Module.PredefinedTypes.AsObject.Resolve(), type_expr.Location);
					}
				}
				return new TypeOf (type_expr, expr.Location).Resolve (ec);
			}

			if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {

				// Implicitly cast references to bools in PlayScript
				if (ec.FileType == SourceFileType.PlayScript && 
				    target_type.BuiltinType == BuiltinTypeSpec.Type.Bool &&
				    ec.Target != Target.JavaScript) {

					var cast_args = new Arguments(1);
					cast_args.Add (new Argument(EmptyCast.Create(expr, ec.BuiltinTypes.Object)));

//					ec.Report.Warning (7164, 1, expr.Location, "Expensive reference conversion to bool");

					return new Invocation(new MemberAccess(new MemberAccess(new SimpleName(
						PsConsts.PsRootNamespace, expr.Location), "Boolean_fn", expr.Location), "Boolean", expr.Location), 
					                      cast_args).Resolve (ec);
				}

				switch (target_type.Kind) {
				case MemberKind.ArrayType:
				case MemberKind.Class:
					if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object)
						return EmptyCast.Create (expr, target_type);

					goto case MemberKind.Struct;
				case MemberKind.Struct:
				case MemberKind.Delegate:
				case MemberKind.Enum:
				case MemberKind.Interface:
				case MemberKind.TypeParameter:
					Arguments args = new Arguments (1);
					args.Add (new Argument (expr));
					return new DynamicConversion (target_type, explicit_cast ? CSharpBinderFlags.ConvertExplicit : 0, args, loc).Resolve (ec);
				}

				return null;
			}



			if (target_type.IsNullableType)
				return ImplicitNulableConversion (ec, expr, target_type);

			//
			// Attempt to do the implicit constant expression conversions
			//
			Constant c = expr as Constant;
			if (c != null) {
				try {
					c = c.ConvertImplicitly (target_type, ec, upconvert_only);
				} catch {
					throw new InternalErrorException ("Conversion error", loc);
				}
				if (c != null)
					return c;
			}

			e = ImplicitNumericConversion (expr, expr_type, target_type, ec, upconvert_only);
			if (e != null)
				return e;

			e = ImplicitPlayScriptConversion (expr, target_type, ec, upconvert_only);
			if (e != null)
				return e;

			e = ImplicitReferenceConversion (expr, target_type, explicit_cast, ec, upconvert_only);
			if (e != null)
				return e;

			e = ImplicitBoxingConversion (expr, expr_type, target_type);
			if (e != null)
				return e;

			if (expr is IntegralConstant && target_type.IsEnum){
				var i = (IntegralConstant) expr;
				//
				// LAMESPEC: csc allows any constant like 0 values to be converted, including const float f = 0.0
				//
				// An implicit enumeration conversion permits the decimal-integer-literal 0
				// to be converted to any enum-type and to any nullable-type whose underlying
				// type is an enum-type
				//
				if (i.IsZeroInteger) {
					// Recreate 0 literal to remove any collected conversions
					return new EnumConstant (new IntLiteral (ec.BuiltinTypes, 0, i.Location), target_type);
				}
			}

			if (ec.IsUnsafe) {
				var target_pc = target_type as PointerContainer;
				if (target_pc != null) {
					if (expr_type.IsPointer) {
						//
						// Pointer types are same when they have same element types
						//
						if (expr_type == target_pc)
							return expr;

						if (target_pc.Element.Kind == MemberKind.Void)
							return EmptyCast.Create (expr, target_type);

						//return null;
					}

					if (expr_type == InternalType.NullLiteral)
						return new NullPointer (target_type, loc);
				}
			}

			if (expr_type == InternalType.AnonymousMethod){
				AnonymousMethodExpression ame = (AnonymousMethodExpression) expr;
				if (ec.FileType == SourceFileType.PlayScript && 
				    (target_type == ec.BuiltinTypes.Dynamic || target_type == ec.BuiltinTypes.Delegate)) {
					var del_type = Delegate.CreateDelegateType (ec, ame.AsParameters, ame.AsReturnType.ResolveAsType(ec), loc);
					return new Cast(new TypeExpression(del_type, loc), expr, loc).Resolve(ec);
				}
				Expression am = ame.Compatible (ec, target_type);
				if (am != null)
					return am.Resolve (ec);
			}

			if (expr_type == InternalType.Arglist && target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec)
				return expr;

			//
			// dynamic erasure conversion on value types
			//
			if (expr_type.IsStruct && TypeSpecComparer.IsEqual (expr_type, target_type))
				return expr_type == target_type ? expr : EmptyCast.Create (expr, target_type);

			return null;
		}
Ejemplo n.º 25
0
        public Expression TryInline(ResolveContext rc)
        {
            if (!(Expr is Invocation))
            {
                return(Expr);
            }

            invocation = (Expr as Invocation);
            if (invocation.MethodGroup.BestCandidate == null)
            {
                return(Expr);
            }

            methodSpec = invocation.MethodGroup.BestCandidate;
            if (!(methodSpec.MemberDefinition is MethodCore))
            {
                return(Expr);
            }

            method     = methodSpec.MemberDefinition as MemberCore;
            methodData = method as IMethodData;

            if (methodData.IsInlinable)
            {
                return(Expr);
            }

            TypeSpec returnType = methodData.ReturnType;

            ToplevelBlock block = methodData.Block;

            if (block.Parameters.Count > 0 || block.TopBlock.NamesCount > 0 && block.TopBlock.LabelsCount > 0)
            {
                return(Expr);
            }

            if (returnType != rc.BuiltinTypes.Void &&
                block.Statements.Count == 1 && block.Statements [0] is Return)
            {
                inlineExpr = ((Return)block.Statements [0]).Expr.Clone(new CloneContext());
            }
            else if (returnType == rc.BuiltinTypes.Void)
            {
                Block newBlock = new Block(rc.CurrentBlock, block.StartLocation, block.EndLocation);
                foreach (var st in block.Statements)
                {
                    newBlock.AddStatement(st.Clone(new CloneContext()));
                }
//				inlineExpr = newBlock;
            }

            this.inlineFailed = false;

            Expression ret;

            inlineExpr.Accept(this);
            ret = inlineExpr;

            if (inlineFailed)
            {
                return(Expr);
            }

            return(ret);
        }
Ejemplo n.º 26
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			if (ec.Target == Target.JavaScript) {
				type = ec.BuiltinTypes.Dynamic;
				eclass = ExprClass.Value;
				return this;
			}

			if (Expr is ElementAccess) {

				var elem_access = Expr as ElementAccess;

				if (elem_access.Arguments.Count != 1) {
					ec.Report.Error (7021, loc, "delete statement must have only one index argument.");
					return null;
				}

				var expr = elem_access.Expr.Resolve (ec);
				if (expr.Type == null) {
					return null;
				}

				if (expr.Type.IsArray) {
					ec.Report.Error (7021, loc, "delete statement not allowed on arrays.");
					return null;
				}

				if (ec.Target == Target.JavaScript) {
					Expr = Expr.Resolve(ec);
					return this;
				}

				if (!expr.Type.IsAsDynamicClass && (expr.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic))
				{
					ec.Report.Error (7021, loc, "delete statement only allowed on dynamic types or dynamic classes");
					return null;
				}

				// cast expression to IDynamicClass and invoke __DeleteDynamicValue
				var dynClass = new Cast(new MemberAccess(new SimpleName("PlayScript", loc), "IDynamicClass", loc), expr, loc);
				removeExpr = new Invocation (new MemberAccess (dynClass, "__DeleteDynamicValue", loc), elem_access.Arguments);
				return removeExpr.Resolve (ec);

			} else if (Expr is MemberAccess) {

				if (ec.Target == Target.JavaScript) {
					Expr = Expr.Resolve(ec);
					return this;
				}

				var memb_access = Expr as MemberAccess;

				var expr = memb_access.LeftExpression.Resolve (ec);
				if (expr.Type == null) {
					return null;
				}

				if (!expr.Type.IsAsDynamicClass && (expr.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic))
				{
					ec.Report.Error (7021, loc, "delete statement only allowed on dynamic types or dynamic classes");
					return null;
				}

				// cast expression to IDynamicClass and invoke __DeleteDynamicValue
				var dynClass = new Cast(new MemberAccess(new SimpleName("PlayScript", loc), "IDynamicClass", loc), expr, loc);
				var args = new Arguments(1);
				args.Add (new Argument(new StringLiteral(ec.BuiltinTypes, memb_access.Name, loc)));
				removeExpr = new Invocation (new MemberAccess (dynClass, "__DeleteDynamicValue", loc), args);
				return removeExpr.Resolve (ec);

			} else {
				// Error is reported elsewhere.
				return null;
			}
		}
Ejemplo n.º 27
0
Archivo: async.cs Proyecto: zcz527/mono
        public override bool Resolve(BlockContext bc)
        {
            if (bc.CurrentBlock is Linq.QueryBlock)
            {
                bc.Report.Error(1995, loc,
                                "The `await' operator may only be used in a query expression within the first collection expression of the initial `from' clause or within the collection expression of a `join' clause");
                return(false);
            }

            if (!base.Resolve(bc))
            {
                return(false);
            }

            type = expr.Type;
            Arguments args = new Arguments(0);

            //
            // The await expression is of dynamic type
            //
            if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
            {
                result_type = type;
                expr        = new Invocation(new MemberAccess(expr, "GetAwaiter"), args).Resolve(bc);
                return(true);
            }

            //
            // Check whether the expression is awaitable
            //
            Expression ama = new AwaitableMemberAccess(expr).Resolve(bc);

            if (ama == null)
            {
                return(false);
            }

            var errors_printer = new SessionReportPrinter();
            var old            = bc.Report.SetPrinter(errors_printer);

            ama = new Invocation(ama, args).Resolve(bc);
            bc.Report.SetPrinter(old);

            if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(ama.Type))
            {
                bc.Report.Error(1986, expr.Location,
                                "The `await' operand type `{0}' must have suitable GetAwaiter method",
                                expr.Type.GetSignatureForError());

                return(false);
            }

            var awaiter_type = ama.Type;

            awaiter_definition = bc.Module.GetAwaiter(awaiter_type);

            if (!awaiter_definition.IsValidPattern)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            if (!awaiter_definition.INotifyCompletion)
            {
                bc.Report.Error(4027, loc, "The awaiter type `{0}' must implement interface `{1}'",
                                awaiter_type.GetSignatureForError(), bc.Module.PredefinedTypes.INotifyCompletion.GetSignatureForError());
                return(false);
            }

            expr        = ama;
            result_type = awaiter_definition.GetResult.ReturnType;

            return(true);
        }
Ejemplo n.º 28
0
 public virtual object Visit(Invocation invocationExpression)
 {
     return(null);
 }
Ejemplo n.º 29
0
        protected override Expression DoResolve(ResolveContext ec)
        {
            constructor_method = Delegate.GetConstructor(type);

            var invoke_method = Delegate.GetInvokeMethod(type);

            Arguments arguments = CreateDelegateMethodArguments(invoke_method.Parameters, invoke_method.Parameters.Types, loc);

            method_group = method_group.OverloadResolve(ec, ref arguments, this, OverloadResolver.Restrictions.CovariantDelegate);
            if (method_group == null)
            {
                return(null);
            }

            var delegate_method = method_group.BestCandidate;

            if (delegate_method.DeclaringType.IsNullableType)
            {
                ec.Report.Error(1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
                                delegate_method.GetSignatureForError());
                return(null);
            }

            Invocation.IsSpecialMethodInvocation(ec, delegate_method, loc);

            ExtensionMethodGroupExpr emg = method_group as ExtensionMethodGroupExpr;

            if (emg != null)
            {
                method_group.InstanceExpression = emg.ExtensionExpression;
                TypeSpec e_type = emg.ExtensionExpression.Type;
                if (TypeManager.IsValueType(e_type))
                {
                    ec.Report.Error(1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates",
                                    delegate_method.GetSignatureForError(), TypeManager.CSharpName(e_type));
                }
            }

            TypeSpec rt = delegate_method.ReturnType;

            if (!Delegate.IsTypeCovariant(ec, rt, invoke_method.ReturnType))
            {
                Expression ret_expr = new TypeExpression(rt, loc);
                Error_ConversionFailed(ec, delegate_method, ret_expr);
            }

            if (delegate_method.IsConditionallyExcluded(ec.Module.Compiler, loc))
            {
                ec.Report.SymbolRelatedToPreviousError(delegate_method);
                MethodOrOperator m = delegate_method.MemberDefinition as MethodOrOperator;
                if (m != null && m.IsPartialDefinition)
                {
                    ec.Report.Error(762, loc, "Cannot create delegate from partial method declaration `{0}'",
                                    delegate_method.GetSignatureForError());
                }
                else
                {
                    ec.Report.Error(1618, loc, "Cannot create delegate with `{0}' because it has a Conditional attribute",
                                    TypeManager.CSharpSignature(delegate_method));
                }
            }

            var expr = method_group.InstanceExpression;

            if (expr != null && (expr.Type.IsGenericParameter || !TypeManager.IsReferenceType(expr.Type)))
            {
                method_group.InstanceExpression = new BoxedCast(expr, ec.BuiltinTypes.Object);
            }

            eclass = ExprClass.Value;
            return(this);
        }
Ejemplo n.º 30
0
			Method GenerateNumberMatcher ()
			{
				var loc = Location;
				var parameters = ParametersCompiled.CreateFullyResolved (
					new [] {
						new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc),
						new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "value", 0, null, loc),
						new Parameter (new TypeExpression (Compiler.BuiltinTypes.Bool, loc), "enumType", 0, null, loc),
					},
					new [] {
						Compiler.BuiltinTypes.Object,
						Compiler.BuiltinTypes.Object,
						Compiler.BuiltinTypes.Bool
					});

				var m = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
					Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("NumberMatcher", loc),
					parameters, null);

				parameters [0].Resolve (m, 0);
				parameters [1].Resolve (m, 1);
				parameters [2].Resolve (m, 2);

				ToplevelBlock top_block = new ToplevelBlock (Compiler, parameters, loc);
				m.Block = top_block;

				//
				// if (enumType)
				//		return Equals (obj, value);
				//
				var equals_args = new Arguments (2);
				equals_args.Add (new Argument (top_block.GetParameterReference (0, loc)));
				equals_args.Add (new Argument (top_block.GetParameterReference (1, loc)));

				var if_type = new If (
					              top_block.GetParameterReference (2, loc),
					              new Return (new Invocation (new SimpleName ("Equals", loc), equals_args), loc),
					              loc);

				top_block.AddStatement (if_type);

				//
				// if (obj is Enum || obj == null)
				//		return false;
				//

				var if_enum = new If (
					              new Binary (Binary.Operator.LogicalOr,
						              new Is (top_block.GetParameterReference (0, loc), new TypeExpression (Compiler.BuiltinTypes.Enum, loc), loc),
						              new Binary (Binary.Operator.Equality, top_block.GetParameterReference (0, loc), new NullLiteral (loc))),
					              new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc),
					              loc);

				top_block.AddStatement (if_enum);


				var system_convert = new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Convert", loc);
				var expl_block = new ExplicitBlock (top_block, loc, loc);

				//
				// var converted = System.Convert.ChangeType (obj, System.Convert.GetTypeCode (value));
				//
				var lv_converted = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Object, top_block, loc);

				var arguments_gettypecode = new Arguments (1);
				arguments_gettypecode.Add (new Argument (top_block.GetParameterReference (1, loc)));

				var gettypecode = new Invocation (new MemberAccess (system_convert, "GetTypeCode", loc), arguments_gettypecode);

				var arguments_changetype = new Arguments (1);
				arguments_changetype.Add (new Argument (top_block.GetParameterReference (0, loc)));
				arguments_changetype.Add (new Argument (gettypecode));

				var changetype = new Invocation (new MemberAccess (system_convert, "ChangeType", loc), arguments_changetype);

				expl_block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (lv_converted, loc), changetype, loc)));


				//
				// return converted.Equals (value)
				//
				var equals_arguments = new Arguments (1);
				equals_arguments.Add (new Argument (top_block.GetParameterReference (1, loc)));
				var equals_invocation = new Invocation (new MemberAccess (new LocalVariableReference (lv_converted, loc), "Equals"), equals_arguments);
				expl_block.AddStatement (new Return (equals_invocation, loc));

				var catch_block = new ExplicitBlock (top_block, loc, loc);
				catch_block.AddStatement (new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc));
				top_block.AddStatement (new TryCatch (expl_block, new List<Catch> () {
					new Catch (catch_block, loc)
				}, loc, false));

				m.Define ();
				m.PrepareEmit ();
				AddMember (m);

				return m;
			}
Ejemplo n.º 31
0
 public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx)
 {
     return(Invocation.MakeExpression(ctx, InstanceExpr, method, arguments));
 }
Ejemplo n.º 32
0
			public override bool Resolve (BlockContext ec)
			{
				Block variables_block = variable.local_info.Block;
				copy = TemporaryVariableReference.Create (for_each.expr.Type, variables_block, loc);
				copy.Resolve (ec);

				int rank = length_exprs.Length;
				Arguments list = new Arguments (rank);
				for (int i = 0; i < rank; i++) {
					var v = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc);
					variables[i] = v;
					counter[i] = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, v, loc));
					counter[i].Resolve (ec);

					if (rank == 1) {
						length_exprs [i] = new MemberAccess (copy, "Length").Resolve (ec);
					} else {
						lengths[i] = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc);
						lengths[i].Resolve (ec);

						Arguments args = new Arguments (1);
						args.Add (new Argument (new IntConstant (i, loc)));
						length_exprs [i] = new Invocation (new MemberAccess (copy, "GetLength"), args).Resolve (ec);
					}

					list.Add (new Argument (v));
				}

				access = new ElementAccess (copy, list, loc).Resolve (ec);
				if (access == null)
					return false;

				Expression var_type = for_each.type;
				VarExpr ve = var_type as VarExpr;
				if (ve != null) {
					// Infer implicitly typed local variable from foreach array type
					var_type = new TypeExpression (access.Type, ve.Location);
				}

				var_type = var_type.ResolveAsTypeTerminal (ec, false);
				if (var_type == null)
					return false;

				conv = Convert.ExplicitConversion (ec, access, var_type.Type, loc);
				if (conv == null)
					return false;

				bool ok = true;

				ec.StartFlowBranching (FlowBranching.BranchingType.Loop, loc);
				ec.CurrentBranching.CreateSibling ();

				variable.local_info.Type = conv.Type;
				variable.Resolve (ec);

				ec.StartFlowBranching (FlowBranching.BranchingType.Embedded, loc);
				if (!statement.Resolve (ec))
					ok = false;
				ec.EndFlowBranching ();

				// There's no direct control flow from the end of the embedded statement to the end of the loop
				ec.CurrentBranching.CurrentUsageVector.Goto ();

				ec.EndFlowBranching ();

				return ok;
			}
Ejemplo n.º 33
0
void case_446()
#line 3310 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);

		yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
Ejemplo n.º 34
0
		public virtual object Visit (Invocation invocationExpression)
		{
			return null;
		}
Ejemplo n.º 35
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			CloneContext cc = new CloneContext ();
			Expression clone = source.Clone (cc);

			//
			// A useful feature for the REPL: if we can resolve the expression
			// as a type, Describe the type;
			//
			if (Evaluator.DescribeTypeExpressions){
				var old_printer = Evaluator.SetPrinter (new StreamReportPrinter (TextWriter.Null));
				clone = clone.Resolve (ec);
				if (clone == null){
					clone = source.Clone (cc);
					clone = clone.Resolve (ec, ResolveFlags.Type);
					if (clone == null){
						Evaluator.SetPrinter (old_printer);
						clone = source.Clone (cc);
						clone = clone.Resolve (ec);
						return null;
					}
					
					Arguments args = new Arguments (1);
					args.Add (new Argument (new TypeOf ((TypeExpr) clone, Location)));
					source = new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec);
				}
				Evaluator.SetPrinter (old_printer);
			} else {
				clone = clone.Resolve (ec);
				if (clone == null)
					return null;
			}
	
			// This means its really a statement.
			if (clone.Type == TypeManager.void_type){
				source = source.Resolve (ec);
				target = null;
				type = TypeManager.void_type;
				eclass = ExprClass.Value;
				return this;
			}

			return base.DoResolve (ec);
		}
Ejemplo n.º 36
0
void case_445()
#line 3305 "cs-parser.jay"
{
		yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
Ejemplo n.º 37
0
        public override bool Resolve(BlockContext bc)
        {
            if (!base.Resolve(bc))
            {
                return(false);
            }

            Arguments args = new Arguments(0);

            type = expr.Type;

            //
            // The await expression is of dynamic type
            //
            if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
            {
                result_type = type;

                awaiter = ((AsyncTaskStorey)machine_initializer.Storey).AddAwaiter(type, loc);

                expr = new Invocation(new MemberAccess(expr, "GetAwaiter"), args).Resolve(bc);
                return(true);
            }

            //
            // Check whether the expression is awaitable
            //
            Expression ama = new AwaitableMemberAccess(expr).Resolve(bc);

            if (ama == null)
            {
                return(false);
            }

            var errors_printer = new SessionReportPrinter();
            var old            = bc.Report.SetPrinter(errors_printer);

            ama = new Invocation(ama, args).Resolve(bc);
            bc.Report.SetPrinter(old);

            if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(ama.Type))
            {
                bc.Report.Error(1986, expr.Location,
                                "The `await' operand type `{0}' must have suitable GetAwaiter method",
                                expr.Type.GetSignatureForError());

                return(false);
            }

            var awaiter_type = ama.Type;

            awaiter = ((AsyncTaskStorey)machine_initializer.Storey).AddAwaiter(awaiter_type, loc);

            expr = ama;

            //
            // Predefined: bool IsCompleted { get; }
            //
            is_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Property("IsCompleted", bc.Module.Compiler.BuiltinTypes.Bool),
                                                  BindingRestriction.InstanceOnly) as PropertySpec;

            if (is_completed == null || !is_completed.HasGet)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            //
            // Predefined: OnCompleted (Action)
            //
            if (bc.Module.PredefinedTypes.Action.Define())
            {
                on_completed = MemberCache.FindMember(awaiter_type, MemberFilter.Method("OnCompleted", 0,
                                                                                        ParametersCompiled.CreateFullyResolved(bc.Module.PredefinedTypes.Action.TypeSpec), bc.Module.Compiler.BuiltinTypes.Void),
                                                      BindingRestriction.InstanceOnly) as MethodSpec;

                if (on_completed == null)
                {
                    Error_WrongAwaiterPattern(bc, awaiter_type);
                    return(false);
                }
            }

            //
            // Predefined: GetResult ()
            //
            // The method return type is also result type of await expression
            //
            get_result = MemberCache.FindMember(awaiter_type, MemberFilter.Method("GetResult", 0,
                                                                                  ParametersCompiled.EmptyReadOnlyParameters, null),
                                                BindingRestriction.InstanceOnly) as MethodSpec;

            if (get_result == null)
            {
                Error_WrongAwaiterPattern(bc, awaiter_type);
                return(false);
            }

            result_type = get_result.ReturnType;

            return(true);
        }
Ejemplo n.º 38
0
void case_447()
#line 3317 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);

		yyVal = new Invocation ((Expression) yyVals[-2+yyTop], null);
		lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
Ejemplo n.º 39
0
		public override void Emit (EmitContext ec)
		{
			Expression concat = new Invocation (CreateConcatMemberExpression (), arguments, true);
			concat = concat.Resolve (new ResolveContext (ec.MemberContext));
			if (concat != null)
				concat.Emit (ec);
		}
Ejemplo n.º 40
0
		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			MemberAccess ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc);

			Arguments args = new Arguments (3);
			args.Add (new Argument (new TypeOf (type, loc)));

			if (method_group.InstanceExpression == null)
				args.Add (new Argument (new NullLiteral (loc)));
			else
				args.Add (new Argument (method_group.InstanceExpression));

			args.Add (new Argument (method_group.CreateExpressionTree (ec)));
			Expression e = new Invocation (ma, args).Resolve (ec);
			if (e == null)
				return null;

			e = Convert.ExplicitConversion (ec, e, type, loc);
			if (e == null)
				return null;

			return e.CreateExpressionTree (ec);
		}
Ejemplo n.º 41
0
		void DefineOverrides ()
		{
			Location loc = Location;

			Method equals = new Method (this, null, TypeManager.system_boolean_expr,
				Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
				Mono.CSharp.ParametersCompiled.CreateFullyResolved (new Parameter (null, "obj", 0, null, loc), TypeManager.object_type), null);

			Method tostring = new Method (this, null, TypeManager.system_string_expr,
				Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
				Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);

			ToplevelBlock equals_block = new ToplevelBlock (Compiler, equals.Parameters, loc);
			TypeExpr current_type;
			if (IsGeneric)
				current_type = new GenericTypeExpr (this, loc);
			else
				current_type = new TypeExpression (TypeBuilder, loc);

			equals_block.AddVariable (current_type, "other", loc);
			LocalVariableReference other_variable = new LocalVariableReference (equals_block, "other", loc);

			MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
				new QualifiedAliasMember ("global", "System", loc), "Collections", loc), "Generic", loc);

			Expression rs_equals = null;
			Expression string_concat = new StringConstant ("{", loc);
			Expression rs_hashcode = new IntConstant (-2128831035, loc);
			for (int i = 0; i < parameters.Count; ++i) {
				AnonymousTypeParameter p = (AnonymousTypeParameter) parameters [i];
				Field f = (Field) Fields [i];

				MemberAccess equality_comparer = new MemberAccess (new MemberAccess (
					system_collections_generic, "EqualityComparer",
						new TypeArguments (new SimpleName (TypeParameters [i].Name, loc)), loc),
						"Default", loc);

				Arguments arguments_equal = new Arguments (2);
				arguments_equal.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
				arguments_equal.Add (new Argument (new MemberAccess (other_variable, f.Name)));

				Expression field_equal = new Invocation (new MemberAccess (equality_comparer,
					"Equals", loc), arguments_equal);

				Arguments arguments_hashcode = new Arguments (1);
				arguments_hashcode.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
				Expression field_hashcode = new Invocation (new MemberAccess (equality_comparer,
					"GetHashCode", loc), arguments_hashcode);

				IntConstant FNV_prime = new IntConstant (16777619, loc);				
				rs_hashcode = new Binary (Binary.Operator.Multiply,
					new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode),
					FNV_prime);

				Expression field_to_string = new Conditional (new Binary (Binary.Operator.Inequality,
					new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc)),
					new Invocation (new MemberAccess (
						new MemberAccess (new This (f.Location), f.Name), "ToString"), null),
					new StringConstant (string.Empty, loc));

				if (rs_equals == null) {
					rs_equals = field_equal;
					string_concat = new Binary (Binary.Operator.Addition,
						string_concat,
						new Binary (Binary.Operator.Addition,
							new StringConstant (" " + p.Name + " = ", loc),
							field_to_string));
					continue;
				}

				//
				// Implementation of ToString () body using string concatenation
				//				
				string_concat = new Binary (Binary.Operator.Addition,
					new Binary (Binary.Operator.Addition,
						string_concat,
						new StringConstant (", " + p.Name + " = ", loc)),
					field_to_string);

				rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal);
			}

			string_concat = new Binary (Binary.Operator.Addition,
				string_concat,
				new StringConstant (" }", loc));

			//
			// Equals (object obj) override
			//		
			LocalVariableReference other_variable_assign = new LocalVariableReference (equals_block, "other", loc);
			equals_block.AddStatement (new StatementExpression (
				new SimpleAssign (other_variable_assign,
					new As (equals_block.GetParameterReference ("obj", loc),
						current_type, loc), loc)));

			Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc));
			if (rs_equals != null)
				equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals);
			equals_block.AddStatement (new Return (equals_test, loc));

			equals.Block = equals_block;
			equals.Define ();
			AddMethod (equals);

			//
			// GetHashCode () override
			//
			Method hashcode = new Method (this, null, TypeManager.system_int32_expr,
				Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN,
				new MemberName ("GetHashCode", loc),
				Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);

			//
			// Modified FNV with good avalanche behavior and uniform
			// distribution with larger hash sizes.
			//
			// const int FNV_prime = 16777619;
			// int hash = (int) 2166136261;
			// foreach (int d in data)
			//     hash = (hash ^ d) * FNV_prime;
			// hash += hash << 13;
			// hash ^= hash >> 7;
			// hash += hash << 3;
			// hash ^= hash >> 17;
			// hash += hash << 5;

			ToplevelBlock hashcode_top = new ToplevelBlock (Compiler, loc);
			Block hashcode_block = new Block (hashcode_top);
			hashcode_top.AddStatement (new Unchecked (hashcode_block));

			hashcode_block.AddVariable (TypeManager.system_int32_expr, "hash", loc);
			LocalVariableReference hash_variable = new LocalVariableReference (hashcode_block, "hash", loc);
			LocalVariableReference hash_variable_assign = new LocalVariableReference (hashcode_block, "hash", loc);
			hashcode_block.AddStatement (new StatementExpression (
				new SimpleAssign (hash_variable_assign, rs_hashcode)));

			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.Addition, hash_variable,
					new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (13, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable,
					new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (7, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.Addition, hash_variable,
					new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (3, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable,
					new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (17, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.Addition, hash_variable,
					new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (5, loc)))));

			hashcode_block.AddStatement (new Return (hash_variable, loc));
			hashcode.Block = hashcode_top;
			hashcode.Define ();
			AddMethod (hashcode);

			//
			// ToString () override
			//

			ToplevelBlock tostring_block = new ToplevelBlock (Compiler, loc);
			tostring_block.AddStatement (new Return (string_concat, loc));
			tostring.Block = tostring_block;
			tostring.Define ();
			AddMethod (tostring);
		}
Ejemplo n.º 42
0
			public override object Visit (Invocation invocationExpression)
			{
				var result = new InvocationExpression ();
				var location = LocationsBag.GetLocations (invocationExpression);
				result.AddChild ((INode)invocationExpression.Expression.Accept (this), InvocationExpression.Roles.TargetExpression);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), InvocationExpression.Roles.LPar);
				AddArguments (result, location, invocationExpression.Arguments);
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), InvocationExpression.Roles.RPar);
				return result;
			}
Ejemplo n.º 43
0
		private Expression CreateDynamicUnaryOperation(ResolveContext rc)
		{
			this.Arguments.CastDynamicArgs(rc);

			TypeSpec unary = rc.Module.PredefinedTypes.PsUnaryOperation.Resolve();
			string type = GetDynamicUnaryTypeName(Arguments[0].Type);

			// create unary method name
			string unaryMethod = this.name + type;

			var ret = new Invocation(new MemberAccess(new TypeExpression(unary, loc), unaryMethod, loc), this.Arguments).Resolve(rc);
			if (ret.Type == rc.BuiltinTypes.Object) {
				// cast object to dynamic for return types
				ret = new Cast (new TypeExpression (rc.BuiltinTypes.Dynamic, loc), ret, loc).Resolve (rc);
			} 
			return ret;
		}
Ejemplo n.º 44
0
		protected override bool DoDefineMembers ()
		{
			if (!base.DoDefineMembers ())
				return false;

			Location loc = Location;

			var equals_parameters = ParametersCompiled.CreateFullyResolved (
				new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc), Compiler.BuiltinTypes.Object);

			Method equals = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
				Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
				equals_parameters, null);

			equals_parameters[0].Resolve (equals, 0);

			Method tostring = new Method (this, new TypeExpression (Compiler.BuiltinTypes.String, loc),
				Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
				Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);

			ToplevelBlock equals_block = new ToplevelBlock (Compiler, equals.ParameterInfo, loc);

			TypeExpr current_type;
			if (CurrentTypeParameters != null) {
				var targs = new TypeArguments ();
				for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
					targs.Add (new TypeParameterExpr (CurrentTypeParameters[i], Location));
				}

				current_type = new GenericTypeExpr (Definition, targs, loc);
			} else {
				current_type = new TypeExpression (Definition, loc);
			}

			var li_other = LocalVariable.CreateCompilerGenerated (CurrentType, equals_block, loc);
			equals_block.AddStatement (new BlockVariableDeclaration (new TypeExpression (li_other.Type, loc), li_other));
			var other_variable = new LocalVariableReference (li_other, loc);

			MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
				new QualifiedAliasMember ("global", "System", loc), "Collections", loc), "Generic", loc);

			Expression rs_equals = null;
			Expression string_concat = new StringConstant (Compiler.BuiltinTypes, "{", loc);
			Expression rs_hashcode = new IntConstant (Compiler.BuiltinTypes, -2128831035, loc);
			for (int i = 0; i < parameters.Count; ++i) {
				var p = parameters [i];
				var f = (Field) Members [i * 2];

				MemberAccess equality_comparer = new MemberAccess (new MemberAccess (
					system_collections_generic, "EqualityComparer",
						new TypeArguments (new SimpleName (CurrentTypeParameters [i].Name, loc)), loc),
						"Default", loc);

				Arguments arguments_equal = new Arguments (2);
				arguments_equal.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
				arguments_equal.Add (new Argument (new MemberAccess (other_variable, f.Name)));

				Expression field_equal = new Invocation (new MemberAccess (equality_comparer,
					"Equals", loc), arguments_equal);

				Arguments arguments_hashcode = new Arguments (1);
				arguments_hashcode.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
				Expression field_hashcode = new Invocation (new MemberAccess (equality_comparer,
					"GetHashCode", loc), arguments_hashcode);

				IntConstant FNV_prime = new IntConstant (Compiler.BuiltinTypes, 16777619, loc);				
				rs_hashcode = new Binary (Binary.Operator.Multiply,
					new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode),
					FNV_prime);

				Expression field_to_string = new Conditional (new BooleanExpression (new Binary (Binary.Operator.Inequality,
					new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc))),
					new Invocation (new MemberAccess (
						new MemberAccess (new This (f.Location), f.Name), "ToString"), null),
					new StringConstant (Compiler.BuiltinTypes, string.Empty, loc), loc);

				if (rs_equals == null) {
					rs_equals = field_equal;
					string_concat = new Binary (Binary.Operator.Addition,
						string_concat,
						new Binary (Binary.Operator.Addition,
							new StringConstant (Compiler.BuiltinTypes, " " + p.Name + " = ", loc),
							field_to_string));
					continue;
				}

				//
				// Implementation of ToString () body using string concatenation
				//				
				string_concat = new Binary (Binary.Operator.Addition,
					new Binary (Binary.Operator.Addition,
						string_concat,
						new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc)),
					field_to_string);

				rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal);
			}

			string_concat = new Binary (Binary.Operator.Addition,
				string_concat,
				new StringConstant (Compiler.BuiltinTypes, " }", loc));

			//
			// Equals (object obj) override
			//		
			var other_variable_assign = new TemporaryVariableReference (li_other, loc);
			equals_block.AddStatement (new StatementExpression (
				new SimpleAssign (other_variable_assign,
					new As (equals_block.GetParameterReference (0, loc),
						current_type, loc), loc)));

			Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc));
			if (rs_equals != null)
				equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals);
			equals_block.AddStatement (new Return (equals_test, loc));

			equals.Block = equals_block;
			equals.Define ();
			Members.Add (equals);

			//
			// GetHashCode () override
			//
			Method hashcode = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Int, loc),
				Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN,
				new MemberName ("GetHashCode", loc),
				Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);

			//
			// Modified FNV with good avalanche behavior and uniform
			// distribution with larger hash sizes.
			//
			// const int FNV_prime = 16777619;
			// int hash = (int) 2166136261;
			// foreach (int d in data)
			//     hash = (hash ^ d) * FNV_prime;
			// hash += hash << 13;
			// hash ^= hash >> 7;
			// hash += hash << 3;
			// hash ^= hash >> 17;
			// hash += hash << 5;

			ToplevelBlock hashcode_top = new ToplevelBlock (Compiler, loc);
			Block hashcode_block = new Block (hashcode_top, loc, loc);
			hashcode_top.AddStatement (new Unchecked (hashcode_block, loc));

			var li_hash = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Int, hashcode_top, loc);
			hashcode_block.AddStatement (new BlockVariableDeclaration (new TypeExpression (li_hash.Type, loc), li_hash));
			LocalVariableReference hash_variable_assign = new LocalVariableReference (li_hash, loc);
			hashcode_block.AddStatement (new StatementExpression (
				new SimpleAssign (hash_variable_assign, rs_hashcode)));

			var hash_variable = new LocalVariableReference (li_hash, loc);
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.Addition, hash_variable,
					new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 13, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable,
					new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 7, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.Addition, hash_variable,
					new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 3, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable,
					new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 17, loc)))));
			hashcode_block.AddStatement (new StatementExpression (
				new CompoundAssign (Binary.Operator.Addition, hash_variable,
					new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 5, loc)))));

			hashcode_block.AddStatement (new Return (hash_variable, loc));
			hashcode.Block = hashcode_top;
			hashcode.Define ();
			Members.Add (hashcode);

			//
			// ToString () override
			//

			ToplevelBlock tostring_block = new ToplevelBlock (Compiler, loc);
			tostring_block.AddStatement (new Return (string_concat, loc));
			tostring.Block = tostring_block;
			tostring.Define ();
			Members.Add (tostring);

			return true;
		}
Ejemplo n.º 45
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			if (ec.Target == Target.JavaScript) {
				type = ec.BuiltinTypes.Dynamic;
				eclass = ExprClass.Value;
				return this;
			}

			if (Expr is ElementAccess) {

				var elem_access = Expr as ElementAccess;

				if (elem_access.Arguments.Count != 1) {
					ec.Report.Error (7021, loc, "delete statement must have only one index argument.");
					return null;
				}

				var expr = elem_access.Expr.Resolve (ec);
				if (expr.Type == null) {
					return null;
				}

				if (expr.Type.IsArray) {
					ec.Report.Error (7021, loc, "delete statement not allowed on arrays.");
					return null;
				}

				if (ec.Target == Target.JavaScript) {
					Expr = Expr.Resolve(ec);
					return this;
				}

				removeExpr = new Invocation (new MemberAccess (expr, "Remove", loc), elem_access.Arguments);
				return removeExpr.Resolve (ec);

			} else if (Expr is MemberAccess) {

				if (ec.Target == Target.JavaScript) {
					Expr = Expr.Resolve(ec);
					return this;
				}

				var memb_access = Expr as MemberAccess;

				var expr = memb_access.LeftExpression.Resolve (ec);
				if (expr.Type == null) {
					return null;
				}

				var args = new Arguments(1);
				args.Add (new Argument(new StringLiteral(ec.BuiltinTypes, memb_access.Name, loc)));
				removeExpr = new Invocation (new MemberAccess (expr, "Remove", loc), args);
				return removeExpr.Resolve (ec);

			} else {
				// Error is reported elsewhere.
				return null;
			}
		}