本文整理汇总了C#中IndexExpression类的典型用法代码示例。如果您正苦于以下问题:C# IndexExpression类的具体用法?C# IndexExpression怎么用?C# IndexExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexExpression类属于命名空间,在下文中一共展示了IndexExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateIndexExpression
protected virtual IndexExpression UpdateIndexExpression(IndexExpression exp, Expression obj, ReadOnlyCollection<Expression> args)
{
if (exp.Object != obj || exp.Arguments != args)
{
return Expression.MakeIndex(obj, exp.Indexer, args);
}
return exp;
}
示例2: IndexVisitor
public IndexVisitor(IndexExpression expr, Expression newObject, Expression[] newArguments)
{
_dict = new Dictionary<Expression, Expression>
{
{expr.Object, newObject}
};
for (int i = 0; i < expr.Arguments.Count; i++)
{
_dict.Add(expr.Arguments[i], newArguments?[i]);
}
}
示例3: EvalIndexExpression
/////////////////////////////////////////////////////////////////////////////
public override object EvalIndexExpression( object objIn, IndexExpression exp )
{
// ******
//
// expression: macro.fieldOrProperty[ i ]
//
// exp.MemberName should be the name of an indexer (property with arguments)
// that we need to access
//
var invoker = Invokers.GetIndexerInvoker( objIn, exp.MemberName, typeHelpers );
if( null == invoker ) {
ThreadContext.MacroError( "there is no indexer named \"{0}\" on the object type \"{1}\"", exp.MemberName, ObjectInfo.GetTypeName(objIn) );
}
object objResult = invoker.Invoke( EvaluateArguments(exp.Arguments) );
// ******
CheckNullResult( objResult, objIn, exp.MemberName );
return objResult;
}
示例4: IndexExpressionProxy
public IndexExpressionProxy(IndexExpression node) {
_node = node;
}
示例5: DumpIndexExpression
public abstract string DumpIndexExpression( IndexExpression exp );
示例6: PostWalk
public virtual void PostWalk(IndexExpression node) { }
示例7: AddressOfWriteBackCore
private WriteBack AddressOfWriteBackCore(IndexExpression node)
{
// emit instance, if any
LocalBuilder instanceLocal = null;
Type instanceType = null;
if (node.Object != null)
{
EmitInstance(node.Object, out instanceType);
// store in local
_ilg.Emit(OpCodes.Dup);
_ilg.Emit(OpCodes.Stloc, instanceLocal = GetInstanceLocal(instanceType));
}
// Emit indexes. We don't allow byref args, so no need to worry
// about write-backs or EmitAddress
int n = node.ArgumentCount;
var args = new LocalBuilder[n];
for (var i = 0; i < n; i++)
{
Expression arg = node.GetArgument(i);
EmitExpression(arg);
LocalBuilder argLocal = GetLocal(arg.Type);
_ilg.Emit(OpCodes.Dup);
_ilg.Emit(OpCodes.Stloc, argLocal);
args[i] = argLocal;
}
// emit the get
EmitGetIndexCall(node, instanceType);
// emit the address of the value
LocalBuilder valueLocal = GetLocal(node.Type);
_ilg.Emit(OpCodes.Stloc, valueLocal);
_ilg.Emit(OpCodes.Ldloca, valueLocal);
// Set the property after the method call
// don't re-evaluate anything
return @this =>
{
if (instanceLocal != null)
{
@this._ilg.Emit(OpCodes.Ldloc, instanceLocal);
@this.FreeLocal(instanceLocal);
}
foreach (LocalBuilder arg in args)
{
@this._ilg.Emit(OpCodes.Ldloc, arg);
@this.FreeLocal(arg);
}
@this._ilg.Emit(OpCodes.Ldloc, valueLocal);
@this.FreeLocal(valueLocal);
@this.EmitSetIndexCall(node, instanceLocal?.LocalType);
};
}
示例8: AddressOf
private void AddressOf(IndexExpression node, Type type)
{
if (!TypeUtils.AreEquivalent(type, node.Type) || node.Indexer != null)
{
EmitExpressionAddress(node, type);
return;
}
if (node.ArgumentCount == 1)
{
EmitExpression(node.Object);
EmitExpression(node.GetArgument(0));
_ilg.Emit(OpCodes.Ldelema, node.Type);
}
else
{
MethodInfo address = node.Object.Type.GetMethod("Address", BindingFlags.Public | BindingFlags.Instance);
EmitMethodCall(node.Object, address, node);
}
}
示例9: Walk
// IndexExpression
public override bool Walk(IndexExpression node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
示例10: EvalIndexExpression
public abstract object EvalIndexExpression( object obj, IndexExpression exp );
示例11: VisitIndexExpression
protected virtual Expression VisitIndexExpression(IndexExpression exp)
{
var obj = this.Visit(exp.Object);
var args = this.VisitExpressionList(exp.Arguments);
return this.UpdateIndexExpression(exp, obj, args);
}
示例12: VisitIndexExpression
protected override Expression VisitIndexExpression(IndexExpression exp)
{
Accumulate(exp.Indexer);
return base.VisitIndexExpression(exp);
}
示例13: VisitIndex
protected virtual Expression VisitIndex(IndexExpression index)
{
return index;
}
示例14: Walk
public override bool Walk(IndexExpression node)
{
node.Parent = _currentScope;
return base.Walk(node);
}
示例15: EmitSetIndexCall
private void EmitSetIndexCall(IndexExpression node, Type objectType) {
if (node.Indexer != null) {
// For indexed properties, just call the setter
var method = node.Indexer.GetSetMethod(true);
EmitCall(objectType, method);
} else if (node.Arguments.Count != 1) {
// Multidimensional arrays, call set
_ilg.Emit(OpCodes.Call, node.Object.Type.GetMethod("Set", BindingFlags.Public | BindingFlags.Instance));
} else {
// For one dimensional arrays, emit store
_ilg.EmitStoreElement(node.Type);
}
}