public AsLocalFunction(Location loc, string name, AnonymousMethodExpression methodExpr, BlockVariableDeclaration varDecl) { this.loc = loc; this.Name = name; this.MethodExpr = methodExpr; this.VarDecl = varDecl; }
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; }
public virtual object Visit (BlockVariableDeclaration blockVariableDeclaration) { return null; }
void case_924() #line 6211 "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_865() #line 5781 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_790() #line 5313 "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_788() #line 5300 "cs-parser.jay" { yyVal = current_variable; current_variable = null; lbag.AppendTo (yyVal, GetLocation (yyVals[0+yyTop])); }
void case_849() #line 5426 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_800() #line 5103 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_882() #line 5864 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_825() #line 5469 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_877() #line 5832 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_811() #line 5197 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_883() { yyVal = current_variable; current_variable = null; }
void case_879() { 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.FixedVariable | LocalVariable.Flags.Used, lt.Location); current_block.AddLocalName (li); current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); }
void case_751() { yyVal = current_variable; current_variable = null; lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop])); }
void case_846() #line 5399 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_850() #line 5431 "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; }
public AsLocalFunction (Location loc, string name, AnonymousMethodExpression methodExpr, BlockVariableDeclaration varDecl) { this.loc = loc; this.Name = name; this.MethodExpr = methodExpr; this.VarDecl = varDecl; }
void case_789() #line 5306 "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); }
void case_799() #line 5384 "cs-parser.jay" { yyVal = current_variable; current_variable = null; if (yyVals[-2+yyTop] != null) lbag.AddLocation (yyVal, PopLocation (), GetLocation (yyVals[0+yyTop])); else lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); }
void case_864() #line 5774 "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_874() #line 5831 "cs-parser.jay" { yyVal = current_variable; if (yyVals[-1+yyTop] != null) lbag.AddLocation (current_variable, PopLocation ()); current_variable = null; }
void case_922() #line 6193 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_934() #line 6274 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_925() #line 6221 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
// // Creates the type // public override bool Define () { if (!base.Define ()) return false; if (member_type.Kind == MemberKind.Void && parameters.IsEmpty && MemberName.Arity == 0 && MemberName.Name == Destructor.MetadataName) { Report.Warning (465, 1, Location, "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?"); } if (Compiler.Settings.StdLib && ReturnType.IsSpecialRuntimeType) { Error1599 (Location, ReturnType, Report); return false; } if (CurrentTypeParameters == null) { if (base_method != null && !IsExplicitImpl) { if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && MemberName.Name == "Equals") Parent.PartialContainer.Mark_HasEquals (); else if (parameters.IsEmpty && MemberName.Name == "GetHashCode") Parent.PartialContainer.Mark_HasGetHashCode (); } } else { DefineTypeParameters (); } // PlayScript - We need to create an "Array" for our args parameters for ActionScript/PlayScript.. if ((Parent.FileType == SourceFileType.PlayScript && !PsExtended) && parameters != null && parameters.FixedParameters != null && parameters.FixedParameters.Length > 0 && block != null) { var param = parameters.FixedParameters[parameters.FixedParameters.Length - 1] as Parameter; if (param != null && (param.ParameterModifier & Parameter.Modifier.PARAMS) != 0) { string argName = param.Name.Substring(2); // Arg should start with "__" (we added it in the parser). var li = new LocalVariable (block.ParametersBlock.TopBlock, argName, block.loc); var decl = new BlockVariableDeclaration(new Mono.CSharp.TypeExpression(this.Module.PredefinedTypes.AsArray.Resolve(), block.loc), li); var arguments = new Arguments(1); arguments.Add (new Argument(new SimpleName(param.Name, block.loc))); decl.Initializer = new Invocation(new MemberAccess(new MemberAccess(new SimpleName("PlayScript", block.loc), "Support", block.loc), "CreateArgListArray", block.loc), arguments); block.AddLocalName (li); block.ParametersBlock.TopBlock.AddScopeStatement (decl); } } if (block != null) { if (block.IsIterator) { // // Current method is turned into automatically generated // wrapper which creates an instance of iterator // Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); ModFlags |= Modifiers.DEBUGGER_HIDDEN; } if ((ModFlags & Modifiers.ASYNC) != 0) { if (ReturnType.Kind != MemberKind.Void && ReturnType != Module.PredefinedTypes.Task.TypeSpec && !ReturnType.IsGenericTask) { Report.Error (1983, Location, "The return type of an async method must be void, Task, or Task<T>"); } block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, null, Location); ModFlags |= Modifiers.DEBUGGER_HIDDEN; } if (Compiler.Settings.WriteMetadataOnly) block = null; } if ((ModFlags & Modifiers.STATIC) == 0) return true; if (parameters.HasExtensionMethodType) { if (Parent.PartialContainer.IsStatic && !Parent.IsGenericOrParentIsGeneric) { if (!Parent.IsTopLevel) Report.Error (1109, Location, "`{0}': Extension methods cannot be defined in a nested class", GetSignatureForError ()); PredefinedAttribute pa = Module.PredefinedAttributes.Extension; if (!pa.IsDefined) { Report.Error (1110, Location, "`{0}': Extension methods require `System.Runtime.CompilerServices.ExtensionAttribute' type to be available. Are you missing an assembly reference?", GetSignatureForError ()); } ModFlags |= Modifiers.METHOD_EXTENSION; Parent.PartialContainer.ModFlags |= Modifiers.METHOD_EXTENSION; Spec.DeclaringType.SetExtensionMethodContainer (); Parent.Module.HasExtensionMethod = true; } else { Report.Error (1106, Location, "`{0}': Extension methods must be defined in a non-generic static class", GetSignatureForError ()); } } // // This is used to track the Entry Point, // var settings = Compiler.Settings; if (settings.NeedsEntryPoint && MemberName.Name == "Main" && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) { if (IsEntryPoint ()) { if (Parent.DeclaringAssembly.EntryPoint == null) { if (Parent.IsGenericOrParentIsGeneric || MemberName.IsGeneric) { Report.Warning (402, 4, Location, "`{0}': an entry point cannot be generic or in a generic type", GetSignatureForError ()); } else if ((ModFlags & Modifiers.ASYNC) != 0) { Report.Error (4009, Location, "`{0}': an entry point cannot be async method", GetSignatureForError ()); } else { SetIsUsed (); Parent.DeclaringAssembly.EntryPoint = this; } } else { Error_DuplicateEntryPoint (Parent.DeclaringAssembly.EntryPoint); Error_DuplicateEntryPoint (this); } } else { Report.Warning (28, 4, Location, "`{0}' has the wrong signature to be an entry point", GetSignatureForError ()); } } return true; }
public virtual object Visit(BlockVariableDeclaration blockVariableDeclaration) { return(null); }
void case_744() #line 4772 "cs-parser.jay" { yyVal = current_variable; current_variable = null; lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[0+yyTop])); }
void case_799() #line 5098 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }
void case_861() #line 5553 "cs-parser.jay" { yyVal = current_variable; current_variable = null; }