本文整理汇总了C#中Emitter.EmitLoadVariableAddress方法的典型用法代码示例。如果您正苦于以下问题:C# Emitter.EmitLoadVariableAddress方法的具体用法?C# Emitter.EmitLoadVariableAddress怎么用?C# Emitter.EmitLoadVariableAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emitter
的用法示例。
在下文中一共展示了Emitter.EmitLoadVariableAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
public override void Compile(Emitter.Emitter emitter)
{
var type = Expression.GetExpressionType(emitter);
if (type.IsAnyOf("int", "float", "complex"))
{
if(type == "complex")
{
// simple case: the complex is a constant
if(Expression is ComplexNode)
{
(Expression as ComplexNode).Imaginary *= -1;
Expression.Compile(emitter);
}
// complex case: complex is an expression result
else
{
Expression.Compile(emitter);
// tmp = ...
var tmpVar = emitter.CurrentMethod.Scope.Introduce("complex", emitter.FindType("complex").Type);
emitter.EmitSaveVariable(tmpVar);
// tmp.real
emitter.EmitLoadVariableAddress(tmpVar);
emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("get_Real")));
// tmp.imaginary * -1
emitter.EmitLoadVariableAddress(tmpVar);
emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("get_Imaginary")));
emitter.EmitLoadFloat(-1);
emitter.EmitMul();
// new complex
emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
}
}
else
{
// multiply by -1
Expression.Compile(emitter);
if (type == "int")
emitter.EmitLoadInt(-1);
else
emitter.EmitLoadFloat(-1);
emitter.EmitMul();
}
}
else
Error(String.Format(Resources.errInvertType, type));
}