本文整理汇总了C#中TypeParameters类的典型用法代码示例。如果您正苦于以下问题:C# TypeParameters类的具体用法?C# TypeParameters怎么用?C# TypeParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeParameters类属于命名空间,在下文中一共展示了TypeParameters类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MemberName
public MemberName (string name, TypeParameters tparams, Location loc)
{
this.Name = name;
this.Location = loc;
this.TypeParameters = tparams;
}
开发者ID:johnluetke,项目名称:mono,代码行数:7,代码来源:decl.cs
示例2: MakeMemberName
protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameter[] tparams, Location loc)
{
string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.Name;
string tname = MakeName (host_name, "c", name, unique_id);
TypeParameters args = null;
if (tparams != null) {
args = new TypeParameters ();
foreach (TypeParameter tparam in tparams)
args.Add (new TypeParameterName (tparam.Name, null, loc));
}
return new MemberName (tname, args, loc);
}
开发者ID:jordanbtucker,项目名称:mono,代码行数:13,代码来源:anonymous.cs
示例3: MakeMemberName
protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc)
{
string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.MemberName.Name;
string tname = MakeName (host_name, "c", name, unique_id);
TypeParameters args = null;
if (tparams != null) {
args = new TypeParameters (tparams.Count);
// Type parameters will be filled later when we have TypeContainer
// instance, for now we need only correct arity to create valid name
for (int i = 0; i < tparams.Count; ++i)
args.Add ((TypeParameter) null);
}
return new MemberName (tname, args, loc);
}
开发者ID:rabink,项目名称:mono,代码行数:16,代码来源:anonymous.cs
示例4: AddConstraints
void AddConstraints(AstNode parent, TypeParameters d)
{
if (d == null)
return;
for (int i = 0; i < d.Count; i++) {
var typeParameter = d [i];
if (typeParameter == null)
continue;
var c = typeParameter.Constraints;
if (c == null)
continue;
var location = LocationsBag.GetLocations(c);
var constraint = new Constraint();
constraint.AddChild(new CSharpTokenNode(Convert(c.Location), Roles.WhereKeyword), Roles.WhereKeyword);
constraint.AddChild(new SimpleType(Identifier.Create(c.TypeParameter.Value, Convert(c.TypeParameter.Location))), Roles.ConstraintTypeParameter);
if (location != null)
constraint.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.Colon), Roles.Colon);
var commaLocs = LocationsBag.GetLocations(c.ConstraintExpressions);
int curComma = 0;
if (c.ConstraintExpressions != null) {
foreach (var expr in c.ConstraintExpressions) {
constraint.AddChild(ConvertToType(expr), Roles.BaseType);
var sce = expr as SpecialContraintExpr;
if (sce != null) {
switch (sce.Constraint) {
case SpecialConstraint.Class:
break;
case SpecialConstraint.Struct:
break;
case SpecialConstraint.Constructor:
var bl = LocationsBag.GetLocations(expr);
if (bl != null) {
constraint.AddChild(new CSharpTokenNode(Convert(bl [0]), Roles.LPar), Roles.LPar);
constraint.AddChild(new CSharpTokenNode(Convert(bl [1]), Roles.RPar), Roles.RPar);
}
break;
}
}
if (commaLocs != null && curComma < commaLocs.Count)
constraint.AddChild(new CSharpTokenNode(Convert(commaLocs [curComma++]), Roles.Comma), Roles.Comma);
}
}
// We need to sort the constraints by position; as they might be in a different order than the type parameters
AstNode prevSibling = parent.LastChild;
while (prevSibling.StartLocation > constraint.StartLocation && prevSibling.PrevSibling != null)
prevSibling = prevSibling.PrevSibling;
parent.InsertChildAfter(prevSibling, constraint, Roles.Constraint);
}
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:51,代码来源:CSharpParser.cs
示例5: AddConstraints
void AddConstraints(AstNode parent, TypeParameters d)
{
if (d == null)
return;
for (int i = d.Count - 1; i >= 0; i--) {
var typeParameter = d [i];
if (typeParameter == null)
continue;
var c = typeParameter.Constraints;
if (c == null)
continue;
var location = LocationsBag.GetLocations (c);
var constraint = new Constraint ();
constraint.AddChild (new CSharpTokenNode (Convert (c.Location), Roles.WhereKeyword), Roles.WhereKeyword);
constraint.AddChild (new SimpleType (Identifier.Create (c.TypeParameter.Value, Convert (c.TypeParameter.Location))), Roles.ConstraintTypeParameter);
if (location != null)
constraint.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.Colon), Roles.Colon);
var commaLocs = LocationsBag.GetLocations (c.ConstraintExpressions);
int curComma = 0;
if (c.ConstraintExpressions != null) {
foreach (var expr in c.ConstraintExpressions) {
constraint.AddChild (ConvertToType (expr), Roles.BaseType);
if (commaLocs != null && curComma < commaLocs.Count)
constraint.AddChild (new CSharpTokenNode (Convert (commaLocs [curComma++]), Roles.Comma), Roles.Comma);
}
}
parent.AddChild (constraint, Roles.Constraint);
}
}
开发者ID:kaagati,项目名称:NRefactory,代码行数:30,代码来源:CSharpParser.cs
示例6: 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;
TypeDefinition parent = null;
var src_block = Block.Original.Explicit;
if (src_block.HasCapturedVariable || src_block.HasCapturedThis) {
parent = storey = FindBestMethodStorey ();
if (storey == null) {
var top_block = src_block.ParametersBlock.TopBlock;
var sm = top_block.StateMachine;
if (src_block.HasCapturedThis) {
//
// Remove hoisted 'this' request when simple instance method is
// enough. No hoisted variables only 'this' and don't need to
// propagate this to value type state machine.
//
StateMachine sm_parent;
var pb = src_block.ParametersBlock;
do {
sm_parent = pb.StateMachine;
pb = pb.Parent == null ? null : pb.Parent.ParametersBlock;
} while (sm_parent == null && pb != null);
if (sm_parent == null) {
top_block.RemoveThisReferenceFromChildrenBlock (src_block);
} else if (sm_parent.Kind == MemberKind.Struct) {
//
// Special case where parent class is used to emit instance method
// because currect storey is of value type (async host) and we cannot
// use ldftn on non-boxed instances either to share mutated state
//
parent = sm_parent.Parent.PartialContainer;
} else if (sm is IteratorStorey) {
//
// For iterators we can host everything in one class
//
parent = storey = sm;
}
}
}
modifiers = storey != null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
} else {
if (ec.CurrentAnonymousMethod != null)
parent = storey = ec.CurrentAnonymousMethod.Storey;
modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
}
if (parent == null)
parent = ec.CurrentTypeDefinition.Parent.PartialContainer;
string name = CompilerGeneratedContainer.MakeName (parent != storey ? block_name : null,
"m", null, parent.PartialContainer.CounterAnonymousMethods++);
MemberName member_name;
if (storey == null && ec.CurrentTypeParameters != null) {
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameters (hoisted_tparams.Count);
for (int i = 0; i < hoisted_tparams.Count; ++i) {
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
}
member_name = new MemberName (name, type_params, Location);
} else {
member_name = new MemberName (name, Location);
}
return new AnonymousMethodMethod (parent,
this, storey, new TypeExpression (ReturnType, Location), modifiers,
member_name, parameters);
}
开发者ID:erik-kallen,项目名称:NRefactory,代码行数:87,代码来源:anonymous.cs
示例7: DoResolveCore
protected bool DoResolveCore (ResolveContext rc)
{
foreach (var arg in arguments) {
if (arg.Type == InternalType.VarOutType) {
// Should be special error message about dynamic dispatch
rc.Report.Error (8047, arg.Expr.Location, "Declaration expression cannot be used in this context");
}
}
if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter)
context_mvars = rc.CurrentTypeParameters;
int errors = rc.Report.Errors;
var pt = rc.Module.PredefinedTypes;
binder_type = pt.Binder.Resolve ();
pt.CallSite.Resolve ();
pt.CallSiteGeneric.Resolve ();
eclass = ExprClass.Value;
if (type == null)
type = rc.BuiltinTypes.Dynamic;
if (rc.Report.Errors == errors)
return true;
rc.Report.Error (1969, loc,
"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly reference");
return false;
}
开发者ID:caomw,项目名称:mono,代码行数:31,代码来源:dynamic.cs
示例8: CreateTypeParameters
string[] CreateTypeParameters ()
{
string[] names;
int parent_offset = 0;
var parent_all = Parent.all_type_parameters;
if (parent_all != null) {
if (CurrentTypeParameters == null) {
all_type_parameters = Parent.all_type_parameters;
return Parent.all_tp_builders.Select (l => l.Name).ToArray ();
}
names = new string[parent_all.Count + CurrentTypeParameters.Count];
all_type_parameters = new TypeParameters (names.Length);
all_type_parameters.Add (Parent.all_type_parameters);
parent_offset = all_type_parameters.Count;
for (int i = 0; i < parent_offset; ++i)
names[i] = all_type_parameters[i].MemberName.Name;
} else {
names = new string[CurrentTypeParameters.Count];
}
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
if (all_type_parameters != null)
all_type_parameters.Add (MemberName.TypeParameters[i]);
var name = CurrentTypeParameters[i].MemberName.Name;
names[parent_offset + i] = name;
for (int ii = 0; ii < parent_offset + i; ++ii) {
if (names[ii] != name)
continue;
var tp = CurrentTypeParameters[i];
var conflict = all_type_parameters[ii];
tp.WarningParentNameConflict (conflict);
}
}
if (all_type_parameters == null)
all_type_parameters = CurrentTypeParameters;
return names;
}
开发者ID:agallero,项目名称:mono,代码行数:45,代码来源:class.cs
示例9: DoResolveCore
protected bool DoResolveCore (ResolveContext rc)
{
if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters [0].IsMethodTypeParameter)
context_mvars = rc.CurrentTypeParameters;
int errors = rc.Report.Errors;
var pt = rc.Module.PredefinedTypes;
binder_type = pt.GetBinder (rc).Resolve ();
isPlayScriptDynamicMode = pt.IsPlayScriptDynamicMode;
isPlayScriptAotMode = pt.IsPlayScriptAotMode;
// NOTE: Use AsCallSite if in PlayScript AOT mode only.
if (isPlayScriptAotMode) {
pt.AsCallSite.Resolve ();
pt.AsCallSiteGeneric.Resolve ();
} else {
pt.CallSite.Resolve ();
pt.CallSiteGeneric.Resolve ();
}
eclass = ExprClass.Value;
if (type == null)
type = rc.BuiltinTypes.Dynamic;
if (rc.Report.Errors == errors)
return true;
if (isPlayScriptDynamicMode) {
rc.Report.Error (7027, loc,
"PlayScript dynamic operation cannot be compiled without `ascorlib.dll' assembly reference");
} else {
rc.Report.Error (1969, loc,
"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly reference");
}
return false;
}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:39,代码来源:dynamic.cs
示例10: case_357
void case_357()
{
var tparams = new TypeParameters ();
tparams.Add ((TypeParameter)yyVals[0+yyTop]);
yyVal = tparams;
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:6,代码来源:cs-parser.cs
示例11: 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;
TypeDefinition parent = null;
var src_block = Block.Original.Explicit;
if (src_block.HasCapturedVariable || src_block.HasCapturedThis) {
parent = storey = FindBestMethodStorey ();
if (storey == null) {
var sm = src_block.ParametersBlock.TopBlock.StateMachine;
//
// Remove hoisted this demand when simple instance method is enough (no hoisted variables only this)
//
if (src_block.HasCapturedThis && src_block.ParametersBlock.StateMachine == null) {
src_block.ParametersBlock.TopBlock.RemoveThisReferenceFromChildrenBlock (src_block);
//
// Special case where parent class is used to emit instance method
// because currect storey is of value type (async host) and we don't
// want to create another childer storey to host this reference only
//
if (sm != null && sm.Kind == MemberKind.Struct)
parent = sm.Parent.PartialContainer;
}
//
// For iterators we can host everything in one class
//
if (sm is IteratorStorey)
parent = storey = sm;
}
modifiers = storey != null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
} else {
if (ec.CurrentAnonymousMethod != null)
parent = storey = ec.CurrentAnonymousMethod.Storey;
modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
}
if (parent == null)
parent = ec.CurrentTypeDefinition.Parent.PartialContainer;
string name = CompilerGeneratedContainer.MakeName (parent != storey ? block_name : null,
"m", null, ec.Module.CounterAnonymousMethods++);
MemberName member_name;
if (storey == null && ec.CurrentTypeParameters != null) {
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameters (hoisted_tparams.Count);
for (int i = 0; i < hoisted_tparams.Count; ++i) {
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
}
member_name = new MemberName (name, type_params, Location);
} else {
member_name = new MemberName (name, Location);
}
return new AnonymousMethodMethod (parent,
this, storey, new TypeExpression (ReturnType, Location), modifiers,
member_name, parameters);
}
开发者ID:rabink,项目名称:mono,代码行数:77,代码来源:anonymous.cs
示例12: case_364
void case_364()
#line 2999 "cs-parser.jay"
{
var tparams = new TypeParameters ();
tparams.Add ((TypeParameter)yyVals[0+yyTop]);
yyVal = tparams;
locationListStack.Push (new List<Location> ());
}
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs
示例13: MakeName
public static string MakeName (string name, TypeParameters args)
{
if (args == null)
return name;
return name + "`" + args.Count;
}
开发者ID:johnluetke,项目名称:mono,代码行数:7,代码来源:decl.cs
示例14: AnonymousMethodStorey
public AnonymousMethodStorey (Block block, TypeContainer parent, MemberBase host, TypeParameters tparams, string name)
: base (parent, MakeMemberName (host, name, unique_id, tparams, block.StartLocation),
tparams, Modifiers.SEALED)
{
OriginalSourceBlock = block;
ID = unique_id++;
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:7,代码来源:anonymous.cs
示例15: 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;
if (storey == null && ec.CurrentTypeParameters != null) {
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameters (hoisted_tparams.Count);
for (int i = 0; i < hoisted_tparams.Count; ++i) {
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
}
member_name = new MemberName (name, type_params, Location);
} else {
member_name = new MemberName (name, Location);
}
string real_name = String.Format (
"{0}~{1}{2}", mc.GetSignatureForError (), GetSignatureForError (),
parameters.GetSignatureForError ());
return new AnonymousMethodMethod (parent,
this, storey, new TypeExpression (ReturnType, Location), modifiers,
real_name, member_name, parameters);
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:52,代码来源:anonymous.cs
示例16: DoResolveCore
protected bool DoResolveCore (ResolveContext rc)
{
if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter)
context_mvars = rc.CurrentTypeParameters;
int errors = rc.Report.Errors;
var pt = rc.Module.PredefinedTypes;
binder_type = pt.Binder.Resolve ();
pt.CallSite.Resolve ();
pt.CallSiteGeneric.Resolve ();
eclass = ExprClass.Value;
if (type == null)
type = rc.BuiltinTypes.Dynamic;
if (rc.Report.Errors == errors)
return true;
rc.Report.Error (1969, loc,
"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly reference");
return false;
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:24,代码来源:dynamic.cs
示例17: CreateTypeParameters
string[] CreateTypeParameters (TypeParameters parentAllTypeParameters)
{
string[] names;
int parent_offset = 0;
if (parentAllTypeParameters != null) {
if (CurrentTypeParameters == null) {
all_type_parameters = parentAllTypeParameters;
return parentAllTypeParameters.GetAllNames ();
}
names = new string[parentAllTypeParameters.Count + CurrentTypeParameters.Count];
all_type_parameters = new TypeParameters (names.Length);
all_type_parameters.Add (parentAllTypeParameters);
parent_offset = all_type_parameters.Count;
for (int i = 0; i < parent_offset; ++i)
names[i] = all_type_parameters[i].MemberName.Name;
} else {
names = new string[CurrentTypeParameters.Count];
}
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
if (all_type_parameters != null)
all_type_parameters.Add (MemberName.TypeParameters[i]);
var name = CurrentTypeParameters[i].MemberName.Name;
names[parent_offset + i] = name;
for (int ii = 0; ii < parent_offset + i; ++ii) {
if (names[ii] != name)
continue;
var tp = CurrentTypeParameters[i];
var conflict = all_type_parameters[ii];
tp.WarningParentNameConflict (conflict);
}
}
if (all_type_parameters == null)
all_type_parameters = CurrentTypeParameters;
return names;
}
开发者ID:fvalette,项目名称:mono,代码行数:44,代码来源:class.cs
示例18: AnonymousMethodStorey
public AnonymousMethodStorey (ExplicitBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind)
: base (parent, MakeMemberName (host, name, parent.Module.CounterAnonymousContainers, tparams, block.StartLocation),
tparams, 0, kind)
{
OriginalSourceBlock = block;
ID = parent.Module.CounterAnonymousContainers++;
}
开发者ID:rabink,项目名称:mono,代码行数:7,代码来源:anonymous.cs
示例19: CreateHoistedBaseCallProxy
//
// Creates a proxy base method call inside this container for hoisted base member calls
//
public MethodSpec CreateHoistedBaseCallProxy (ResolveContext rc, MethodSpec method)
{
Method proxy_method;
//
// One proxy per base method is enough
//
if (hoisted_base_call_proxies == null) {
hoisted_base_call_proxies = new Dictionary<MethodSpec, Method> ();
proxy_method = null;
} else {
hoisted_base_call_proxies.TryGetValue (method, out proxy_method);
}
if (proxy_method == null) {
string name = CompilerGeneratedContainer.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
MemberName member_name;
TypeArguments targs = null;
TypeSpec return_type = method.ReturnType;
var local_param_types = method.Parameters.Types;
if (method.IsGeneric) {
//
// Copy all base generic method type parameters info
//
var hoisted_tparams = method.GenericDefinition.TypeParameters;
var tparams = new TypeParameters ();
targs = new TypeArguments ();
targs.Arguments = new TypeSpec[hoisted_tparams.Length];
for (int i = 0; i < hoisted_tparams.Length; ++i) {
var tp = hoisted_tparams[i];
var local_tp = new TypeParameter (tp, null, new MemberName (tp.Name, Location), null);
tparams.Add (local_tp);
targs.Add (new SimpleName (tp.Name, Location));
targs.Arguments[i] = local_tp.Type;
}
member_name = new MemberName (name, tparams, Location);
//
// Mutate any method type parameters from original
// to newly created hoisted version
//
var mutator = new TypeParameterMutator (hoisted_tparams, tparams);
return_type = mutator.Mutate (return_type);
local_param_types = mutator.Mutate (local_param_types);
} else {
member_name = new MemberName (name);
}
var base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (local_param_types [i], Location),
base_param.Name, base_param.ModFlags, null, Location);
base_parameters[i].Resolve (this, i);
}
var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
if (method.Parameters.HasArglist) {
cloned_params.FixedParameters[0] = new Parameter (null, "__arglist", Parameter.Modifier.NONE, null, Location);
cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve ();
}
// Compiler generated proxy
proxy_method = new Method (this, new TypeExpression (return_type, Location),
Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
member_name, cloned_params, null);
var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location) {
IsCompilerGenerated = true
};
var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);
if (targs != null)
mg.SetTypeArguments (rc, targs);
// Get all the method parameters and pass them as arguments
var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
Statement statement;
if (method.ReturnType.Kind == MemberKind.Void)
statement = new StatementExpression (real_base_call);
else
statement = new Return (real_base_call, Location);
block.AddStatement (statement);
proxy_method.Block = block;
members.Add (proxy_method);
proxy_method.Define ();
proxy_method.PrepareEmit ();
hoisted_base_call_proxies.Add (method, proxy_method);
//.........这里部分代码省略.........
开发者ID:fvalette,项目名称:mono,代码行数:101,代码来源:class.cs
示例20: 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;
var src_block = Block.Original.Explicit;
if (src_block.HasCapturedVariable || src_block.HasCapturedThis) {
storey = FindBestMethodStorey ();
//
// For iterators we can host everything in one class
//
if (storey == null && Block.TopBlock.StateMachine is IteratorStorey)
storey = block.TopBlock.StateMachine;
modifiers = storey != null ? Modifiers.INTERNAL : Modifiers.PRIVATE;
} else {
if (ec.CurrentAnonymousMethod != null)
storey = ec.CurrentAnonymousMethod.Storey;
modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
}
var parent = storey != null ? storey : ec.CurrentTypeDefinition.Parent.PartialContainer;
string name = CompilerGeneratedContainer.MakeName (parent != storey ? block_name : null,
"m", null, ec.Module.CounterAnonymousMethods++);
MemberName member_name;
if (storey == null && ec.CurrentTypeParameters != null) {
var hoisted_tparams = ec.CurrentTypeParameters;
var type_params = new TypeParameters (hoisted_tparams.Count);
for (int i = 0; i < hoisted_tparams.Count; ++i) {
type_params.Add (hoisted_tparams[i].CreateHoistedCopy (null));
}
member_name = new MemberName (name, type_params, Location);
} else {
member_name = new MemberName (name, Location);
}
return new AnonymousMethodMethod (parent,
this, storey, new TypeExpression (ReturnType, Location), modifiers,
member_name, parameters);
}
开发者ID:zzlang,项目名称:mono,代码行数:55,代码来源:anonymous.cs
注:本文中的TypeParameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论