本文整理汇总了C#中Mono.CSharp.MemberAccess类的典型用法代码示例。如果您正苦于以下问题:C# MemberAccess类的具体用法?C# MemberAccess怎么用?C# MemberAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberAccess类属于Mono.CSharp命名空间,在下文中一共展示了MemberAccess类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jdecuyper,项目名称:mono,代码行数:27,代码来源:CSharpSetMemberBinder.cs
示例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);
}
开发者ID:afaerber,项目名称:mono,代码行数:11,代码来源:CSharpGetMemberBinder.cs
示例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);
}
开发者ID:stabbylambda,项目名称:mono,代码行数:17,代码来源:CSharpSetMemberBinder.cs
示例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);
}
开发者ID:afaerber,项目名称:mono,代码行数:38,代码来源:CSharpInvokeMemberBinder.cs
示例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]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:7,代码来源:cs-parser.cs
示例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);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:dynamic.cs
示例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]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:7,代码来源:cs-parser.cs
示例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;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:26,代码来源:CSharpParser.cs
示例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);
}
开发者ID:Ein,项目名称:monodevelop,代码行数:6,代码来源:cs-parser.cs
示例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 ());
}
开发者ID:segaman,项目名称:NRefactory,代码行数:12,代码来源:cs-parser.cs
示例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;
}
开发者ID:N3X15,项目名称:ILSpy,代码行数:26,代码来源:CSharpParser.cs
示例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])
};
}
开发者ID:kaagati,项目名称:NRefactory,代码行数:12,代码来源:cs-parser.cs
示例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));
}
开发者ID:alisci01,项目名称:mono,代码行数:61,代码来源:statement.cs
示例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])
};
}
开发者ID:kaagati,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs
示例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])
};
}
开发者ID:kaagati,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs
示例16: case_431
void case_431()
#line 3215 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new MemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[0+yyTop], lt.Location) {
DotLocation = GetLocation (yyVals[-2+yyTop])
};
}
开发者ID:kaagati,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs
示例17: Resolve
public void Resolve ()
{
if (RootContext.Unsafe) {
//
// Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)]
// when -unsafe option was specified
//
Location loc = Location.Null;
MemberAccess system_security_permissions = new MemberAccess (new MemberAccess (
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc);
Arguments pos = new Arguments (1);
pos.Add (new Argument (new MemberAccess (new MemberAccess (system_security_permissions, "SecurityAction", loc), "RequestMinimum")));
Arguments named = new Arguments (1);
named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (true, loc)));
GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (null, null, null), "assembly",
new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
new Arguments[] { pos, named }, loc, false);
g.AttachTo (this, this);
if (g.Resolve () != null) {
declarative_security = new Dictionary<SecurityAction, PermissionSet> ();
g.ExtractSecurityPermissionSet (declarative_security);
}
}
if (OptAttributes == null)
return;
// Ensure that we only have GlobalAttributes, since the Search isn't safe with other types.
if (!OptAttributes.CheckTargets())
return;
ClsCompliantAttribute = ResolveAttribute (PredefinedAttributes.Get.CLSCompliant);
if (ClsCompliantAttribute != null) {
is_cls_compliant = ClsCompliantAttribute.GetClsCompliantAttributeValue ();
}
Attribute a = ResolveAttribute (PredefinedAttributes.Get.RuntimeCompatibility);
if (a != null) {
var val = a.GetPropertyValue ("WrapNonExceptionThrows") as BoolConstant;
if (val != null)
wrap_non_exception_throws = val.Value;
}
}
开发者ID:afaerber,项目名称:mono,代码行数:50,代码来源:codegen.cs
示例18: GenerateNumberMatcher
Method GenerateNumberMatcher ()
{
var loc = Location;
var parameters = ParametersCompiled.CreateFullyResolved (
new [] {
new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc),
new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "value", 0, null, loc),
new Parameter (new TypeExpression (Compiler.BuiltinTypes.Bool, loc), "enumType", 0, null, loc),
},
new [] {
Compiler.BuiltinTypes.Object,
Compiler.BuiltinTypes.Object,
Compiler.BuiltinTypes.Bool
});
var m = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("NumberMatcher", loc),
parameters, null);
parameters [0].Resolve (m, 0);
parameters [1].Resolve (m, 1);
parameters [2].Resolve (m, 2);
ToplevelBlock top_block = new ToplevelBlock (Compiler, parameters, loc);
m.Block = top_block;
//
// if (enumType)
// return Equals (obj, value);
//
var equals_args = new Arguments (2);
equals_args.Add (new Argument (top_block.GetParameterReference (0, loc)));
equals_args.Add (new Argument (top_block.GetParameterReference (1, loc)));
var if_type = new If (
top_block.GetParameterReference (2, loc),
new Return (new Invocation (new SimpleName ("Equals", loc), equals_args), loc),
loc);
top_block.AddStatement (if_type);
//
// if (obj is Enum || obj == null)
// return false;
//
var if_enum = new If (
new Binary (Binary.Operator.LogicalOr,
new Is (top_block.GetParameterReference (0, loc), new TypeExpression (Compiler.BuiltinTypes.Enum, loc), loc),
new Binary (Binary.Operator.Equality, top_block.GetParameterReference (0, loc), new NullLiteral (loc))),
new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc),
loc);
top_block.AddStatement (if_enum);
var system_convert = new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Convert", loc);
var expl_block = new ExplicitBlock (top_block, loc, loc);
//
// var converted = System.Convert.ChangeType (obj, System.Convert.GetTypeCode (value));
//
var lv_converted = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Object, top_block, loc);
var arguments_gettypecode = new Arguments (1);
arguments_gettypecode.Add (new Argument (top_block.GetParameterReference (1, loc)));
var gettypecode = new Invocation (new MemberAccess (system_convert, "GetTypeCode", loc), arguments_gettypecode);
var arguments_changetype = new Arguments (1);
arguments_changetype.Add (new Argument (top_block.GetParameterReference (0, loc)));
arguments_changetype.Add (new Argument (gettypecode));
var changetype = new Invocation (new MemberAccess (system_convert, "ChangeType", loc), arguments_changetype);
expl_block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (lv_converted, loc), changetype, loc)));
//
// return converted.Equals (value)
//
var equals_arguments = new Arguments (1);
equals_arguments.Add (new Argument (top_block.GetParameterReference (1, loc)));
var equals_invocation = new Invocation (new MemberAccess (new LocalVariableReference (lv_converted, loc), "Equals"), equals_arguments);
expl_block.AddStatement (new Return (equals_invocation, loc));
var catch_block = new ExplicitBlock (top_block, loc, loc);
catch_block.AddStatement (new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc));
top_block.AddStatement (new TryCatch (expl_block, new List<Catch> () {
new Catch (catch_block, loc)
}, loc, false));
m.Define ();
m.PrepareEmit ();
AddMember (m);
return m;
}
开发者ID:nobled,项目名称:mono,代码行数:98,代码来源:module.cs
示例19: case_536
void case_536()
#line 3874 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[0+yyTop];
yyVal = new MemberAccess ((Expression) yyVals[-2+yyTop], lt.Value, lt.Location);
lbag.AddLocation (yyVal, savedLocation, GetLocation (yyVals[-1+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs
示例20: Resolve
public override bool Resolve (BlockContext ec)
{
Block variables_block = variable.local_info.Block;
copy = TemporaryVariableReference.Create (for_each.expr.Type, variables_block, loc);
copy.Resolve (ec);
int rank = length_exprs.Length;
Arguments list = new Arguments (rank);
for (int i = 0; i < rank; i++) {
var v = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc);
variables[i] = v;
counter[i] = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, v, loc));
counter[i].Resolve (ec);
if (rank == 1) {
length_exprs [i] = new MemberAccess (copy, "Length").Resolve (ec);
} else {
lengths[i] = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc);
lengths[i].Resolve (ec);
Arguments args = new Arguments (1);
args.Add (new Argument (new IntConstant (i, loc)));
length_exprs [i] = new Invocation (new MemberAccess (copy, "GetLength"), args).Resolve (ec);
}
list.Add (new Argument (v));
}
access = new ElementAccess (copy, list, loc).Resolve (ec);
if (access == null)
return false;
Expression var_type = for_each.type;
VarExpr ve = var_type as VarExpr;
if (ve != null) {
// Infer implicitly typed local variable from foreach array type
var_type = new TypeExpression (access.Type, ve.Location);
}
var_type = var_type.ResolveAsTypeTerminal (ec, false);
if (var_type == null)
return false;
conv = Convert.ExplicitConversion (ec, access, var_type.Type, loc);
if (conv == null)
return false;
bool ok = true;
ec.StartFlowBranching (FlowBranching.BranchingType.Loop, loc);
ec.CurrentBranching.CreateSibling ();
variable.local_info.Type = conv.Type;
variable.Resolve (ec);
ec.StartFlowBranching (FlowBranching.BranchingType.Embedded, loc);
if (!statement.Resolve (ec))
ok = false;
ec.EndFlowBranching ();
// There's no direct control flow from the end of the embedded statement to the end of the loop
ec.CurrentBranching.CurrentUsageVector.Goto ();
ec.EndFlowBranching ();
return ok;
}
开发者ID:alisci01,项目名称:mono,代码行数:67,代码来源:statement.cs
注:本文中的Mono.CSharp.MemberAccess类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论