net.sf.farrago.ojrex
Class FarragoOJRexCastImplementor

java.lang.Object
  extended by net.sf.farrago.ojrex.FarragoOJRexImplementor
      extended by net.sf.farrago.ojrex.FarragoOJRexCastImplementor
All Implemented Interfaces:
OJRexImplementor

public class FarragoOJRexCastImplementor
extends FarragoOJRexImplementor

FarragoOJRexCastImplementor implements Farrago specifics of OJRexImplementor for CAST expressions.

A cast is described in terms of an assignment: lhs = rhs, with "lhs" meaning the variable on the left hand side and "rhs" meaning the value right hand side. The general arguments are as follows:

The two main kinds of assignment are to "primitive" types and to "AssignableValue" types. If the target type is "primitive", it is represented by a primitive Java value in generated code, or a thin wrapper around one. Non-primitive types are expected to fulfill the AssignableValue interface and are assigned using that interface.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/ojrex/FarragoOJRexCastImplementor.java#41 $
Author:
John V. Sichi

Nested Class Summary
private  class FarragoOJRexCastImplementor.CastHelper
          Helps to implement the CAST operator for a specific cast node.
 
Field Summary
private static StatementList throwOverflowStmtList
           
 
Constructor Summary
FarragoOJRexCastImplementor()
           
 
Method Summary
 Expression convertCastOrAssignment(FarragoRexToOJTranslator translator, StatementList stmtList, String targetName, RelDataType lhsType, RelDataType rhsType, Expression lhsExp, Expression rhsExp)
          Generates code to cast an OJ expression as another type.
 Expression convertCastToAssignableValue(FarragoRexToOJTranslator translator, StatementList stmtList, RelDataType lhsType, RelDataType rhsType, Expression lhsExp, Expression rhsExp)
          Generates code to cast an OJ expression as another type.
private static StatementList getThrowStmtList()
          Gets a list of statements that throw an overflow exception
 Expression implementFarrago(FarragoRexToOJTranslator translator, RexCall call, Expression[] operands)
          Refined version of OJRexImplementor.implement(org.eigenbase.oj.rex.RexToOJTranslator, org.eigenbase.rex.RexCall, openjava.ptree.Expression[]).
 
Methods inherited from class net.sf.farrago.ojrex.FarragoOJRexImplementor
canImplement, implement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

throwOverflowStmtList

private static StatementList throwOverflowStmtList
Constructor Detail

FarragoOJRexCastImplementor

public FarragoOJRexCastImplementor()
Method Detail

getThrowStmtList

private static StatementList getThrowStmtList()
Gets a list of statements that throw an overflow exception


implementFarrago

public Expression implementFarrago(FarragoRexToOJTranslator translator,
                                   RexCall call,
                                   Expression[] operands)
Description copied from class: FarragoOJRexImplementor
Refined version of OJRexImplementor.implement(org.eigenbase.oj.rex.RexToOJTranslator, org.eigenbase.rex.RexCall, openjava.ptree.Expression[]).

Specified by:
implementFarrago in class FarragoOJRexImplementor
Parameters:
translator - provides Farrago-specific translation context
call - the call to be translated
operands - call's operands, which have already been translated independently

convertCastOrAssignment

public Expression convertCastOrAssignment(FarragoRexToOJTranslator translator,
                                          StatementList stmtList,
                                          String targetName,
                                          RelDataType lhsType,
                                          RelDataType rhsType,
                                          Expression lhsExp,
                                          Expression rhsExp)
Generates code to cast an OJ expression as another type. See class description for an explanation of arguments.

Returns:
resulting expression. If lhsExp was provided, assigns this expression to lhsExp.

convertCastToAssignableValue

public Expression convertCastToAssignableValue(FarragoRexToOJTranslator translator,
                                               StatementList stmtList,
                                               RelDataType lhsType,
                                               RelDataType rhsType,
                                               Expression lhsExp,
                                               Expression rhsExp)
Generates code to cast an OJ expression as another type. The target type is limited to being an AssignableValue. See class description for an explanation of the arguments.

Returns:
resulting expression. If lhsExp was provided, assigns this expression to lhsExp.