本文整理汇总了C#中Mono.CSharp.GenericMethod类的典型用法代码示例。如果您正苦于以下问题:C# GenericMethod类的具体用法?C# GenericMethod怎么用?C# GenericMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericMethod类属于Mono.CSharp命名空间,在下文中一共展示了GenericMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MethodCore
public MethodCore (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs, ParametersCompiled parameters)
: base (parent, generic, type, mod, allowed_mod, name, attrs)
{
this.parameters = parameters;
}
示例2: CompilerGeneratedClass
protected CompilerGeneratedClass (DeclSpace parent, GenericMethod generic, MemberName name, int mod)
: this (parent, name, mod)
{
if (generic != null) {
ArrayList list = new ArrayList ();
foreach (TypeParameter tparam in generic.TypeParameters) {
if (tparam.Constraints != null)
list.Add (tparam.Constraints.Clone ());
}
SetParameterInfo (list);
}
}
示例3: DoCreateMethodHost
//
// Creates a host for the anonymous method
//
AnonymousMethodMethod DoCreateMethodHost (EmitContext ec)
{
//
// Anonymous method body can be converted to
//
// 1, an instance method in current scope when only `this' is hoisted
// 2, a static method in current scope when neither `this' nor any variable is hoisted
// 3, an instance method in compiler generated storey when any hoisted variable exists
//
Modifiers modifiers;
if (Block.HasCapturedVariable || Block.HasCapturedThis) {
storey = FindBestMethodStorey ();
modifiers = storey != null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
} else {
if (ec.CurrentAnonymousMethod != null)
storey = ec.CurrentAnonymousMethod.Storey;
modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
}
TypeContainer parent = storey != null ? storey : ec.CurrentTypeDefinition.Parent.PartialContainer;
MemberCore mc = ec.MemberContext as MemberCore;
string name = CompilerGeneratedClass.MakeName (parent != storey ? block_name : null,
"m", null, unique_id++);
MemberName member_name;
GenericMethod generic_method;
if (storey == null && mc.MemberName.TypeArguments != null) {
member_name = new MemberName (name, mc.MemberName.TypeArguments.Clone (), Location);
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameter[hoisted_tparams.Length];
for (int i = 0; i < type_params.Length; ++i) {
type_params[i] = hoisted_tparams[i].CreateHoistedCopy (parent, null);
}
generic_method = new GenericMethod (parent.NamespaceEntry, parent, member_name, type_params,
new TypeExpression (ReturnType, Location), parameters);
} else {
member_name = new MemberName (name, Location);
generic_method = null;
}
string real_name = String.Format (
"{0}~{1}{2}", mc.GetSignatureForError (), GetSignatureForError (),
parameters.GetSignatureForError ());
return new AnonymousMethodMethod (parent,
this, storey, generic_method, new TypeExpression (ReturnType, Location), modifiers,
real_name, member_name, parameters);
}
示例4: FindMemberToOverride
//
// This finds the method or property for us to override. invocation_type is the type where
// the override is going to be declared, name is the name of the method/property, and
// param_types is the parameters, if any to the method or property
//
// Because the MemberCache holds members from this class and all the base classes,
// we can avoid tons of reflection stuff.
//
public MemberInfo FindMemberToOverride (Type invocation_type, string name, AParametersCollection parameters, GenericMethod generic_method, bool is_property)
{
ArrayList applicable;
if (method_hash != null && !is_property)
applicable = (ArrayList) method_hash [name];
else
applicable = (ArrayList) member_hash [name];
if (applicable == null)
return null;
//
// Walk the chain of methods, starting from the top.
//
for (int i = applicable.Count - 1; i >= 0; i--) {
CacheEntry entry = (CacheEntry) applicable [i];
if ((entry.EntryType & (is_property ? (EntryType.Property | EntryType.Field) : EntryType.Method)) == 0)
continue;
PropertyInfo pi = null;
MethodInfo mi = null;
FieldInfo fi = null;
AParametersCollection cmp_attrs;
if (is_property) {
if ((entry.EntryType & EntryType.Field) != 0) {
fi = (FieldInfo)entry.Member;
cmp_attrs = ParametersCompiled.EmptyReadOnlyParameters;
} else {
pi = (PropertyInfo) entry.Member;
cmp_attrs = TypeManager.GetParameterData (pi);
}
} else {
mi = (MethodInfo) entry.Member;
cmp_attrs = TypeManager.GetParameterData (mi);
}
if (fi != null) {
// TODO: Almost duplicate !
// Check visibility
switch (fi.Attributes & FieldAttributes.FieldAccessMask) {
case FieldAttributes.PrivateScope:
continue;
case FieldAttributes.Private:
//
// A private method is Ok if we are a nested subtype.
// The spec actually is not very clear about this, see bug 52458.
//
if (!invocation_type.Equals (entry.Container.Type) &&
!TypeManager.IsNestedChildOf (invocation_type, entry.Container.Type))
continue;
break;
case FieldAttributes.FamANDAssem:
case FieldAttributes.Assembly:
//
// Check for assembly methods
//
if (fi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
continue;
break;
}
return entry.Member;
}
//
// Check the arguments
//
if (cmp_attrs.Count != parameters.Count)
continue;
int j;
for (j = 0; j < cmp_attrs.Count; ++j) {
//
// LAMESPEC: No idea why `params' modifier is ignored
//
if ((parameters.FixedParameters [j].ModFlags & ~Parameter.Modifier.PARAMS) !=
(cmp_attrs.FixedParameters [j].ModFlags & ~Parameter.Modifier.PARAMS))
break;
if (!TypeManager.IsEqual (parameters.Types [j], cmp_attrs.Types [j]))
break;
}
if (j < cmp_attrs.Count)
continue;
//
// check generic arguments for methods
//
if (mi != null) {
Type [] cmpGenArgs = TypeManager.GetGenericArguments (mi);
if (generic_method == null && cmpGenArgs != null && cmpGenArgs.Length != 0)
//.........这里部分代码省略.........
示例5: case_169
void case_169()
#line 1328 "cs-parser.jay"
{
lexer.ConstraintsParsing = false;
valid_param_mod = 0;
MemberName name = (MemberName) yyVals[-6+yyTop];
current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop];
if (yyVals[-1+yyTop] != null && name.TypeArguments == null)
Report.Error (80, lexer.Location,
"Constraints are not allowed on non-generic declarations");
Method method;
GenericMethod generic = null;
if (name.TypeArguments != null) {
generic = new GenericMethod (current_namespace, current_class, name,
new TypeExpression (TypeManager.void_type, GetLocation (yyVals[-7+yyTop])),
current_local_parameters);
generic.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);
}
var modifiers = (Modifiers) yyVals[-9+yyTop];
const Modifiers invalid_partial_mod = Modifiers.AccessibilityMask | Modifiers.ABSTRACT | Modifiers.EXTERN |
Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.SEALED | Modifiers.VIRTUAL;
if ((modifiers & invalid_partial_mod) != 0) {
Report.Error (750, name.Location, "A partial method cannot define access modifier or " +
"any of abstract, extern, new, override, sealed, or virtual modifiers");
modifiers &= ~invalid_partial_mod;
}
if ((current_class.ModFlags & Modifiers.PARTIAL) == 0) {
Report.Error (751, name.Location, "A partial method must be declared within a " +
"partial class or partial struct");
}
modifiers |= Modifiers.PARTIAL | Modifiers.PRIVATE;
method = new Method (current_class, generic, new TypeExpression (TypeManager.void_type, GetLocation (yyVals[-7+yyTop])),
modifiers, name, current_local_parameters, (Attributes) yyVals[-10+yyTop]);
if (RootContext.Documentation != null)
method.DocComment = Lexer.consume_doc_comment ();
/* TODO: lbag, push void*/
StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[-8+yyTop]));
lbag.AddMember (method, GetModifierLocations (), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop]));
yyVal = method;
}
示例6: AnonymousMethodMethod
public AnonymousMethodMethod (DeclSpace parent, AnonymousExpression am, AnonymousMethodStorey storey,
GenericMethod generic, TypeExpr return_type,
Modifiers mod, string real_name, MemberName name,
ParametersCompiled parameters)
: base (parent, generic, return_type, mod | Modifiers.COMPILER_GENERATED,
name, parameters, null)
{
this.AnonymousMethod = am;
this.Storey = storey;
this.RealName = real_name;
Parent.PartialContainer.AddMethod (this);
Block = new ToplevelBlock (am.block, parameters);
}
示例7: InterfaceMemberBase
public InterfaceMemberBase (DeclSpace parent, GenericMethod generic,
FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
MemberName name, Attributes attrs)
: base (parent, generic, type, mod, allowed_mod, Modifiers.PRIVATE,
name, attrs)
{
IsInterface = parent.PartialContainer.Kind == MemberKind.Interface;
IsExplicitImpl = (MemberName.ExplicitInterface != null);
explicit_mod_flags = mod;
}
示例8: yyparse
//.........这里部分代码省略.........
} finally {
isInteraction = false;
interactionInitializationDone = false;
}
}
break;
case 162:
#line 1399 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
isInteraction = true;
interactionInitializationDone = false;
}
break;
case 163:
#line 1405 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
valid_param_mod = ParameterModifierType.All;
}
break;
case 164:
#line 1409 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
lexer.ConstraintsParsing = true;
}
break;
case 165:
#line 1413 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
lexer.ConstraintsParsing = false;
valid_param_mod = 0;
MemberName name = (MemberName) yyVals[-6+yyTop];
current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop];
GenericMethod generic = null;
if (name.TypeArguments != null) {
generic = new GenericMethod (current_namespace, current_class, name,
(FullNamedExpression) yyVals[-7+yyTop], current_local_parameters);
generic.SetParameterInfo ((List<Constraints>) yyVals[0+yyTop]);
} else if (yyVals[0+yyTop] != null) {
report.Error (80, GetLocation (yyVals[0+yyTop]),
"Constraints are not allowed on non-generic declarations");
}
var modifiers = Modifiers.PUBLIC;
var method = Method.Create (current_class, generic, (FullNamedExpression) yyVals[-7+yyTop], modifiers,
name, current_local_parameters, (Attributes) yyVals[-10+yyTop], yyVals[0+yyTop] != null);
if (doc_support)
method.DocComment = Lexer.consume_doc_comment ();
lbag.AddMember (method, mod_locations, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop]));
yyVal = method;
}
break;
case 166:
#line 1444 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (doc_support)
Lexer.doc_state = XmlCommentState.NotAllowed;
isRoleMethod = true;
/* Add it early in the case of body being eof for full ast*/
var m = (Method) yyVals[0+yyTop];
async_block = (m.ModFlags & Modifiers.ASYNC) != 0;
current_container.AddMethod (m);
}
示例9: MethodOrOperator
protected MethodOrOperator (DeclSpace parent, GenericMethod generic, FullNamedExpression type, Modifiers mod,
Modifiers allowed_mod, MemberName name,
Attributes attrs, ParametersCompiled parameters)
: base (parent, generic, type, mod, allowed_mod, name,
attrs, parameters)
{
}
示例10: case_149
void case_149()
#line 1346 "cs-parser.jay"
{
lexer.ConstraintsParsing = false;
valid_param_mod = 0;
MemberName name = (MemberName) yyVals[-6+yyTop];
current_local_parameters = (ParametersCompiled) yyVals[-3+yyTop];
if (yyVals[-1+yyTop] != null && name.TypeArguments == null)
report.Error (80, lexer.Location,
"Constraints are not allowed on non-generic declarations");
GenericMethod generic = null;
if (name.TypeArguments != null) {
generic = new GenericMethod (current_namespace, current_class, name,
new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])),
current_local_parameters);
generic.SetParameterInfo ((List<Constraints>) yyVals[-1+yyTop]);
}
var modifiers = (Modifiers) yyVals[-10+yyTop];
modifiers |= Modifiers.PARTIAL;
var method = Method.Create (current_class, generic, new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-8+yyTop])),
modifiers, name, current_local_parameters, (Attributes) yyVals[-11+yyTop], yyVals[-1+yyTop] != null);
if (doc_support)
method.DocComment = Lexer.consume_doc_comment ();
StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[-9+yyTop]));
lbag.AddMember (method, mod_locations, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop]));
yyVal = method;
}
示例11: AnonymousMethodStorey
public AnonymousMethodStorey (Block block, TypeContainer parent, MemberBase host, GenericMethod generic, string name)
: base (parent, generic, MakeMemberName (host, name, generic, block.StartLocation), Modifiers.PRIVATE)
{
Parent = parent;
OriginalSourceBlock = block;
ID = unique_id++;
}
示例12: MakeMemberName
static MemberName MakeMemberName (MemberBase host, string name, GenericMethod generic, Location loc)
{
string host_name = host == null ? null : host.Name;
string tname = MakeName (host_name, "c", name, unique_id);
TypeArguments args = null;
if (generic != null) {
args = new TypeArguments ();
foreach (TypeParameter tparam in generic.CurrentTypeParameters)
args.Add (new TypeParameterName (tparam.Name, null, loc));
}
return new MemberName (tname, args, loc);
}
示例13: AnonymousMethodStorey
public AnonymousMethodStorey (Block block, TypeContainer parent, MemberBase host, GenericMethod generic, string name)
: base (parent, MakeMemberName (host, name, generic, block.StartLocation), Modifiers.PRIVATE | Modifiers.SEALED)
{
Parent = parent;
OriginalSourceBlock = block;
ID = unique_id++;
if (generic != null) {
var hoisted_tparams = generic.CurrentTypeParameters;
type_params = new TypeParameter [hoisted_tparams.Length];
for (int i = 0; i < type_params.Length; ++i) {
type_params[i] = hoisted_tparams[i].CreateHoistedCopy (this, spec);
}
}
}
示例14: ToplevelBlock
public ToplevelBlock (Block parent, Parameters parameters, GenericMethod generic, Location start) :
this (parent, parameters, start)
{
this.generic = generic;
}
示例15: ToplevelBlock
public ToplevelBlock (CompilerContext ctx, Block parent, ParametersCompiled parameters, GenericMethod generic, Location start) :
this (ctx, parent, parameters, start)
{
this.generic = generic;
}