本文整理汇总了C#中IndexExpression.GetArgument方法的典型用法代码示例。如果您正苦于以下问题:C# IndexExpression.GetArgument方法的具体用法?C# IndexExpression.GetArgument怎么用?C# IndexExpression.GetArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexExpression
的用法示例。
在下文中一共展示了IndexExpression.GetArgument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
};
}
示例3: AddressOfWriteBack
private WriteBack AddressOfWriteBack(IndexExpression node)
{
if (node.Indexer == null || !node.Indexer.CanWrite)
{
return null;
}
// emit instance, if any
LocalBuilder instanceLocal = null;
Type instanceType = null;
if (node.Object != null)
{
EmitInstance(node.Object, instanceType = node.Object.Type);
// 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
var n = node.ArgumentCount;
List<LocalBuilder> args = new List<LocalBuilder>(n);
for (var i = 0; i < n; i++)
{
var arg = node.GetArgument(i);
EmitExpression(arg);
var argLocal = GetLocal(arg.Type);
_ilg.Emit(OpCodes.Dup);
_ilg.Emit(OpCodes.Stloc, argLocal);
args.Add(argLocal);
}
// emit the get
EmitGetIndexCall(node, instanceType);
// emit the address of the value
var 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 delegate ()
{
if (instanceLocal != null)
{
_ilg.Emit(OpCodes.Ldloc, instanceLocal);
FreeLocal(instanceLocal);
}
foreach (var arg in args)
{
_ilg.Emit(OpCodes.Ldloc, arg);
FreeLocal(arg);
}
_ilg.Emit(OpCodes.Ldloc, valueLocal);
FreeLocal(valueLocal);
EmitSetIndexCall(node, instanceType);
};
}