本文整理汇总了C#中Mono.CSharp.MemberAccess类的典型用法代码示例。如果您正苦于以下问题:C# MemberAccess类的具体用法?C# MemberAccess怎么用?C# MemberAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberAccess类属于Mono.CSharp命名空间,在下文中一共展示了MemberAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FallbackSetMember
public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
var ctx = DynamicContext.Create ();
var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
// Field assignment
expr = new Compiler.MemberAccess (expr, Name);
// Compound assignment under dynamic context does not convert result
// expression but when setting member type we need to do explicit
// conversion to ensure type match between member type and dynamic
// expression type
if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0) {
expr = new Compiler.RuntimeExplicitAssign (expr, source);
} else {
expr = new Compiler.SimpleAssign (expr, source);
}
expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (value);
return binder.Bind (ctx, callingContext);
}
示例2: FallbackGetMember
public override DynamicMetaObject FallbackGetMember (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
{
var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
expr = new Compiler.MemberAccess (expr, Name);
expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
return binder.Bind (callingContext, target);
}
示例3: FallbackSetMember
public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
var ctx = DynamicContext.Create ();
var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
// Field assignment
expr = new Compiler.MemberAccess (expr, Name);
expr = new Compiler.SimpleAssign (expr, source);
expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (value);
return binder.Bind (ctx, callingContext);
}
示例4: FallbackInvokeMember
public override DynamicMetaObject FallbackInvokeMember (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
{
var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
var t_args = typeArguments == null ?
null :
new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (TypeImporter.Import (l), Compiler.Location.Null)).ToArray ());
var expr = CSharpBinder.CreateCompilerExpression (argumentInfo[0], target);
//
// Simple name invocation is actually member access invocation
// to capture original this argument. This brings problem when
// simple name is resolved as a static invocation and member access
// has to be reduced back to simple name without reporting an error
//
if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
var value = expr as Compiler.RuntimeValueExpression;
if (value != null)
value.IsSuggestionOnly = true;
}
expr = new Compiler.MemberAccess (expr, Name, t_args, Compiler.Location.Null);
expr = new Compiler.Invocation (expr, c_args);
if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
else
expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
binder.AddRestrictions (args);
if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;
return binder.Bind (callingContext, target);
}
示例5: case_439
void case_439()
#line 3273 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[-1+yyTop];
yyVal = new MemberAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location);
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
}
示例6: CreateCallSiteBinder
public Expression CreateCallSiteBinder (ResolveContext ec, Arguments args)
{
Arguments binder_args = new Arguments (3);
MemberAccess sle = new MemberAccess (new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Linq", loc), "Expressions", loc);
MemberAccess binder = GetBinderNamespace (loc);
binder_args.Add (new Argument (new MemberAccess (new MemberAccess (sle, "ExpressionType", loc), name, loc)));
binder_args.Add (new Argument (new BoolLiteral (ec.HasSet (ResolveContext.Options.CheckedScope), loc)));
binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation ("[]", args.CreateDynamicBinderArguments (), loc)));
return new New (new MemberAccess (binder, "CSharpUnaryOperationBinder", loc), binder_args, loc);
}
示例7: case_361
void case_361()
#line 2975 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[-2+yyTop];
yyVal = new MemberAccess ((ATypeNameExpression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location);
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
示例8: Visit
public override object Visit(MemberAccess memberAccess)
{
Expression result;
var ind = memberAccess.LeftExpression as Indirection;
if (ind != null) {
result = new PointerReferenceExpression();
result.AddChild((Expression)ind.Expr.Accept(this), Roles.TargetExpression);
result.AddChild(new CSharpTokenNode(Convert(ind.Location), PointerReferenceExpression.ArrowRole), PointerReferenceExpression.ArrowRole);
} else {
result = new MemberReferenceExpression();
if (memberAccess.LeftExpression != null) {
var leftExpr = memberAccess.LeftExpression.Accept(this);
result.AddChild((Expression)leftExpr, Roles.TargetExpression);
}
var loc = LocationsBag.GetLocations(memberAccess);
if (loc != null) {
result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Dot), Roles.Dot);
}
}
result.AddChild(Identifier.Create(memberAccess.Name, Convert(memberAccess.Location)), Roles.Identifier);
AddTypeArguments(result, memberAccess);
return result;
}
示例9: case_544
void case_544()
#line 3741 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
yyVal = new MemberAccess (new Indirection ((Expression) yyVals[-2+yyTop], GetLocation (yyVals[-1+yyTop])), lt.Value, lt.Location);
}
示例10: case_538
void case_538()
#line 3890 "cs-parser.jay"
{
var tne = (ATypeNameExpression) yyVals[-3+yyTop];
if (tne.HasTypeArguments)
Error_TypeExpected (GetLocation (yyVals[0+yyTop]));
var lt = (LocatedToken) yyVals[-1+yyTop];
var ma = new MemberAccess (tne, lt.Value, (int) yyVals[0+yyTop], lt.Location);
yyVal = ma;
lbag.AddLocation (ma.TypeArguments, Lexer.GetGenericDimensionLocations ());
}
示例11: Visit
public override object Visit (MemberAccess memberAccess)
{
Expression result;
if (memberAccess.LeftExpression is Indirection) {
var ind = memberAccess.LeftExpression as Indirection;
result = new PointerReferenceExpression ();
result.AddChild ((Expression)ind.Expr.Accept (this), PointerReferenceExpression.Roles.TargetExpression);
result.AddChild (new CSharpTokenNode (Convert (ind.Location), "->".Length), PointerReferenceExpression.ArrowRole);
} else {
result = new MemberReferenceExpression ();
if (memberAccess.LeftExpression != null) {
var leftExpr = memberAccess.LeftExpression.Accept (this);
result.AddChild ((Expression)leftExpr, MemberReferenceExpression.Roles.TargetExpression);
}
if (!memberAccess.DotLocation.IsNull) {
result.AddChild (new CSharpTokenNode (Convert (memberAccess.DotLocation), 1), MemberReferenceExpression.Roles.Dot);
}
}
result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier);
if (memberAccess.TypeArguments != null) {
AddTypeArguments (result, memberAccess.TypeArguments);
}
return result;
}
示例12: case_531
void case_531()
#line 3835 "cs-parser.jay"
{
var tne = (ATypeNameExpression) yyVals[-3+yyTop];
if (tne.HasTypeArguments)
Error_TypeExpected (GetLocation (yyVals[0+yyTop]));
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new MemberAccess (tne, lt.Value, (int) yyVals[0+yyTop], lt.Location) {
DotLocation = GetLocation (yyVals[-2+yyTop])
};
}
示例13: ResolveStringSwitchMap
void ResolveStringSwitchMap (ResolveContext ec)
{
FullNamedExpression string_dictionary_type;
if (TypeManager.generic_ienumerable_type != null) {
MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc), "Generic", loc);
string_dictionary_type = new MemberAccess (system_collections_generic, "Dictionary",
new TypeArguments (
new TypeExpression (TypeManager.string_type, loc),
new TypeExpression (TypeManager.int32_type, loc)), loc);
} else {
MemberAccess system_collections_generic = new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc);
string_dictionary_type = new MemberAccess (system_collections_generic, "Hashtable", loc);
}
var ctype = ec.CurrentMemberDefinition.Parent.PartialContainer;
Field field = new Field (ctype, string_dictionary_type,
Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED,
new MemberName (CompilerGeneratedClass.MakeName (null, "f", "switch$map", unique_counter++), loc), null);
if (!field.Define ())
return;
ctype.AddField (field);
var init = new List<Expression> ();
int counter = 0;
Elements.Clear ();
string value = null;
foreach (SwitchSection section in Sections) {
int last_count = init.Count;
foreach (SwitchLabel sl in section.Labels) {
if (sl.Label == null || sl.Converted == SwitchLabel.NullStringCase)
continue;
value = (string) sl.Converted;
var init_args = new List<Expression> (2);
init_args.Add (new StringLiteral (value, sl.Location));
init_args.Add (new IntConstant (counter, loc));
init.Add (new CollectionElementInitializer (init_args, loc));
}
//
// Don't add empty sections
//
if (last_count == init.Count)
continue;
Elements.Add (counter, section.Labels [0]);
++counter;
}
Arguments args = new Arguments (1);
args.Add (new Argument (new IntConstant (init.Count, loc)));
Expression initializer = new NewInitialize (string_dictionary_type, args,
new CollectionOrObjectInitializers (init, loc), loc);
switch_cache_field = new FieldExpr (field, loc);
string_dictionary = new SimpleAssign (switch_cache_field, initializer.Resolve (ec));
}
示例14: case_432
void case_432()
#line 3222 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new MemberAccess (new BaseThis (GetLocation (yyVals[-3+yyTop])), lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location) {
DotLocation = GetLocation (yyVals[-2+yyTop])
};
}
示例15: case_530
void case_530()
#line 3827 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (int) yyVals[0+yyTop], lt.Location) {
DotLocation = GetLocation (yyVals[-2+yyTop])
};
}