[Nice-commit] Nice/src/bossa/syntax MethodImplementation.java,1.2,1.3
Brought to you by:
bonniot
From: <ar...@us...> - 2003-11-24 23:56:29
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv20395/F:/nice/src/bossa/syntax Modified Files: MethodImplementation.java Log Message: Make readResolve and writeReplace member methods when they are declared in a Nice class. Index: MethodImplementation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodImplementation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MethodImplementation.java 24 Nov 2003 14:47:50 -0000 1.2 --- MethodImplementation.java 24 Nov 2003 23:56:25 -0000 1.3 *************** *** 194,224 **** { final int arity = formals.length; ! if (arity != 2) return; ! String name = this.name.toString(); ! ! if (name.equals("writeObject") || name.equals("readObject")) ! { ! ClassDefinition def = ClassDefinition.get(firstArgument()); ! if (def == null || ! (def.getImplementation() instanceof NiceClass)) ! return; ! NiceClass c = (NiceClass) def.getImplementation(); ! gnu.expr.Expression[] params = new gnu.expr.Expression[arity]; ! gnu.expr.LambdaExp method = Gen.createMemberMethod (name.toString(), c.getClassExp().getType(), ! new Type[]{declaration.javaArgTypes()[1]}, declaration.javaReturnType(), params); ! Gen.setMethodBody(method, ! new gnu.expr.ApplyExp(getRefExp(), params)); - c.getClassExp().addMethod(method, true); - } } --- 194,225 ---- { final int arity = formals.length; + String name = this.name.toString(); + boolean isPrivate; ! if ((arity == 2) && (name.equals("writeObject") || name.equals("readObject"))) ! isPrivate = true; ! else if ((arity == 1) && (name.equals("writeReplace") || name.equals("readResolve"))) ! isPrivate = false; ! else return; ! ClassDefinition def = ClassDefinition.get(firstArgument()); ! if (def == null || ! (def.getImplementation() instanceof NiceClass)) ! return; ! NiceClass c = (NiceClass) def.getImplementation(); ! gnu.expr.Expression[] params = new gnu.expr.Expression[arity]; ! gnu.expr.LambdaExp method = Gen.createMemberMethod (name.toString(), c.getClassExp().getType(), ! arity==2 ? new Type[]{declaration.javaArgTypes()[1]} : null, declaration.javaReturnType(), params); ! Gen.setMethodBody(method, new gnu.expr.ApplyExp(getRefExp(), params)); ! ! c.getClassExp().addMethod(method, isPrivate); } |