1 33 34 package bsh; 35 36 class BSHFormalParameters extends SimpleNode 37 { 38 private String [] paramNames; 39 42 Class [] paramTypes; 44 int numArgs; 45 String [] typeDescriptors; 46 47 BSHFormalParameters(int id) { super(id); } 48 49 void insureParsed() 50 { 51 if ( paramNames != null ) 52 return; 53 54 this.numArgs = jjtGetNumChildren(); 55 String [] paramNames = new String [numArgs]; 56 57 for(int i=0; i<numArgs; i++) 58 { 59 BSHFormalParameter param = (BSHFormalParameter)jjtGetChild(i); 60 paramNames[i] = param.name; 61 } 62 63 this.paramNames = paramNames; 64 } 65 66 public String [] getParamNames() { 67 insureParsed(); 68 return paramNames; 69 } 70 71 public String [] getTypeDescriptors( 72 CallStack callstack, Interpreter interpreter, String defaultPackage ) 73 { 74 if ( typeDescriptors != null ) 75 return typeDescriptors; 76 77 insureParsed(); 78 String [] typeDesc = new String [numArgs]; 79 80 for(int i=0; i<numArgs; i++) 81 { 82 BSHFormalParameter param = (BSHFormalParameter)jjtGetChild(i); 83 typeDesc[i] = param.getTypeDescriptor( 84 callstack, interpreter, defaultPackage ); 85 } 86 87 this.typeDescriptors = typeDesc; 88 return typeDesc; 89 } 90 91 95 public Object eval( CallStack callstack, Interpreter interpreter ) 96 throws EvalError 97 { 98 if ( paramTypes != null ) 99 return paramTypes; 100 101 insureParsed(); 102 Class [] paramTypes = new Class [numArgs]; 103 104 for(int i=0; i<numArgs; i++) 105 { 106 BSHFormalParameter param = (BSHFormalParameter)jjtGetChild(i); 107 paramTypes[i] = (Class )param.eval( callstack, interpreter ); 108 } 109 110 this.paramTypes = paramTypes; 111 112 return paramTypes; 113 } 114 } 115 116 | Popular Tags |