public void Divide() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Assert.NotNull(Method.Divide(Local1, Local2)); }
public virtual void Visit(ArithmeticExpression operand) { bool oldInArithmetic = _inArithmetic; _inArithmetic = true; operand.Left().Accept(this); operand.Right().Accept(this); ITypeRef operandType = ArithmeticType(operand); switch (operand.Op().Id()) { case ArithmeticOperator.AddId: { _methodBuilder.Add(operandType); break; } case ArithmeticOperator.SubtractId: { _methodBuilder.Subtract(operandType); break; } case ArithmeticOperator.MultiplyId: { _methodBuilder.Multiply(operandType); break; } case ArithmeticOperator.DivideId: { _methodBuilder.Divide(operandType); break; } case ArithmeticOperator.ModuloId: { _methodBuilder.Modulo(operandType); break; } default: { throw new Exception("Unknown operand: " + operand.Op()); } } Box(_opClass, !oldInArithmetic); _inArithmetic = oldInArithmetic; }