本文整理汇总了C#中System.TypeSpec.GetMetaInfo方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSpec.GetMetaInfo方法的具体用法?C# TypeSpec.GetMetaInfo怎么用?C# TypeSpec.GetMetaInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TypeSpec
的用法示例。
在下文中一共展示了TypeSpec.GetMetaInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginCatchBlock
public void BeginCatchBlock (TypeSpec type)
{
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
ig.BeginCatchBlock (type.GetMetaInfo ());
}
示例2: DeclareLocal
public LocalBuilder DeclareLocal (TypeSpec type, bool pinned)
{
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
return ig.DeclareLocal (type.GetMetaInfo (), pinned);
}
示例3: AddTypeForwarder
public void AddTypeForwarder (TypeSpec type, Location loc)
{
try {
if (add_type_forwarder == null) {
add_type_forwarder = typeof (AssemblyBuilder).GetMethod ("AddTypeForwarder", BindingFlags.NonPublic | BindingFlags.Instance);
}
add_type_forwarder.Invoke (builder, new object[] { type.GetMetaInfo () });
} catch {
ctx.Report.RuntimeMissingSupport (loc, "TypeForwardedToAttribute");
}
}
示例4: ContainsGenericParameters
// TODO: Implement correctly
public static bool ContainsGenericParameters (TypeSpec type)
{
return type.GetMetaInfo ().ContainsGenericParameters;
}
示例5: EmitStoreFromPtr
//
// The stack contains the pointer and the value of type `type'
//
public void EmitStoreFromPtr (TypeSpec type)
{
if (type.IsEnum)
type = EnumSpec.GetUnderlyingType (type);
if (type == TypeManager.int32_type || type == TypeManager.uint32_type)
ig.Emit (OpCodes.Stind_I4);
else if (type == TypeManager.int64_type || type == TypeManager.uint64_type)
ig.Emit (OpCodes.Stind_I8);
else if (type == TypeManager.char_type || type == TypeManager.short_type ||
type == TypeManager.ushort_type)
ig.Emit (OpCodes.Stind_I2);
else if (type == TypeManager.float_type)
ig.Emit (OpCodes.Stind_R4);
else if (type == TypeManager.double_type)
ig.Emit (OpCodes.Stind_R8);
else if (type == TypeManager.byte_type || type == TypeManager.sbyte_type ||
type == TypeManager.bool_type)
ig.Emit (OpCodes.Stind_I1);
else if (type == TypeManager.intptr_type)
ig.Emit (OpCodes.Stind_I);
else if (TypeManager.IsStruct (type) || TypeManager.IsGenericParameter (type))
ig.Emit (OpCodes.Stobj, type.GetMetaInfo ());
else
ig.Emit (OpCodes.Stind_Ref);
}
示例6: BeginCatchBlock
public void BeginCatchBlock (TypeSpec type)
{
ig.BeginCatchBlock (type.GetMetaInfo ());
}
示例7: EncodeTypeName
public void EncodeTypeName (TypeSpec type)
{
var old_type = type.GetMetaInfo ();
Encode (type.MemberDefinition.IsImported ? old_type.AssemblyQualifiedName : old_type.FullName);
}
示例8: GetReferenceType
//
// Gets the reference to T version of the Type (T&)
//
public static Type GetReferenceType(TypeSpec t)
{
return t.GetMetaInfo ().MakeByRefType ();
}
示例9: DeclareLocal
public LocalBuilder DeclareLocal (TypeSpec type, bool pinned)
{
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
if (pinned) {
//
// This is for .net compatibility. I am not sure why pinned
// pointer temps are converted to & even if they are pointers to
// pointers.
//
var pt = type as PointerContainer;
if (pt != null) {
type = pt.Element;
if (type.Kind == MemberKind.Void)
type = Module.Compiler.BuiltinTypes.IntPtr;
return ig.DeclareLocal (type.GetMetaInfo ().MakeByRefType (), true);
}
}
return ig.DeclareLocal (type.GetMetaInfo (), pinned);
}
示例10: GetSignatureForDoc
static string GetSignatureForDoc (TypeSpec type)
{
var tp = type as TypeParameterSpec;
if (tp != null) {
int c = 0;
type = type.DeclaringType;
while (type != null && type.DeclaringType != null) {
type = type.DeclaringType;
c += type.MemberDefinition.TypeParametersCount;
}
var prefix = tp.IsMethodOwned ? "``" : "`";
return prefix + (c + tp.DeclaredPosition);
}
var pp = type as PointerContainer;
if (pp != null)
return GetSignatureForDoc (pp.Element) + "*";
ArrayContainer ap = type as ArrayContainer;
if (ap != null)
return GetSignatureForDoc (ap.Element) +
ArrayContainer.GetPostfixSignature (ap.Rank);
if (TypeManager.IsGenericType (type)) {
string g = type.MemberDefinition.Namespace;
if (g != null && g.Length > 0)
g += '.';
int idx = type.Name.LastIndexOf ('`');
g += (idx < 0 ? type.Name : type.Name.Substring (0, idx)) + '{';
int argpos = 0;
foreach (TypeSpec t in TypeManager.GetTypeArguments (type))
g += (argpos++ > 0 ? "," : String.Empty) + GetSignatureForDoc (t);
g += '}';
return g;
}
string name = type.GetMetaInfo ().FullName != null ? type.GetMetaInfo ().FullName : type.Name;
return name.Replace ("+", ".").Replace ('&', '@');
}
示例11: ExactInference
//
// 26.3.3.8 Exact Inference
//
public int ExactInference (TypeSpec u, TypeSpec v)
{
// If V is an array type
if (v.IsArray) {
if (!u.IsArray)
return 0;
// TODO MemberCache: GetMetaInfo ()
if (u.GetMetaInfo ().GetArrayRank () != v.GetMetaInfo ().GetArrayRank ())
return 0;
return ExactInference (TypeManager.GetElementType (u), TypeManager.GetElementType (v));
}
// If V is constructed type and U is constructed type
if (TypeManager.IsGenericType (v)) {
if (!TypeManager.IsGenericType (u))
return 0;
TypeSpec [] ga_u = TypeManager.GetTypeArguments (u);
TypeSpec [] ga_v = TypeManager.GetTypeArguments (v);
if (ga_u.Length != ga_v.Length)
return 0;
int score = 0;
for (int i = 0; i < ga_u.Length; ++i)
score += ExactInference (ga_u [i], ga_v [i]);
return score > 0 ? 1 : 0;
}
// If V is one of the unfixed type arguments
int pos = IsUnfixed (v);
if (pos == -1)
return 0;
AddToBounds (new BoundInfo (u, BoundKind.Exact), pos);
return 1;
}
示例12: EmitLoadFromPtr
//
// Load the object from the pointer.
//
public void EmitLoadFromPtr (TypeSpec type)
{
if (type.Kind == MemberKind.Enum)
type = EnumSpec.GetUnderlyingType (type);
switch (type.BuiltinType) {
case BuiltinTypeSpec.Type.Int:
ig.Emit (OpCodes.Ldind_I4);
break;
case BuiltinTypeSpec.Type.UInt:
ig.Emit (OpCodes.Ldind_U4);
break;
case BuiltinTypeSpec.Type.Short:
ig.Emit (OpCodes.Ldind_I2);
break;
case BuiltinTypeSpec.Type.UShort:
case BuiltinTypeSpec.Type.Char:
ig.Emit (OpCodes.Ldind_U2);
break;
case BuiltinTypeSpec.Type.Byte:
ig.Emit (OpCodes.Ldind_U1);
break;
case BuiltinTypeSpec.Type.SByte:
case BuiltinTypeSpec.Type.Bool:
ig.Emit (OpCodes.Ldind_I1);
break;
case BuiltinTypeSpec.Type.ULong:
case BuiltinTypeSpec.Type.Long:
ig.Emit (OpCodes.Ldind_I8);
break;
case BuiltinTypeSpec.Type.Float:
ig.Emit (OpCodes.Ldind_R4);
break;
case BuiltinTypeSpec.Type.Double:
ig.Emit (OpCodes.Ldind_R8);
break;
case BuiltinTypeSpec.Type.IntPtr:
ig.Emit (OpCodes.Ldind_I);
break;
default:
switch (type.Kind) {
case MemberKind.Struct:
case MemberKind.TypeParameter:
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
ig.Emit (OpCodes.Ldobj, type.GetMetaInfo ());
break;
case MemberKind.PointerType:
ig.Emit (OpCodes.Ldind_I);
break;
default:
ig.Emit (OpCodes.Ldind_Ref);
break;
}
break;
}
if (TrackStackTypes) {
// TODO: test for async when `this' can be used inside structs
SetStackType (type);
}
}
示例13: Emit
public void Emit (OpCode opcode, TypeSpec type)
{
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
ig.Emit (opcode, type.GetMetaInfo ());
if (TrackStackTypes) {
switch (opcode.StackBehaviourPush) {
case StackBehaviour.Push0:
// Nothing
break;
case StackBehaviour.Pushi:
SetStackType (ReferenceContainer.MakeType (Module, type));
break;
case StackBehaviour.Push1:
SetStackType (type);
break;
default:
if (opcode == OpCodes.Box) {
SetStackType (Module.Compiler.BuiltinTypes.Object);
} else if (opcode == OpCodes.Castclass) {
SetStackType (type);
} else {
throw new NotImplementedException (opcode.Name);
}
break;
}
}
}
示例14: Emit
public void Emit (OpCode opcode, TypeSpec type)
{
if (IsAnonymousStoreyMutateRequired)
type = CurrentAnonymousMethod.Storey.Mutator.Mutate (type);
ig.Emit (opcode, type.GetMetaInfo ());
}
示例15: GetSignatureForDoc
static string GetSignatureForDoc(TypeSpec type)
{
var tp = type as TypeParameterSpec;
if (tp != null) {
var prefix = tp.IsMethodOwned ? "``" : "`";
return prefix + tp.DeclaredPosition;
}
if (TypeManager.IsGenericType (type)) {
string g = type.MemberDefinition.Namespace;
if (g != null && g.Length > 0)
g += '.';
int idx = type.Name.LastIndexOf ('`');
g += (idx < 0 ? type.Name : type.Name.Substring (0, idx)) + '{';
int argpos = 0;
foreach (TypeSpec t in TypeManager.GetTypeArguments (type))
g += (argpos++ > 0 ? "," : String.Empty) + GetSignatureForDoc (t);
g += '}';
return g;
}
string name = type.GetMetaInfo ().FullName != null ? type.GetMetaInfo ().FullName : type.Name;
return name.Replace ("+", ".").Replace ('&', '@');
}