本文整理汇总了C#中Mono.CSharp.EmitContext.GetThis方法的典型用法代码示例。如果您正苦于以下问题:C# EmitContext.GetThis方法的具体用法?C# EmitContext.GetThis怎么用?C# EmitContext.GetThis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.EmitContext
的用法示例。
在下文中一共展示了EmitContext.GetThis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoSimpleNameResolve
//.........这里部分代码省略.........
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = lookup_ds.TypeBuilder;
almost_matched = (ArrayList) almost_matched_members.Clone ();
}
}
if (e == null) {
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = ec.ContainerType;
almost_matched = (ArrayList) almost_matched_members.Clone ();
}
e = ResolveAsTypeStep (ec, true);
}
if (e == null) {
if (current_block != null) {
IKnownVariable ikv = current_block.Explicit.GetKnownVariable (Name);
if (ikv != null) {
LocalInfo li = ikv as LocalInfo;
// Supress CS0219 warning
if (li != null)
li.Used = true;
Error_VariableIsUsedBeforeItIsDeclared (Name);
return null;
}
}
if (RootContext.EvalMode){
FieldInfo fi = Evaluator.LookupField (Name);
if (fi != null)
return new FieldExpr (fi, loc).Resolve (ec);
}
if (almost_matched != null)
almost_matched_members = almost_matched;
if (almost_matched_type == null)
almost_matched_type = ec.ContainerType;
return Error_MemberLookupFailed (ec.ContainerType, null, almost_matched_type, Name,
ec.DeclContainer.Name, AllMemberTypes, AllBindingFlags);
}
if (e is MemberExpr) {
MemberExpr me = (MemberExpr) e;
Expression left;
if (me.IsInstance) {
if (ec.IsStatic || ec.IsInFieldInitializer) {
//
// Note that an MemberExpr can be both IsInstance and IsStatic.
// An unresolved MethodGroupExpr can contain both kinds of methods
// and each predicate is true if the MethodGroupExpr contains
// at least one of that kind of method.
//
if (!me.IsStatic &&
(!intermediate || !IdenticalNameAndTypeName (ec, me, loc))) {
Error_ObjectRefRequired (ec, loc, me.GetSignatureForError ());
return null;
}
//
// Pass the buck to MemberAccess and Invocation.
//
left = EmptyExpression.Null;
} else {
left = ec.GetThis (loc);
}
} else {
left = new TypeExpression (ec.ContainerType, loc);
}
me = me.ResolveMemberAccess (ec, left, loc, null);
if (me == null)
return null;
if (targs != null) {
if (!targs.Resolve (ec))
return null;
me.SetTypeArguments (targs);
}
if (!me.IsStatic && (me.InstanceExpression != null) &&
TypeManager.IsNestedFamilyAccessible (me.InstanceExpression.Type, me.DeclaringType) &&
me.InstanceExpression.Type != me.DeclaringType &&
!TypeManager.IsFamilyAccessible (me.InstanceExpression.Type, me.DeclaringType) &&
(!intermediate || !IdenticalNameAndTypeName (ec, e, loc))) {
Report.Error (38, loc, "Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'",
TypeManager.CSharpName (me.DeclaringType), TypeManager.CSharpName (me.InstanceExpression.Type));
return null;
}
return (right_side != null)
? me.DoResolveLValue (ec, right_side)
: me.DoResolve (ec);
}
return e;
}
示例2: CommonResolve
Expression CommonResolve (EmitContext ec)
{
Expression member_lookup;
Type current_type = ec.ContainerType;
Type base_type = current_type.BaseType;
if (!This.IsThisAvailable (ec)) {
if (ec.IsStatic) {
Error (1511, "Keyword `base' is not available in a static method");
} else {
Error (1512, "Keyword `base' is not available in the current context");
}
return null;
}
member_lookup = MemberLookup (ec.ContainerType, null, base_type, Identifier,
AllMemberTypes, AllBindingFlags, loc);
if (member_lookup == null) {
Error_MemberLookupFailed (ec.ContainerType, base_type, base_type, Identifier,
null, AllMemberTypes, AllBindingFlags);
return null;
}
Expression left;
if (ec.IsStatic)
left = new TypeExpression (base_type, loc);
else
left = ec.GetThis (loc);
MemberExpr me = (MemberExpr) member_lookup;
me = me.ResolveMemberAccess (ec, left, loc, null);
if (me == null)
return null;
me.IsBase = true;
if (args != null) {
args.Resolve (ec);
me.SetTypeArguments (args);
}
return me;
}
示例3: DoResolveInstanceExpression
void DoResolveInstanceExpression (EmitContext ec)
{
//
// Argument is another delegate
//
if (delegate_instance_expression != null)
return;
Expression instance = method_group.InstanceExpression;
if (instance != null && instance != EmptyExpression.Null) {
delegate_instance_expression = instance;
Type instance_type = delegate_instance_expression.Type;
if (TypeManager.IsValueType (instance_type) || TypeManager.IsGenericParameter (instance_type)) {
delegate_instance_expression = new BoxedCast (
delegate_instance_expression, TypeManager.object_type);
}
} else if (!delegate_method.IsStatic && !ec.IsStatic) {
delegate_instance_expression = ec.GetThis (loc);
}
}