1public
2class IntToDouble extends UnaryExpr {
3
4
5
6 public
7 IntToDouble(Expr operand) {
8 super(operand);
9 }
10
11
12
13
14
15 protected
16 Object op1(Object v1) {
17
18
19
20 if ( v1 instanceof Integer ) {
21 return
22 new Double( ((Integer)v1).doubleValue() );
23 }
24
25
26
27 throw
28 new IllegalArgumentException("int to double: illegal operand type");
29 }
30
31
32
33 public
34 String op1ToString() {
35 return
36 "(double)";
37 }
38}
39