本文整理汇总了C#中Mono.CSharp.MethodData类的典型用法代码示例。如果您正苦于以下问题:C# MethodData类的具体用法?C# MethodData怎么用?C# MethodData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodData类属于Mono.CSharp命名空间,在下文中一共展示了MethodData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit ()
{
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
Compiler.PredefinedAttributes.CompilerGenerated.EmitAttribute (MethodBuilder);
if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
Compiler.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);
if (ReturnType == InternalType.Dynamic) {
return_attributes = new ReturnParameter (this, MethodBuilder, Location);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
} else if (ReturnType.HasDynamicElement) {
return_attributes = new ReturnParameter (this, MethodBuilder, Location);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType);
}
if (OptAttributes != null)
OptAttributes.Emit ();
if (declarative_security != null) {
foreach (var de in declarative_security) {
MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
}
}
if (MethodData != null)
MethodData.Emit (Parent);
base.Emit ();
Block = null;
MethodData = null;
}
示例2: Emit
public override void Emit ()
{
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (MethodBuilder);
if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
PredefinedAttributes.Get.DebuggerHidden.EmitAttribute (MethodBuilder);
if (TypeManager.IsDynamicType (ReturnType)) {
return_attributes = new ReturnParameter (MethodBuilder, Location);
return_attributes.EmitPredefined (PredefinedAttributes.Get.Dynamic, Location);
}
if (OptAttributes != null)
OptAttributes.Emit ();
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
MethodBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
}
}
if (MethodData != null)
MethodData.Emit (Parent);
base.Emit ();
Block = null;
MethodData = null;
}
示例3: IsInterfaceMethod
/// <summary>
/// Whether the specified method is an interface method implementation
/// </summary>
public MethodSpec IsInterfaceMethod(MemberName name, TypeSpec ifaceType, MethodData method)
{
return InterfaceMethod (name, ifaceType, method, Operation.Lookup);
}
示例4: IsInterfaceMethod
/// <summary>
/// Whether the specified method is an interface method implementation
/// </summary>
public MethodSpec IsInterfaceMethod (MemberName name, TypeSpec ifaceType, MethodData method, out MethodSpec ambiguousCandidate, ref bool optional)
{
return InterfaceMethod (name, ifaceType, method, Operation.Lookup, out ambiguousCandidate, ref optional);
}
示例5: InterfaceMethod
/// <remarks>
/// If a method in Type `t' (or null to look in all interfaces
/// and the base abstract class) with name `Name', return type `ret_type' and
/// arguments `args' implements an interface, this method will
/// return the MethodInfo that this method implements.
///
/// If `name' is null, we operate solely on the method's signature. This is for
/// instance used when implementing indexers.
///
/// The `Operation op' controls whether to lookup, clear the pending bit, or clear
/// all the methods with the given signature.
///
/// The `MethodInfo need_proxy' is used when we're implementing an interface's
/// indexer in a class. If the new indexer's IndexerName does not match the one
/// that was used in the interface, then we always need to create a proxy for it.
///
/// </remarks>
public MethodSpec InterfaceMethod (MemberName name, TypeSpec iType, MethodData method, Operation op, out MethodSpec ambiguousCandidate, ref bool optional)
{
ambiguousCandidate = null;
if (pending_implementations == null)
return null;
TypeSpec ret_type = method.method.ReturnType;
ParametersCompiled args = method.method.ParameterInfo;
bool is_indexer = method.method is Indexer.SetIndexerMethod || method.method is Indexer.GetIndexerMethod;
MethodSpec m;
foreach (TypeAndMethods tm in pending_implementations){
if (!(iType == null || tm.type == iType))
continue;
int method_count = tm.methods.Count;
for (int i = 0; i < method_count; i++){
m = tm.methods [i];
if (m == null)
continue;
if (is_indexer) {
if (!m.IsAccessor || m.Parameters.IsEmpty)
continue;
} else {
if (name.Name != m.Name)
continue;
if (m.Arity != name.Arity)
continue;
}
if (!TypeSpecComparer.Override.IsEqual (m.Parameters, args))
continue;
if (!TypeSpecComparer.Override.IsEqual (m.ReturnType, ret_type)) {
tm.found[i] = method;
continue;
}
//
// `need_proxy' is not null when we're implementing an
// interface indexer and this is Clear(One/All) operation.
//
// If `name' is null, then we do a match solely based on the
// signature and not on the name (this is done in the Lookup
// for an interface indexer).
//
if (op != Operation.Lookup) {
if (m.IsAccessor != method.method.IsAccessor)
continue;
// If `t != null', then this is an explicitly interface
// implementation and we can always clear the method.
// `need_proxy' is not null if we're implementing an
// interface indexer. In this case, we need to create
// a proxy if the implementation's IndexerName doesn't
// match the IndexerName in the interface.
if (m.DeclaringType.IsInterface && iType == null && name.Name != m.Name) { // TODO: This is very expensive comparison
tm.need_proxy[i] = method.method.Spec;
} else {
tm.methods[i] = null;
}
} else {
tm.found [i] = method;
optional = tm.optional;
}
if (op == Operation.Lookup && name.ExplicitInterface != null && ambiguousCandidate == null) {
ambiguousCandidate = m;
continue;
}
//
// Lookups and ClearOne return
//
if (op != Operation.ClearAll)
return m;
}
// If a specific type was requested, we can stop now.
//.........这里部分代码省略.........
示例6: Define
public virtual MethodBuilder Define (DeclSpace parent)
{
parameters.Resolve (this);
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
if (!method_data.Define (parent, method.GetFullName (MemberName), Report))
return null;
MethodBuilder mb = method_data.MethodBuilder;
ParameterInfo.ApplyAttributes (mb);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags);
Spec.IsAccessor = true;
return mb;
}
示例7: Define
public virtual MethodBuilder Define (TypeContainer parent)
{
// Fill in already resolved event type to speed things up and
// avoid confusing duplicate errors
((Parameter) parameters.FixedParameters[0]).Type = method.member_type;
parameters.Types = new TypeSpec[] { method.member_type };
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName)))
return null;
method_data.DefineMethodBuilder (parent.PartialContainer, ParameterInfo);
if (Compiler.Settings.WriteMetadataOnly)
block = null;
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, method.ModFlags);
Spec.IsAccessor = true;
return method_data.MethodBuilder;
}
示例8: Define
public override bool Define (TypeContainer parent)
{
if (!DoDefine (parent))
return false;
if (!CheckBase (parent))
return false;
flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName;
if (Get != null) {
Type [] parameters = TypeManager.NoTypes;
InternalParameters ip = new InternalParameters (
parent, Parameters.EmptyReadOnlyParameters);
GetData = new MethodData (this, "get", MemberType,
parameters, ip, CallingConventions.Standard,
Get.OptAttributes, ModFlags, flags, false);
if (!GetData.Define (parent))
return false;
GetBuilder = GetData.MethodBuilder;
}
if (Set != null) {
Type [] parameters = new Type [1];
parameters [0] = MemberType;
Parameter [] parms = new Parameter [1];
parms [0] = new Parameter (Type, "value", Parameter.Modifier.NONE, null);
InternalParameters ip = new InternalParameters (
parent, new Parameters (parms, null, Location));
SetData = new MethodData (this, "set", TypeManager.void_type,
parameters, ip, CallingConventions.Standard,
Set.OptAttributes, ModFlags, flags, false);
if (!SetData.Define (parent))
return false;
SetBuilder = SetData.MethodBuilder;
SetBuilder.DefineParameter (1, ParameterAttributes.None, "value");
}
// FIXME - PropertyAttributes.HasDefault ?
PropertyAttributes prop_attr =
PropertyAttributes.RTSpecialName |
PropertyAttributes.SpecialName;
if (!IsExplicitImpl){
PropertyBuilder = parent.TypeBuilder.DefineProperty (
Name, prop_attr, MemberType, null);
if (Get != null)
PropertyBuilder.SetGetMethod (GetBuilder);
if (Set != null)
PropertyBuilder.SetSetMethod (SetBuilder);
//
// HACK for the reasons exposed above
//
if (!TypeManager.RegisterProperty (PropertyBuilder, GetBuilder, SetBuilder)) {
Report.Error (
111, Location,
"Class `" + parent.Name +
"' already contains a definition for the property `" +
Name + "'");
return false;
}
}
return true;
}
示例9: InterfaceMethod
/// <remarks>
/// If a method in Type `t' (or null to look in all interfaces
/// and the base abstract class) with name `Name', return type `ret_type' and
/// arguments `args' implements an interface, this method will
/// return the MethodInfo that this method implements.
///
/// If `name' is null, we operate solely on the method's signature. This is for
/// instance used when implementing indexers.
///
/// The `Operation op' controls whether to lookup, clear the pending bit, or clear
/// all the methods with the given signature.
///
/// The `MethodInfo need_proxy' is used when we're implementing an interface's
/// indexer in a class. If the new indexer's IndexerName does not match the one
/// that was used in the interface, then we always need to create a proxy for it.
///
/// </remarks>
public MethodInfo InterfaceMethod (string name, Type iType, MethodData method, Operation op)
{
if (pending_implementations == null)
return null;
Type ret_type = method.method.ReturnType;
ParametersCompiled args = method.method.ParameterInfo;
int arg_len = args.Count;
bool is_indexer = method.method is Indexer.SetIndexerMethod || method.method is Indexer.GetIndexerMethod;
foreach (TypeAndMethods tm in pending_implementations){
if (!(iType == null || tm.type == iType))
continue;
int method_count = tm.methods.Length;
MethodInfo m;
for (int i = 0; i < method_count; i++){
m = tm.methods [i];
if (m == null)
continue;
//
// Check if we have the same parameters
//
if (tm.args [i] == null && arg_len != 0)
continue;
if (tm.args [i] != null && tm.args [i].Length != arg_len)
continue;
string mname = TypeManager.GetMethodName (m);
//
// `need_proxy' is not null when we're implementing an
// interface indexer and this is Clear(One/All) operation.
//
// If `name' is null, then we do a match solely based on the
// signature and not on the name (this is done in the Lookup
// for an interface indexer).
//
if (is_indexer) {
IMethodData md = TypeManager.GetMethod (m);
if (md != null) {
if (!(md is Indexer.SetIndexerMethod || md is Indexer.GetIndexerMethod))
continue;
} else {
if (TypeManager.GetPropertyFromAccessor (m) == null)
continue;
}
} else if (name != mname) {
continue;
}
int j;
for (j = 0; j < arg_len; j++) {
if (!TypeManager.IsEqual (tm.args [i][j], args.Types [j]))
break;
if (tm.mods [i][j] == args.FixedParameters [j].ModFlags)
continue;
// The modifiers are different, but if one of them
// is a PARAMS modifier, and the other isn't, ignore
// the difference.
if (tm.mods [i][j] != Parameter.Modifier.PARAMS &&
args.FixedParameters [j].ModFlags != Parameter.Modifier.PARAMS)
break;
}
if (j != arg_len)
continue;
Type rt = TypeManager.TypeToCoreType (m.ReturnType);
if (!TypeManager.IsEqual (ret_type, rt) &&
!(ret_type == null && rt == TypeManager.void_type) &&
!(rt == null && ret_type == TypeManager.void_type)) {
tm.found [i] = method;
continue;
}
if (op != Operation.Lookup) {
// If `t != null', then this is an explicitly interface
// implementation and we can always clear the method.
//.........这里部分代码省略.........
示例10: IsInterfaceMethod
/// <summary>
/// Whether the specified method is an interface method implementation
/// </summary>
public MethodInfo IsInterfaceMethod (string name, Type ifaceType, MethodData method)
{
return InterfaceMethod (name, ifaceType, method, Operation.Lookup);
}
示例11: Define
public virtual MethodBuilder Define (DeclSpace parent)
{
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
if (!method_data.Define (parent, method.GetFullName (MemberName), Report))
return null;
MethodBuilder mb = method_data.MethodBuilder;
ParameterInfo.ApplyAttributes (mb);
return mb;
}
示例12: Define
public override void Define (TypeContainer parent)
{
base.Define (parent);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, ModFlags);
method_data = new MethodData (method, ModFlags, flags, this);
method_data.Define (parent.PartialContainer, method.GetFullName (MemberName));
}
示例13: Define
public override bool Define ()
{
if (!base.Define ())
return false;
if (!CheckBase ())
return false;
MemberKind kind;
if (this is Operator)
kind = MemberKind.Operator;
else if (this is Destructor)
kind = MemberKind.Destructor;
else
kind = MemberKind.Method;
if (IsPartialDefinition) {
caching_flags &= ~Flags.Excluded_Undetected;
caching_flags |= Flags.Excluded;
// Add to member cache only when a partial method implementation has not been found yet
if ((caching_flags & Flags.PartialDefinitionExists) == 0) {
// MethodBase mb = new PartialMethodDefinitionInfo (this);
spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, null, parameters, ModFlags);
if (MemberName.Arity > 0) {
spec.IsGeneric = true;
// TODO: Have to move DefineMethod after Define (ideally to Emit)
throw new NotImplementedException ("Generic partial methods");
}
Parent.MemberCache.AddMember (spec);
}
return true;
}
MethodData = new MethodData (
this, ModFlags, flags, this, MethodBuilder, base_method);
if (!MethodData.Define (Parent.PartialContainer, GetFullName (MemberName)))
return false;
MethodBuilder = MethodData.MethodBuilder;
spec = new MethodSpec (kind, Parent.Definition, this, ReturnType, MethodBuilder, parameters, ModFlags);
if (MemberName.Arity > 0)
spec.IsGeneric = true;
Parent.MemberCache.AddMember (this, MethodBuilder.Name, spec);
return true;
}
示例14: Emit
public override void Emit ()
{
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (MethodBuilder);
if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
Module.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);
if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
return_attributes = new ReturnParameter (this, MethodBuilder, Location);
Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
} else if (ReturnType.HasDynamicElement) {
return_attributes = new ReturnParameter (this, MethodBuilder, Location);
Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType, Location);
}
if (OptAttributes != null)
OptAttributes.Emit ();
if (declarative_security != null) {
foreach (var de in declarative_security) {
#if STATIC
MethodBuilder.__AddDeclarativeSecurity (de);
#else
MethodBuilder.AddDeclarativeSecurity (de.Key, de.Value);
#endif
}
}
if (type_expr != null)
ConstraintChecker.Check (this, member_type, type_expr.Location);
base.Emit ();
if (MethodData != null)
MethodData.Emit (Parent);
Block = null;
MethodData = null;
}
示例15: Define
public virtual MethodBuilder Define (DeclSpace parent)
{
// Fill in already resolved event type to speed things up and
// avoid confusing duplicate errors
((Parameter) parameters.FixedParameters[0]).Type = method.member_type;
parameters.Types = new TypeSpec[] { method.member_type };
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
if (!method_data.Define (parent, method.GetFullName (MemberName), Report))
return null;
MethodBuilder mb = method_data.MethodBuilder;
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags);
Spec.IsAccessor = true;
return mb;
}