本文整理汇总了C#中CodeGenerator.LoadAddress方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.LoadAddress方法的具体用法?C# CodeGenerator.LoadAddress怎么用?C# CodeGenerator.LoadAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.LoadAddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteNullableMethod
void WriteNullableMethod(NullableMapping nullableMapping) {
string methodName = (string)MethodNames[nullableMapping];
ilg = new CodeGenerator(this.typeBuilder);
ilg.BeginMethod(
nullableMapping.TypeDesc.Type,
GetMethodBuilder(methodName),
new Type[] { typeof(Boolean) },
new string[] { "checkType" },
CodeGenerator.PrivateMethodAttributes);
LocalBuilder oLoc = ilg.DeclareLocal(nullableMapping.TypeDesc.Type, "o");
ilg.LoadAddress(oLoc);
ilg.InitObj(nullableMapping.TypeDesc.Type);
MethodInfo XmlSerializationReader_ReadNull = typeof(XmlSerializationReader).GetMethod(
"ReadNull",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null);
ilg.Ldarg(0);
ilg.Call(XmlSerializationReader_ReadNull);
ilg.If();
{
ilg.Ldloc(oLoc);
ilg.Stloc(ilg.ReturnLocal);
ilg.Br(ilg.ReturnLabel);
}
ilg.EndIf();
ElementAccessor element = new ElementAccessor();
element.Mapping = nullableMapping.BaseMapping;
element.Any = false;
element.IsNullable = nullableMapping.BaseMapping.TypeDesc.IsNullable;
WriteElement("o", null, null, element, null, null, false, false, -1, -1);
ilg.Ldloc(oLoc);
ilg.Stloc(ilg.ReturnLocal);
ilg.Br(ilg.ReturnLabel);
ilg.MarkLabel(ilg.ReturnLabel);
ilg.Ldloc(ilg.ReturnLocal);
ilg.EndMethod();
}
示例2: Generate
/// <summary>
/// Emit the code to generate a call to the READ library function. A
/// parse node must be provided which evaluates to the address of the
/// identifier into which the data is read.
/// </summary>
/// <param name="cg">A CodeGenerator object</param>
/// <param name="node">A parse node for the READ identifier</param>
public override void Generate(CodeGenerator cg, ParseNode node)
{
if (cg == null) {
throw new ArgumentNullException("cg");
}
if (node is LoopParseNode) {
LoopParseNode loopNode = (LoopParseNode)node;
loopNode.Callback = this;
loopNode.Generate(cg);
} else {
Type readManagerType = typeof(JComLib.ReadManager);
List<Type> readParamTypes = new List<Type>();
cg.Emitter.LoadLocal(ReadManagerIndex);
readParamTypes.Add(readManagerType);
readParamTypes.AddRange(ReadParamsNode.Generate(cg));
if (node is IdentifierParseNode) {
IdentifierParseNode identNode = (IdentifierParseNode)node;
if (identNode.IsArrayBase) {
cg.Emitter.LoadInteger(identNode.Symbol.ArraySize);
identNode.Generate(cg);
readParamTypes.Add(typeof(int));
readParamTypes.Add(Symbol.SymTypeToSystemType(identNode.Symbol.Type).MakeArrayType());
} else if (identNode.HasSubstring) {
cg.GenerateExpression(SymType.INTEGER, identNode.SubstringStart);
if (identNode.SubstringEnd != null) {
cg.GenerateExpression(SymType.INTEGER, identNode.SubstringEnd);
} else {
cg.Emitter.LoadInteger(-1);
}
cg.LoadAddress(identNode);
readParamTypes.Add(typeof(int));
readParamTypes.Add(typeof(int));
readParamTypes.Add(Symbol.SymTypeToSystemType(identNode.Symbol.Type).MakeByRefType());
} else {
cg.LoadAddress(identNode);
readParamTypes.Add(Symbol.SymTypeToSystemType(identNode.Symbol.Type).MakeByRefType());
}
}
cg.Emitter.Call(cg.GetMethodForType(_libraryName, _name, readParamTypes.ToArray()));
cg.Emitter.StoreLocal(ReturnIndex);
if (EndLabel != null) {
cg.Emitter.LoadLocal(ReturnIndex);
cg.Emitter.LoadInteger(0);
cg.Emitter.BranchEqual((Label)EndLabel.Symbol.Info);
}
if (ErrLabel != null) {
cg.Emitter.LoadLocal(ReturnIndex);
cg.Emitter.LoadInteger(-1);
cg.Emitter.BranchEqual((Label)ErrLabel.Symbol.Info);
}
}
}