1 6 7 package fr.emn.info.eaop.recoderaux; 8 9 import recoder.java.*; 10 import recoder.java.declaration.*; 11 import recoder.java.reference.*; 12 import recoder.list.*; 13 import recoder.service.*; 14 15 21 public class AuxListKit { 22 26 public static String paramTs2argTs(ParameterDeclarationMutableList ps, 27 SourceInfo si) { 28 String args = ""; 29 30 for (int i=0; i<ps.size(); i++) { 31 ParameterDeclaration p = ps.getParameterDeclaration(i); 32 if (args != "") args = args + ", "; 33 TypeReference tr = p.getTypeReference(); 34 args += AuxTypeKit.type2representingType(si.getType(tr)); 35 } 36 37 return "new Class[] { " + args + " }"; 38 } 39 40 44 public static String params2argsObj(ParameterDeclarationMutableList ps) { 45 String args = ""; 46 47 for (int i=0; i<ps.size(); i++) { 48 ParameterDeclaration p = ps.getParameterDeclaration(i); 49 VariableSpecification v = p.getVariableSpecification(); 50 String vName = v.getName(); 51 String tName = p.getTypeReference().getName(); 52 if (AuxTypeKit.isPrimitive(tName)) 53 vName = "new " + AuxTypeKit.primitiveT2objectT(tName) 54 + "(" + vName + ")"; 55 if (args != "") args = args + ", "; 56 args = args + vName; 57 } 58 59 return "new Object[] { " + args + " }"; 60 } 61 62 66 public static String paramsObj2args(ParameterDeclarationMutableList ps) { 67 String args = ""; 68 String arg; 69 70 for (int i=0; i<ps.size(); i++) { 71 arg = "e1.args[" + i + "]"; 72 ParameterDeclaration p = ps.getParameterDeclaration(i); 73 String tName = p.getTypeReference().getName(); 74 if (AuxTypeKit.isPrimitive(tName)) 75 arg = "((" + AuxTypeKit.primitiveT2objectT(tName) + ") " 76 + arg +")." + tName + "Value()"; 77 else arg = "(" + tName + ") " + arg; 78 if (args != "") args += ", "; 79 args += arg; 80 } 81 82 return args; 83 } 84 85 89 public static String params2args(ParameterDeclarationMutableList ps, 90 SourceInfo si) { 91 String args = ""; 92 93 for (int i=0; i<ps.size(); i++) { 94 ParameterDeclaration p = ps.getParameterDeclaration(i); 95 if (args != "") args = args + ", "; 96 TypeReference tr = p.getTypeReference(); 97 args += AuxTypeKit.type2representingType(si.getType(tr)); 98 } 99 100 return "new Class[] { " + args + " }"; 101 } 102 103 public static ExpressionMutableList 104 ParameterDeclarationList2ExpressionList (ParameterDeclarationList pl) { 105 106 ExpressionMutableList el = new ExpressionArrayList(); 107 for (int i=0; i<pl.size(); i++) { 108 Identifier id = 109 pl.getParameterDeclaration(i).getVariableSpecification() 110 .getIdentifier(); 111 el.add(new VariableReference(id)) ; 112 } 113 114 return el; 115 } 116 } 117 | Popular Tags |