KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > TIR > Impl > ValueGenElementImpl


1 /* $Id: ValueGenElementImpl.java,v 1.2 2004/05/20 14:23:52 bures Exp $ */
2 package SOFA.SOFAnode.Made.TIR.Impl;
3 import java.io.IOException JavaDoc;
4 import java.rmi.RemoteException JavaDoc;
5 import java.rmi.server.UnicastRemoteObject JavaDoc;
6
7 import SOFA.SOFAnode.Made.TIR.Container;
8 import SOFA.SOFAnode.Made.TIR.DefinitionKind;
9 import SOFA.SOFAnode.Made.TIR.ExprOperDef;
10 import SOFA.SOFAnode.Made.TIR.Repository;
11 import SOFA.SOFAnode.Made.TIR.StateKind;
12 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit;
13 import SOFA.SOFAnode.Made.TIR.ValueGenElement;
14
15 public class ValueGenElementImpl extends UnicastRemoteObject JavaDoc implements ValueGenElement, TIRImplObject {
16   ExprOperDef op1;
17   ExprOperDef op2;
18   DefinitionKindImpl defKindImpl;
19   StateKindImpl stKindImpl;
20
21   public ValueGenElementImpl(ExprOperDef oper1, ExprOperDef oper2) throws RemoteException JavaDoc {
22     op1 = oper1;
23     op2 = oper2;
24     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_ValueGenElem);
25     stKindImpl = new StateKindImpl(StateKind.sk_work);
26   }
27
28   public ValueGenElementImpl() throws RemoteException JavaDoc {
29     op1 = null;
30     op2 = null;
31     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_ValueGenElem);
32     stKindImpl = new StateKindImpl(StateKind.sk_normal);
33   }
34
35   public ExprOperDef expr1() throws RemoteException JavaDoc {
36     return op1;
37   }
38   
39   public ExprOperDef expr2() throws RemoteException JavaDoc {
40     return op2;
41   }
42
43   /* from interface TIRObject */
44   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
45     return (DefinitionKind) defKindImpl;
46   }
47
48   /* from interface TIRObject */
49   public StateKind get_state() throws RemoteException JavaDoc {
50     return (StateKind) stKindImpl;
51   }
52
53   public void save(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
54     try {
55       Storage.writeExprOperDef(st, op1);
56       if (op2 !=null) {
57         st.curOutFile.writeInt(1);
58         Storage.writeExprOperDef(st, op2);
59       } else {
60         st.curOutFile.writeInt(0);
61       }
62     } catch (IOException JavaDoc e) {
63       throw new TIRExceptStorage("Access error in file \""+st.currentFile+"\".");
64     }
65   }
66
67   public void load(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
68     try {
69       op1 = Storage.readExprOperDef(st);
70       if (st.curInFile.readInt()==1)
71         op2 = Storage.readExprOperDef(st);
72       else
73         op2 = null;
74     } catch (IOException JavaDoc e) {
75       throw new TIRExceptStorage("Access error in file \""+st.currentFile+"\".");
76     }
77   }
78
79   public void postLoad(RepositoryImpl r) throws RemoteException JavaDoc, TIRExceptStorage {
80     ((TIRImplObject) op1).postLoad(r);
81     if (op2 != null)
82       ((TIRImplObject) op2).postLoad(r);
83   }
84
85   public boolean isNew() {
86     return (stKindImpl.value()==StateKind.sk_work);
87   }
88
89   public void canCommit() throws RemoteException JavaDoc, TIRExceptCommit {;}
90
91   public void doCommit(Container in, Repository rep) throws RemoteException JavaDoc {
92     if (stKindImpl.value()==StateKind.sk_work) {
93       stKindImpl.toNormal();
94       ((TIRImplObject)op1).doCommit(in,rep);
95       if (op2 != null)
96         ((TIRImplObject)op2).doCommit(in,rep);
97     }
98   }
99
100   public void doAbort(long workId) throws RemoteException JavaDoc {}
101 }
102
Popular Tags