net.sf.farrago.fennel.calc
Class CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor
java.lang.Object
net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.AbstractCalcRexImplementor
net.sf.farrago.fennel.calc.CalcRexImplementorTableImpl.InstrDefImplementor
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
useSameTypeResult
boolean useSameTypeResult
CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor
public CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor(CalcProgramBuilder.InstructionDef instr)
CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor
public CalcRexImplementorTableImpl.BinaryNumericMakeSametypeImplementor(CalcProgramBuilder.InstructionDef instr,
boolean useSameTypeResult)
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