Nice/src/bossa/syntax niceclass.nice,1.22,1.23 niceMethod.nice,1.18,1.19 Module.java,1.23,1.24

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15108/src/bossa/syntax

Modified Files:
	niceclass.nice niceMethod.nice Module.java 
Log Message:
Find compiled version of dispatch methods even when they are members of
Nice classes (and not static members of the dispatch class).


Index: niceMethod.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** niceMethod.nice	16 Jan 2005 00:28:21 -0000	1.18
--- niceMethod.nice	28 Feb 2005 14:01:07 -0000	1.19
***************
*** 326,329 ****
--- 326,347 ----
    gnu.bytecode.Type retType;
  
+   // Try to compile the dispatch method as a member method if possible.
+   ?NiceClass receiver;
+   if (def.getArity() == 0)
+     receiver = null;
+   else
+     {
+       receiver = getNiceClass(def.getArgTypes()[0]);
+ 
+       // JVM interfaces cannot contain code.
+       if (receiver != null && receiver.isInterface())
+         receiver = null;
+ 
+       // Special treatment for serialization at the moment.
+       if (def.getArity() == 2 &&
+           (name.equals("writeObject")||name.equals("readObject")))
+         receiver = null;
+     }
+ 
    /*
      If this package is not recompiled,
***************
*** 335,339 ****
        as the precise types are found during typechecking.
    */
!   ?gnu.bytecode.Method meth = module.lookupDispatchClassMethod(name, "id", def.getFullName());
    if (meth != null) // Reuse existing dispatch method header
      {
--- 353,359 ----
        as the precise types are found during typechecking.
    */
!   ?gnu.bytecode.Method meth = module.lookupDispatchClassMethod
!    (receiver == null ? null : receiver.getClassType(),
!     name, "id", def.getFullName());
    if (meth != null) // Reuse existing dispatch method header
      {
***************
*** 342,346 ****
--- 362,371 ----
  
        argTypes = notNull(meth.arg_types);
+ 
+       if (receiver != null)
+ 	argTypes = [receiver.getClassType()] + argTypes;
+ 
        retType  = notNull(meth.return_type);
+ 
        // Make sure we use the same bytecode name, since compiled code
        // can rely on it.
***************
*** 353,374 ****
      }
  
-   // Try to compile the dispatch method as a member method if possible.
-   ?NiceClass receiver;
-   if (argTypes.length == 0)
-     receiver = null;
-   else
-     {
-       receiver = getNiceClass(def.getArgTypes()[0]);
- 
-       // JVM interfaces cannot contain code.
-       if (receiver != null && receiver.isInterface())
-         receiver = null;
- 
-       // Special treatment for serialization at the moment.
-       if (def.getArity() == 2 && 
-           (name.equals("writeObject")||name.equals("readObject")))
-         receiver = null;
-     }
- 
    res = generateMethod
      (name, argTypes, retType, def.getSymbols(), toplevel: true, member: receiver != null);
--- 378,381 ----

Index: niceclass.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceclass.nice,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** niceclass.nice	16 Jan 2005 00:28:21 -0000	1.22
--- niceclass.nice	28 Feb 2005 14:00:58 -0000	1.23
***************
*** 388,391 ****
--- 388,393 ----
    public gnu.expr.ClassExp getClassExp() = classe;
  
+   public gnu.bytecode.ClassType getClassType() = classe.getClassType();
+ 
    /**
       Collect in 'constraints' the constraints set by each class

Index: Module.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Module.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** Module.java	14 Jan 2005 11:12:10 -0000	1.23
--- Module.java	28 Feb 2005 14:01:07 -0000	1.24
***************
*** 32,36 ****
    gnu.bytecode.ClassType createClass(String name);
    void addGlobalVar(gnu.expr.Declaration declaration, boolean constant);
!   gnu.bytecode.Method lookupDispatchClassMethod(String name, String attribute, String value);
    gnu.expr.ReferenceExp addMethod(gnu.expr.LambdaExp method, 
  				  boolean packageMethod);
--- 32,36 ----
    gnu.bytecode.ClassType createClass(String name);
    void addGlobalVar(gnu.expr.Declaration declaration, boolean constant);
!   gnu.bytecode.Method lookupDispatchClassMethod(gnu.bytecode.ClassType clas, String name, String attribute, String value);
    gnu.expr.ReferenceExp addMethod(gnu.expr.LambdaExp method, 
  				  boolean packageMethod);



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.