本文整理汇总了C#中Mono.CSharp.HoistedThis类的典型用法代码示例。如果您正苦于以下问题:C# HoistedThis类的具体用法?C# HoistedThis怎么用?C# HoistedThis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HoistedThis类属于Mono.CSharp命名空间,在下文中一共展示了HoistedThis类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThisInitializer
public ThisInitializer (HoistedThis hoisted_this)
{
this.hoisted_this = hoisted_this;
}
示例2: AddCapturedThisField
public void AddCapturedThisField (EmitContext ec)
{
TypeExpr type_expr = new TypeExpression (ec.CurrentType, Location);
Field f = AddCompilerGeneratedField ("$this", type_expr);
hoisted_this = new HoistedThis (this, f);
initialize_hoisted_this = true;
}
示例3: ThisInitializer
public ThisInitializer (HoistedThis hoisted_this, AnonymousMethodStorey parent)
{
this.hoisted_this = hoisted_this;
this.parent = parent;
}
示例4: AddCapturedThisField
public void AddCapturedThisField (EmitContext ec)
{
TypeExpr type_expr = new TypeExpression (ec.CurrentType, Location);
Field f = AddCompilerGeneratedField ("<>f__this", type_expr);
f.Define ();
hoisted_this = new HoistedThis (this, f);
// Inflated type instance has to be updated manually
if (Instance.Type is InflatedTypeSpec) {
var inflator = new TypeParameterInflator (this, Instance.Type, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes);
Instance.Type.MemberCache.AddMember (f.Spec.InflateMember (inflator));
inflator = new TypeParameterInflator (this, f.Parent.CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes);
f.Parent.CurrentType.MemberCache.AddMember (f.Spec.InflateMember (inflator));
}
}
示例5: AddCapturedThisField
public void AddCapturedThisField (EmitContext ec)
{
TypeExpr type_expr = new TypeExpression (ec.CurrentType, Location);
Field f = AddCompilerGeneratedField ("<>f__this", type_expr);
f.Define ();
hoisted_this = new HoistedThis (this, f);
}
示例6: CaptureThis
public HoistedThis CaptureThis (EmitContext ec, This t)
{
hoisted_this = new HoistedThis (this, t);
return hoisted_this;
}
示例7: EmitStoreyInstantiation
//
// Initializes all hoisted variables
//
public void EmitStoreyInstantiation (EmitContext ec)
{
// There can be only one instance variable for each storey type
if (Instance != null)
throw new InternalErrorException ();
//
// A storey with hoisted `this' is an instance method
//
if (!HasHoistedVariables) {
hoisted_this.RemoveHoisting ();
hoisted_this = null;
return;
}
SymbolWriter.OpenCompilerGeneratedBlock (ec.ig);
DefineStoreyReferences ();
//
// Create an instance of storey type
//
Expression storey_type_expr;
if (is_generic) {
//
// Use current method type parameter (MVAR) for top level storey only. All
// nested storeys use class type parameter (VAR)
//
TypeParameter[] tparams = ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null ?
ec.CurrentAnonymousMethod.Storey.TypeParameters :
ec.GenericDeclContainer.TypeParameters;
TypeArguments targs = new TypeArguments ();
if (tparams.Length < CountTypeParameters) {
TypeParameter[] parent_tparams = ec.DeclContainer.Parent.CurrentTypeParameters;
for (int i = 0; i < parent_tparams.Length; ++i)
targs.Add (new TypeParameterExpr (parent_tparams[i], Location));
}
for (int i = 0; i < tparams.Length; ++i)
targs.Add (new TypeParameterExpr (tparams[i], Location));
storey_type_expr = new GenericTypeExpr (TypeBuilder, targs, Location);
} else {
storey_type_expr = new TypeExpression (TypeBuilder, Location);
}
Expression e = new New (storey_type_expr, new ArrayList (0), Location).Resolve (ec);
e.Emit (ec);
Instance = new LocalTemporary (storey_type_expr.Type);
Instance.Store (ec);
EmitHoistedFieldsInitialization (ec);
SymbolWriter.DefineScopeVariable (ID, Instance.Builder);
SymbolWriter.CloseCompilerGeneratedBlock (ec.ig);
}