1 2 package SOFA.SOFAnode.Made.CDL; 3 import java.rmi.RemoteException ; 4 5 import SOFA.SOFAnode.Made.TIR.CDLRepository; 6 import SOFA.SOFAnode.Made.TIR.ConstantDef; 7 import SOFA.SOFAnode.Made.TIR.Contained; 8 import SOFA.SOFAnode.Made.TIR.Container; 9 import SOFA.SOFAnode.Made.TIR.ExprOperDef; 10 import SOFA.SOFAnode.Made.TIR.Repository; 11 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate; 12 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 13 14 class CompExprConstant extends CompExprOper { 15 public CompReffer value; 16 17 public CompExprConstant(CompReffer val) { 18 super(CompExprKind.e_constant); 19 value = val; 20 } 21 22 public int type() { 23 switch (value.basereffer) { 24 case ObjectsKind.o_Primitive: 25 switch (value.baserefferprim) { 26 case CompPrimKind.p_short: 27 case CompPrimKind.p_long: 28 case CompPrimKind.p_longlong: 29 case CompPrimKind.p_ushort: 30 case CompPrimKind.p_ulong: 31 case CompPrimKind.p_ulonglong: 32 return CompExprKind.e_int; 33 case CompPrimKind.p_float: 34 case CompPrimKind.p_double: 35 case CompPrimKind.p_longdouble: 36 return CompExprKind.e_float; 37 case CompPrimKind.p_boolean: 38 return CompExprKind.e_boolean; 39 case CompPrimKind.p_char: 40 return CompExprKind.e_char; 41 case CompPrimKind.p_wchar: 42 return CompExprKind.e_wchar; 43 case CompPrimKind.p_string: 44 return CompExprKind.e_string; 45 case CompPrimKind.p_wstring: 46 return CompExprKind.e_wstring; 47 } 48 case ObjectsKind.o_Enum: 49 return CompExprKind.e_enum; 50 case ObjectsKind.o_String: 51 return CompExprKind.e_string; 52 case ObjectsKind.o_Wstring: 53 return CompExprKind.e_wstring; 54 case ObjectsKind.o_Fixed: 55 return CompExprKind.e_fixed; 56 } 57 return CompExprKind.e_all; 58 } 59 60 public String toString() { 61 return value.ref.toStringWithoutVersion(); 62 } 63 64 public EnumList nameProp(CompRepository rep) throws CDLExceptRemote, CDLExceptLock { 65 int i,j; 66 if (value.isNew) { 67 CompContainer con = rep; 68 value.ref.sn.names.toFirst(); 69 for(i=0;i<value.ref.sn.names.size();i++) { 70 CompContained[] a = con.lookup((String ) value.ref.sn.names.aktual()); 71 con = (CompContainer) a[0]; 72 value.ref.sn.names.toNext(); 73 } 74 CompContained sec = con.lookup(value.ref.name, value.ref.version); 75 return ((CompConstant) sec).expr.nameProp(rep); 76 } else { 77 try { 78 Container con = rep.cdlRepository; 79 value.ref.sn.names.toFirst(); 80 for(i=0;i<value.ref.sn.names.size();i++) { 81 Contained[] a = con.lookup_name((String ) value.ref.sn.names.aktual()); 82 if (a.length==1) { 83 con = (Container) a[0]; 84 } else { 85 for(j=0;j<a.length;j++) { 86 if (a[j].get_identification().version().compareTo(value.ref.version)==0) { 87 con = (Container) a[j]; 88 break; 89 } 90 } 91 } 92 value.ref.sn.names.toNext(); 93 } 94 Contained sec = con.lookup(value.ref.name, value.ref.version); 95 return CompExprOper.scanNormalExpr(((ConstantDef) sec).value()); 96 } catch (TIRExceptLock e) { 97 throw new CDLExceptLock("Repository is locked."); 98 } catch (RemoteException e) { 99 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 100 } 101 } 102 } 103 104 public ExprOperDef toNormal(CDLRepository rep) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock { 105 try { 106 int i,j; 107 Container con = rep; 108 value.ref.sn.names.toFirst(); 109 for(i=0;i<value.ref.sn.names.size();i++) { 110 Contained[] a = con.lookup_name((String ) value.ref.sn.names.aktual()); 111 if (a.length==1) { 112 con = (Container) a[0]; 113 } else { 114 for(j=0;j<a.length;j++) { 115 if (a[j].get_identification().version().compareTo(value.ref.version)==0) { 116 con = (Container) a[j]; 117 break; 118 } 119 } 120 } 121 value.ref.sn.names.toNext(); 122 } 123 Contained sec = con.lookup(value.ref.name, value.ref.version); 124 return ((Repository) rep.get_containing_repository()).create_exprconstant((ConstantDef) sec); 125 } catch (RemoteException e) { 126 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 127 } catch (TIRExceptCreate ecr) { 128 throw new CDLExceptToNormal("Can't create expression"); 129 } catch (TIRExceptLock e) { 130 throw new CDLExceptLock("Repository is locked."); 131 } 132 } 133 134 public boolean isProp() { return false; } 135 136 public void checkConsist(EnumList props, CompRepository rep) throws CDLExceptCheck, CDLExceptLock, CDLExceptRemote { 137 value.checkConsist(props, rep); 138 } 139 140 146 147 } 148 | Popular Tags |