本文整理汇总了C#中Mono.CSharp.TypeParameterInflator.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# TypeParameterInflator.Inflate方法的具体用法?C# TypeParameterInflator.Inflate怎么用?C# TypeParameterInflator.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.TypeParameterInflator
的用法示例。
在下文中一共展示了TypeParameterInflator.Inflate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeGenericMethod
public MethodSpec MakeGenericMethod (IMemberContext context, params TypeSpec[] targs)
{
if (targs == null)
throw new ArgumentNullException ();
// TODO MemberCache
// if (generic_intances != null && generic_intances.TryGetValue (targs, out ginstance))
// return ginstance;
//if (generic_intances == null)
// generic_intances = new Dictionary<TypeSpec[], Method> (TypeSpecArrayComparer.Default);
var inflator = new TypeParameterInflator (context, DeclaringType, GenericDefinition.TypeParameters, targs);
var inflated = (MethodSpec) MemberwiseClone ();
inflated.declaringType = inflator.TypeInstance;
inflated.returnType = inflator.Inflate (returnType);
inflated.parameters = parameters.Inflate (inflator);
inflated.targs = targs;
inflated.constraints = TypeParameterSpec.InflateConstraints (inflator, constraints ?? GenericDefinition.TypeParameters);
inflated.state |= StateFlags.PendingMakeMethod;
// if (inflated.parent == null)
// inflated.parent = parent;
//generic_intances.Add (targs, inflated);
return inflated;
}
示例2: InflateMember
public override MemberSpec InflateMember (TypeParameterInflator inflator)
{
var fs = (FieldSpec) base.InflateMember (inflator);
fs.memberType = inflator.Inflate (memberType);
return fs;
}
示例3: InflateMember
public override MemberSpec InflateMember (TypeParameterInflator inflator)
{
var ps = (PropertySpec) base.InflateMember (inflator);
ps.memberType = inflator.Inflate (memberType);
return ps;
}
示例4: InflateMember
public override MemberSpec InflateMember (TypeParameterInflator inflator)
{
var ms = (MethodSpec) base.InflateMember (inflator);
ms.inflatedMetaInfo = null;
ms.returnType = inflator.Inflate (returnType);
ms.parameters = parameters.Inflate (inflator);
if (IsGeneric)
ms.constraints = TypeParameterSpec.InflateConstraints (inflator, Constraints);
return ms;
}
示例5: Inflate
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;
var c = expr as Constant;
if (c != null) {
//
// It may fail we are inflating before type validation is done
//
c = Constant.ExtractConstantFromValue (inflated_types[i], c.GetValue (), expr.Location);
if (c == null)
expr = new DefaultValueExpression (new TypeExpression (inflated_types[i], expr.Location), expr.Location);
else
expr = c;
} else if (expr is DefaultValueExpression)
expr = new DefaultValueExpression (new TypeExpression (inflated_types[i], expr.Location), expr.Location);
clone.FixedParameters[i] = new ParameterData (fp.Name, fp.ModFlags, expr);
}
}
return clone;
}
示例6: Inflate
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] is DefaultValueExpression;
inflated_types = new TypeSpec[types.Length];
Array.Copy (types, inflated_types, types.Length);
}
inflated_types[i] = inflated_param;
}
if (inflated_types == null)
return this;
var clone = (AParametersCollection) MemberwiseClone ();
clone.types = inflated_types;
if (default_value) {
for (int i = 0; i < Count; ++i) {
var dve = clone.FixedParameters[i] as DefaultValueExpression;
if (dve != null) {
throw new NotImplementedException ("net");
// clone.FixedParameters [i].DefaultValue = new DefaultValueExpression ();
}
}
}
return clone;
}
示例7: InflateMember
public override MemberSpec InflateMember (TypeParameterInflator inflator)
{
var es = (EventSpec) base.InflateMember (inflator);
es.MemberType = inflator.Inflate (MemberType);
return es;
}
示例8: InflateConstraints
public void InflateConstraints (TypeParameterInflator inflator, TypeParameterSpec tps)
{
tps.BaseType = inflator.Inflate (BaseType);
if (ifaces != null) {
tps.ifaces = new List<TypeSpec> (ifaces.Count);
for (int i = 0; i < ifaces.Count; ++i)
tps.ifaces.Add (inflator.Inflate (ifaces[i]));
}
if (targs != null) {
tps.targs = new TypeSpec[targs.Length];
for (int i = 0; i < targs.Length; ++i)
tps.targs[i] = inflator.Inflate (targs[i]);
}
}
示例9: InitializeMemberCache
protected override void InitializeMemberCache (bool onlyTypes)
{
if (cache == null)
cache = new MemberCache (onlyTypes ? open_type.MemberCacheTypes : open_type.MemberCache);
TypeParameterSpec[] tparams_full;
TypeSpec[] targs_full = targs;
if (IsNested) {
//
// Special case is needed when we are inflating an open type (nested type definition)
// on inflated parent. Consider following case
//
// Foo<T>.Bar<U> => Foo<string>.Bar<U>
//
// Any later inflation of Foo<string>.Bar<U> has to also inflate T if used inside Bar<U>
//
List<TypeSpec> merged_targs = null;
List<TypeParameterSpec> merged_tparams = null;
var type = DeclaringType;
do {
if (type.TypeArguments.Length > 0) {
if (merged_targs == null) {
merged_targs = new List<TypeSpec> ();
merged_tparams = new List<TypeParameterSpec> ();
if (targs.Length > 0) {
merged_targs.AddRange (targs);
merged_tparams.AddRange (open_type.MemberDefinition.TypeParameters);
}
}
merged_tparams.AddRange (type.MemberDefinition.TypeParameters);
merged_targs.AddRange (type.TypeArguments);
}
type = type.DeclaringType;
} while (type != null);
if (merged_targs != null) {
// Type arguments are not in the right order but it should not matter in this case
targs_full = merged_targs.ToArray ();
tparams_full = merged_tparams.ToArray ();
} else if (targs.Length == 0) {
tparams_full = TypeParameterSpec.EmptyTypes;
} else {
tparams_full = open_type.MemberDefinition.TypeParameters;
}
} else if (targs.Length == 0) {
tparams_full = TypeParameterSpec.EmptyTypes;
} else {
tparams_full = open_type.MemberDefinition.TypeParameters;
}
var inflator = new TypeParameterInflator (this, tparams_full, targs_full);
//
// Two stage inflate due to possible nested types recursive
// references
//
// class A<T> {
// B b;
// class B {
// T Value;
// }
// }
//
// When resolving type of `b' members of `B' cannot be
// inflated because are not yet available in membercache
//
if ((state & StateFlags.PendingMemberCacheMembers) == 0) {
open_type.MemberCacheTypes.InflateTypes (cache, inflator);
//
// Inflate any implemented interfaces
//
if (open_type.Interfaces != null) {
ifaces = new List<TypeSpec> (open_type.Interfaces.Count);
foreach (var iface in open_type.Interfaces) {
var iface_inflated = inflator.Inflate (iface);
AddInterface (iface_inflated);
}
}
//
// Handles the tricky case of recursive nested base generic type
//
// class A<T> : Base<A<T>.Nested> {
// class Nested {}
// }
//
// When inflating A<T>. base type is not yet known, secondary
// inflation is required (not common case) once base scope
// is known
//
if (open_type.BaseType == null) {
if (IsClass)
state |= StateFlags.PendingBaseTypeInflate;
} else {
BaseType = inflator.Inflate (open_type.BaseType);
}
} else if ((state & StateFlags.PendingBaseTypeInflate) != 0) {
//.........这里部分代码省略.........
示例10: InflateMember
public override MemberSpec InflateMember(TypeParameterInflator inflator)
{
var tps = (TypeParameterSpec) MemberwiseClone ();
tps.BaseType = inflator.Inflate (BaseType);
if (ifaces != null) {
tps.ifaces = new TypeSpec[ifaces.Count];
for (int i = 0; i < ifaces.Count; ++i)
tps.ifaces[i] = inflator.Inflate (ifaces[i]);
}
if (targs != null) {
tps.targs = new TypeSpec[targs.Length];
for (int i = 0; i < targs.Length; ++i)
tps.targs[i] = inflator.Inflate (targs[i]);
}
return tps;
}