private void EnsureScope(ParseContext ec) { if (_scope != null) { return; } ParametersCompiled parameters; if (HasExplicitParameters) { parameters = new ParametersCompiled( Parameters.Select(o => new Parameter(o.Name, null, o.Span) { ParameterType = o.Type.Resolve(ec).Type })); } else { parameters = new ParametersCompiled(Parameters.Select(o => new ImplicitLambdaParameter(o.Name, null, o.Span))); } var scope = Scope = new TopLevelScope(ec.Compiler, ec.CurrentScope, parameters, Span.Start); for (int i = 0; i < parameters.Count; i++) { parameters[i].Scope = scope; } }
public void AddAnonymousChild(TopLevelScope b) { if (_anonymousChildren == null) { _anonymousChildren = new List <Scope>(); } _anonymousChildren.Add(b); }
public Scope(CompilerContext compilerContext, TopLevelScope parent, TopLevelScope source) : this(compilerContext, parent, source.StartLocation, SourceLocation.None) { if (compilerContext != null) { _compilerContext = compilerContext; } _children = source._children; _variables = source._variables; }
public Scope(CompilerContext compilerContext, Scope parent, SourceLocation startLocation, SourceLocation endLocation) { if (parent != null) { parent.AddChild(this); TopLevel = parent.TopLevel; Explicit = parent.Explicit; } _startLocation = startLocation; _compilerContext = compilerContext ?? ((parent == null) ? null : parent._compilerContext); EndLocation = endLocation; Parent = parent; }
public override void BeginInit(ParseContext parseContext, bool raiseInitialized) { base.BeginInit(parseContext, false); if (_queryScope == null) { _queryScope = new QueryScope( parseContext.Compiler, parseContext.CurrentScope, Span.Start); } if (Scope == null) { Scope = _queryScope.TopLevel; } parseContext.CurrentScope = _queryScope; if (raiseInitialized) { OnInitialized(); } }
protected virtual bool CheckParentConflictName(TopLevelScope scope, string name, SourceSpan span) { if (scope != null) { var e = scope.GetParameterReference(name, span); if (e != null) { var pr = e as ParameterReference; if ((this is QueryScope) && (((pr != null) && (pr.Parameter is QueryScope.ImplicitQueryParameter)) || e is MemberAccessExpression)) { _compilerContext.Errors.Add( _compilerContext.SourceUnit, "Duplicate variable name: " + name, span, 255, Severity.Error); return(false); } } } return(true); }
protected static Expression CreateRangeVariableType( TopLevelScope scope, ParseContext parseContext, RangeDeclaration declaration, Expression initializer) { var anonInitializer = new AnonymousObjectInitializer { FileName = declaration.FileName, Span = initializer.Span, }; anonInitializer.MemberDeclarators.Add(new AnonymousMemberDeclarator(scope.Parameters[0])); anonInitializer.MemberDeclarators.Add( new RangeAnonymousMemberDeclarator( initializer, declaration)); return(new AnonymousObjectCreationExpression { FileName = declaration.FileName, Span = declaration.Span, Initializer = anonInitializer }); }
public SelectManyClause(TopLevelScope scope, RangeDeclaration lt, Expression expr) : base(scope, expr) { RangeVariable = lt; }
protected override bool CheckParentConflictName(TopLevelScope block, string name, SourceSpan span) { return(true); }
protected RangeVariableQueryClause(TopLevelScope scope, Expression baseExpression) { Scope = scope; Expression = baseExpression; Span = baseExpression.Span; }
public TopLevelParameterInfo(TopLevelScope block, int index) { Scope = block; Index = index; }