KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > CDL > CompExprUnOper


1 /* $Id: CompExprUnOper.java,v 1.2 2004/05/20 14:23:51 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3 import java.rmi.RemoteException JavaDoc;
4
5 import SOFA.SOFAnode.Made.TIR.CDLRepository;
6 import SOFA.SOFAnode.Made.TIR.ExprOperDef;
7 import SOFA.SOFAnode.Made.TIR.Repository;
8 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate;
9
10 class CompExprUnOper extends CompExprOper {
11   public CompExprOper operand;
12   public CompExprUnOper(int type, CompExprOper op) {
13     super(type);
14     operand = op;
15   }
16
17   public int type() { return operand.type(); }
18   public boolean isProp() { return operand.isProp(); }
19
20   public EnumList nameProp(CompRepository rep) throws CDLExceptRemote, CDLExceptLock {
21     return operand.nameProp(rep);
22   }
23
24   public ExprOperDef toNormal(CDLRepository rep) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock {
25     try {
26       return ((Repository) rep.get_containing_repository()).create_exprunoperation(kind, operand.toNormal(rep));
27     } catch (RemoteException JavaDoc e) {
28       throw new CDLExceptRemote("Remote exception occured: "+e.getMessage());
29     } catch (TIRExceptCreate ecr) {
30       throw new CDLExceptToNormal("Can't create expression");
31     }
32   }
33
34   public String JavaDoc toString() {
35     StringBuffer JavaDoc sb = new StringBuffer JavaDoc("(");
36     switch (kind) {
37     case CompExprKind.e_unminus:
38       sb.append("-");
39       break;
40     case CompExprKind.e_unplus:
41       sb.append("+");
42       break;
43     case CompExprKind.e_untilde:
44       sb.append("~");
45       break;
46     }
47     sb.append(operand.toString());
48     sb.append(")");
49     return sb.toString();
50   }
51 }
52
Popular Tags