public static void BoundTransform(AffeCompilerState state, Expression[] exprs) { Assert.AreEqual(2, exprs.Length, "Argument count to BoundTransform"); state.CastTo(exprs[0], typeof(double)).Emit(state); state.CastTo(exprs[1], typeof(double)).Emit(state); state.ILGenerator.Emit(OpCodes.Call, typeof(Math).GetMethod("Pow")); state.ILGenerator.Emit(OpCodes.Conv_R4); }
public static void abs(AffeCompilerState comp, Expression[] exp) { if (exp.Length != 1) throw new ArgumentException("Wrong number of arguments to method."); ILGenerator il = comp.ILGenerator; Label l = il.DefineLabel(); exp[0].Emit(comp); il.Emit(OpCodes.Dup); il.Emit(OpCodes.Ldc_R4, 0f); il.Emit(OpCodes.Bge_Un, l); il.Emit(OpCodes.Neg); il.MarkLabel(l); }