本文整理匯總了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