void ILambdaContainerSymbol.AddLambda(SourceLambdaSymbol routine) { Contract.ThrowIfNull(routine); if (_lambdas == null) { _lambdas = new List <SourceLambdaSymbol>(); } _lambdas.Add(routine); }
public override void VisitLambdaFunctionExpr(LambdaFunctionExpr x) { var container = _containerStack.Peek(); var lambdasymbol = new SourceLambdaSymbol(x, container, !x.IsStatic); Debug.Assert(container is ILambdaContainerSymbol); ((ILambdaContainerSymbol)container).AddLambda(lambdasymbol); // base.VisitLambdaFunctionExpr(x); }
public void AddSyntaxTree(PhpSyntaxTree tree) { Contract.ThrowIfNull(tree); Debug.Assert(tree.Root != null); // create file symbol (~ php script containing type) var fsymbol = new SourceFileSymbol(_compilation, tree); if (FirstScript == null) { FirstScript = fsymbol; } // collect type declarations foreach (var t in tree.Types) { var typesymbol = (t is AnonymousTypeDecl) ? new SourceAnonymousTypeSymbol(fsymbol, (AnonymousTypeDecl)t) : new SourceTypeSymbol(fsymbol, t); t.SetProperty(typesymbol); // remember bound type symbol fsymbol.ContainedTypes.Add(typesymbol); } // annotate routines that contain yield if (!tree.YieldNodes.IsDefaultOrEmpty) { var yieldsInRoutines = new Dictionary <LangElement, List <IYieldLikeEx> >(); foreach (var y in tree.YieldNodes) { Debug.Assert(y is IYieldLikeEx); var yield = y as IYieldLikeEx; var containingRoutine = y.GetContainingRoutine(); Debug.Assert(containingRoutine != null); if (!yieldsInRoutines.ContainsKey(containingRoutine)) { yieldsInRoutines.Add(containingRoutine, new List <IYieldLikeEx>()); } yieldsInRoutines[containingRoutine].Add(yield); } foreach (var yieldsInRoutine in yieldsInRoutines) { var routine = yieldsInRoutine.Key; var yields = yieldsInRoutine.Value; routine.Properties.SetProperty(typeof(ImmutableArray <IYieldLikeEx>), yields.ToImmutableArray()); } } // foreach (var f in tree.Functions) { var routine = new SourceFunctionSymbol(fsymbol, f); f.SetProperty(routine); // remember bound function symbol fsymbol.AddFunction(routine); } // foreach (var l in tree.Lambdas) { var containingtype = l.ContainingType; var container = (containingtype != null) ? (NamedTypeSymbol)containingtype.GetProperty <SourceTypeSymbol>() : fsymbol; var lambdasymbol = new SourceLambdaSymbol(l, container, !l.IsStatic); Debug.Assert(container is ILambdaContainerSymbol); ((ILambdaContainerSymbol)container).AddLambda(lambdasymbol); } // _files.Add(fsymbol.RelativeFilePath, fsymbol); _ordinalMap.Add(tree, _ordinalMap.Count); _version++; }
public void AddSyntaxTree(PhpSyntaxTree tree) { Contract.ThrowIfNull(tree); Debug.Assert(tree.Root != null); // create file symbol (~ php script containing type) var fsymbol = new SourceFileSymbol(_compilation, tree); if (FirstScript == null) { FirstScript = fsymbol; } // collect type declarations foreach (var t in tree.Types) { var typesymbol = (t is AnonymousTypeDecl) ? new SourceAnonymousTypeSymbol(fsymbol, (AnonymousTypeDecl)t) : new SourceTypeSymbol(fsymbol, t); t.SetProperty(typesymbol); // remember bound type symbol fsymbol.ContainedTypes.Add(typesymbol); } // annotate routines that contain yield if (!tree.YieldNodes.IsDefaultOrEmpty) { foreach (var y in tree.YieldNodes) { var containingroutine = y.GetContainingRoutine(); Debug.Assert(containingroutine != null); // TODO: annotate routine as generator ! so it can be bound as generator already } } // foreach (var f in tree.Functions) { var routine = new SourceFunctionSymbol(fsymbol, f); f.SetProperty(routine); // remember bound function symbol fsymbol.AddFunction(routine); } // foreach (var l in tree.Lambdas) { var containingtype = l.ContainingType; var container = (containingtype != null) ? (NamedTypeSymbol)containingtype.GetProperty <SourceTypeSymbol>() : fsymbol; var lambdasymbol = new SourceLambdaSymbol(l, container, !l.IsStatic); Debug.Assert(container is ILambdaContainerSymbol); ((ILambdaContainerSymbol)container).AddLambda(lambdasymbol); } // _files.Add(fsymbol.RelativeFilePath, fsymbol); _ordinalMap.Add(tree, _ordinalMap.Count); _version++; }
void ILambdaContainerSymbol.AddLambda(SourceLambdaSymbol routine) { Contract.ThrowIfNull(routine); _lazyMembers.Add(routine); }