Пример #1
0
        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;
            }
        }
Пример #2
0
        public void AddAnonymousChild(TopLevelScope b)
        {
            if (_anonymousChildren == null)
            {
                _anonymousChildren = new List <Scope>();
            }

            _anonymousChildren.Add(b);
        }
Пример #3
0
 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;
 }
Пример #4
0
        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;
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
 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);
 }
Пример #7
0
        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
            });
        }
Пример #8
0
 public SelectManyClause(TopLevelScope scope, RangeDeclaration lt, Expression expr)
     : base(scope, expr)
 {
     RangeVariable = lt;
 }
Пример #9
0
 protected override bool CheckParentConflictName(TopLevelScope block, string name, SourceSpan span)
 {
     return(true);
 }
Пример #10
0
 protected RangeVariableQueryClause(TopLevelScope scope, Expression baseExpression)
 {
     Scope      = scope;
     Expression = baseExpression;
     Span       = baseExpression.Span;
 }
Пример #11
0
 public TopLevelParameterInfo(TopLevelScope block, int index)
 {
     Scope = block;
     Index = index;
 }