public AsLocalFunction(Location loc, string name, AnonymousMethodExpression methodExpr, BlockVariableDeclaration varDecl)
 {
     this.loc        = loc;
     this.Name       = name;
     this.MethodExpr = methodExpr;
     this.VarDecl    = varDecl;
 }
void case_929()
#line 6236 "cs-parser.jay"
{
		yyVal = current_variable;
		current_variable = null;
	  }
void case_872()
#line 5824 "cs-parser.jay"
{
		yyVal = current_variable;
		current_variable = null;
	  }
void case_871()
#line 5817 "cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		var li = new LocalVariable (current_block, lt.Value, lt.Location);
		current_block.AddLocalName (li);
		current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li);
	  }
void case_797()
#line 5355 "cs-parser.jay"
{
		if (current_variable.Initializer != null) {
			lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop]));
		} else {
			lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop]));
		}
		yyVal = current_variable;;
		current_variable = null;
	  }
void case_552()
#line 4730 "ps-parser.jay"
{
	    var lt = (Tokenizer.LocatedToken) yyVals[-8+yyTop];
		var anonMethod = end_anonymous ((ParametersBlock) yyVals[0+yyTop]);
		var li = new LocalVariable (current_block.ParametersBlock.TopBlock, lt.Value, lt.Location);
		var type = Delegate.CreateDelegateTypeExpression(compiler.BuiltinTypes, anonMethod.AsParameters, anonMethod.AsReturnType, GetLocation(yyVals[-10+yyTop]));
		var decl = new BlockVariableDeclaration(type, li);
		decl.Initializer = anonMethod;
		current_block.AddLocalName (li);
		current_block.ParametersBlock.TopBlock.AddScopeStatement (decl);	
		yyVal = new AsLocalFunction(GetLocation(yyVals[-10+yyTop]), lt.Value, anonMethod, decl);
	  }
		public AsLocalFunction (Location loc, string name, AnonymousMethodExpression methodExpr, BlockVariableDeclaration varDecl)
		{
			this.loc = loc;
			this.Name = name;
			this.MethodExpr = methodExpr;
			this.VarDecl = varDecl;
		}
Example #8
0
 public virtual object Visit(BlockVariableDeclaration blockVariableDeclaration)
 {
     return(null);
 }
void case_947()
#line 7245 "ps-parser.jay"
{
		yyVal = current_variable;	  
		current_variable = null;
	  }
void case_888()
#line 6829 "ps-parser.jay"
{
		yyVal = current_variable;
		current_variable = null;
	  }
void case_887()
#line 6822 "ps-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		var type = (FullNamedExpression) yyVals[0+yyTop];
		var li = GetOrCreateLocalVariable (current_block, lt.Value, 0, type, lt.Location);
		current_variable = new BlockVariableDeclaration (type, li);
	  }
void case_808()
#line 6281 "ps-parser.jay"
{
		yyVal = current_variable;
		current_variable = null;
		lbag.AddLocation (yyVal, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-1+yyTop]));
	  }
void case_807()
#line 6275 "ps-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		var li = GetOrCreateLocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, null, lt.Location);
		current_variable = new BlockConstantDeclaration ((FullNamedExpression) yyVals[0+yyTop], li);
	  }
void case_806()
#line 6269 "ps-parser.jay"
{
		yyVal = current_variable;
		current_variable = null;
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
void case_805()
#line 6263 "ps-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		var li = GetOrCreateLocalVariable (current_block, lt.Value, 0, null, lt.Location);
		current_variable = new BlockVariableDeclaration (new VarExpr (GetLocation(yyVals[-1+yyTop])), li);
	  }
void case_931()
#line 6254 "cs-parser.jay"
{
	    start_block (GetLocation (yyVals[-2+yyTop]));
	    
		current_block.IsCompilerGenerated = true;
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.UsingVariable | LocalVariable.Flags.Used, lt.Location);
		current_block.AddLocalName (li);
		current_variable = new Using.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li);
	  }
void case_932()
#line 6264 "cs-parser.jay"
{
		yyVal = current_variable;	  
		current_variable = null;
	  }
/*
 * Completes the anonymous method processing, if lambda_expr is null, this
 * means that we have a Statement instead of an Expression embedded 
 */
AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
{
	AnonymousMethodExpression retval;

	if (async_block)
		anon_block.IsAsync = true;

	current_anonymous_method.Block = anon_block;
	retval = current_anonymous_method;

	async_block = (bool) oob_stack.Pop ();
	current_variable = (BlockVariableDeclaration) oob_stack.Pop ();
	current_local_parameters = (ParametersCompiled) oob_stack.Pop ();
	current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();

	return retval;
}
Example #19
0
		public virtual object Visit (BlockVariableDeclaration blockVariableDeclaration)
		{
			return null;
		}
void case_795()
#line 5342 "cs-parser.jay"
{
		yyVal = current_variable;
		current_variable = null;
		lbag.AppendTo (yyVal, GetLocation (yyVals[0+yyTop]));
	  }
			public override object Visit (BlockVariableDeclaration blockVariableDeclaration)
			{
				var result = new VariableDeclarationStatement ();
				result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), Roles.Type);
				
				var varInit = new VariableInitializer ();
				var location = LocationsBag.GetLocations (blockVariableDeclaration);
				varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), Roles.Identifier);
				if (blockVariableDeclaration.Initializer != null) {
					if (location != null && location.Count > 0)
						varInit.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.Assign), Roles.Assign);
					varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), Roles.Expression);
				}
				
				result.AddChild (varInit, Roles.Variable);
				
				if (blockVariableDeclaration.Declarators != null) {
					foreach (var decl in blockVariableDeclaration.Declarators) {
						var loc = LocationsBag.GetLocations (decl);
						var init = new VariableInitializer ();
						if (loc != null && loc.Count > 0)
							result.AddChild (new CSharpTokenNode (Convert (loc [0]), Roles.Comma), Roles.Comma);
						init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), Roles.Identifier);
						if (decl.Initializer != null) {
							if (loc != null && loc.Count > 1)
								init.AddChild (new CSharpTokenNode (Convert (loc [1]), Roles.Assign), Roles.Assign);
							init.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression);
						} else {
						}
						result.AddChild (init, Roles.Variable);
					}
				}
				if (location != null && (blockVariableDeclaration.Initializer == null || location.Count > 1))
					result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1]), Roles.Semicolon), Roles.Semicolon);
				return result;
			}
void case_796()
#line 5348 "cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
		var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location);
		current_block.AddLocalName (li);
		current_variable = new BlockConstantDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li);
	  }