本文整理汇总了C#中AstExpression.SPut方法的典型用法代码示例。如果您正苦于以下问题:C# AstExpression.SPut方法的具体用法?C# AstExpression.SPut怎么用?C# AstExpression.SPut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstExpression
的用法示例。
在下文中一共展示了AstExpression.SPut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitExpression
//.........这里部分代码省略.........
var valueR = frame.AllocateTemp(fieldType.GetReference(targetPackage));
string resourceName;
if ((fieldDef != null) && fieldDef.TryGetResourceIdAttribute(out resourceName))
{
// Replace by resource id.
var id = FindResourceId(compiler.ResourceTable, resourceName);
return new RLRange(args, this.Add(node.SourceLocation, RCode.Const, id, valueR), valueR);
}
else
{
// Normal get from field
var dField = field.GetReference(targetPackage);
var iget = this.Add(node.SourceLocation, node.SGet(), dField, valueR);
return new RLRange(iget, valueR);
}
}
case AstCode.Stsfld:
{
var field = (XFieldReference) node.Operand;
var dField = field.GetReference(targetPackage);
var type = node.InferredType;
var first = this.Add(node.SourceLocation, RCode.Nop);
var valueR = args[0].Result;
// Perform type conversion if needed
bool isConverted;
var converted = this.ConvertTypeBeforeStore(node.SourceLocation, type, field.FieldType, valueR,
targetPackage, frame, compiler,
out isConverted);
if (isConverted) valueR = converted.Result;
// Store in field
var sput = this.Add(node.SourceLocation, node.SPut(), dField, valueR);
return new RLRange(first, sput, valueR);
}
#endregion
#region Object model
case AstCode.Newobj: // IL new
{
var ilCtorRef = (XMethodReference) node.Operand;
var ilType = ilCtorRef.DeclaringType;
// New normal object
var ilCtor = ilCtorRef.Resolve();
var dCtor = ilCtor.GetReference(targetPackage);
var dType = ilType.GetReference(targetPackage);
// Create instance
var r = frame.AllocateTemp(dType);
var first = this.Add(node.SourceLocation, RCode.New_instance, dType, r);
// Prepare arguments
int argsOffset;
List<RLRange> originalArgs;
ConvertParametersBeforeCall(node, args, ilCtor, out argsOffset, out originalArgs);
// Collect arguments
var arguments = args.SelectMany(x => x.Result.Registers).ToList();
// Insert this argument
arguments.Insert(0, r);
// Invoke ctor