1 package kawa.standard; 2 import kawa.lang.*; 3 import gnu.mapping.*; 4 import gnu.expr.*; 5 6 public class make extends ProcedureN 7 { 8 public int numArgs() { return 0xFFFFF001; } 10 public Object applyN (Object [] args) 11 { 12 int nargs = args.length; 13 if (nargs == 0) 14 throw new WrongArguments(this, nargs); 15 Object arg_0 = args[0]; 16 Class clas; 17 if (arg_0 instanceof Class ) 18 clas = (Class ) arg_0; 19 else if (arg_0 instanceof gnu.bytecode.ClassType) 20 clas = ((gnu.bytecode.ClassType) arg_0).getReflectClass(); 21 else 22 clas = null; 23 if (clas == null) 24 throw new WrongType(this, 1, arg_0, "class"); 25 Object result; 26 try 27 { 28 result = clas.newInstance(); 29 } 30 catch (Exception ex) 31 { 32 throw new WrappedException(ex); 33 } 34 for (int i = 1; i < nargs; ) 35 { 36 Keyword key = (Keyword) args[i++]; 37 Object arg = args[i++]; 38 Record.set1(arg, key.getName(), result); 39 } 40 return result; 41 } 42 } 43 | Popular Tags |