logo       

Nice/src/nice/tools/code IsOfClassProc.java,1.2,1.3 Gen.java,1.20,1.21: msg#00022

Subject: Nice/src/nice/tools/code IsOfClassProc.java,1.2,1.3 Gen.java,1.20,1.21
Update of /cvsroot/nice/Nice/src/nice/tools/code
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18206/src/nice/tools/code

Modified Files:
        IsOfClassProc.java Gen.java 
Log Message:
Compile initializers in a $init method that is called after all constructors
have been executed so that the instance is valid.

(This implies that code in proper constructors cannot capture 'this' anymore,
hence the simplification of gnu.expr.ConstructorExp)


Index: Gen.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Gen.java    30 Jun 2004 09:42:34 -0000      1.20
--- Gen.java    9 Oct 2004 09:28:40 -0000       1.21
***************
*** 29,35 ****
    }
    
!   public static Expression isOfClass(Expression value, Type ct)
    {
!     return Inline.inline(new IsOfClassProc(ct), value);
    }
  
--- 29,36 ----
    }
    
!   public static Expression isOfClass(Expression value, Type ct,
!                                      boolean possiblyNull)
    {
!     return Inline.inline(new IsOfClassProc(ct, possiblyNull), value);
    }
  
***************
*** 227,231 ****
       Expression[] params)
    {
!     LambdaExp lexp = new LambdaExp();
      bytecodeName = nice.tools.code.Strings.escape(bytecodeName);
      int arity = 1 + (argTypes == null ? 0 : argTypes.length);
--- 228,234 ----
       Expression[] params)
    {
!     Declaration thisDecl = new Declaration("this");
!     LambdaExp lexp = new MemberLambdaExp(thisDecl);
! 
      bytecodeName = nice.tools.code.Strings.escape(bytecodeName);
      int arity = 1 + (argTypes == null ? 0 : argTypes.length);
***************
*** 247,252 ****
        if (isThis)
          {
!           d = new Declaration(parameterName);
!           d.context = lexp;
            d.setType(receiver);
            params[n] = new ThisExp(d);
--- 250,254 ----
        if (isThis)
          {
!           d = thisDecl;
            d.setType(receiver);
            params[n] = new ThisExp(d);
***************
*** 261,266 ****
        d.setCanRead(true);
        d.setCanWrite(true);
-         
        }
      return lexp;
    }
--- 263,268 ----
        d.setCanRead(true);
        d.setCanWrite(true);
        }
+ 
      return lexp;
    }
***************
*** 350,353 ****
      lambda.body = new ApplyExp(proc, args);
      return lambda;
!   }  
  }
--- 352,366 ----
      lambda.body = new ApplyExp(proc, args);
      return lambda;
!   }
! 
!   public static Expression superCall(Expression method, Expression[] args)
!   {
!     return new ApplyExp(method, args, true);
!   }
! 
! 
!   public static Expression superCaller(Method method)
!   {
!     return new QuoteExp(PrimProcedure.specialCall(method));
!   }
  }

Index: IsOfClassProc.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/code/IsOfClassProc.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IsOfClassProc.java  24 May 2003 19:55:58 -0000      1.2
--- IsOfClassProc.java  9 Oct 2004 09:28:40 -0000       1.3
***************
*** 19,29 ****
  public class IsOfClassProc extends Procedure1 implements Inlineable
  {
!   public IsOfClassProc(Type type)
    {
      this.type = type;
    }
  
    private Type type;
!   
    public void compile (ApplyExp exp, Compilation comp, Target target)
    {
--- 19,31 ----
  public class IsOfClassProc extends Procedure1 implements Inlineable
  {
!   public IsOfClassProc(Type type, boolean possiblyNull)
    {
      this.type = type;
+     this.possiblyNull = possiblyNull;
    }
  
    private Type type;
!   private boolean possiblyNull;
! 
    public void compile (ApplyExp exp, Compilation comp, Target target)
    {
***************
*** 31,46 ****
      CodeAttr code = comp.getCode();
  
-     //first a check is needed for the case that the argument is null
      args[0].compile(comp, Target.pushObject);
!     code.emitDup();
!     code.emitIfNotNull();
      code.emitInvokeVirtual(getClassMethod);
      code.emitInvokeVirtual(getNameMethod);
      code.emitPushString(type.getName());
      code.emitInvokeVirtual(equalsMethod);
!     code.emitElse();
!     code.emitPop(1);
!     code.emitPushBoolean(false);
!     code.emitFi();
      target.compileFromStack(comp, Type.boolean_type);
    }
--- 33,58 ----
      CodeAttr code = comp.getCode();
  
      args[0].compile(comp, Target.pushObject);
! 
!     if (possiblyNull)
!       {
!         //first a check is needed for the case that the argument is null
!         code.emitDup();
!         code.emitIfNotNull();
!       }
! 
      code.emitInvokeVirtual(getClassMethod);
      code.emitInvokeVirtual(getNameMethod);
      code.emitPushString(type.getName());
      code.emitInvokeVirtual(equalsMethod);
! 
!     if (possiblyNull)
!       {
!         code.emitElse();
!         code.emitPop(1);
!         code.emitPushBoolean(false);
!         code.emitFi();
!       }
! 
      target.compileFromStack(comp, Type.boolean_type);
    }



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl


<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