Inheritance: Microsoft.Cci.IParameterTypeInformation, Microsoft.Cci.IParameterDefinition
コード例 #1
0
 private SubstitutedParameterSymbol(Symbol containingSymbol, TypeMap map, ParameterSymbol originalParameter) :
     base(originalParameter)
 {
     Debug.Assert(originalParameter.IsDefinition);
     _containingSymbol = containingSymbol;
     _mapOrType = map;
 }
コード例 #2
0
 /// <summary>
 /// Determines whether given parameter is treated as a special Context parameter
 /// which is always first and of type <c>Pchp.Core.Context</c>.
 /// </summary>
 public static bool IsContextParameter(ParameterSymbol p)
     => p != null && p.Ordinal == 0 && p.Type != null && p.Type.MetadataName == "Context"; // TODO: && namespace == Pchp.Core.
コード例 #3
0
ファイル: PEPropertySymbol.cs プロジェクト: iolevel/peachpie
        private static ImmutableArray<ParameterSymbol> GetParameters(
            PEModuleSymbol moduleSymbol,
            PEPropertySymbol property,
            ParamInfo<TypeSymbol>[] propertyParams,
            ParamInfo<TypeSymbol>[] accessorParams,
            out bool anyParameterIsBad)
        {
            anyParameterIsBad = false;

            // First parameter is the property type.
            if (propertyParams.Length < 2)
            {
                return ImmutableArray<ParameterSymbol>.Empty;
            }

            var numAccessorParams = accessorParams.Length;

            var parameters = new ParameterSymbol[propertyParams.Length - 1];
            for (int i = 1; i < propertyParams.Length; i++) // from 1 to skip property/return type
            {
                // NOTE: this is a best guess at the Dev10 behavior.  The actual behavior is
                // in the unmanaged helper code that Dev10 uses to load the metadata.
                var propertyParam = propertyParams[i];
                var paramHandle = i < numAccessorParams ? accessorParams[i].Handle : propertyParam.Handle;
                var ordinal = i - 1;
                bool isBad;
                parameters[ordinal] = PEParameterSymbol.Create(moduleSymbol, property, ordinal, paramHandle, propertyParam, out isBad);

                if (isBad)
                {
                    anyParameterIsBad = true;
                }
            }
            return parameters.AsImmutableOrNull();
        }
コード例 #4
0
        => p != null && p.Ordinal == 0 && p.Type != null && p.Type.MetadataName == "Context";     // TODO: && namespace == Pchp.Core.

        /// <summary>
        /// Determines whether given parameter is a special lately static bound parameter.
        /// This parameter provides late static bound type, of type <c>PhpTypeInfo</c>.
        /// </summary>
        public static bool IsLateStaticParameter(ParameterSymbol p)
        => p != null && p.Type != null && p.Type.MetadataName == "PhpTypeInfo" && !(p is SourceParameterSymbol) && p.Name == StaticTypeName;     // TODO: && namespace == Pchp.Core.
コード例 #5
0
 /// <summary>
 /// Helper method that checks whether this parameter can be passed to anothers method parameter.
 /// </summary>
 internal bool CanBePassedTo(ParameterSymbol another)
 {
     return(another != null && this.Type.IsOfType(another.Type));
 }
コード例 #6
0
        protected WrappedParameterSymbol(ParameterSymbol underlyingParameter)
        {
            Debug.Assert((object)underlyingParameter != null);

            this.underlyingParameter = underlyingParameter;
        }
コード例 #7
0
 internal SubstitutedParameterSymbol(PropertySymbol containingSymbol, TypeMap map, ParameterSymbol originalParameter) :
     this((Symbol)containingSymbol, map, originalParameter)
 {
 }
コード例 #8
0
ファイル: PEMethodSymbol.cs プロジェクト: iolevel/peachpie
 public SignatureData(SignatureHeader header, ImmutableArray<ParameterSymbol> parameters, ParameterSymbol returnParam)
 {
     this.Header = header;
     this.Parameters = parameters;
     this.ReturnParam = returnParam;
 }
コード例 #9
0
        => p != null && p.Type != null && p.Type.MetadataName == "PhpTypeInfo" && !(p is SourceParameterSymbol) && p.Name == StaticTypeName;     // TODO: && namespace == Pchp.Core.

        /// <summary>
        /// Determines whether given parameter is a special self parameter.
        /// This parameter provides self type, of type <c>RuntimeTypeHandle</c>.
        /// </summary>
        public static bool IsSelfParameter(ParameterSymbol p)
        => p != null && p.Type != null && p.Type.MetadataName == "RuntimeTypeHandle" && !(p is SourceParameterSymbol) && p.Name == SelfName;
コード例 #10
0
 public static bool IsCallerClassParameter(ParameterSymbol p) => p.ImportValueAttributeData.Value == ImportValueAttributeData.ValueSpec.CallerClass;
コード例 #11
0
        /// <summary>
        /// Emits default value of given parameter.
        /// Puts value of target parameter's type.
        /// </summary>
        /// <param name="targetp">Parameter to emit its default value.</param>
        void EmitParameterDefaultValue(ParameterSymbol targetp)
        {
            Contract.ThrowIfNull(targetp);

            //
            TypeSymbol ptype; // emitted type to be eventually converted to target parameter type

            // emit targetp default value:
            ConstantValue cvalue;
            BoundExpression boundinitializer;

            // TODO: targetp.IsParams

            if ((cvalue = targetp.ExplicitDefaultConstantValue) != null)
            {
                // keep NULL if parameter is a reference type
                if (cvalue.IsNull && targetp.Type.IsReferenceType)
                {
                    _il.EmitNullConstant();
                    return;
                }

                //
                ptype = EmitLoadConstant(cvalue.Value, targetp.Type);
            }
            else if ((boundinitializer = (targetp as SourceParameterSymbol)?.Initializer) != null)
            {
                _emitTypeRefContext.Push((targetp as SourceParameterSymbol).Routine.TypeRefContext);
                EmitConvert(boundinitializer, ptype = targetp.Type);
                _emitTypeRefContext.Pop();
            }
            else
            {
                ptype = targetp.Type;
                EmitLoadDefault(ptype, 0);
            }

            // eventually convert emitted value to target parameter type
            EmitConvert(ptype, 0, targetp.Type);
        }
コード例 #12
0
        /// <summary>
        /// Loads argument 
        /// </summary>
        void EmitLoadArgument(ParameterSymbol targetp, BoundExpression expr, List<WriteBackInfo> writebacks)
        {
            if (targetp.RefKind == RefKind.None)
            {
                EmitConvert(expr, targetp.Type); // load argument
            }
            else
            {
                var refexpr = expr as BoundReferenceExpression;
                if (refexpr != null)
                {
                    var place = refexpr.Place(_il);
                    if (place != null && place.HasAddress && place.TypeOpt == targetp.Type)
                    {
                        // ref place directly
                        place.EmitLoadAddress(_il);
                        return;
                    }

                    // write-back
                    writebacks.Add(WriteBackInfo.CreateAndLoad(this, targetp, refexpr));
                    return;
                }
                else
                {
                    throw new ArgumentException("Argument must be passed as a variable.");
                }
            }
        }
コード例 #13
0
            void EmitLoadArgument(CodeGenerator cg, ParameterSymbol targetp)
            {
                Debug.Assert(TmpLocal != null);
                Debug.Assert(targetp.Type == (Symbol)TmpLocal.Type);

                if (targetp.RefKind != RefKind.Out)
                {
                    // copy Target to TmpLocal
                    // Template: TmpLocal = Target;
                    cg.EmitConvert(Target, (TypeSymbol)TmpLocal.Type);
                    cg.Builder.EmitLocalStore(TmpLocal);
                }

                if (targetp.RefKind != RefKind.None)
                {
                    // LOAD_REF TmpLocal
                    cg.Builder.EmitLocalAddress(TmpLocal);
                }
                else
                {
                    // unreachable
                    // LOAD TmpLocal
                    cg.Builder.EmitLocalLoad(TmpLocal);
                }
            }
コード例 #14
0
            /// <summary>
            /// Loads temporary local variable as an argument to <paramref name="targetp"/>.
            /// </summary>
            /// <param name="cg"></param>
            /// <param name="targetp">Target parameter.</param>
            /// <param name="expr">Value to be passed as its argument.</param>
            /// <returns><see cref="WriteBackInfo"/> which has to be finalized with <see cref="WriteBackAndFree(CodeGenerator)"/> once the routine call ends.</returns>
            public static WriteBackInfo CreateAndLoad(CodeGenerator cg, ParameterSymbol targetp, BoundReferenceExpression expr)
            {
                var writeback =  new WriteBackInfo()
                {
                    TmpLocal = cg.GetTemporaryLocal(targetp.Type),
                    Target = expr,
                };

                //
                writeback.EmitLoadArgument(cg, targetp);

                //
                return writeback;
            }
コード例 #15
0
            internal InvokeMethod(SynthesizedDelegateSymbol containingType, BitVector byRefParameters, TypeSymbol voidReturnTypeOpt)
            {
                var typeParams = containingType.TypeParameters;

                _containingType = containingType;

                // if we are given Void type the method returns Void, otherwise its return type is the last type parameter of the delegate:
                _returnType = voidReturnTypeOpt ?? typeParams.Last();

                var parameters = new ParameterSymbol[typeParams.Length - ((object)voidReturnTypeOpt != null ? 0 : 1)];
                for (int i = 0; i < parameters.Length; i++)
                {
                    // we don't need to distinguish between out and ref since this is an internal synthesized symbol:
                    var refKind = !byRefParameters.IsNull && byRefParameters[i] ? RefKind.Ref : RefKind.None;

                    parameters[i] = new SynthesizedParameterSymbol(this, typeParams[i], i, refKind);
                }

                _parameters = parameters.AsImmutableOrNull();
            }
コード例 #16
0
ファイル: Places.cs プロジェクト: iolevel/peachpie
 public ParamPlace(ParameterSymbol p)
 {
     Contract.ThrowIfNull(p);
     _p = p;
 }
コード例 #17
0
 /// <summary>
 /// Determines whether given parameter is treated as a special implicitly provided, by the compiler or the runtime.
 /// </summary>
 public static bool IsImportValueParameter(ParameterSymbol p) => p.ImportValueAttributeData.IsValid;
コード例 #18
0
        static bool CanBePassedTo(ParameterSymbol[] givenparams, ParameterSymbol[] calledparams)
        {
            if (calledparams.Length > givenparams.Length)
                return false;

            for (int i = 0; i < calledparams.Length; i++)
            {
                if (!givenparams[i].CanBePassedTo(calledparams[i]))
                {
                    return false;
                }
            }

            return true;
        }
        protected WrappedParameterSymbol(ParameterSymbol underlyingParameter)
        {
            Debug.Assert((object)underlyingParameter != null);

            this.underlyingParameter = underlyingParameter;
        }
コード例 #20
0
 /// <summary>
 /// Helper method that checks whether this parameter can be passed to anothers method parameter.
 /// </summary>
 internal bool CanBePassedTo(ParameterSymbol another)
 {
     return(another != null && this.Type.IsEqualToOrDerivedFrom(another.Type));
 }
コード例 #21
0
 /// <summary>
 /// Determines whether given parameter is treated as a special Context parameter
 /// which is always first and of type <c>Pchp.Core.Context</c>.
 /// </summary>
 public static bool IsContextParameter(ParameterSymbol p)
 => p != null && p.Ordinal == 0 && p.Type != null && p.Type.MetadataName == "Context";     // TODO: && namespace == Pchp.Core.
コード例 #22
0
        //internal override OverriddenOrHiddenMembersResult OverriddenOrHiddenMembers
        //{
        //    get
        //    {
        //        if (_lazyOverriddenOrHiddenMembers == null)
        //        {
        //            Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
        //        }
        //        return _lazyOverriddenOrHiddenMembers;
        //    }
        //}

        private ImmutableArray<ParameterSymbol> SubstituteParameters()
        {
            var unsubstitutedParameters = _originalDefinition.Parameters;

            if (unsubstitutedParameters.IsEmpty)
            {
                return unsubstitutedParameters;
            }
            else
            {
                int count = unsubstitutedParameters.Length;
                var substituted = new ParameterSymbol[count];
                for (int i = 0; i < count; i++)
                {
                    substituted[i] = new SubstitutedParameterSymbol(this, _containingType.TypeSubstitution, unsubstitutedParameters[i]);
                }
                return substituted.AsImmutableOrNull();
            }
        }
コード例 #23
0
ファイル: ParameterSymbol.cs プロジェクト: iolevel/peachpie
 /// <summary>
 /// Helper method that checks whether this parameter can be passed to anothers method parameter.
 /// </summary>
 internal bool CanBePassedTo(ParameterSymbol another)
 {
     return another != null && this.Type.IsEqualToOrDerivedFrom(another.Type);
 }