コード例 #1
0
ファイル: SourceTypeSymbol.cs プロジェクト: ph777/peachpie
        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()));
                }
            }
        }
コード例 #2
0
ファイル: BuilderVisitor.cs プロジェクト: allisterb/peachpie
        private CaseBlock /*!*/ NewBlock(SwitchItem item)
        {
            BoundItemsBag <BoundExpression> caseValueBag = item is CaseItem caseItem
                ? _binder.BindWholeExpression(caseItem.CaseVal, BoundAccess.Read)
                : BoundItemsBag <BoundExpression> .Empty; // BoundItem -eq null => DefaultItem

            return(WithNewOrdinal(new CaseBlock(caseValueBag)
            {
                PhpSyntax = item, Naming = _naming
            }));
        }