IEnumerable <FieldSymbol> LoadFields() { var binder = new SemanticsBinder(null); // fields foreach (var flist in _syntax.Members.OfType <FieldDeclList>()) { var fkind = (flist.Modifiers & PhpMemberAttributes.Static) == 0 ? SourceFieldSymbol.KindEnum.InstanceField : SourceFieldSymbol.KindEnum.StaticField; foreach (var f in flist.Fields) { yield return(new SourceFieldSymbol(this, f.Name.Value, flist.Modifiers.GetAccessibility(), f.PHPDoc ?? flist.PHPDoc, fkind, (f.Initializer != null) ? binder.BindExpression(f.Initializer, BoundAccess.Read) : null)); } } // constants foreach (var clist in _syntax.Members.OfType <ConstDeclList>()) { foreach (var c in clist.Constants) { yield return(new SourceFieldSymbol(this, c.Name.Name.Value, Accessibility.Public, c.PHPDoc ?? clist.PHPDoc, SourceFieldSymbol.KindEnum.ClassConstant, binder.BindExpression(c.Initializer, BoundAccess.Read))); } } }
private BuilderVisitor(IList <Statement> /*!*/ statements, SemanticsBinder /*!*/ binder, NamingContext naming) { Contract.ThrowIfNull(statements); Contract.ThrowIfNull(binder); // TODO: Implement a cleaner way to enable SemanticsBinder to create BoundBlocks trough BuilderVisitor if (binder is GeneratorSemanticsBinder gsb) { gsb.GetNewBlock = this.NewBlock; } _binder = binder; _naming = naming; this.Start = WithNewOrdinal(new StartBlock() { Naming = _naming }); this.Exit = new ExitBlock(); _current = WithOpenScope(this.Start); statements.ForEach(this.VisitElement); FinalizeRoutine(); _current = Connect(_current, this.Exit); // WithNewOrdinal(this.Exit); CloseScope(); // Debug.Assert(_scopes.Count == 0); Debug.Assert(_tryTargets == null || _tryTargets.Count == 0); Debug.Assert(_breakTargets == null || _breakTargets.Count == 0); }
IEnumerable <FieldSymbol> LoadFields() { var binder = new SemanticsBinder(locals: null, diagnostics: DeclaringCompilation.DeclarationDiagnostics); // fields foreach (var flist in _syntax.Members.OfType <FieldDeclList>()) { var fkind = (flist.Modifiers & PhpMemberAttributes.Static) == 0 ? SourceFieldSymbol.KindEnum.InstanceField : SourceFieldSymbol.KindEnum.StaticField; foreach (var f in flist.Fields) { yield return(new SourceFieldSymbol(this, f.Name.Value, CreateLocation(f.NameSpan.ToTextSpan()), flist.Modifiers.GetAccessibility(), f.PHPDoc ?? flist.PHPDoc, fkind, (f.Initializer != null) ? binder.BindWholeExpression(f.Initializer, BoundAccess.Read).GetOnlyBoundElement() : null)); } } // constants foreach (var clist in _syntax.Members.OfType <ConstDeclList>()) { foreach (var c in clist.Constants) { yield return(new SourceFieldSymbol(this, c.Name.Name.Value, CreateLocation(c.Name.Span.ToTextSpan()), Accessibility.Public, c.PHPDoc ?? clist.PHPDoc, SourceFieldSymbol.KindEnum.ClassConstant, binder.BindWholeExpression(c.Initializer, BoundAccess.Read).GetOnlyBoundElement())); } } }
private BuilderVisitor(IList <Statement> /*!*/ statements, SemanticsBinder /*!*/ binder, NamingContext naming) { Contract.ThrowIfNull(statements); Contract.ThrowIfNull(binder); _binder = binder; _naming = naming; this.Start = WithNewOrdinal(new StartBlock() { Naming = _naming }); this.Exit = new ExitBlock(); _current = WithOpenScope(this.Start); statements.ForEach(this.VisitElement); _current = Connect(_current, this.Exit); // WithNewOrdinal(this.Exit); CloseScope(); // Debug.Assert(_scopes.Count == 0); Debug.Assert(_tryTargets == null || _tryTargets.Count == 0); Debug.Assert(_breakTargets == null || _breakTargets.Count == 0); }
private BuilderVisitor(IList <Statement> /*!*/ statements, SemanticsBinder /*!*/ binder) { Contract.ThrowIfNull(statements); Contract.ThrowIfNull(binder); // setup the binder binder.SetupBuilder(this.NewBlock); _binder = binder; this.Start = WithNewOrdinal(new StartBlock()); this.Exit = new ExitBlock(); _current = WithOpenScope(this.Start); statements.ForEach(this.VisitElement); FinalizeRoutine(); _current = Connect(_current, this.Exit); // WithNewOrdinal(this.Exit); CloseScope(); // Debug.Assert(_scopes.Count == 0); Debug.Assert(_tryTargets == null || _tryTargets.Count == 0); Debug.Assert(_breakTargets == null || _breakTargets.Count == 0); }
/// <summary> /// Ensures the routine has flow context. /// Otherwise it is created and routine is enqueued for analysis. /// </summary> void EnsureRoutine(SourceRoutineSymbol routine) { Contract.ThrowIfNull(routine); var cfg = routine.ControlFlowGraph; if (cfg == null) { // create initial flow state var state = StateBinder.CreateInitialState(routine); var binder = new SemanticsBinder(routine, state.FlowContext); // create control flow routine.ControlFlowGraph = cfg = new ControlFlowGraph(routine.Statements, binder); // enqueue the method for the analysis cfg.Start.FlowState = state; _worklist.Enqueue(cfg.Start); } }
public static BuilderVisitor /*!*/ Build(IList <Statement> /*!*/ statements, SemanticsBinder /*!*/ binder, NamingContext naming) { return(new BuilderVisitor(statements, binder, naming)); }
public static BuilderVisitor /*!*/ Build(IList <Statement> /*!*/ statements, SemanticsBinder /*!*/ binder) { return(new BuilderVisitor(statements, binder)); }
internal override ConstantValue GetConstantValue(bool earlyDecodingWellKnownAttributes) { return(_resolvedValue ?? (_resolvedValue = SemanticsBinder.TryGetConstantValue(this.DeclaringCompilation, _value))); }
protected SemanticsBinder CreateBinder() { return(SemanticsBinder.Create(DeclaringCompilation, ContainingFile.SyntaxTree, LocalsTable, ContainingType as SourceTypeSymbol)); }
internal ControlFlowGraph(IList<Statement>/*!*/statements, SemanticsBinder/*!*/binder, NamingContext naming) : this(BuilderVisitor.Build(statements, binder, naming)) { }
internal ControlFlowGraph(IList <Statement> /*!*/ statements, SemanticsBinder /*!*/ binder) : this(BuilderVisitor.Build(statements, binder)) { }