• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PhpType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PhpType的典型用法代码示例。如果您正苦于以下问题:C# PhpType类的具体用法?C# PhpType怎么用?C# PhpType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PhpType类属于命名空间,在下文中一共展示了PhpType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ResolveType

        /// <summary>
        /// Resolves type based on provided <paramref name="typeName"/>.
        /// </summary>
        /// <param name="typeName">Either <see cref="GenericQualifiedName"/> or <see cref="PrimitiveTypeName"/> or <c>null</c> reference.</param>
        /// <param name="referringType"></param>
        /// <param name="referringRoutine"></param>
        /// <param name="position"></param>
        /// <param name="mustResolve"></param>
        /// <returns></returns>
        internal DType ResolveType(object typeName, PhpType referringType, PhpRoutine referringRoutine,
				Position position, bool mustResolve)
		{
			DType result = null;

            if (typeName != null)
            {
                if (typeName.GetType() == typeof(GenericQualifiedName))
                {
                    result = ResolveTypeName((GenericQualifiedName)typeName,
                        referringType, referringRoutine, position, mustResolve);
                }
                else if (typeName.GetType() == typeof(PrimitiveTypeName))
                {
                    result = PrimitiveType.GetByName((PrimitiveTypeName)typeName);
                }
                else
                {
                    throw new ArgumentException("typeName");
                }
            }

            return result;
		}
开发者ID:kripper,项目名称:Phalanger,代码行数:33,代码来源:Analyzer.cs


示例2: PhpField

		/// <summary>
		/// Used by full reflection.
		/// </summary>
		public PhpField(VariableName name, DPropertyDesc/*!*/ fieldDesc, FieldInfo/*!*/ fieldInfo,
			PropertyInfo exportedProperty)
			: base(fieldDesc, name)
		{
			Debug.Assert(fieldDesc is DPhpFieldDesc);

			this.realField = fieldInfo;
			this.exportedProperty = exportedProperty;
			this.hasInitialValue = realField.IsDefined(typeof(PhpHasInitValueAttribute), false);
			this.builder = null;

			this.implementor = DeclaringPhpType;
		}
开发者ID:tiaohai,项目名称:Phalanger,代码行数:16,代码来源:Properties.cs


示例3: ReportMethodNotCompatible

 internal virtual void ReportMethodNotCompatible(ErrorSink/*!*/ errors, DType/*!*/ declaringType, PhpType/*!*/ referringType)
 {
     // to be implemented by methods and properties
     Debug.Fail();
     throw null;
 }
开发者ID:jdluzen,项目名称:Phalanger,代码行数:6,代码来源:Members.cs


示例4: EmitOverrideStubs

		/// <summary>
		/// Emits stubs for all overloads of one overridden or implemented method.
		/// </summary>
		/// <param name="stubs">Already generated stubs.</param>
		/// <param name="target">The overriding/implementing method.</param>
		/// <param name="targetType">The type (perhaps constructed) that declared <paramref name="target"/>.</param>
		/// <param name="declaringType">The type where the stubs should be emitted.</param>
		/// <param name="template">The method being overridden/implemented.</param>
		/// <param name="newSlot"><B>True</B> if the stub should be assigned a new vtable slot,
		/// <B>false</B> otherwise.</param>
		private void EmitOverrideStubs(IDictionary<string, MethodBuilder>/*!*/ stubs, PhpMethod/*!*/ target,
			DType/*!*/ targetType, PhpType/*!*/ declaringType, DMemberRef/*!*/ template, bool newSlot)
		{
			ClrMethod clr_template = template.Member as ClrMethod;
			if (clr_template == null)
			{
                if (!target.IsStatic)
				    EmitOverrideStubsForPhpTemplate(stubs, target, targetType, declaringType, template, newSlot);

				return;
			}

            //
            // following code emits stubs in case of CLR base method
            //

			ConstructedType constructed_type = template.Type as ConstructedType;
			TypeBuilder type_builder = declaringType.RealTypeBuilder;

			// override all virtual non-final overloads
			foreach (ClrMethod.Overload overload in clr_template.Overloads)
			{
				if (overload.Method.IsVirtual && !overload.Method.IsFinal)
				{
					// map generic type parameters according to the constructed type
					Type constructed_return_type;
					ParameterInfo[] constructed_params = overload.MakeConstructed(constructed_type, out constructed_return_type);

					// check whether we have not generated this signature before
					string clr_sig = ClrMethod.Overload.ClrSignatureToString(
						overload.GenericParamCount,
						constructed_params,
						constructed_return_type);

					if (stubs.ContainsKey(clr_sig)) continue;

					Type[] param_types = new Type[constructed_params.Length];

					for (int j = 0; j < param_types.Length; j++)
					{
						param_types[j] = constructed_params[j].ParameterType;
					}

					// determine the stub attributes
					MethodAttributes attr;
					string name;

					name = overload.Method.Name;
					attr = Reflection.Enums.ToMethodAttributes(target.MemberDesc.MemberAttributes);
					attr |= (MethodAttributes.Virtual | MethodAttributes.HideBySig);

					if (newSlot) attr |= MethodAttributes.NewSlot;

					MethodBuilder overload_builder = type_builder.DefineMethod(name, attr);

					if (overload.MandatoryGenericParamCount > 0)
					{
						// define the same generic parameters that are defined for the overridden method
						// (the same constraints but possibly having different names)
						ClrStubBuilder.DefineStubGenericParameters(
							overload_builder,
							overload.GenericParameters,
							target.Signature,
							param_types);
					}

					overload_builder.SetReturnType(constructed_return_type);
					overload_builder.SetParameters(param_types);

					// set parameter names and attributes
					ClrStubBuilder.DefineStubParameters(overload_builder,
						target.Builder.Signature.FormalParams, constructed_params);

					if (!overload_builder.IsAbstract)
					{
						EmissionContext emission_context = SetupStubPlaces(target.DeclaringPhpType, false);

						try
						{
							// convert parameters and invoke the target
							ClrStubBuilder.EmitMethodStubBody(
								new ILEmitter(overload_builder),
								ScriptContextPlace,
								constructed_params,
								overload.GenericParameters,
								constructed_return_type,
								target,
								targetType);
						}
						finally
//.........这里部分代码省略.........
开发者ID:dw4dev,项目名称:Phalanger,代码行数:101,代码来源:CodeGenerator.cs


示例5: EnterTypeDeclaration

		/// <summary>
		/// Called when a <see cref="PHP.Core.AST.TypeDecl"/> AST node is entered during the emit phase.
		/// </summary>
		public void EnterTypeDeclaration(PhpType/*!*/ type)
		{
			CompilerLocationStack.TypeDeclContext cd_context = new CompilerLocationStack.TypeDeclContext();
			cd_context.Type = type;

			cd_context.TypeContextPlace = TypeContextPlace;
			TypeContextPlace = new Place(null, type.TypeDescFieldInfo);

            // CallSites
            cd_context.CallSites = callSites;
            this.callSites = new CallSitesBuilder(
                sourceUnit.CompilationUnit.Module.GlobalType.RealModuleBuilder,
                type.QualifiedName.ToString(),
                TypeContextPlace, /*class_context = TypeContextPlace, can be used in .cctor of call sites container*/
                type);

            //
            locationStack.PushTypeDecl(cd_context);
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:22,代码来源:CodeGenerator.cs


示例6: SetupStubPlaces

		private EmissionContext SetupStubPlaces(PhpType/*!*/ type, bool stubIsStatic)
		{
			EmissionContext context = new EmissionContext(ScriptContextPlace, SelfPlace, il);

			ScriptContextPlace = new LazyLoadSCPlace();
			if (stubIsStatic)
			{
				SelfPlace = LiteralPlace.Null;
			}
			else
			{
				if (type.ProxyFieldInfo != null)
				{
					// the real this is not a DObject
					SelfPlace = new Place(IndexedPlace.ThisArg, type.ProxyFieldInfo);
				}
				else
				{
					// the real this is a DObject
					SelfPlace = IndexedPlace.ThisArg;
				}
			}

			return context;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:25,代码来源:CodeGenerator.cs


示例7: ResolveMethod

        /// <summary>
        /// Resolves a method of given <see cref="DType"/> by its name.
        /// </summary>
        /// <param name="type">The type of routine being resolved.</param>
        /// <param name="methodName">The name of routine to be resolved.</param>
        /// <param name="position">Position of method call used for error reporting.</param>
        /// <param name="referringType">The type where the seached routine is being called. Can be <c>null</c>.</param>
        /// <param name="referringRoutine">The routine where the searched routine is being called. Can be <c>null</c>.</param>
        /// <param name="calledStatically">True if the searched routine is called statically - if it uses static method call syntax.
        /// This affects the __call or __callStatic method lookup.
        /// It affects also the error reporting, where for instance method calls, the bad visibility error is
        /// ignored and falls back to return <see cref="UnknownMethod"/>.</param>
        /// <param name="checkVisibilityAtRuntime">Will determine if the routine call must be checked for visibility at runtime.</param>
        /// <param name="isCallMethod">Will determine if __call or __callStatic magic methods were found instead.</param>
        /// <returns>The resolved routine. Cannot return <c>null</c>.</returns>
		public DRoutine/*!*/ ResolveMethod(DType/*!*/ type, Name methodName, Position position,
			PhpType referringType, PhpRoutine referringRoutine, bool calledStatically,
            out bool checkVisibilityAtRuntime, out bool isCallMethod)
		{
			checkVisibilityAtRuntime = false;
            isCallMethod = false;

			// we cannot resolve a method unless we know the inherited members:
			if (type.IsDefinite)
			{
				KnownType known;

				// the method is a constructor:
				if (methodName.IsConstructName || (known = type as KnownType) != null && methodName.Equals(known.QualifiedName.Name))
					return ResolveConstructor(type, position, referringType, referringRoutine, out checkVisibilityAtRuntime);

				DRoutine routine;
				GetMemberResult member_result;

				member_result = type.GetMethod(methodName, referringType, out routine);

                // Look for __call or __callStatic magic methods if no method was found:
                // Note: __call when looking for instance method is disabled, since there can be the searched method in some future override.
                if (member_result == GetMemberResult.NotFound && calledStatically)
                {
                    // in PHP, it is possible to call instance methods statically if we are in instance method context.
                    // In such case we have to look for __call instead of __callStatic:
                    
                    // determine the proper call method:
                    // use __call for instance method invocation, including static method invocation within the current type (e.g. A::foo(), parent::foo(), ...)
                    // use __callStatic for static method invocation
                    Name callMethodName =
                        (!calledStatically ||   // just to have complete condition here, always false
                        (referringRoutine != null && referringType != null && !referringRoutine.IsStatic &&  // in non-static method
                        type.TypeDesc.IsAssignableFrom(referringType.TypeDesc)) // {CurrentType} is inherited from or equal {type}
                        ) ? DObject.SpecialMethodNames.Call : DObject.SpecialMethodNames.CallStatic;

                    member_result = type.GetMethod(callMethodName, referringType, out routine);

                    if (member_result != GetMemberResult.NotFound)
                        isCallMethod = true;
                }

				switch (member_result)
				{
					case GetMemberResult.OK:
						return routine;

					case GetMemberResult.NotFound:
                        if (calledStatically) // throw an error only in we are looking for static method, instance method can be defined in some future inherited class
                            ErrorSink.Add(Errors.UnknownMethodCalled, SourceUnit, position, type.FullName, methodName);
						return new UnknownMethod(type, methodName.Value);

					case GetMemberResult.BadVisibility:
						{
                            if (!calledStatically)    // instance method will check the routine dynamically, there can be some override later
                                return new UnknownMethod(type, methodName.Value);

							if (referringType == null && referringRoutine == null)
							{
								// visibility must be checked at run-time:
								checkVisibilityAtRuntime = true;
								return routine;
							}
							else
							{
								// definitive error:
								if (routine.IsPrivate)
								{
									ErrorSink.Add(Errors.PrivateMethodCalled, SourceUnit, position, type.FullName, methodName.Value,
										referringType.FullName);
								}
								else
								{
									ErrorSink.Add(Errors.ProtectedMethodCalled, SourceUnit, position, type.FullName, methodName.Value,
					  referringType.FullName);
								}

								return new UnknownMethod(type, methodName.Value);
							}
						}

					default:
						Debug.Fail();
						return null;
//.........这里部分代码省略.........
开发者ID:Ashod,项目名称:Phalanger,代码行数:101,代码来源:Analyzer.cs


示例8: ResolveConstructor

		/// <summary>
		/// Resolves constructor of the specified type within the current context (location).
		/// </summary>
		public DRoutine/*!*/ ResolveConstructor(DType/*!*/ type, Position position, PhpType referringType,
			PhpRoutine referringRoutine, out bool checkVisibilityAtRuntime)
		{
			checkVisibilityAtRuntime = false;
			KnownRoutine ctor;

			// Do resolve ctor despite of the indefiniteness of the type to make error reporting consistent
			// when accessing the constructors thru the new operator.

			switch (type.GetConstructor(referringType, out ctor))
			{
				case GetMemberResult.OK:
					return ctor;

				case GetMemberResult.NotFound:
					// default ctor to be used:
					return new UnknownMethod(type);

				case GetMemberResult.BadVisibility:
					if (referringType == null && referringRoutine == null)
					{
						// visibility must be checked at run-time:
						checkVisibilityAtRuntime = true;
						return ctor;
					}
					else
					{
						// definitive error:
						if (ctor.IsPrivate)
						{
							ErrorSink.Add(Errors.PrivateCtorCalled, SourceUnit, position, type.FullName,
								ctor.FullName, referringType.FullName);
						}
						else
						{
							ErrorSink.Add(Errors.ProtectedCtorCalled, SourceUnit, position, type.FullName,
								ctor.FullName, referringType.FullName);
						}

						return new UnknownMethod(type);
					}

				default:
					Debug.Fail();
					return null;
			}
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:50,代码来源:Analyzer.cs


示例9: ResolveTypeParameterName

		private GenericParameter ResolveTypeParameterName(Name name, PhpType referringType, PhpRoutine referringRoutine)
		{
			GenericParameter result = null;

			if (referringRoutine != null)
			{
				result = referringRoutine.Signature.GetGenericParameter(name);
				if (result != null)
					return result;
			}

			if (referringType != null)
			{
				result = referringType.GetGenericParameter(name);
				if (result != null)
					return result;
			}

			return result;
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:20,代码来源:Analyzer.cs


示例10: ResolveTypeName

		public DType/*!*/ ResolveTypeName(GenericQualifiedName genericName, PhpType referringType,
			PhpRoutine referringRoutine, Position position, bool mustResolve)
		{
			DType type = ResolveTypeName(genericName.QualifiedName, referringType, referringRoutine, position, mustResolve);

			DTypeDesc[] arguments = (genericName.GenericParams.Length > 0) ? new DTypeDesc[genericName.GenericParams.Length] : DTypeDesc.EmptyArray;

			for (int i = 0; i < arguments.Length; i++)
			{
				arguments[i] = ResolveType(genericName.GenericParams[i], referringType, referringRoutine, position, mustResolve).TypeDesc;
			}

			return type.MakeConstructedType(this, arguments, position);
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:14,代码来源:Analyzer.cs


示例11: ResolveType

		public DType ResolveType(object typeNameOrPrimitiveType, PhpType referringType, PhpRoutine referringRoutine,
				Position position, bool mustResolve)
		{
			Debug.Assert(typeNameOrPrimitiveType == null || typeNameOrPrimitiveType is PrimitiveType
			  || typeNameOrPrimitiveType is GenericQualifiedName);

			DType result = typeNameOrPrimitiveType as PrimitiveType;
			if (result != null)
				return result;

			if (typeNameOrPrimitiveType != null)
			{
				return ResolveTypeName((GenericQualifiedName)typeNameOrPrimitiveType, referringType,
							referringRoutine, position, mustResolve);
			}

			return null;
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:18,代码来源:Analyzer.cs


示例12: GetReferringScope

		private Scope GetReferringScope(PhpType referringType, PhpRoutine referringRoutine)
		{
			if (referringType != null) return referringType.Declaration.Scope;
            if (referringRoutine is PhpFunction) return ((PhpFunction)referringRoutine).Declaration.Scope;
            //if (referringRoutine is PhpLambdaFunction) ...

			// used for global statements during full analysis:
			Debug.Assert(currentScope.IsValid, "Scope is available only during full analysis.");
			return currentScope;
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:10,代码来源:Analyzer.cs


示例13: CallSitesBuilder

        /// <summary>
        /// Create new call sites builder.
        /// </summary>
        /// <param name="moduleBuilder">Module to contain call sites container.</param>
        /// <param name="userFriendlyName">User friendly name used to identify the call sites container by user.</param>
        /// <param name="classContextPlace">If known and if it can be emitted in static .cctor, defines the place where the class context can be loaded. Otherwise <c>null</c> if the class context will be determined in run time.</param>
        /// <param name="classContext">Current PHP type context.</param>
        public CallSitesBuilder(ModuleBuilder/*!*/moduleBuilder, string/*!*/userFriendlyName, IPlace classContextPlace, PhpType classContext)
        {
            Debug.Assert(moduleBuilder != null && userFriendlyName != null);

            this.userFriendlyName = userFriendlyName;
            this.moduleBuilder = moduleBuilder;
            this.PushClassContext(classContextPlace, classContext);
            this.delegateBuilder = new DelegateBuilder(moduleBuilder);
        }
开发者ID:Ashod,项目名称:Phalanger,代码行数:16,代码来源:CallSitesBuilder.cs


示例14: ResolveProperty

		/// <summary>
		/// Resolves static properties.
		/// </summary>
		public DProperty/*!*/ ResolveProperty(DType/*!*/ type, VariableName propertyName, Position position, bool staticOnly,
			PhpType referringType, PhpRoutine referringRoutine, out bool checkVisibilityAtRuntime)
		{
			Debug.Assert(type != null);

			checkVisibilityAtRuntime = false;

			// we cannot resolve a property unless we know the inherited members:
			if (type.IsDefinite)
			{
				DProperty property;
				GetMemberResult member_result = type.GetProperty(propertyName, referringType, out property);

				switch (member_result)
				{
					case GetMemberResult.OK:
						if (staticOnly && !property.IsStatic) goto case GetMemberResult.NotFound;
						return property;

					case GetMemberResult.NotFound:
						ErrorSink.Add(Errors.UnknownPropertyAccessed, SourceUnit, position, type.FullName, propertyName);
						return new UnknownProperty(type, propertyName.Value);

					case GetMemberResult.BadVisibility:
						if (referringType == null && referringRoutine == null)
						{
							// visibility must be checked at run-time:
							checkVisibilityAtRuntime = true;
							return property;
						}
						else
						{
							// definitive error:
							if (property.IsPrivate)
							{
								ErrorSink.Add(Errors.PrivatePropertyAccessed, SourceUnit, position, type.FullName, propertyName.Value,
									referringType.FullName);
							}
							else
							{
								ErrorSink.Add(Errors.ProtectedPropertyAccessed, SourceUnit, position, type.FullName, propertyName.Value,
									referringType.FullName);
							}

							return new UnknownProperty(type, propertyName.Value);
						}

					default:
						Debug.Fail();
						throw null;
				}
			}
			else
			{
				// warning (if any) reported by the type resolver:
				return new UnknownProperty(type, propertyName.Value);
			}
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:61,代码来源:Analyzer.cs


示例15: DefineMethodExportStubs

		/// <summary>
		/// Enumerates all export overloads for the given target PHP method.
		/// </summary>
		public static IEnumerable<StubInfo> DefineMethodExportStubs(
			PhpRoutine/*!*/ target, PhpType/*!*/ declaringType,
			MethodAttributes attributes,
			bool defineConstructors,
			StubSignatureFilter/*!*/ signatureFilter)
		{
            Debug.Assert(target.Builder != null);

            Type return_type = Types.Object[0];

            PhpRoutineSignature signature = target.Signature;
			AST.FormalParam[] formal_params = target.Builder.Signature.FormalParams;
			AST.FormalTypeParam[] formal_type_params = target.Builder.TypeSignature.TypeParams;

			int gen_sig_count = signature.GenericParamCount - signature.MandatoryGenericParamCount + 1;
			int arg_sig_count = signature.ParamCount - signature.MandatoryParamCount + 1;

			// TODO: return type hints
			// HACK: change return type to void for methods that are apparently event handlers
			if (signature.GenericParamCount == 0 && arg_sig_count == 1 && signature.ParamCount == 2 &&
				(signature.TypeHints[0] == null || signature.TypeHints[0].RealType == Types.Object[0]) &&
				(signature.TypeHints[1] != null && typeof(EventArgs).IsAssignableFrom(signature.TypeHints[1].RealType)))
			{
				return_type = Types.Void;
			}

			for (int gen_sig = 0; gen_sig < gen_sig_count; gen_sig++)
			{
				for (int arg_sig = 0; arg_sig < arg_sig_count; arg_sig++)
				{
					// determine parameter types (except for method mandatory generic parameters)
					object[] parameter_types = GetStubParameterTypes(
						arg_sig + signature.MandatoryParamCount,
						gen_sig + signature.MandatoryGenericParamCount,
						signature,
						formal_type_params);

					// determine generic parameter names
					string[] generic_param_names = new string[target.Signature.MandatoryGenericParamCount + gen_sig];
					for (int i = 0; i < generic_param_names.Length; i++)
					{
						generic_param_names[i] = formal_type_params[i].Name.ToString();
					}

					// are we allowed to generate this signature?
					if (!signatureFilter(generic_param_names, parameter_types, return_type)) continue;

					GenericTypeParameterBuilder[] generic_params = StubInfo.EmptyGenericParameters;
					MethodBase method_base = null;
					MethodBuilder method = null;

					if (!defineConstructors)
					{
                        method = declaringType.RealTypeBuilder.DefineMethod(target.FullName, attributes);

						// determine generic parameters
						if (generic_param_names.Length > 0) generic_params = method.DefineGenericParameters(generic_param_names);

						method_base = method;
					}

					ParameterInfo[] parameters = new ParameterInfo[parameter_types.Length];

					// fill in parameter infos
					Type[] real_parameter_types = new Type[parameters.Length];
					for (int i = 0; i < parameters.Length; i++)
					{
						Type type = parameter_types[i] as Type;

						// generic method parameter fixup
						if (type == null)
						{
							int index = (int)parameter_types[i];
							if (index < 0) type = generic_params[-(index + 1)].MakeByRefType();
							else type = generic_params[index];
						}

						string param_name;
						ParameterAttributes param_attrs;
						if (i < formal_params.Length)
						{
							param_name = formal_params[i].Name.ToString();
							param_attrs = (formal_params[i].IsOut ? ParameterAttributes.Out : ParameterAttributes.None);
						}
						else
						{
							param_name = "args" + (i + 1);
							param_attrs = ParameterAttributes.None;
						}

						parameters[i] = new StubParameterInfo(i, type, param_attrs, param_name);
						real_parameter_types[i] = type;
					}

					if (method != null)
					{
						method.SetParameters(real_parameter_types);
//.........这里部分代码省略.........
开发者ID:dw4dev,项目名称:Phalanger,代码行数:101,代码来源:ClrStubBuilder.cs


示例16: ResolveClassConstantName

		internal DConstant ResolveClassConstantName(DType/*!*/ type, VariableName constantName,
			Position position, PhpType referringType, PhpRoutine referringRoutine, out bool checkVisibilityAtRuntime)
		{
			checkVisibilityAtRuntime = false;

			// we cannot resolve a class constant unless we know the inherited members:
			if (type.IsDefinite)
			{
				ClassConstant constant;
				GetMemberResult member_result = type.GetConstant(constantName, referringType, out constant);

				switch (member_result)
				{
					case GetMemberResult.OK:
						return constant;

					case GetMemberResult.NotFound:
						ErrorSink.Add(Errors.UnknownClassConstantAccessed, SourceUnit, position, type.FullName, constantName);
						return new UnknownClassConstant(type, constantName.Value);

					case GetMemberResult.BadVisibility:
						if (referringType == null && referringRoutine == null)
						{
							// visibility must be checked at run-time:
							checkVisibilityAtRuntime = true;
							return constant;
						}
						else
						{
							// definitive error:
							if (constant.IsPrivate)
							{
								ErrorSink.Add(Errors.PrivateConstantAccessed, SourceUnit, position, type.FullName, constantName.Value,
				  referringType.FullName);
							}
							else
							{
								ErrorSink.Add(Errors.ProtectedConstantAccessed, SourceUnit, position, type.FullName, constantName.Value,
				  referringType.FullName);
							}

							return new UnknownClassConstant(type, constantName.Value);
						}

					default:
						Debug.Fail();
						throw null;
				}
			}
			else
			{
				// warning (if any) reported by the type resolver:
				return new UnknownClassConstant(type, constantName.Value);
			}
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:55,代码来源:Analyzer.cs


示例17: EmitGhostStubs

		/// <summary>
		/// Emits ghost stubs for methods and properties that are declared by a <paramref name="type"/>'s
		/// base type but need to be adapted to a particular CLR signature because of implementing an
		/// interface by the <paramref name="type"/>.
		/// </summary>
		/// <param name="type">The <see cref="PhpType"/> that possibly released ghosts by implementing an interface.
		/// </param>
		public void EmitGhostStubs(PhpType/*!*/ type)
		{
			List<KeyValuePair<DMemberRef, DMemberRef>> ghosts = type.Builder.GhostImplementations;
			if (ghosts != null)
			{
				Dictionary<string, MethodBuilder> m_stubs = new Dictionary<string, MethodBuilder>();
				Dictionary<Type, PropertyBuilder> f_stubs = new Dictionary<Type, PropertyBuilder>();

				for (int i = 0; i < ghosts.Count; i++)
				{
					PhpMethod impl_method;
					PhpField impl_field;

					if ((impl_method = ghosts[i].Value.Member as PhpMethod) != null)
					{
						// emit ghost method stub
						EmitOverrideStubs(m_stubs, impl_method, ghosts[i].Value.Type, type, ghosts[i].Key, true);
					}
					else if ((impl_field = ghosts[i].Value.Member as PhpField) != null)
					{
						// emit ghost property stub
						EmitOverrideStubs(f_stubs, impl_field, type, ghosts[i].Key, true);
					}
				}
			}
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:33,代码来源:CodeGenerator.cs


示例18: TypeDeclLocation

			internal TypeDeclLocation(PhpType/*!*/ type, int nestingLevel)
				: base(nestingLevel)
			{
				this.type = type;
			}
开发者ID:Ashod,项目名称:Phalanger,代码行数:5,代码来源:Analyzer.cs


示例19: DefineOverrideAccessor

		/// <summary>
		/// Defines a property accessor method and installs an explicit override if necessary.
		/// </summary>
		private MethodBuilder/*!*/ DefineOverrideAccessor(PhpType/*!*/ declaringType, PhpField/*!*/ target,
			MethodInfo/*!*/ template, bool newSlot, Type/*!*/ returnType, Type[]/*!!*/ paramTypes)
		{
			bool changed;
			string name = ClrStubBuilder.GetNonConflictingMethodName(declaringType.TypeDesc, template.Name, out changed);

			MethodAttributes attr;

			if (changed) attr = MethodAttributes.PrivateScope;
			else attr = Reflection.Enums.ToMethodAttributes(target.MemberDesc.MemberAttributes);

			attr |= (MethodAttributes.Virtual | MethodAttributes.HideBySig);
			if (newSlot) attr |= MethodAttributes.NewSlot;

			MethodBuilder method_builder = declaringType.RealTypeBuilder.DefineMethod(
				name,
				attr,
				returnType,
				paramTypes);

			if (changed)
			{
				declaringType.RealTypeBuilder.DefineMethodOverride(
					method_builder,
					template);
			}

			return method_builder;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:32,代码来源:CodeGenerator.cs


示例20: EnterTypeDecl

        /// <summary>
		/// Notices the analyzer that class declaration is entered.
		/// </summary>
		internal void EnterTypeDecl(PhpType type)
		{
			TypeDeclLocation c = new TypeDeclLocation(type, locationStack.Count);
			typeDeclStack.Push(c);
			locationStack.Push(c);
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:9,代码来源:Analyzer.cs



注:本文中的PhpType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PhpTypeCode类代码示例发布时间:2022-05-24
下一篇:
C# PhpReference类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap