jakarta-bcel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject cvs commit: jakarta-bcel/src/java/org/apache/bcel/generic MethodGen.java FieldGenOrMethodGen.java
Date Wed, 24 Apr 2002 08:01:36 GMT
mdahm       02/04/24 01:01:36

  Modified:    src/java/org/apache/bcel/generic MethodGen.java
                        FieldGenOrMethodGen.java
  Log:
  Don\'t accept ReturnaddressType as argument
  
  Revision  Changes    Path
  1.4       +22 -14    jakarta-bcel/src/java/org/apache/bcel/generic/MethodGen.java
  
  Index: MethodGen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/MethodGen.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MethodGen.java	1 Mar 2002 10:53:23 -0000	1.3
  +++ MethodGen.java	24 Apr 2002 08:01:36 -0000	1.4
  @@ -68,7 +68,7 @@
    * use the `removeNOPs' method to get rid off them.
    * The resulting method object can be obtained via the `getMethod()' method.
    *
  - * @version $Id: MethodGen.java,v 1.3 2002/03/01 10:53:23 mdahm Exp $
  + * @version $Id: MethodGen.java,v 1.4 2002/04/24 08:01:36 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    * @author  <A HREF="http://www.vmeng.com/beard">Patrick C. Beard</A>
    * @see     InstructionList
  @@ -265,20 +265,28 @@
     public LocalVariableGen addLocalVariable(String name, Type type, int slot,
   					   InstructionHandle start,
   					   InstructionHandle end) {
  -    byte t   = type.getType();
  -    int  add = type.getSize();
  -    
  -    if(slot + add > max_locals) 
  -      max_locals = slot + add;
  -
  -    LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end);
  -    int i;
  +    byte t = type.getType();
   
  -    if((i = variable_vec.indexOf(l)) >= 0) // Overwrite if necessary
  -      variable_vec.set(i, l);
  -    else
  -      variable_vec.add(l);
  -    return l;
  +    if(t != Constants.T_ADDRESS) {
  +      int  add = type.getSize();
  +    
  +      if(slot + add > max_locals) 
  +	max_locals = slot + add;
  +      
  +      LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end);
  +      int i;
  +      
  +      if((i = variable_vec.indexOf(l)) >= 0) // Overwrite if necessary
  +	variable_vec.set(i, l);
  +      else
  +	variable_vec.add(l);
  +
  +      return l;
  +    } else {
  +      throw new IllegalArgumentException("Can not use " + type + 
  +					 " as type for local variable");
  +					 
  +    }
     }
   
     /**
  
  
  
  1.2       +8 -2      jakarta-bcel/src/java/org/apache/bcel/generic/FieldGenOrMethodGen.java
  
  Index: FieldGenOrMethodGen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/FieldGenOrMethodGen.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FieldGenOrMethodGen.java	29 Oct 2001 20:00:12 -0000	1.1
  +++ FieldGenOrMethodGen.java	24 Apr 2002 08:01:36 -0000	1.2
  @@ -1,4 +1,5 @@
   package org.apache.bcel.generic;
  +import org.apache.bcel.Constants;
   
   /* ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,7 +62,7 @@
    * Super class for FieldGen and MethodGen objects, since they have
    * some methods in common!
    *
  - * @version $Id: FieldGenOrMethodGen.java,v 1.1 2001/10/29 20:00:12 jvanzyl Exp $
  + * @version $Id: FieldGenOrMethodGen.java,v 1.2 2002/04/24 08:01:36 mdahm Exp $
    * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
    */
   public abstract class FieldGenOrMethodGen extends AccessFlags
  @@ -74,7 +75,12 @@
   
     protected FieldGenOrMethodGen() {}
   
  -  public void            setType(Type type)   { this.type = type; }
  +  public void            setType(Type type)   {
  +    if(type.getType() == Constants.T_ADDRESS)
  +      throw new IllegalArgumentException("Type can not be " + type);
  +
  +    this.type = type;
  +  }
     public Type            getType()            { return type; }
   
     /** @return name of method/field.
  
  
  

--
To unsubscribe, e-mail:   <mailto:bcel-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:bcel-dev-help@jakarta.apache.org>


Mime
View raw message