Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gp.vm.instructions.arith.DivHandler.java

Here you can find all the information about the file org.dgpf.gp.vm.instructions.arith.DivHandler.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-07-03 07:02:36
 * Original Filename: org.dgpf.gp.vm.instructions.arith.DivHandler.java
 * Version          : 1.0.0
 * Last modification: 2006-07-03
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.dgpf.gp.vm.instructions.arith;

import org.dgpf.gp.vm.base.IInstructionHandler;
import org.dgpf.gp.vm.base.Instruction;
import org.dgpf.gp.vm.base.VMContext;
import org.dgpf.gp.vm.instructions.base.MemInstr3Handler;
import org.dgpf.gp.vm.mutation.MutationInfo;

/**
 * The instruction handler for the div instruction.
 *
 * @author Thomas Weise
 */

public final  class DivHandler  extends MemInstr3Handler
  {
/**
 * The serial version uid.
 */

  private static final long serialVersionUID = 1;
/**
 * The globally shared instance of the div handler.
 */

  public  static  final IInstructionHandler  INSTANCE = new DivHandler();
  
/**
 * Create a new div handler - you cannot do this, use the shared instance.
 * @see #INSTANCE
 */

  private DivHandler()
    {
    super(null);
    }
  

/**
 * Create a new randomized instance of this instruction.
 * @param p_context The vm context to be used.
 * @param p_info    The information record holding the infos on the
 *                  instruction to be created.
 * @return  The new instruction instance.
 */

  public  final Instruction create      (final VMContext    p_context,
                                         final MutationInfo p_info)
    {
    Addresses l_a;
    
    l_a = new Addresses(3, p_context, p_info);
    
    return new Div(l_a.m_addr[0], l_a.m_rel[0],
                   l_a.m_addr[1], l_a.m_rel[1],
                   l_a.m_addr[2], l_a.m_rel[2]);
    }
  
/**
 * Get an instruction that better represents the passed in instruction.
 * @param p_i   The instruction to replace.
 * @return  An instruction that better represents <code>p_i</code>, or
 *          <code>p_i</code> if it is already perfect, or <code>null</code>
 *          if <code>p_i</code> itself is totally useless.
 */

  @Override
  public Instruction get_replacement (final Instruction p_i)
    {
    Div l_s;
    
    l_s = ((Div)p_i);
    
    if((l_s.get_addr_2() == l_s.get_addr_3()) &&
       (l_s.is_relative_2() == l_s.is_relative_3()))
      {
      return new LoadC(l_s.get_addr_1(), l_s.is_relative_1(), 1);
      }
    
    return p_i;
    }
  }

File Information:

file name:DivHandler.java
package:org.dgpf.gp.vm.instructions.arith
qualified name:org.dgpf.gp.vm.instructions.arith.DivHandler.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gp/vm/instructions/arith/DivHandler.java
size:3.241 KB (3319 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-07-16 06:45:15 GMT+0000
last access: 2017-11-23 03:53:29 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-23 05:35:00 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo