net.sf.farrago.fennel.calc
Class CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor

java.lang.Object
  extended by net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.AbstractCalcRexImplementor
      extended by net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.InstrDefImplementor
          extended by net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor
All Implemented Interfaces:
CalcRexImplementor
Enclosing class:
CalcRexImplementorTableImpl

private static class CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor
extends CalcRexImplementorTableImpl.InstrDefImplementor

Makes all numeric types the same before calling a given instruction. The way to make the types the same is by inserting appropiate calls to cast functions depending on the types. The "biggest" (least restrictive) type will always win and other types will be conveted into that bigger type. For example. In the expression 1.0+2, the '+' instruction is potentially called with types (DOUBLE) + (INTEGER) which is illegal (in terms of the calculator). Therefore the expression's implementation will logically end looking something like 1.0 + CAST(2 AS DOUBLE) LIMITATION: For now only Binary operators are supported with numeric types If any operand is of any other type than a numeric one, the base class implementation will be called


Field Summary
(package private)  boolean useSameTypeResult
           
 
Fields inherited from class net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.InstrDefImplementor
instr
 
Constructor Summary
CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor(CalcProgramBuilder.InstructionDef instr)
           
CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor(CalcProgramBuilder.InstructionDef instr, boolean useSameTypeResult)
           
 
Method Summary
private  int getRestrictiveness(CalcProgramBuilder.RegisterDescriptor rd)
           
 CalcReg implement(RexCall call, RexToCalcTranslator translator)
          Generates instructions to implement this call, and returns the register which holds the result.
 
Methods inherited from class net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.InstrDefImplementor
makeRegList
 
Methods inherited from class net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.AbstractCalcRexImplementor
canImplement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useSameTypeResult

boolean useSameTypeResult
Constructor Detail

CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor

public CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor(CalcProgramBuilder.InstructionDef instr)

CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor

public CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor(CalcProgramBuilder.InstructionDef instr,
                                                                        boolean useSameTypeResult)
Method Detail

getRestrictiveness

private int getRestrictiveness(CalcProgramBuilder.RegisterDescriptor rd)

implement

public CalcReg implement(RexCall call,
                         RexToCalcTranslator translator)
Description copied from interface: CalcRexImplementor
Generates instructions to implement this call, and returns the register which holds the result.

Specified by:
implement in interface CalcRexImplementor
Overrides:
implement in class CalcRexImplementorTableImpl.InstrDefImplementor