|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.oj.rex.RexToOJTranslator net.sf.farrago.ojrex.FarragoRexToOJTranslator
public class FarragoRexToOJTranslator
FarragoRexToOJTranslator refines RexToOJTranslator
with
Farrago-specifics.
NOTE jvs 22-June-2004: If you're scratching your head trying to understand
the code generation methods in this package, it might help to look at
examples of the generated code. One way to do this is by turning on FarragoTrace.getDynamicTracer()
and then examining the
code for generated classes after running queries. See also the .ref files
under farrago/testlog/FarragoRexToOJTranslatorTest; these correspond to the
test cases in FarragoRexToOJTranslatorTest
. You
can also add new test cases to that class, run the test, and examine the
output.
Field Summary | |
---|---|
private FarragoOJRexCastImplementor |
castImplementor
|
private Map<Integer,String> |
localRefMap
|
private MemberDeclarationList |
memberList
|
private OJClass |
ojNullablePrimitive
|
private FarragoRepos |
repos
|
private StatementList |
stmtList
|
private static String |
TO_STRING_METHOD_NAME
|
Constructor Summary | |
---|---|
FarragoRexToOJTranslator(FarragoRepos repos,
JavaRelImplementor relImplementor,
RelNode contextRel,
OJRexImplementorTable implementorTable,
StatementList stmtList,
MemberDeclarationList memberList,
RexProgram program)
|
|
FarragoRexToOJTranslator(FarragoRepos repos,
JavaRelImplementor relImplementor,
RelNode contextRel,
OJRexImplementorTable implementorTable,
StatementList stmtList,
MemberDeclarationList memberList,
RexProgram program,
Map<Integer,String> localRefMap)
Creates a translator based on a OJRexImplementorTable . |
Methods inherited from class org.eigenbase.oj.rex.RexToOJTranslator |
---|
canConvertCall, convertByteArrayLiteral, convertByteArrayLiteralToInitializer, convertCall, getContextRel, getImplementorTable, getProgram, getRelImplementor, getSubStmtList, getTranslation, getTypeFactory, isInputRef, popProgram, pushProgram, setTranslation, translateRexNode, translateSubExpression, visitCall, visitCorrelVariable, visitFieldAccess, visitInputRef, visitOver, visitRangeRef |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static String TO_STRING_METHOD_NAME
private final FarragoRepos repos
private StatementList stmtList
private final MemberDeclarationList memberList
private final FarragoOJRexCastImplementor castImplementor
private final OJClass ojNullablePrimitive
private final Map<Integer,String> localRefMap
Constructor Detail |
---|
public FarragoRexToOJTranslator(FarragoRepos repos, JavaRelImplementor relImplementor, RelNode contextRel, OJRexImplementorTable implementorTable, StatementList stmtList, MemberDeclarationList memberList, RexProgram program, Map<Integer,String> localRefMap)
OJRexImplementorTable
.
repos
- repositoryrelImplementor
- implementation contextcontextRel
- relational expression which is the context for the
row-expressions which are to be translatedimplementorTable
- table of implementations for SQL operatorsstmtList
- statement list for side-effects of translationmemberList
- member list for class-level state required byprogram
- Program, may be nulllocalRefMap
- map from RexLocalRef index to name of method whichpublic FarragoRexToOJTranslator(FarragoRepos repos, JavaRelImplementor relImplementor, RelNode contextRel, OJRexImplementorTable implementorTable, StatementList stmtList, MemberDeclarationList memberList, RexProgram program)
Method Detail |
---|
public FarragoRexToOJTranslator push(StatementList stmtList)
RexToOJTranslator
The default implementation simply returns this translator. Other implementations may create a new translator which contains the expression-to-variable mappings of the sub-block.
push
in class RexToOJTranslator
stmtList
- Sub-block to generate code into
public void addMember(MemberDeclaration member)
public void addStatement(Statement stmt)
public void addStatementsFromList(StatementList newStmtList)
public Expression visitLocalRef(RexLocalRef localRef)
visitLocalRef
in interface RexVisitor<Expression>
visitLocalRef
in class RexToOJTranslator
public Expression visitDynamicParam(RexDynamicParam dynamicParam)
visitDynamicParam
in interface RexVisitor<Expression>
visitDynamicParam
in class RexToOJTranslator
public Expression convertVariable(RelDataType type, String accessorName, ExpressionList accessorArgList)
public Expression convertVariableWithCast(RelDataType type, Class accessorClassCast, String accessorName, ExpressionList accessorArgList)
public Expression visitLiteral(RexLiteral literal)
visitLiteral
in interface RexVisitor<Expression>
visitLiteral
in class RexToOJTranslator
public Variable createScratchVariable(OJClass ojClass, ExpressionList exprs, MemberDeclarationList mdlst)
public Variable createScratchVariableWithExpression(OJClass ojClass, Expression exp)
ojClass
- Type of the variableexp
- Expression to initialize it
public Variable createScratchVariable(RelDataType type)
public Variable createPrimitiveScratchVariable(OJClass ojClass)
ojClass
- Variable's type
public Variable newVariable()
public FieldDeclaration newMember(int modifiers, OJClass ojClass, Variable var, VariableInitializer init)
addMember(openjava.ptree.MemberDeclaration)
.
modifiers
- bitmap of modifiers such as private, or staticojClass
- type of the membervar
- uniquely named variableinit
- the initial value of the member, may be nullpublic OJClass typeToOJClass(RelDataType type)
type
- the Sql typepublic Statement declareLocalVariable(OJClass ojClass, Variable var, Expression init)
ojClass
- type of the variablevar
- the uniquely named variableinit
- the initial value of the variable, may be nullpublic Expression isNull(Expression exp)
exp
- the input expressionpublic Expression toString(Expression exp)
exp.toString()
exp
- expression to be converted into a stringpublic Statement assign(Expression lhs, Expression rhs)
lhs
- the expression on left side of the assignmentrhs
- the expression on the right side of the assignmentpublic Statement setIfNull(Variable var, Expression init)
var
- the variable to be initialedinit
- the initial value for the variablepublic Statement createSetNullStatement(Expression varResult, boolean isNull)
public Expression createNullTest(RexNode node, Expression originalOperand, Expression nullTest)
public boolean isNullablePrimitive(RelDataType type)
public FieldAccess convertFieldAccess(Variable variable, RelDataTypeField field)
public Expression convertPrimitiveAccess(Expression expr, RexNode op)
public Expression convertCastOrAssignmentWithStmtList(StatementList stmtList, String targetName, RelDataType lhsType, RelDataType rhsType, Expression lhsExp, Expression rhsExp)
public Expression convertCastOrAssignment(String targetName, RelDataType lhsType, RelDataType rhsType, Expression lhsExp, Expression rhsExp)
public FarragoTypeFactory getFarragoTypeFactory()
public FarragoRepos getRepos()
public void translateAssignment(RelDataTypeField lhsField, Expression lhsExp, RexNode rhs)
RexToOJTranslator
NOTE: This method is only implemented in translators which can
generate sequences of statements. The default implementation of this
method throws UnsupportedOperationException
.
translateAssignment
in class RexToOJTranslator
lhsField
- target fieldlhsExp
- target field as OpenJavarhs
- the source expression (as RexNode)public void addAssignmentStatement(StatementList stmtList, Expression funcResult, RelDataType retType, Variable varResult, boolean needCast)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |