logo       

Nice/src/bossa/syntax compilation.nice,1.8,1.9 modifiers.nice,1.1,1.2: msg#00005

Subject: Nice/src/bossa/syntax compilation.nice,1.8,1.9 modifiers.nice,1.1,1.2
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14762/src/bossa/syntax

Modified Files:
        compilation.nice modifiers.nice 
Log Message:
Emit method signatures into Nice interface classes.

Index: compilation.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/compilation.nice,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** compilation.nice    26 Mar 2005 15:33:02 -0000      1.8
--- compilation.nice    21 May 2005 16:24:58 -0000      1.9
***************
*** 23,32 ****
        [cast(gnu.bytecode.Type.string_type)]);
  
! public void compileNiceMethod(NiceMethod m, 
!                     Stack<Alternative> sortedAlternatives, 
!                     bossa.modules.Package module)
! {
!   gnu.expr.LambdaExp lexp = m.getLambda();
!     
    // parameters of the alternative function are the same in each case, 
    // so we compute them just once
--- 23,30 ----
        [cast(gnu.bytecode.Type.string_type)]);
  
! private void makeBody(NiceMethod m,
!                       gnu.expr.LambdaExp lexp,
!                       Stack<Alternative> sortedAlternatives){
! 
    // parameters of the alternative function are the same in each case, 
    // so we compute them just once
***************
*** 40,52 ****
  
    gnu.expr.Expression body = dispatchNiceMethod
!       (sortedAlternatives.iterator(), 
!        m.javaReturnType(), m.javaReturnType().isVoid(), params);
  
    if (m.isMain())
      body = beautifyUncaughtExceptions(body);
  
!   nice.tools.code.Gen.setMethodBody(lexp, m.getContract().compile(body));
  }
!   
  private gnu.expr.Expression dispatchNiceMethod(Iterator<Alternative> 
sortedAlternatives, 
                                     gnu.bytecode.Type returnType, 
--- 38,95 ----
  
    gnu.expr.Expression body = dispatchNiceMethod
!     (sortedAlternatives.iterator(), 
!      m.javaReturnType(), m.javaReturnType().isVoid(), params);
  
    if (m.isMain())
      body = beautifyUncaughtExceptions(body);
  
!   body = m.getContract().compile(body);
!   nice.tools.code.Gen.setMethodBody(lexp, body);
  }
! 
! public void compileNiceMethod(NiceMethod m, 
!                     Stack<Alternative> sortedAlternatives, 
!                     bossa.modules.Package module)
! {
!   gnu.expr.LambdaExp lexp = m.getLambda();
! 
!   makeBody( m, lexp, sortedAlternatives );
! 
!   if(m.getArity() != 0){
!     ?NiceClass iface = getNiceClass(m.getArgTypes()[0]);
!     if(iface != null && iface.isInterface() && ! ( m instanceof 
MethodWithDefault )){
! 
!       // If alternative method is implementing an interface,
!       // then generate a dispatch method as a class member,
!       // for Java interface invocations to find the implementation.
! 
!       if(bossa.util.Debug.codeGeneration)
!         bossa.util.Debug.println("Generating Nice interface signature for " 
iface );
!       String name = m.getName().toString();
!       let argTypes = m.javaArgTypes();
!       let retType  = m.javaReturnType();
!       let fullName = m.getFullName();
!       gnu.expr.LambdaExp res = generateMethod
!         (name, argTypes, retType, m.getSymbols(), toplevel: true, member: 
true);
!       res.parameterCopies = 
cast(notNull(m.formalParameters()).getParameterCopies());
!       iface.addJavaMethod(res);
! 
!       for(alt : sortedAlternatives){
!         ?NiceClass cl = declaringClass(alt);
!         if(cl == null) continue;
!         if(bossa.util.Debug.codeGeneration)
!           bossa.util.Debug.println("Generating Nice dispatch function 
(interface implementation) for " alt);
! 
!         res = generateMethod
!           (name, argTypes, retType, m.getSymbols(), toplevel: true, member: 
true);
!         res.parameterCopies = 
cast(notNull(m.formalParameters()).getParameterCopies());
!         res.addBytecodeAttribute(new gnu.bytecode.MiscAttr("id", 
fullName.getBytes()));
!         makeBody( m, res, sortedAlternatives );
!         cl.addJavaMethod(res);
!       }
!     }
!   }
! }
! 
  private gnu.expr.Expression dispatchNiceMethod(Iterator<Alternative> 
sortedAlternatives, 
                                     gnu.bytecode.Type returnType, 
***************
*** 146,150 ****
  }
  
! private NiceClass declaringClass(JavaMethod m, Alternative alt)
  {
    ?mlsub.typing.TypeConstructor firstArgument = alt.getPatterns()[0].getTC();
--- 189,193 ----
  }
  
! private ?NiceClass declaringClass(Alternative alt)
  {
    ?mlsub.typing.TypeConstructor firstArgument = alt.getPatterns()[0].getTC();
***************
*** 153,161 ****
    if (def != null && def.getImplementation() instanceof NiceClass)
      return cast(def.getImplementation());
  
    // Explain that this cannot be done.
    String msg = m + " is a native method.\n";
  
!   if (firstArgument == null)
      msg += "It cannot be implemented without dispatch on the first argument";
    else
--- 196,210 ----
    if (def != null && def.getImplementation() instanceof NiceClass)
      return cast(def.getImplementation());
+   return null;
+ }
+ 
+ private NiceClass declaringClass(JavaMethod m, Alternative alt)
+ {
+   let cl = declaringClass(alt); if(cl != null) return cl;
  
    // Explain that this cannot be done.
    String msg = m + " is a native method.\n";
  
!   if (maybeNull(firstArgument) == null)
      msg += "It cannot be implemented without dispatch on the first argument";
    else

Index: modifiers.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/modifiers.nice,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** modifiers.nice      25 Nov 2004 19:28:18 -0000      1.1
--- modifiers.nice      21 May 2005 16:24:58 -0000      1.2
***************
*** 126,129 ****
--- 126,132 ----
     {
        this.setModifier( INTERFACE );
+         // "Every interface is implicitly abstract",
+         // The Javaâ?¢ Language Specification Third Edition, 9.1.1.1
+         this.setModifier( ABSTRACT );
     }
  
***************
*** 152,156 ****
       if( this.getModifier( TRANSIENT ) )    buf.append(" transient");
       if( this.getModifier( NATIVE ) )       buf.append(" native");
!      if( this.getModifier( ABSTRACT ) )     buf.append(" abstract");
       return buf.toString();
    }
--- 155,160 ----
       if( this.getModifier( TRANSIENT ) )    buf.append(" transient");
       if( this.getModifier( NATIVE ) )       buf.append(" native");
!      if( ! this.getModifier( INTERFACE ) )
!        if( this.getModifier( ABSTRACT ) )   buf.append(" abstract");
       return buf.toString();
    }



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe