本文整理汇总了C#中Emitter.EmitSub方法的典型用法代码示例。如果您正苦于以下问题:C# Emitter.EmitSub方法的具体用法?C# Emitter.EmitSub怎么用?C# Emitter.EmitSub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emitter
的用法示例。
在下文中一共展示了Emitter.EmitSub方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
public override void Compile(Emitter.Emitter emitter)
{
var leftType = Left.GetExpressionType(emitter);
var rightType = Right.GetExpressionType(emitter);
var type = GetExpressionType(emitter);
// subtract matrices
if(type == "matrix")
{
Left.Compile(emitter);
Right.Compile(emitter);
var matrixType = typeof(MN.Matrix<double>);
var method = emitter.AssemblyImport(matrixType.GetMethod("Subtract", new [] { matrixType } ));
emitter.EmitCall(method);
}
// subtract dicts
else if (type == "dict")
{
Left.Compile(emitter);
Right.Compile(emitter);
var dictType = typeof(Dict);
var method = emitter.AssemblyImport(dictType.GetMethod("Subtract", new[] { dictType }));
emitter.EmitCall(method);
}
// subtract complex numbers
else if (type == "complex")
{
Left.Compile(emitter);
if (leftType != "complex")
{
emitter.EmitUpcastBasicType(leftType, "float");
emitter.EmitLoadFloat(0);
emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
}
Right.Compile(emitter);
if (rightType != "complex")
{
emitter.EmitUpcastBasicType(rightType, "float");
emitter.EmitLoadFloat(0);
emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
}
emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Subtraction", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
}
// add floating point numbers or integers
else if (type.IsAnyOf("int", "float"))
{
Left.Compile(emitter);
emitter.EmitUpcastBasicType(leftType, type);
Right.Compile(emitter);
emitter.EmitUpcastBasicType(rightType, type);
emitter.EmitSub();
}
}