net.sf.farrago.fennel.calc
Class CalcProgramBuilder.InstructionDef

java.lang.Object
  extended by net.sf.farrago.fennel.calc.CalcProgramBuilder.InstructionDef
Direct Known Subclasses:
CalcProgramBuilder.BoolInstructionDef, CalcProgramBuilder.BoolNativeInstructionDef, CalcProgramBuilder.ComparisonInstructionDef, CalcProgramBuilder.ExtInstrDef, CalcProgramBuilder.IntegralNativeInstructionDef, CalcProgramBuilder.JumpInstructionDef, CalcProgramBuilder.NativeInstructionDef, CalcProgramBuilder.PointerBoolInstructionDef
Enclosing class:
CalcProgramBuilder

static class CalcProgramBuilder.InstructionDef
extends Object

Definition for an instruction. An instruction can only do one thing -- add itself to a program -- so this class is basically just a functor. The concrete derived class must provide a name, and implement the add(CalcProgramBuilder, List) method.


Field Summary
 String name
           
protected  int regCount
           
 
Constructor Summary
CalcProgramBuilder.InstructionDef(String name, int regCount)
           
 
Method Summary
(package private)  void add(CalcProgramBuilder builder, CalcProgramBuilder.Operand... operands)
          Adds this instruction with a set of operands to a program.
(package private)  void add(CalcProgramBuilder builder, CalcReg... regs)
          Adds this instruction to a program.
(package private)  void add(CalcProgramBuilder builder, List<CalcReg> registers)
          Convenience method which converts the register list into an array and calls the add(CalcProgramBuilder,CalcReg[]) method.
protected  void addInternal(CalcProgramBuilder builder, CalcProgramBuilder.Operand[] regs)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final String name

regCount

protected final int regCount
Constructor Detail

CalcProgramBuilder.InstructionDef

CalcProgramBuilder.InstructionDef(String name,
                                  int regCount)
Method Detail

add

final void add(CalcProgramBuilder builder,
               List<CalcReg> registers)
Convenience method which converts the register list into an array and calls the add(CalcProgramBuilder,CalcReg[]) method.


add

void add(CalcProgramBuilder builder,
         CalcProgramBuilder.Operand... operands)
Adds this instruction with a set of operands to a program.

The default implementation casts each operand to a CalcReg, and calls add(CalcProgramBuilder, CalcReg[]). If this instruction's operands are not registers, override this method.

Parameters:
builder - Program builder
operands - Operands

addInternal

protected final void addInternal(CalcProgramBuilder builder,
                                 CalcProgramBuilder.Operand[] regs)

add

void add(CalcProgramBuilder builder,
         CalcReg... regs)
Adds this instruction to a program.


toString

public String toString()
Overrides:
toString in class Object