Inheritance: Microsoft.Cci.IFieldReference, Microsoft.Cci.IFieldDefinition, Microsoft.Cci.ITypeMemberReference, Microsoft.Cci.ITypeDefinitionMember, Microsoft.Cci.ISpecializedFieldReference
示例#1
0
        /// <summary>
        /// A field representing the function info at runtime.
        /// Lazily associated with index by runtime.
        /// </summary>
        internal FieldSymbol EnsureRoutineInfoField(Emit.PEModuleBuilder module)
        {
            if (_lazyRoutineInfoField == null)
            {
                _lazyRoutineInfoField = module.SynthesizedManager
                    .GetOrCreateSynthesizedField(_file, this.DeclaringCompilation.CoreTypes.RoutineInfo, "!" + this.MetadataName, Accessibility.Internal, true, true);
            }

            return _lazyRoutineInfoField;
        }
示例#2
0
 internal static bool IsConstantField(FieldSymbol field)
 {
     return (field.IsConst || (field.IsReadOnly && field.IsStatic)) && field.DeclaredAccessibility == Accessibility.Public;
 }
示例#3
0
        public FieldPlace(IPlace holder, IFieldSymbol field)
        {
            Contract.ThrowIfNull(field);
            Debug.Assert(holder != null || field.IsStatic);

            _holder = holder;
            _field = (FieldSymbol)field;
        }
示例#4
0
 public BoundPhpStaticFieldPlace(FieldSymbol field, BoundExpression boundref)
     : base(null, field, boundref)
 {
     Debug.Assert(!field.IsStatic);
     Debug.Assert(field.ContainingType.TryGetStatics() != null);
 }
示例#5
0
        public BoundFieldPlace(BoundExpression instance, FieldSymbol field, BoundExpression boundref)
        {
            Contract.ThrowIfNull(field);

            _instance = instance;
            _field = field;
            _boundref = boundref;
        }
 /// <summary>
 /// Determines if given field is declared as static.
 /// Note: actual CLI metadata might be confusing since static PHP fields are represented as instance .NET fields in a class that lives within a PHP context.
 /// </summary>
 public static bool IsPhpStatic(this FieldSymbol f)
 {
     return(f.IsStatic || (f is SourceFieldSymbol sf && sf.FieldKind == SourceFieldSymbol.KindEnum.StaticField));
 }
示例#7
0
 public SynthesizedTraitFieldSymbol(SourceTypeSymbol containing, FieldSymbol traitInstanceField, IPhpPropertySymbol sourceField)
     : base(containing, null, sourceField.Name, sourceField.DeclaredAccessibility, isStatic: false, isReadOnly: false)
 {
     _traitInstanceField = traitInstanceField;
     _traitmember        = sourceField;
 }
 public static TypeSymbol ContainingStaticsHolder(this FieldSymbol f) => f is IPhpPropertySymbol phpf ? phpf.ContainingStaticsHolder : null;
 internal SubstitutedFieldSymbol(NamedTypeSymbol containingType, FieldSymbol substitutedFrom, object token)
 {
     _containingType     = containingType;
     _originalDefinition = substitutedFrom.OriginalDefinition as FieldSymbol;
     _token = token ?? _containingType;
 }
 internal SubstitutedFieldSymbol(NamedTypeSymbol containingType, FieldSymbol substitutedFrom)
     : this(containingType, substitutedFrom, containingType)
 {
 }
示例#11
0
        bool BindConstantValue(BoundExpression target, FieldSymbol symbol)
        {
            if (symbol != null && symbol.IsConst)
            {
                var cvalue = symbol.GetConstantValue(false);
                target.ConstantValue = (cvalue != null) ? new Optional<object>(cvalue.Value) : null;
                target.TypeRefMask = TypeRefFactory.CreateMask(TypeCtx, symbol.Type);

                return true;
            }

            return false;
        }
示例#12
0
 internal void EmitSymbolToken(FieldSymbol symbol, SyntaxNode syntaxNode)
 {
     _il.EmitSymbolToken(_moduleBuilder, _diagnostics, symbol, syntaxNode);
 }
示例#13
0
 /// <summary>
 /// Loads field address on top of evaluation stack.
 /// </summary>
 public void EmitFieldAddress(FieldSymbol fld)
 {
     Debug.Assert(fld != null);
     _il.EmitOpCode(fld.IsStatic ? ILOpCode.Ldsflda : ILOpCode.Ldflda);
     EmitSymbolToken(fld, null);
 }
示例#14
0
 public static void EmitSymbolToken(this ILBuilder il, PEModuleBuilder module, DiagnosticBag diagnostics, FieldSymbol symbol, SyntaxNode syntaxNode)
 {
     il.EmitToken(symbol, syntaxNode, diagnostics);
 }
示例#15
0
 internal SubstitutedFieldSymbol(NamedTypeSymbol containingType, FieldSymbol substitutedFrom)
 {
     _containingType = containingType;
     _originalDefinition = substitutedFrom.OriginalDefinition as FieldSymbol;
 }
        //public static AttributeData CreateDefaultValueAttribute(this PhpCompilation compilation, IMethodSymbol method, BoundArrayEx arr)
        //{
        //    var typeParameter = new KeyValuePair<string, TypedConstant>("Type", new TypedConstant(compilation.CoreTypes.DefaultValueType.Symbol, TypedConstantKind.Enum, 1/*PhpArray*/));
        //    var namedparameters = ImmutableArray.Create(typeParameter);

        //    if (arr.Items.Length != 0)
        //    {
        //        try
        //        {
        //            var byteSymbol = compilation.GetSpecialType(SpecialType.System_Byte);
        //            var serializedValue = Encoding.UTF8.GetBytes(arr.PhpSerializeOrThrow());
        //            var p = new KeyValuePair<string, TypedConstant>(
        //                "SerializedValue",
        //                new TypedConstant(compilation.CreateArrayTypeSymbol(byteSymbol), serializedValue.Select(compilation.CreateTypedConstant).AsImmutable()));

        //            namedparameters = namedparameters.Add(p);
        //        }
        //        catch (Exception ex)
        //        {
        //            throw new InvalidOperationException($"Cannot construct serialized parameter default value. Routine '{method.Name}', {ex.Message}.", ex);
        //        }
        //    }

        //    return new SynthesizedAttributeData(
        //        compilation.CoreMethods.Ctors.DefaultValueAttribute,
        //        ImmutableArray<TypedConstant>.Empty, namedparameters);
        //}

        public static AttributeData CreateDefaultValueAttribute(this PhpCompilation compilation, TypeSymbol containingType, FieldSymbol field)
        {
            var namedparameters = ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty;

            var fieldContainer = field.ContainingType;

            if (fieldContainer != containingType)
            {
                namedparameters = ImmutableArray.Create(new KeyValuePair <string, TypedConstant>(
                                                            "ExplicitType",
                                                            compilation.CreateTypedConstant(fieldContainer)));
            }

            // [DefaultValueAttribute(name) { ExplicitType = ... }]
            return(new SynthesizedAttributeData(
                       compilation.CoreMethods.Ctors.DefaultValueAttribute_string,
                       ImmutableArray.Create(compilation.CreateTypedConstant(field.Name)),
                       namedparameters));
        }
示例#17
0
        //internal static Symbol GetOverriddenMember(this Symbol member)
        //{
        //    switch (member.Kind)
        //    {
        //        case SymbolKind.Method:
        //            return ((MethodSymbol)member).OverriddenMethod;
        //        case SymbolKind.Property:
        //            return ((PropertySymbol)member).OverriddenProperty;
        //        case SymbolKind.Event:
        //            return ((EventSymbol)member).OverriddenEvent;
        //        default:
        //            throw ExceptionUtilities.UnexpectedValue(member.Kind);
        //    }
        //}

        //internal static Symbol GetLeastOverriddenMember(this Symbol member, NamedTypeSymbol accessingTypeOpt)
        //{
        //    switch (member.Kind)
        //    {
        //        case SymbolKind.Method:
        //            var method = (MethodSymbol)member;
        //            return method.GetConstructedLeastOverriddenMethod(accessingTypeOpt);

        //        case SymbolKind.Property:
        //            var property = (PropertySymbol)member;
        //            return property.GetLeastOverriddenProperty(accessingTypeOpt);

        //        case SymbolKind.Event:
        //            var evnt = (EventSymbol)member;
        //            return evnt.GetLeastOverriddenEvent(accessingTypeOpt);

        //        default:
        //            return member;
        //    }
        //}

        internal static bool IsFieldOrFieldLikeEvent(this Symbol member, out FieldSymbol field)
        {
            switch (member.Kind)
            {
                case SymbolKind.Field:
                    field = (FieldSymbol)member;
                    return true;
                case SymbolKind.Event:
                    throw new NotImplementedException();
                    //field = ((EventSymbol)member).AssociatedField;
                    //return (object)field != null;
                default:
                    field = null;
                    return false;
            }
        }
 /// <summary>
 /// Determines if given field is declared as static.
 /// Note: actual CLI metadata might be confusing since static PHP fields are represented as instance .NET fields in a class that lives within a PHP context.
 /// </summary>
 public static bool IsPhpStatic(this FieldSymbol f)
 {
     return(f.IsStatic || (f is IPhpPropertySymbol phpf && (phpf.FieldKind == PhpPropertyKind.StaticField || phpf.FieldKind == PhpPropertyKind.AppStaticField)));
 }