return result;
}
private Statement compileIf(Routine routine, StatementCompound context) {
HsqlArrayList list = new HsqlArrayList();
readThis(Tokens.IF);
Expression e = XreadBooleanValueExpression();
resolveOuterReferencesAndTypes(routine, context, e);
Statement statement = new StatementExpression(session, compileContext,
StatementTypes.CONDITION, e);
list.add(statement);
readThis(Tokens.THEN);
Statement[] statements = compileSQLProcedureStatementList(routine,
context);
for (int i = 0; i < statements.length; i++) {
list.add(statements[i]);
}
while (token.tokenType == Tokens.ELSEIF) {
read();
e = XreadBooleanValueExpression();
resolveOuterReferencesAndTypes(routine, context, e);
statement = new StatementExpression(session, compileContext,
StatementTypes.CONDITION, e);
list.add(statement);
readThis(Tokens.THEN);
statements = compileSQLProcedureStatementList(routine, context);
for (int i = 0; i < statements.length; i++) {
list.add(statements[i]);
}
}
if (token.tokenType == Tokens.ELSE) {
read();
e = Expression.EXPR_TRUE;
statement = new StatementExpression(session, compileContext,
StatementTypes.CONDITION, e);
list.add(statement);
statements = compileSQLProcedureStatementList(routine, context);
for (int i = 0; i < statements.length; i++) {
list.add(statements[i]);
}
}
readThis(Tokens.END);
readThis(Tokens.IF);
statements = new Statement[list.size()];
list.toArray(statements);
StatementCompound result = new StatementCompound(StatementTypes.IF,
null);
result.setStatements(statements);