當前位置: 首頁>>代碼示例>>C#>>正文


C# CSharp.ResolveContext類代碼示例

本文整理匯總了C#中Mono.CSharp.ResolveContext的典型用法代碼示例。如果您正苦於以下問題:C# ResolveContext類的具體用法?C# ResolveContext怎麽用?C# ResolveContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ResolveContext類屬於Mono.CSharp命名空間,在下文中一共展示了ResolveContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateExpressionTree

		public virtual Expression CreateExpressionTree (ResolveContext ec)
		{
			if (ArgType == AType.Default)
				ec.Report.Error (854, Expr.Location, "An expression tree cannot contain an invocation which uses optional parameter");

			return Expr.CreateExpressionTree (ec);
		}
開發者ID:pgoron,項目名稱:monodevelop,代碼行數:7,代碼來源:argument.cs

示例2: Bind

		public DynamicMetaObject Bind (DynamicContext ctx, Type callingType)
		{
			Expression res;
			try {
				var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions);

				// Static typemanager and internal caches are not thread-safe
				lock (resolver) {
					expr = expr.Resolve (rc, Compiler.ResolveFlags.VariableOrValue);
				}

				if (expr == null)
					throw new RuntimeBinderInternalCompilerException ("Expression resolved to null");

				res = expr.MakeExpression (new Compiler.BuilderContext ());
			} catch (RuntimeBinderException e) {
				if (errorSuggestion != null)
					return errorSuggestion;

				res = CreateBinderException (e.Message);
			} catch (Exception) {
				if (errorSuggestion != null)
					return errorSuggestion;

				throw;
			}

			return new DynamicMetaObject (res, restrictions);
		}
開發者ID:bbqchickenrobot,項目名稱:playscript-mono,代碼行數:29,代碼來源:CSharpBinder.cs

示例3: DoResolve

		public override Expression DoResolve (ResolveContext ec)
		{
			//
			// We are born fully resolved
			//
			return this;
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:7,代碼來源:expression.cs

示例4: CreateDelegateType

		public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
		{
			Namespace type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);
			if (type_ns == null) {
				return null;
			}
			if (returnType == rc.BuiltinTypes.Void) {
				var actArgs = parameters.Types;
				var actionSpec = type_ns.LookupType (rc.Module, "Action", actArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (actionSpec == null) {
					return null;
				}
				if (actArgs.Length == 0)
					return actionSpec;
				else
					return actionSpec.MakeGenericType(rc, actArgs);
			} else {
				TypeSpec[] funcArgs = new TypeSpec[parameters.Types.Length + 1];
				parameters.Types.CopyTo(funcArgs, 0);
				funcArgs[parameters.Types.Length] = returnType;
				var funcSpec = type_ns.LookupType (rc.Module, "Func", funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
				if (funcSpec == null)
					return null;
				return funcSpec.MakeGenericType(rc, funcArgs);
			}
		}
開發者ID:OpenFlex,項目名稱:playscript-mono,代碼行數:26,代碼來源:delegate.cs

示例5: ExplicitConversion

        /// <summary>
        ///   Performs an explicit conversion of the expression `expr' whose
        ///   type is expr.Type to `target_type'.
        /// </summary>
        public static Expression ExplicitConversion(ResolveContext ec, Expression expr,
			TypeSpec target_type, Location loc)
        {
            Expression e = ExplicitConversionCore (ec, expr, target_type, loc);
            if (e != null) {
                //
                // Don't eliminate explicit precission casts
                //
                if (e == expr) {
                    if (target_type.BuiltinType == BuiltinTypeSpec.Type.Float)
                        return new OpcodeCast (expr, target_type, OpCodes.Conv_R4);

                    if (target_type.BuiltinType == BuiltinTypeSpec.Type.Double)
                        return new OpcodeCast (expr, target_type, OpCodes.Conv_R8);
                }

                return e;
            }

            TypeSpec expr_type = expr.Type;
            if (target_type.IsNullableType) {
                TypeSpec target;

                if (expr_type.IsNullableType) {
                    target = Nullable.NullableInfo.GetUnderlyingType (target_type);
                    Expression unwrap = Nullable.Unwrap.Create (expr);
                    e = ExplicitConversion (ec, unwrap, target, expr.Location);
                    if (e == null)
                        return null;

                    return new Nullable.LiftedConversion (e, unwrap, target_type).Resolve (ec);
                }
                if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Object) {
                    return new UnboxCast (expr, target_type);
                }

                target = TypeManager.GetTypeArguments (target_type) [0];
                e = ExplicitConversionCore (ec, expr, target, loc);
                if (e != null)
                    return TypeSpec.IsReferenceType (expr.Type) ? new UnboxCast (expr, target_type) : Nullable.Wrap.Create (e, target_type);
            } else if (expr_type.IsNullableType) {
                e = ImplicitBoxingConversion (expr, Nullable.NullableInfo.GetUnderlyingType (expr_type), target_type);
                if (e != null)
                    return e;

                e = Nullable.Unwrap.Create (expr, false);
                e = ExplicitConversionCore (ec, e, target_type, loc);
                if (e != null)
                    return EmptyCast.Create (e, target_type);
            }

            e = ExplicitUserConversion (ec, expr, target_type, loc);

            if (e != null)
                return e;

            expr.Error_ValueCannotBeConverted (ec, target_type, true);
            return null;
        }
開發者ID:exodrifter,項目名稱:mcs-ICodeCompiler,代碼行數:63,代碼來源:convert.cs

示例6: ImplicitConversionRequired

		public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type, Location loc)
		{
			Constant c = ConvertImplicitly (type);
			if (c == null)
				Error_ValueCannotBeConverted (ec, type, false);

			return c;
		}
開發者ID:rabink,項目名稱:mono,代碼行數:8,代碼來源:constant.cs

示例7: CreateExpressionTree

		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			// HACK: avoid referencing mcs internal type
			if (type == typeof (NullLiteral))
				type = TypeManager.object_type;

			return base.CreateExpressionTree (ec);
		}		
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:8,代碼來源:literal.cs

示例8: ExplicitConversion

        /// <summary>
        ///   Performs an explicit conversion of the expression `expr' whose
        ///   type is expr.Type to `target_type'.
        /// </summary>
        public static Expression ExplicitConversion(ResolveContext ec, Expression expr,
            TypeSpec target_type, Location loc)
        {
            Expression e = ExplicitConversionCore (ec, expr, target_type, loc);
            if (e != null) {
                //
                // Don't eliminate explicit precission casts
                //
                if (e == expr) {
                    if (target_type == TypeManager.float_type)
                        return new OpcodeCast (expr, target_type, OpCodes.Conv_R4);

                    if (target_type == TypeManager.double_type)
                        return new OpcodeCast (expr, target_type, OpCodes.Conv_R8);
                }

                return e;
            }

            TypeSpec expr_type = expr.Type;
            if (TypeManager.IsNullableType (target_type)) {
                if (TypeManager.IsNullableType (expr_type)) {
                    TypeSpec target = Nullable.NullableInfo.GetUnderlyingType (target_type);
                    Expression unwrap = Nullable.Unwrap.Create (expr);
                    e = ExplicitConversion (ec, unwrap, target, expr.Location);
                    if (e == null)
                        return null;

                    return new Nullable.Lifted (e, unwrap, target_type).Resolve (ec);
                } else if (expr_type == TypeManager.object_type) {
                    return new UnboxCast (expr, target_type);
                } else {
                    TypeSpec target = TypeManager.GetTypeArguments (target_type) [0];

                    e = ExplicitConversionCore (ec, expr, target, loc);
                    if (e != null)
                        return Nullable.Wrap.Create (e, target_type);
                }
            } else if (TypeManager.IsNullableType (expr_type)) {
                bool use_class_cast;
                if (ImplicitBoxingConversionExists (Nullable.NullableInfo.GetUnderlyingType (expr_type), target_type, out use_class_cast))
                    return new BoxedCast (expr, target_type);

                e = Nullable.Unwrap.Create (expr, false);
                e = ExplicitConversionCore (ec, e, target_type, loc);
                if (e != null)
                    return EmptyCast.Create (e, target_type);
            }

            e = ExplicitUserConversion (ec, expr, target_type, loc);
            if (e != null)
                return e;

            expr.Error_ValueCannotBeConverted (ec, loc, target_type, true);
            return null;
        }
開發者ID:speier,項目名稱:shake,代碼行數:60,代碼來源:convert.cs

示例9: DoResolve

        protected override Expression DoResolve(ResolveContext ec){
            var e = base.DoResolve(ec);
            if (e == null || e != this)
                return e;

            var fld = target as FieldExpr;
            if (fld == null){
                var access = target as MemberAccess;
                if (access != null)
                    fld = access.LeftExpression as FieldExpr;

                if (fld == null){
                    Expression simple = target as SimpleName;
                    simple = simple != null ? simple.Resolve(ec) : null;
                    fld = simple as FieldExpr;
                }
                if (fld == null)
                    return e;
            }
            if (!fld.IsRole)
                return e;

            //assigning to a role. Check that the contract is fullfilled
            var contractName = CSharpParser.GetCurrentRoleContractName(fld.DeclaringType.Name, fld.Name);
            if (CSharpParser.RoleContracts.ContainsKey(contractName)){
                if (source.Type == null)
                    source = source.Resolve(ec);
                var contract = CSharpParser.RoleContracts[contractName];
                if (!source.Type.FullfillsContract(contract)){
                    var index = -1;
                    var current_class = contract.Parent;
                    if (current_class.IsGeneric)
                    {
                        var typeParameters = current_class.TypeParameters;
                        for (int i = 0; index < 0 && i < typeParameters.Length; i++)
                        {
                            var param = typeParameters[i];
                            if (target.Type.Name == param.Name)
                            {
                                index = i;
                            }
                        }
                    }
                    if (index < 0)
                    {
                        ec.Report.Error(10009, loc, "Assignment to role '{0}' does not full fill contract", fld.Name);
                    }
                    else
                    {
                        current_class.Spec.AddTypesAndContracts(index, contract);
                    }
                }
            }

            return this;
        }
開發者ID:runefs,項目名稱:Marvin,代碼行數:56,代碼來源:RoleAssign.cs

示例10: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			var results = new List<string> ();

			AppendResults (results, Prefix, ec.Module.Evaluator.GetVarNames ());
			AppendResults (results, Prefix, ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith (Prefix));
			AppendResults (results, Prefix, ec.Module.Evaluator.GetUsingList ());
			
			throw new CompletionResult (Prefix, results.ToArray ());
		}
開發者ID:yayanyang,項目名稱:monodevelop,代碼行數:10,代碼來源:complete.cs

示例11: DoResolve

		public override Expression DoResolve (ResolveContext ec)
		{
			ArrayList results = new ArrayList ();

			AppendResults (results, Prefix, Evaluator.GetVarNames ());
			AppendResults (results, Prefix, ec.CurrentTypeDefinition.NamespaceEntry.CompletionGetTypesStartingWith (Prefix));
			AppendResults (results, Prefix, Evaluator.GetUsingList ());
			
			throw new CompletionResult (Prefix, (string []) results.ToArray (typeof (string)));
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:10,代碼來源:complete.cs

示例12: CheckContext

		public static bool CheckContext (ResolveContext ec, Location loc)
		{
			if (!ec.CurrentAnonymousMethod.IsIterator) {
				ec.Report.Error (1621, loc,
					      "The yield statement cannot be used inside " +
					      "anonymous method blocks");
				return false;
			}

			return true;
		}
開發者ID:Tak,項目名稱:monodevelop-novell,代碼行數:11,代碼來源:iterators.cs

示例13: CreateExpressionTree

		public override Expression CreateExpressionTree (ResolveContext ec)
		{
			if (expr_tree != null)
				return expr_tree (ec, mg);

			Arguments args = Arguments.CreateForExpressionTree (ec, arguments,
				new NullLiteral (loc),
				mg.CreateExpressionTree (ec));

			return CreateExpressionFactoryCall (ec, "Call", args);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:11,代碼來源:expression.cs

示例14: Error_ValueCannotBeConverted

		public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl)
		{
			if (!expl && IsLiteral && 
				BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) &&
				BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) {
				ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
					GetValueAsLiteral (), TypeManager.CSharpName (target));
			} else {
				base.Error_ValueCannotBeConverted (ec, target, expl);
			}
		}
開發者ID:rabink,項目名稱:mono,代碼行數:11,代碼來源:constant.cs

示例15: Error_ValueCannotBeConverted

		public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl)
		{
			if (!expl && IsLiteral && type.BuiltinType != BuiltinTypeSpec.Type.Double &&
				BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) &&
				BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) {
				ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
					GetValueAsLiteral (), target.GetSignatureForError ());
			} else {
				base.Error_ValueCannotBeConverted (ec, target, expl);
			}
		}
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:11,代碼來源:constant.cs


注:本文中的Mono.CSharp.ResolveContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。