public void CSharpFullQualifiedDefaultValue()
        {
            DefaultValueExpression toe = ParseUtilCSharp.ParseExpression <DefaultValueExpression>("default(global::MyNamespace.N1.MyType)");

            Assert.IsTrue(toe.TypeReference.IsGlobal);
            Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
        }
Esempio n. 2
0
        public UnifiedElement VisitDefaultValueExpression(
            DefaultValueExpression expr, object data)
        {
            var type = LookupType(expr.Type);

            return(UnifiedDefault.Create(type));
        }
        public void CSharpGenericDefaultValue()
        {
            DefaultValueExpression toe = ParseUtilCSharp.ParseExpression <DefaultValueExpression>("default(MyNamespace.N1.MyType<string>)");

            Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
            Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].Type);
        }
        public void CSharpDefaultValueInReturnStatement()
        {
            ReturnStatement        rs  = ParseUtilCSharp.ParseStatement <ReturnStatement>("return default(T);");
            DefaultValueExpression dve = (DefaultValueExpression)rs.Expression;

            Assert.AreEqual("T", dve.TypeReference.Type);
        }
        public virtual object Visit(DefaultValueExpression defaultValueExpression, object data)
        {
            Debug.Assert(defaultValueExpression != null);
            Debug.Assert(defaultValueExpression.TypeReference != null);

            defaultValueExpression.TypeReference.AcceptVisitor(this, data);
            return(data);
        }
        public void CSharpDefaultValueAsIntializer()
        {
            // This test is failing because we need a resolver for the "default:" / "default(" conflict.
            LocalVariableDeclaration lvd = ParseUtilCSharp.ParseStatement <LocalVariableDeclaration>("T a = default(T);");
            DefaultValueExpression   dve = (DefaultValueExpression)lvd.Variables[0].Initializer;

            Assert.AreEqual("T", dve.TypeReference.Type);
        }
        public void CSharpCodeGenerator_Default()
        {
            var expr      = new DefaultValueExpression(typeof(string));
            var generator = new CSharpCodeGenerator();
            var result    = generator.Write(expr);

            Assert.That.StringEquals("default(string)", result);
        }
        public override object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
        {
            base.VisitDefaultValueExpression(defaultValueExpression, data);
            Expression defaultValue = ExpressionBuilder.CreateDefaultValueForType(defaultValueExpression.TypeReference);

            if (!(defaultValue is DefaultValueExpression))
            {
                ReplaceCurrentNode(defaultValue);
            }
            return(null);
        }
Esempio n. 9
0
        protected virtual IEnumerable <Syntax> TranslateDefaultValueExpression(DefaultValueExpression defaultValueExpression, ILTranslationContext data)
        {
            var ti = defaultValueExpression.Annotation <TypeInformation>()?.InferredType;

            if (ti?.Namespace == nameof(System))
            {
                switch (ti.Name)
                {
                case nameof(Boolean):
                    yield return(new E.BooleanExpression(false));

                    yield break;

                case nameof(Byte):
                case nameof(SByte):
                case nameof(Int16):
                case nameof(UInt16):
                case nameof(Int32):
                case nameof(UInt32):
                case nameof(Int64):
                case nameof(UInt64):
                case nameof(Single):
                case nameof(Double):
                case nameof(Decimal):
                    yield return(new E.NumberExpression(0));

                    yield break;
                }
            }

            if (ti?.IsValueType == true)
            {
                var ct = ti.ResolveClrType();

                if (ct?.IsEnum == true)
                {
                    var n = Enum.GetName(ct, ((IConvertible)0).ToType(Enum.GetUnderlyingType(ct), null));
                    if (n == null)
                    {
                        yield return(new E.NumberExpression(0));
                    }
                    else
                    {
                        yield return(new E.IdentifierExpression(ct.FullName).Property(n));
                    }
                    yield break;
                }
            }

            yield return(new E.NullExpression());

            yield break;
        }
        public override object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
        {
            base.VisitDefaultValueExpression(defaultValueExpression, data);

            IReturnType type = FixTypeReferenceCasing(defaultValueExpression.TypeReference, defaultValueExpression.StartLocation);

            // the VBNetConstructsConvertVisitor will initialize local variables to
            // default(TypeReference).
            // MyType m = null; looks nicer than MyType m = default(MyType))
            // so we replace default(ReferenceType) with null
            if (type != null && type.IsReferenceType == true)
            {
                ReplaceCurrentNode(new PrimitiveExpression(null, "null"));
            }
            return(null);
        }
        public override object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
        {
            base.VisitDefaultValueExpression(defaultValueExpression, data);

            IReturnType type = FixTypeReferenceCasing(defaultValueExpression.TypeReference, defaultValueExpression.StartLocation);

            // the VBNetConstructsConvertVisitor will initialize local variables to
            // default(TypeReference).
            // MyType m = null; looks nicer than MyType m = default(MyType))
            // so we replace default(ReferenceType) with null
            if (type != null && (type.IsDefaultReturnType || type.IsConstructedReturnType))
            {
                IClass c = type.GetUnderlyingClass();
                if (c != null && (c.ClassType == ClassType.Class || c.ClassType == ClassType.Interface || c.ClassType == ClassType.Delegate))
                {
                    ReplaceCurrentNode(new PrimitiveExpression(null, "null"));
                }
            }
            return(null);
        }
Esempio n. 12
0
 public Expression ConvertConstantValue(IType type, object constantValue)
 {
     if (type == null)
         throw new ArgumentNullException("type");
     if (constantValue == null) {
         if (type.IsReferenceType == true) {
             var expr = new NullReferenceExpression();
             if (AddResolveResultAnnotations)
                 expr.AddAnnotation(new ConstantResolveResult(SpecialType.NullType, null));
             return expr;
         } else {
             var expr = new DefaultValueExpression(ConvertType(type));
             if (AddResolveResultAnnotations)
                 expr.AddAnnotation(new ConstantResolveResult(type, null));
             return expr;
         }
     } else if (type.Kind == TypeKind.Enum) {
         return ConvertEnumValue(type, (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, constantValue, false));
     } else {
         return new PrimitiveExpression(constantValue);
     }
 }
Esempio n. 13
0
 public bool HasExpression(ExpressionType type)
 {
     if (type == ExpressionType.ValueExpression)
     {
         return(ValueExpr != null && !ValueExpr.IsEmpty());
     }
     else if (type == ExpressionType.HideExpression)
     {
         return(HiddenExpr != null && !HiddenExpr.IsEmpty());
     }
     else if (type == ExpressionType.DisableExpression)
     {
         return(DisableExpr != null && !DisableExpr.IsEmpty());
     }
     else if (type == ExpressionType.HideExpression)
     {
         return(DefaultValueExpression != null && !DefaultValueExpression.IsEmpty());
     }
     else
     {
         return(false);
     }
 }
        public void CSharpSimpleDefaultValue()
        {
            DefaultValueExpression toe = ParseUtilCSharp.ParseExpression <DefaultValueExpression>("default(T)");

            Assert.AreEqual("T", toe.TypeReference.Type);
        }
Esempio n. 15
0
 internal DefaultValueEmitter(DefaultValueExpression defaultValueExpression, ILGenerator ilGenerator, IOpCodeIndexer instructionsIndexer)
     : base(ilGenerator, instructionsIndexer)
 {
     _defaultValueExpression = defaultValueExpression;
 }
Esempio n. 16
0
 public DefaultValueBlock(IEmitter emitter, DefaultValueExpression defaultValueExpression)
     : base(emitter, defaultValueExpression)
 {
     this.Emitter = emitter;
     this.DefaultValueExpression = defaultValueExpression;
 }
Esempio n. 17
0
 public virtual void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
 {
     //throw this.CreateException(defaultValueExpression);
 }
Esempio n. 18
0
 public override void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
 {
     HandleExpressionNode(defaultValueExpression);
 }
Esempio n. 19
0
			public override void VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression)
			{
				base.VisitDefaultValueExpression (defaultValueExpression);

				var ctor = GetJsConstructor (defaultValueExpression.Type);

				object val = null;

				switch (ctor) {
				case "Number":
					val = 0;
					break;
				case "Boolean":
					val = false;
					break;
				}

				defaultValueExpression.ReplaceWith (new PrimitiveExpression (val));
			}
Esempio n. 20
0
 public override void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
 {
     new DefaultValueBlock(this, defaultValueExpression).Emit();
 }
Esempio n. 21
0
		public virtual void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
		{
			DebugExpression(defaultValueExpression);
			StartNode(defaultValueExpression);
			
			WriteKeyword(DefaultValueExpression.DefaultKeywordRole);
			var braceHelper = BraceHelper.LeftParen(this, CodeBracesRangeFlags.Parentheses);
			Space(policy.SpacesWithinTypeOfParentheses);
			defaultValueExpression.Type.AcceptVisitor(this);
			Space(policy.SpacesWithinTypeOfParentheses);
			braceHelper.RightParen();
			
			EndNode(defaultValueExpression);
		}
Esempio n. 22
0
	void PrimaryExpr(
#line  1862 "cs.ATG" 
out Expression pexpr) {

#line  1864 "cs.ATG" 
		TypeReference type = null;
		Expression expr;
		pexpr = null;
		

#line  1869 "cs.ATG" 
		Location startLocation = la.Location; 
		if (la.kind == 113) {
			lexer.NextToken();

#line  1871 "cs.ATG" 
			pexpr = new PrimitiveExpression(true, "true");  
		} else if (la.kind == 72) {
			lexer.NextToken();

#line  1872 "cs.ATG" 
			pexpr = new PrimitiveExpression(false, "false"); 
		} else if (la.kind == 90) {
			lexer.NextToken();

#line  1873 "cs.ATG" 
			pexpr = new PrimitiveExpression(null, "null");  
		} else if (la.kind == 2) {
			lexer.NextToken();

#line  1874 "cs.ATG" 
			pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
		} else if (
#line  1875 "cs.ATG" 
StartOfQueryExpression()) {
			QueryExpression(
#line  1876 "cs.ATG" 
out pexpr);
		} else if (
#line  1877 "cs.ATG" 
IdentAndDoubleColon()) {
			Identifier();

#line  1878 "cs.ATG" 
			type = new TypeReference(t.val); 
			Expect(10);

#line  1879 "cs.ATG" 
			pexpr = new TypeReferenceExpression(type); 
			Identifier();

#line  1880 "cs.ATG" 
			if (type.Type == "global") { type.IsGlobal = true; type.Type = t.val ?? "?"; } else type.Type += "." + (t.val ?? "?"); 
		} else if (StartOf(19)) {
			Identifier();

#line  1884 "cs.ATG" 
			pexpr = new IdentifierExpression(t.val); 
			if (la.kind == 48 || 
#line  1887 "cs.ATG" 
IsGenericInSimpleNameOrMemberAccess()) {
				if (la.kind == 48) {
					ShortedLambdaExpression(
#line  1886 "cs.ATG" 
(IdentifierExpression)pexpr, out pexpr);
				} else {

#line  1888 "cs.ATG" 
					List<TypeReference> typeList; 
					TypeArgumentList(
#line  1889 "cs.ATG" 
out typeList, false);

#line  1890 "cs.ATG" 
					((IdentifierExpression)pexpr).TypeArguments = typeList; 
				}
			}
		} else if (
#line  1892 "cs.ATG" 
IsLambdaExpression()) {
			LambdaExpression(
#line  1893 "cs.ATG" 
out pexpr);
		} else if (la.kind == 20) {
			lexer.NextToken();
			Expr(
#line  1896 "cs.ATG" 
out expr);
			Expect(21);

#line  1896 "cs.ATG" 
			pexpr = new ParenthesizedExpression(expr); 
		} else if (StartOf(35)) {

#line  1899 "cs.ATG" 
			string val = null; 
			switch (la.kind) {
			case 52: {
				lexer.NextToken();

#line  1900 "cs.ATG" 
				val = "System.Boolean"; 
				break;
			}
			case 54: {
				lexer.NextToken();

#line  1901 "cs.ATG" 
				val = "System.Byte"; 
				break;
			}
			case 57: {
				lexer.NextToken();

#line  1902 "cs.ATG" 
				val = "System.Char"; 
				break;
			}
			case 62: {
				lexer.NextToken();

#line  1903 "cs.ATG" 
				val = "System.Decimal"; 
				break;
			}
			case 66: {
				lexer.NextToken();

#line  1904 "cs.ATG" 
				val = "System.Double"; 
				break;
			}
			case 75: {
				lexer.NextToken();

#line  1905 "cs.ATG" 
				val = "System.Single"; 
				break;
			}
			case 82: {
				lexer.NextToken();

#line  1906 "cs.ATG" 
				val = "System.Int32"; 
				break;
			}
			case 87: {
				lexer.NextToken();

#line  1907 "cs.ATG" 
				val = "System.Int64"; 
				break;
			}
			case 91: {
				lexer.NextToken();

#line  1908 "cs.ATG" 
				val = "System.Object"; 
				break;
			}
			case 102: {
				lexer.NextToken();

#line  1909 "cs.ATG" 
				val = "System.SByte"; 
				break;
			}
			case 104: {
				lexer.NextToken();

#line  1910 "cs.ATG" 
				val = "System.Int16"; 
				break;
			}
			case 108: {
				lexer.NextToken();

#line  1911 "cs.ATG" 
				val = "System.String"; 
				break;
			}
			case 116: {
				lexer.NextToken();

#line  1912 "cs.ATG" 
				val = "System.UInt32"; 
				break;
			}
			case 117: {
				lexer.NextToken();

#line  1913 "cs.ATG" 
				val = "System.UInt64"; 
				break;
			}
			case 120: {
				lexer.NextToken();

#line  1914 "cs.ATG" 
				val = "System.UInt16"; 
				break;
			}
			case 123: {
				lexer.NextToken();

#line  1915 "cs.ATG" 
				val = "System.Void"; 
				break;
			}
			}

#line  1917 "cs.ATG" 
			pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; 
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  1920 "cs.ATG" 
			pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 51) {
			lexer.NextToken();

#line  1922 "cs.ATG" 
			pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 89) {
			NewExpression(
#line  1925 "cs.ATG" 
out pexpr);
		} else if (la.kind == 115) {
			lexer.NextToken();
			Expect(20);
			if (
#line  1929 "cs.ATG" 
NotVoidPointer()) {
				Expect(123);

#line  1929 "cs.ATG" 
				type = new TypeReference("System.Void", true); 
			} else if (StartOf(10)) {
				TypeWithRestriction(
#line  1930 "cs.ATG" 
out type, true, true);
			} else SynErr(208);
			Expect(21);

#line  1932 "cs.ATG" 
			pexpr = new TypeOfExpression(type); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1934 "cs.ATG" 
out type);
			Expect(21);

#line  1934 "cs.ATG" 
			pexpr = new DefaultValueExpression(type); 
		} else if (la.kind == 105) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1935 "cs.ATG" 
out type);
			Expect(21);

#line  1935 "cs.ATG" 
			pexpr = new SizeOfExpression(type); 
		} else if (la.kind == 58) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1936 "cs.ATG" 
out expr);
			Expect(21);

#line  1936 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
		} else if (la.kind == 118) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1937 "cs.ATG" 
out expr);
			Expect(21);

#line  1937 "cs.ATG" 
			pexpr = new UncheckedExpression(expr); 
		} else if (la.kind == 64) {
			lexer.NextToken();
			AnonymousMethodExpr(
#line  1938 "cs.ATG" 
out expr);

#line  1938 "cs.ATG" 
			pexpr = expr; 
		} else SynErr(209);

#line  1940 "cs.ATG" 
		if (pexpr != null) {
		if (pexpr.StartLocation.IsEmpty)
			pexpr.StartLocation = startLocation;
		if (pexpr.EndLocation.IsEmpty)
			pexpr.EndLocation = t.EndLocation;
		}
		
		while (StartOf(36)) {
			if (la.kind == 31 || la.kind == 32) {

#line  1948 "cs.ATG" 
				startLocation = la.Location; 
				if (la.kind == 31) {
					lexer.NextToken();

#line  1950 "cs.ATG" 
					pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				} else if (la.kind == 32) {
					lexer.NextToken();

#line  1951 "cs.ATG" 
					pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				} else SynErr(210);
			} else if (la.kind == 47) {
				PointerMemberAccess(
#line  1954 "cs.ATG" 
out pexpr, pexpr);
			} else if (la.kind == 15) {
				MemberAccess(
#line  1955 "cs.ATG" 
out pexpr, pexpr);
			} else if (la.kind == 20) {
				lexer.NextToken();

#line  1959 "cs.ATG" 
				List<Expression> parameters = new List<Expression>(); 

#line  1960 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
				if (StartOf(26)) {
					Argument(
#line  1961 "cs.ATG" 
out expr);

#line  1961 "cs.ATG" 
					SafeAdd(pexpr, parameters, expr); 
					while (la.kind == 14) {
						lexer.NextToken();
						Argument(
#line  1962 "cs.ATG" 
out expr);

#line  1962 "cs.ATG" 
						SafeAdd(pexpr, parameters, expr); 
					}
				}
				Expect(21);
			} else {

#line  1968 "cs.ATG" 
				List<Expression> indices = new List<Expression>();
				pexpr = new IndexerExpression(pexpr, indices);
				
				lexer.NextToken();
				Expr(
#line  1971 "cs.ATG" 
out expr);

#line  1971 "cs.ATG" 
				SafeAdd(pexpr, indices, expr); 
				while (la.kind == 14) {
					lexer.NextToken();
					Expr(
#line  1972 "cs.ATG" 
out expr);

#line  1972 "cs.ATG" 
					SafeAdd(pexpr, indices, expr); 
				}
				Expect(19);

#line  1975 "cs.ATG" 
				if (pexpr != null) {
				pexpr.StartLocation = startLocation;
				pexpr.EndLocation = t.EndLocation;
				}
				
			}
		}
	}
		public virtual object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) {
			throw new global::System.NotImplementedException("DefaultValueExpression");
		}
Esempio n. 24
0
		public virtual object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) {
			Debug.Assert((defaultValueExpression != null));
			Debug.Assert((defaultValueExpression.TypeReference != null));
			return defaultValueExpression.TypeReference.AcceptVisitor(this, data);
		}
Esempio n. 25
0
        public void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
        {
            JsonObject expression = CreateJsonExpression(defaultValueExpression);
            AddKeyword(expression, DefaultValueExpression.DefaultKeywordRole);
            expression.AddJsonValue("type-info", GenTypeInfo(defaultValueExpression.Type));

            Push(expression);
        }
		public virtual object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) {
			Debug.Assert((defaultValueExpression != null));
			Debug.Assert((defaultValueExpression.TypeReference != null));
			nodeStack.Push(defaultValueExpression.TypeReference);
			defaultValueExpression.TypeReference.AcceptVisitor(this, data);
			defaultValueExpression.TypeReference = ((TypeReference)(nodeStack.Pop()));
			return null;
		}
		public virtual object TrackedVisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) {
			return base.VisitDefaultValueExpression(defaultValueExpression, data);
		}
 public Expression ConvertConstantValue(IType type, object constantValue)
 {
     if (type == null)
         throw new ArgumentNullException("type");
     if (constantValue == null) {
         if (type.IsReferenceType == true) {
             var expr = new NullReferenceExpression();
             if (AddResolveResultAnnotations)
                 expr.AddAnnotation(new ConstantResolveResult(SpecialType.NullType, null));
             return expr;
         } else {
             var expr = new DefaultValueExpression(ConvertType(type));
             if (AddResolveResultAnnotations)
                 expr.AddAnnotation(new ConstantResolveResult(type, null));
             return expr;
         }
     } else if (type.Kind == TypeKind.Enum) {
         return ConvertEnumValue(type, (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, constantValue, false));
     } else {
         return new PrimitiveExpression(constantValue);
     }
 }
Esempio n. 29
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            DefaultValueExpression o = other as DefaultValueExpression;

            return(o != null && this.Type.DoMatch(o.Type, match));
        }
Esempio n. 30
0
 private void Format_Default_Value_Expression(StringBuilder sb, DefaultValueExpression expression)
 {
     sb.Append("default(").Append(FormatterUtility.FormatDataType(expression.ReturnType, document, controller)).Append(")");
 }
 public virtual void VisitDefaultValueExpression(DefaultValueExpression syntax)
 {
     VisitNode(syntax);
 }
 public override StringBuilder VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, int data)
 {
     throw new NotImplementedException();
 }
Esempio n. 33
0
		//
		// Imports System.Reflection parameters
		//
		AParametersCollection CreateParameters (TypeSpec parent, ParameterInfo[] pi, MethodBase method)
		{
			int varargs = method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0 ? 1 : 0;

			if (pi.Length == 0 && varargs == 0)
				return ParametersCompiled.EmptyReadOnlyParameters;

			TypeSpec[] types = new TypeSpec[pi.Length + varargs];
			IParameterData[] par = new IParameterData[pi.Length + varargs];
			bool is_params = false;
			for (int i = 0; i < pi.Length; i++) {
				ParameterInfo p = pi[i];
				Parameter.Modifier mod = 0;
				Expression default_value = null;
				if (p.ParameterType.IsByRef) {
					if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
						mod = Parameter.Modifier.OUT;
					else
						mod = Parameter.Modifier.REF;

					//
					// Strip reference wrapping
					//
					var el = p.ParameterType.GetElementType ();
					types[i] = ImportType (el, new DynamicTypeReader (p));	// TODO: 1-based positio to be csc compatible
				} else if (i == 0 && method.IsStatic && (parent.Modifiers & Modifiers.METHOD_EXTENSION) != 0 &&
					HasAttribute (CustomAttributeData.GetCustomAttributes (method), "ExtensionAttribute", CompilerServicesNamespace)) {
					mod = Parameter.Modifier.This;
					types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));
				} else {
					types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));

					if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
						if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), "ParamArrayAttribute", "System")) {
							mod = Parameter.Modifier.PARAMS;
							is_params = true;
						}
					}

					if (!is_params && p.IsOptional) {
						object value = p.RawDefaultValue;
						var ptype = types[i];
						if ((p.Attributes & ParameterAttributes.HasDefault) != 0 && ptype.Kind != MemberKind.TypeParameter && (value != null || TypeSpec.IsReferenceType (ptype))) {
							if (value == null) {
								default_value = Constant.CreateConstantFromValue (ptype, null, Location.Null);
							} else {
								default_value = ImportParameterConstant (value);

								if (ptype.IsEnum) {
									default_value = new EnumConstant ((Constant) default_value, ptype);
								}
							}

							var attrs = CustomAttributeData.GetCustomAttributes (p);
							for (int ii = 0; ii < attrs.Count; ++ii) {
								var attr = attrs[ii];
								var dt = attr.Constructor.DeclaringType;
								if (dt.Namespace != CompilerServicesNamespace)
									continue;

								if (dt.Name == "CallerLineNumberAttribute" && (ptype.BuiltinType == BuiltinTypeSpec.Type.Int || Convert.ImplicitNumericConversionExists (module.Compiler.BuiltinTypes.Int, ptype)))
									mod |= Parameter.Modifier.CallerLineNumber;
								else if (dt.Name == "CallerFilePathAttribute" && Convert.ImplicitReferenceConversionExists (module.Compiler.BuiltinTypes.String, ptype))
									mod |= Parameter.Modifier.CallerFilePath;
								else if (dt.Name == "CallerMemberNameAttribute" && Convert.ImplicitReferenceConversionExists (module.Compiler.BuiltinTypes.String, ptype))
									mod |= Parameter.Modifier.CallerMemberName;
							}
						} else if (value == Missing.Value) {
							default_value = EmptyExpression.MissingValue;
						} else if (value == null) {
							default_value = new DefaultValueExpression (new TypeExpression (ptype, Location.Null), Location.Null);
						} else if (ptype.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
							default_value = ImportParameterConstant (value);
						}
					}
				}

				par[i] = new ParameterData (p.Name, mod, default_value);
			}

			if (varargs != 0) {
				par[par.Length - 1] = new ArglistParameter (Location.Null);
				types[types.Length - 1] = InternalType.Arglist;
			}

			return method != null ?
				new ParametersImported (par, types, varargs != 0, is_params) :
				new ParametersImported (par, types, is_params);
		}
 internal DefaultValueEmitter(DefaultValueExpression defaultValueExpression, ILGenerator ilGenerator, IOpCodeIndexer instructionsIndexer)
     : base(ilGenerator, instructionsIndexer) {
     _defaultValueExpression = defaultValueExpression;
 }
Esempio n. 35
0
 public override void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
 {
 }
Esempio n. 36
0
 private void VariableInitializer(out Expression initializerExpression)
 {
     TypeReference type = null;
     Expression expr = null;
     initializerExpression = null;
     if (this.StartOf(5))
     {
         this.Expr(out initializerExpression);
     }
     else if (this.la.kind == 0x10)
     {
         this.ArrayInitializer(out initializerExpression);
     }
     else if (this.la.kind == 0x69)
     {
         base.lexer.NextToken();
         this.Type(out type);
         base.Expect(0x12);
         this.Expr(out expr);
         base.Expect(0x13);
         initializerExpression = new StackAllocExpression(type, expr);
     }
     else if (this.la.kind == 0x3e)
     {
         base.lexer.NextToken();
         base.Expect(20);
         this.Type(out type);
         base.Expect(0x15);
         initializerExpression = new DefaultValueExpression(type);
     }
     else
     {
         base.SynErr(0xa7);
     }
 }
Esempio n. 37
0
 public object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
 {
     AddError(defaultValueExpression, "default() is not supported.");
     return(null);
 }
Esempio n. 38
0
 public override StringBuilder VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, int data)
 {
     throw new NotImplementedException();
 }
 public override void VisitDefaultValueExpression(DefaultValueExpression syntax)
 {
     _underlyingVisitor.VisitDefaultValueExpression(syntax);
 }
Esempio n. 40
0
 public override object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
 {
     return(CreateReturnType(defaultValueExpression.TypeReference));
 }
Esempio n. 41
0
        private void PrimaryExpr(out Expression pexpr)
        {
            TypeReference typeReference = null;
            List<TypeReference> types = null;
            Expression expression;
            bool flag = false;
            pexpr = null;
            if (this.la.kind == 0x70)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(true, "true");
            }
            else if (this.la.kind == 0x47)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(false, "false");
            }
            else if (this.la.kind == 0x59)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(null, "null");
            }
            else if (this.la.kind == 2)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(this.t.literalValue, this.t.val);
            }
            else if ((this.la.kind == 1) && (this.Peek(1).kind == 10))
            {
                base.Expect(1);
                typeReference = new TypeReference(this.t.val);
                base.Expect(10);
                pexpr = new TypeReferenceExpression(typeReference);
                base.Expect(1);
                if (typeReference.Type == "global")
                {
                    typeReference.IsGlobal = true;
                    typeReference.Type = this.t.val ?? "?";
                }
                else
                {
                    typeReference.Type = typeReference.Type + "." + (this.t.val ?? "?");
                }
            }
            else if (this.la.kind == 1)
            {
                base.lexer.NextToken();
                pexpr = new IdentifierExpression(this.t.val);
            }
            else if (this.la.kind == 20)
            {
                base.lexer.NextToken();
                this.Expr(out expression);
                base.Expect(0x15);
                pexpr = new ParenthesizedExpression(expression);
            }
            else if (!this.StartOf(0x1a))
            {
                if (this.la.kind == 110)
                {
                    base.lexer.NextToken();
                    pexpr = new ThisReferenceExpression();
                }
                else if (this.la.kind == 50)
                {
                    base.lexer.NextToken();
                    Expression targetObject = new BaseReferenceExpression();
                    if (this.la.kind == 15)
                    {
                        base.lexer.NextToken();
                        base.Expect(1);
                        targetObject = new FieldReferenceExpression(targetObject, this.t.val);
                    }
                    else if (this.la.kind == 0x12)
                    {
                        base.lexer.NextToken();
                        this.Expr(out expression);
                        List<Expression> indices = new List<Expression>();
                        if (expression != null)
                        {
                            indices.Add(expression);
                        }
                        while (this.la.kind == 14)
                        {
                            base.lexer.NextToken();
                            this.Expr(out expression);
                            if (expression != null)
                            {
                                indices.Add(expression);
                            }
                        }
                        base.Expect(0x13);
                        targetObject = new IndexerExpression(targetObject, indices);
                    }
                    else
                    {
                        base.SynErr(0xb3);
                    }
                    pexpr = targetObject;
                }
                else if (this.la.kind == 0x58)
                {
                    base.lexer.NextToken();
                    this.NonArrayType(out typeReference);
                    List<Expression> parameters = new List<Expression>();
                    if (this.la.kind == 20)
                    {
                        base.lexer.NextToken();
                        ObjectCreateExpression expression3 = new ObjectCreateExpression(typeReference, parameters);
                        if (this.StartOf(0x15))
                        {
                            this.Argument(out expression);
                            if (expression != null)
                            {
                                parameters.Add(expression);
                            }
                            while (this.la.kind == 14)
                            {
                                base.lexer.NextToken();
                                this.Argument(out expression);
                                if (expression != null)
                                {
                                    parameters.Add(expression);
                                }
                            }
                        }
                        base.Expect(0x15);
                        pexpr = expression3;
                    }
                    else if (this.la.kind == 0x12)
                    {
                        base.lexer.NextToken();
                        flag = true;
                        ArrayCreateExpression expression4 = new ArrayCreateExpression(typeReference);
                        pexpr = expression4;
                        int item = 0;
                        List<int> list4 = new List<int>();
                        if ((this.la.kind == 14) || (this.la.kind == 0x13))
                        {
                            while (this.la.kind == 14)
                            {
                                base.lexer.NextToken();
                                item++;
                            }
                            base.Expect(0x13);
                            list4.Add(item);
                            item = 0;
                            while (this.la.kind == 0x12)
                            {
                                base.lexer.NextToken();
                                while (this.la.kind == 14)
                                {
                                    base.lexer.NextToken();
                                    item++;
                                }
                                base.Expect(0x13);
                                list4.Add(item);
                                item = 0;
                            }
                            expression4.CreateType.RankSpecifier = list4.ToArray();
                            this.ArrayInitializer(out expression);
                            expression4.ArrayInitializer = (ArrayInitializerExpression) expression;
                        }
                        else if (this.StartOf(5))
                        {
                            this.Expr(out expression);
                            if (expression != null)
                            {
                                parameters.Add(expression);
                            }
                            while (this.la.kind == 14)
                            {
                                base.lexer.NextToken();
                                item++;
                                this.Expr(out expression);
                                if (expression != null)
                                {
                                    parameters.Add(expression);
                                }
                            }
                            base.Expect(0x13);
                            list4.Add(item);
                            expression4.Arguments = parameters;
                            for (item = 0; this.la.kind == 0x12; item = 0)
                            {
                                base.lexer.NextToken();
                                while (this.la.kind == 14)
                                {
                                    base.lexer.NextToken();
                                    item++;
                                }
                                base.Expect(0x13);
                                list4.Add(item);
                            }
                            expression4.CreateType.RankSpecifier = list4.ToArray();
                            if (this.la.kind == 0x10)
                            {
                                this.ArrayInitializer(out expression);
                                expression4.ArrayInitializer = (ArrayInitializerExpression) expression;
                            }
                        }
                        else
                        {
                            base.SynErr(180);
                        }
                    }
                    else
                    {
                        base.SynErr(0xb5);
                    }
                }
                else if (this.la.kind == 0x72)
                {
                    base.lexer.NextToken();
                    base.Expect(20);
                    if (this.NotVoidPointer())
                    {
                        base.Expect(0x7a);
                        typeReference = new TypeReference("void");
                    }
                    else if (this.StartOf(9))
                    {
                        this.TypeWithRestriction(out typeReference, true, true);
                    }
                    else
                    {
                        base.SynErr(0xb6);
                    }
                    base.Expect(0x15);
                    pexpr = new TypeOfExpression(typeReference);
                }
                else if ((this.la.kind == 0x3e) && (this.Peek(1).kind == 20))
                {
                    base.Expect(0x3e);
                    base.Expect(20);
                    this.Type(out typeReference);
                    base.Expect(0x15);
                    pexpr = new DefaultValueExpression(typeReference);
                }
                else if (this.la.kind == 0x68)
                {
                    base.lexer.NextToken();
                    base.Expect(20);
                    this.Type(out typeReference);
                    base.Expect(0x15);
                    pexpr = new SizeOfExpression(typeReference);
                }
                else if (this.la.kind == 0x39)
                {
                    base.lexer.NextToken();
                    base.Expect(20);
                    this.Expr(out expression);
                    base.Expect(0x15);
                    pexpr = new CheckedExpression(expression);
                }
                else if (this.la.kind == 0x75)
                {
                    base.lexer.NextToken();
                    base.Expect(20);
                    this.Expr(out expression);
                    base.Expect(0x15);
                    pexpr = new UncheckedExpression(expression);
                }
                else if (this.la.kind == 0x3f)
                {
                    base.lexer.NextToken();
                    this.AnonymousMethodExpr(out expression);
                    pexpr = expression;
                }
                else
                {
                    base.SynErr(0xb7);
                }
            }
            else
            {
                string typeName = null;
                switch (this.la.kind)
                {
                    case 0x3d:
                        base.lexer.NextToken();
                        typeName = "decimal";
                        break;

                    case 0x41:
                        base.lexer.NextToken();
                        typeName = "double";
                        break;

                    case 0x4a:
                        base.lexer.NextToken();
                        typeName = "float";
                        break;

                    case 0x33:
                        base.lexer.NextToken();
                        typeName = "bool";
                        break;

                    case 0x35:
                        base.lexer.NextToken();
                        typeName = "byte";
                        break;

                    case 0x38:
                        base.lexer.NextToken();
                        typeName = "char";
                        break;

                    case 0x51:
                        base.lexer.NextToken();
                        typeName = "int";
                        break;

                    case 0x56:
                        base.lexer.NextToken();
                        typeName = "long";
                        break;

                    case 90:
                        base.lexer.NextToken();
                        typeName = "object";
                        break;

                    case 0x65:
                        base.lexer.NextToken();
                        typeName = "sbyte";
                        break;

                    case 0x67:
                        base.lexer.NextToken();
                        typeName = "short";
                        break;

                    case 0x6b:
                        base.lexer.NextToken();
                        typeName = "string";
                        break;

                    case 0x73:
                        base.lexer.NextToken();
                        typeName = "uint";
                        break;

                    case 0x74:
                        base.lexer.NextToken();
                        typeName = "ulong";
                        break;

                    case 0x77:
                        base.lexer.NextToken();
                        typeName = "ushort";
                        break;
                }
                this.t.val = "";
                base.Expect(15);
                base.Expect(1);
                pexpr = new FieldReferenceExpression(new TypeReferenceExpression(typeName), this.t.val);
            }
            while ((this.StartOf(0x1b) || (this.IsGenericFollowedBy(15) && this.IsTypeReferenceExpression(pexpr))) || this.IsGenericFollowedBy(20))
            {
                if ((this.la.kind == 0x1f) || (this.la.kind == 0x20))
                {
                    if (this.la.kind == 0x1f)
                    {
                        base.lexer.NextToken();
                        pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement);
                    }
                    else if (this.la.kind == 0x20)
                    {
                        base.lexer.NextToken();
                        pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement);
                    }
                    else
                    {
                        base.SynErr(0xb8);
                    }
                }
                else
                {
                    if (this.la.kind == 0x2f)
                    {
                        base.lexer.NextToken();
                        base.Expect(1);
                        pexpr = new PointerReferenceExpression(pexpr, this.t.val);
                        continue;
                    }
                    if (this.la.kind == 15)
                    {
                        base.lexer.NextToken();
                        base.Expect(1);
                        pexpr = new FieldReferenceExpression(pexpr, this.t.val);
                        continue;
                    }
                    if (this.IsGenericFollowedBy(15) && this.IsTypeReferenceExpression(pexpr))
                    {
                        this.TypeArgumentList(out types, false);
                        base.Expect(15);
                        base.Expect(1);
                        pexpr = new FieldReferenceExpression(this.GetTypeReferenceExpression(pexpr, types), this.t.val);
                        continue;
                    }
                    if (this.la.kind == 20)
                    {
                        base.lexer.NextToken();
                        List<Expression> arguments = new List<Expression>();
                        if (this.StartOf(0x15))
                        {
                            this.Argument(out expression);
                            if (expression != null)
                            {
                                arguments.Add(expression);
                            }
                            while (this.la.kind == 14)
                            {
                                base.lexer.NextToken();
                                this.Argument(out expression);
                                if (expression != null)
                                {
                                    arguments.Add(expression);
                                }
                            }
                        }
                        base.Expect(0x15);
                        pexpr = new InvocationExpression(pexpr, arguments);
                        continue;
                    }
                    if (this.IsGenericFollowedBy(20))
                    {
                        this.TypeArgumentList(out types, false);
                        base.Expect(20);
                        List<Expression> list6 = new List<Expression>();
                        if (this.StartOf(0x15))
                        {
                            this.Argument(out expression);
                            if (expression != null)
                            {
                                list6.Add(expression);
                            }
                            while (this.la.kind == 14)
                            {
                                base.lexer.NextToken();
                                this.Argument(out expression);
                                if (expression != null)
                                {
                                    list6.Add(expression);
                                }
                            }
                        }
                        base.Expect(0x15);
                        pexpr = new InvocationExpression(pexpr, list6, types);
                        continue;
                    }
                    if (flag)
                    {
                        this.Error("element access not allow on array creation");
                    }
                    List<Expression> list7 = new List<Expression>();
                    base.lexer.NextToken();
                    this.Expr(out expression);
                    if (expression != null)
                    {
                        list7.Add(expression);
                    }
                    while (this.la.kind == 14)
                    {
                        base.lexer.NextToken();
                        this.Expr(out expression);
                        if (expression != null)
                        {
                            list7.Add(expression);
                        }
                    }
                    base.Expect(0x13);
                    pexpr = new IndexerExpression(pexpr, list7);
                }
            }
        }
Esempio n. 42
0
            public override void VisitReturnStatement(ReturnStatement returnStatement)
            {
                base.VisitReturnStatement(returnStatement);
                if (skip)
                {
                    return;
                }

                if (returnStatement.Expression.IsNull)
                {
                    var entity = returnStatement.GetParent <EntityDeclaration>();
                    if (entity is Accessor)
                    {
                        entity = entity.GetParent <EntityDeclaration>();
                    }
                    if (entity == null)
                    {
                        return;
                    }
                    AstNode entityNode;
                    var     rr      = GetRequestedReturnType(ctx, returnStatement, out entityNode);
                    var     actions = new List <CodeAction>();
                    if (rr != null)
                    {
                        actions.Add(new CodeAction(ctx.TranslateString("Return default value"), script => {
                            Expression p;
                            if (rr.IsKnownType(KnownTypeCode.Boolean))
                            {
                                p = new PrimitiveExpression(false);
                            }
                            else if (rr.IsKnownType(KnownTypeCode.String))
                            {
                                p = new PrimitiveExpression("");
                            }
                            else if (rr.IsKnownType(KnownTypeCode.Char))
                            {
                                p = new PrimitiveExpression(' ');
                            }
                            else if (rr.IsReferenceType == true)
                            {
                                p = new NullReferenceExpression();
                            }
                            else if (rr.GetDefinition() != null &&
                                     rr.GetDefinition().KnownTypeCode < KnownTypeCode.DateTime)
                            {
                                p = new PrimitiveExpression(0x0);
                            }
                            else
                            {
                                p = new DefaultValueExpression(ctx.CreateTypeSystemAstBuilder(returnStatement).ConvertType(rr));
                            }

                            script.Replace(returnStatement, new ReturnStatement(p));
                        }, returnStatement));
                    }
                    var method = returnStatement.GetParent <MethodDeclaration>();
                    if (method != null)
                    {
                        actions.Add(new CodeAction(ctx.TranslateString("Change method return type to 'void'"), script => {
                            script.Replace(method.ReturnType, new PrimitiveType("void"));
                        }, returnStatement));
                    }

                    AddIssue(
                        returnStatement,
                        string.Format(ctx.TranslateString("`{0}': A return keyword must be followed by any expression when method returns a value"), currentMethodName),
                        actions
                        );
                }
            }
void case_553()
#line 4757 "ps-parser.jay"
{
	  	CheckIsPlayScript("default values", GetLocation(yyVals[-3+yyTop]));
	  
		if (lang_version < LanguageVersion.ISO_2)
			FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
Esempio n. 44
0
		public void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
		{
			StartNode(defaultValueExpression);
			
			WriteKeyword(DefaultValueExpression.DefaultKeywordRole);
			LPar();
			Space(policy.SpacesWithinTypeOfParentheses);
			defaultValueExpression.Type.AcceptVisitor(this);
			Space(policy.SpacesWithinTypeOfParentheses);
			RPar();
			
			EndNode(defaultValueExpression);
		}
Esempio n. 45
0
void case_597()
#line 4345 "cs-parser.jay"
{
		if (lang_version < LanguageVersion.ISO_2)
			FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression");

		yyVal = new DefaultValueExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
		public sealed override object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) {
			BeginVisit(defaultValueExpression);
			object result = TrackedVisitDefaultValueExpression(defaultValueExpression, data);
			EndVisit(defaultValueExpression);
			return result;
		}
Esempio n. 47
0
 public virtual object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
 {
     throw new global::System.NotImplementedException("DefaultValueExpression");
 }
Esempio n. 48
0
		public virtual object Visit (DefaultValueExpression defaultValueExpression)
		{
			return null;
		}
			public override object Visit (Mono.CSharpPs.DefaultValueExpression defaultValueExpression)
			{
				var result = new DefaultValueExpression ();
				result.AddChild (new CSharpTokenNode (Convert (defaultValueExpression.Location), DefaultValueExpression.DefaultKeywordRole), DefaultValueExpression.DefaultKeywordRole);
				var location = LocationsBag.GetLocations (defaultValueExpression);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar);
				result.AddChild (ConvertToType (defaultValueExpression.Expr), Roles.Type);
				if (location != null && location.Count > 1)
					result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar);
				return result;
			}
Esempio n. 50
0
        public void VisitDefaultValueExpression(DefaultValueExpression node)
        {
            VisitChildren(node);

            // Generate the default value now
            var result = resolver.Resolve(node.Type) as TypeResolveResult;
            if (result != null) {
                node.ReplaceWith(CreateDefaultValue(result.Type));
            }
        }
 public virtual object Visit(DefaultValueExpression defaultValueExpression)
 {
     return(null);
 }
Esempio n. 52
0
 public override void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
 {
     new DefaultValueBlock(this, defaultValueExpression).Emit();
 }
Esempio n. 53
0
        /// <summary>
        ///     Translates a default value expression, e.g. "float3()".
        /// </summary>
        public override StringBuilder VisitDefaultValueExpression(DefaultValueExpression defaultValueExpr)
        {
            var type = defaultValueExpr.Type.AcceptVisitor(this);

            return(new StringBuilder().Method(type.ToString(), "0"));
        }
Esempio n. 54
0
 public abstract StringBuilder VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, int data);
		public virtual void VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression)
		{
			VisitChildren (defaultValueExpression);
		}
Esempio n. 56
0
 public DefaultValueBlock(IEmitter emitter, DefaultValueExpression defaultValueExpression)
     : base(emitter, defaultValueExpression)
 {
     this.Emitter = emitter;
     this.DefaultValueExpression = defaultValueExpression;
 }
		public AParametersCollection Inflate (TypeParameterInflator inflator)
		{
			TypeSpec[] inflated_types = null;
			bool default_value = false;

			for (int i = 0; i < Count; ++i) {
				var inflated_param = inflator.Inflate (types[i]);
				if (inflated_types == null) {
					if (inflated_param == types[i])
						continue;

					default_value |= FixedParameters[i].HasDefaultValue;
					inflated_types = new TypeSpec[types.Length];
					Array.Copy (types, inflated_types, types.Length);
				} else {
					if (inflated_param == types[i])
						continue;

					default_value |= FixedParameters[i].HasDefaultValue;
				}

				inflated_types[i] = inflated_param;
			}

			if (inflated_types == null)
				return this;

			var clone = (AParametersCollection) MemberwiseClone ();
			clone.types = inflated_types;

			//
			// Default expression is original expression from the parameter
			// declaration context which can be of nested enum in generic class type.
			// In such case we end up with expression type of G<T>.E and e.g. parameter
			// type of G<int>.E and conversion would fail without inflate in this
			// context.
			//
			if (default_value) {
				clone.parameters = new IParameterData[Count];
				for (int i = 0; i < Count; ++i) {
					var fp = FixedParameters[i];
					clone.FixedParameters[i] = fp;

					if (!fp.HasDefaultValue)
						continue;

					var expr = fp.DefaultValue;

					if (inflated_types[i] == expr.Type)
						continue;

					if (expr is DefaultValueExpression)
						expr = new DefaultValueExpression (new TypeExpression (inflated_types[i], expr.Location), expr.Location);
					else if (expr is Constant)
						expr = Constant.CreateConstantFromValue (inflated_types[i], ((Constant) expr).GetValue (), expr.Location);

					clone.FixedParameters[i] = new ParameterData (fp.Name, fp.ModFlags, expr);
				}
			}

			return clone;
		}
Esempio n. 58
0
 public virtual void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression)
 {
     //throw this.CreateException(defaultValueExpression);
 }