public void BinopExp(BinopExp e) { e.Left.Visit(this); e.Right.Visit(this); switch(e.Oper){ case Operator.ADD: il.Emit(OpCodes.Add); break; case Operator.SUB: il.Emit(OpCodes.Sub); break; case Operator.MUL: il.Emit(OpCodes.Mul); break; case Operator.DIVIDE: il.Emit(OpCodes.Div); break; } }
public void BinopExp(BinopExp e) { e.Left.Visit(this); CheckInt(e.Left); e.Right.Visit(this); CheckInt(e.Right); if (e.Left.ExpType != typeof(int)){ if (e.Left is CarExp){ e.Left = new ToIntExp(e.Left); } else{ Console.WriteLine("Error 101: Cannot Convert expression to Int"); success = false; } } if (e.Right.ExpType != typeof(int)){ if (e.Right is CarExp){ e.Right = new ToIntExp(e.Right); } else{ Console.WriteLine("Error 102: Connot Convert expression to Int"); success = false; } } e.ExpType = typeof(int); }