8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Avoid method calls in NULL objects.

It's undefined behavior even with non-virtual methods not accessing *this.
This commit is contained in:
Adriano dos Santos Fernandes 2017-06-09 17:09:36 +00:00
parent aa9263e42a
commit d8fea3ec91
26 changed files with 499 additions and 507 deletions

View File

@ -281,7 +281,7 @@ bool AggNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const AggNode* o = other->as<AggNode>();
const AggNode* o = nodeAs<AggNode>(other);
fb_assert(o);
// ASF: We compare name address. That should be ok, as we have only one AggInfo instance

View File

@ -73,7 +73,7 @@ BoolExprNode* BoolExprNode::pass2(thread_db* tdbb, CompilerScratch* csb)
if (csb->csb_current_nodes.hasData())
{
RseNode* topRseNode = csb->csb_current_nodes[0]->as<RseNode>();
RseNode* topRseNode = nodeAs<RseNode>(csb->csb_current_nodes[0]);
fb_assert(topRseNode);
if (!topRseNode->rse_invariants)
@ -144,7 +144,7 @@ bool BinaryBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!BoolExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const BinaryBoolNode* o = other->as<BinaryBoolNode>();
const BinaryBoolNode* o = nodeAs<BinaryBoolNode>(other);
fb_assert(o);
return blrOp == o->blrOp;
@ -152,7 +152,7 @@ bool BinaryBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
bool BinaryBoolNode::sameAs(const ExprNode* other, bool ignoreStreams) const
{
const BinaryBoolNode* const otherNode = other->as<BinaryBoolNode>();
const BinaryBoolNode* const otherNode = nodeAs<BinaryBoolNode>(other);
if (!otherNode || blrOp != otherNode->blrOp)
return false;
@ -366,7 +366,7 @@ BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
if (dsqlSpecialArg)
{
ValueListNode* listNode = dsqlSpecialArg->as<ValueListNode>();
ValueListNode* listNode = nodeAs<ValueListNode>(dsqlSpecialArg);
if (listNode)
{
int listItemCount = 0;
@ -392,7 +392,7 @@ BoolExprNode* ComparativeBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
return resultNode->dsqlPass(dsqlScratch);
}
SelectExprNode* selNode = dsqlSpecialArg->as<SelectExprNode>();
SelectExprNode* selNode = nodeAs<SelectExprNode>(dsqlSpecialArg);
if (selNode)
{
fb_assert(!(selNode->dsqlFlags & RecordSourceNode::DFLAG_SINGLETON));
@ -495,7 +495,7 @@ bool ComparativeBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) c
if (!BoolExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const ComparativeBoolNode* o = other->as<ComparativeBoolNode>();
const ComparativeBoolNode* o = nodeAs<ComparativeBoolNode>(other);
fb_assert(o);
return dsqlFlag == o->dsqlFlag && blrOp == o->blrOp;
@ -503,7 +503,7 @@ bool ComparativeBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) c
bool ComparativeBoolNode::sameAs(const ExprNode* other, bool ignoreStreams) const
{
const ComparativeBoolNode* const otherNode = other->as<ComparativeBoolNode>();
const ComparativeBoolNode* const otherNode = nodeAs<ComparativeBoolNode>(other);
if (!otherNode || blrOp != otherNode->blrOp)
return false;
@ -582,7 +582,7 @@ BoolExprNode* ComparativeBoolNode::pass1(thread_db* tdbb, CompilerScratch* csb)
// If there is no top-level RSE present and patterns are not constant, unmark node as invariant
// because it may be dependent on data or variables.
if ((nodFlags & FLAG_INVARIANT) &&
(!arg2->is<LiteralNode>() || (arg3 && !arg3->is<LiteralNode>())))
(!nodeIs<LiteralNode>(arg2) || (arg3 && !nodeIs<LiteralNode>(arg3))))
{
ExprNode* const* ctx_node;
ExprNode* const* end;
@ -590,7 +590,7 @@ BoolExprNode* ComparativeBoolNode::pass1(thread_db* tdbb, CompilerScratch* csb)
for (ctx_node = csb->csb_current_nodes.begin(), end = csb->csb_current_nodes.end();
ctx_node != end; ++ctx_node)
{
if ((*ctx_node)->as<RseNode>())
if (nodeAs<RseNode>(*ctx_node))
break;
}
@ -614,7 +614,7 @@ void ComparativeBoolNode::pass2Boolean2(thread_db* tdbb, CompilerScratch* csb)
if (arg3)
{
if ((keyNode = arg3->as<RecordKeyNode>()) && keyNode->aggregate)
if ((keyNode = nodeAs<RecordKeyNode>(arg3)) && keyNode->aggregate)
ERR_post(Arg::Gds(isc_bad_dbkey));
dsc descriptor_c;
@ -627,8 +627,8 @@ void ComparativeBoolNode::pass2Boolean2(thread_db* tdbb, CompilerScratch* csb)
}
}
if (((keyNode = arg1->as<RecordKeyNode>()) && keyNode->aggregate) ||
((keyNode = arg2->as<RecordKeyNode>()) && keyNode->aggregate))
if (((keyNode = nodeAs<RecordKeyNode>(arg1)) && keyNode->aggregate) ||
((keyNode = nodeAs<RecordKeyNode>(arg2)) && keyNode->aggregate))
{
ERR_post(Arg::Gds(isc_bad_dbkey));
}
@ -774,7 +774,7 @@ bool ComparativeBoolNode::execute(thread_db* tdbb, jrd_req* request) const
// If we are checking equality of record_version
// and same transaction updated the record, force equality.
const RecordKeyNode* recVersionNode = arg1->as<RecordKeyNode>();
const RecordKeyNode* recVersionNode = nodeAs<RecordKeyNode>(arg1);
if (recVersionNode && recVersionNode->blrOp == blr_record_version && force_equal)
comparison = 0;
@ -1375,7 +1375,7 @@ BoolExprNode* MissingBoolNode::pass1(thread_db* tdbb, CompilerScratch* csb)
void MissingBoolNode::pass2Boolean2(thread_db* tdbb, CompilerScratch* csb)
{
RecordKeyNode* keyNode = arg->as<RecordKeyNode>();
RecordKeyNode* keyNode = nodeAs<RecordKeyNode>(arg);
if (keyNode && keyNode->aggregate)
ERR_post(Arg::Gds(isc_bad_dbkey));
@ -1448,7 +1448,7 @@ BoolExprNode* NotBoolNode::copy(thread_db* tdbb, NodeCopier& copier) const
BoolExprNode* NotBoolNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
RseBoolNode* rseBoolean = arg->as<RseBoolNode>();
RseBoolNode* rseBoolean = nodeAs<RseBoolNode>(arg);
if (rseBoolean)
{
@ -1475,7 +1475,7 @@ bool NotBoolNode::execute(thread_db* tdbb, jrd_req* request) const
// Get rid of redundant nested NOT predicates.
BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert)
{
NotBoolNode* notArg = arg->as<NotBoolNode>();
NotBoolNode* notArg = nodeAs<NotBoolNode>(arg);
if (notArg)
{
@ -1486,12 +1486,12 @@ BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert
if (!invert)
return arg->dsqlPass(dsqlScratch);
ComparativeBoolNode* cmpArg = arg->as<ComparativeBoolNode>();
BinaryBoolNode* binArg = arg->as<BinaryBoolNode>();
ComparativeBoolNode* cmpArg = nodeAs<ComparativeBoolNode>(arg);
BinaryBoolNode* binArg = nodeAs<BinaryBoolNode>(arg);
// Do not handle special case: <value> NOT IN <list>
if (cmpArg && (!cmpArg->dsqlSpecialArg || !cmpArg->dsqlSpecialArg->is<ValueListNode>()))
if (cmpArg && (!cmpArg->dsqlSpecialArg || !nodeIs<ValueListNode>(cmpArg->dsqlSpecialArg)))
{
// Invert the given boolean.
switch (cmpArg->blrOp)
@ -1646,7 +1646,7 @@ BoolExprNode* RseBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
const DsqlContextStack::iterator base(*dsqlScratch->context);
RseBoolNode* node = FB_NEW_POOL(getPool()) RseBoolNode(getPool(), blrOp,
PASS1_rse(dsqlScratch, dsqlRse->as<SelectExprNode>(), false));
PASS1_rse(dsqlScratch, nodeAs<SelectExprNode>(dsqlRse), false));
// Finish off by cleaning up contexts
dsqlScratch->context->clear(base);
@ -1657,7 +1657,7 @@ BoolExprNode* RseBoolNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
void RseBoolNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
dsqlScratch->appendUChar(blrOp);
GEN_rse(dsqlScratch, dsqlRse->as<RseNode>());
GEN_rse(dsqlScratch, nodeAs<RseNode>(dsqlRse));
}
bool RseBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
@ -1665,7 +1665,7 @@ bool RseBoolNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!BoolExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const RseBoolNode* o = other->as<RseBoolNode>();
const RseBoolNode* o = nodeAs<RseBoolNode>(other);
fb_assert(o);
return blrOp == o->blrOp;
@ -1676,7 +1676,7 @@ bool RseBoolNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!BoolExprNode::sameAs(other, ignoreStreams))
return false;
const RseBoolNode* const otherNode = other->as<RseBoolNode>();
const RseBoolNode* const otherNode = nodeAs<RseBoolNode>(other);
fb_assert(otherNode);
return blrOp == otherNode->blrOp;
@ -1730,7 +1730,7 @@ BoolExprNode* RseBoolNode::pass1(thread_db* tdbb, CompilerScratch* csb)
BoolExprNode* boolean = rse->rse_boolean;
if (boolean)
{
BinaryBoolNode* const binaryNode = boolean->as<BinaryBoolNode>();
BinaryBoolNode* const binaryNode = nodeAs<BinaryBoolNode>(boolean);
if (binaryNode && binaryNode->blrOp == blr_and)
boolean = binaryNode->arg2;
@ -1856,7 +1856,7 @@ BoolExprNode* RseBoolNode::convertNeqAllToNotAny(thread_db* tdbb, CompilerScratc
if (!outerRse || outerRse->type != RseNode::TYPE || outerRse->rse_relations.getCount() != 1 ||
!outerRse->rse_boolean ||
!(outerRseNeq = outerRse->rse_boolean->as<ComparativeBoolNode>()) ||
!(outerRseNeq = nodeAs<ComparativeBoolNode>(outerRse->rse_boolean)) ||
outerRseNeq->blrOp != blr_neq)
{
return NULL;

View File

@ -1025,9 +1025,9 @@ void DdlNode::storeGlobalField(thread_db* tdbb, jrd_tra* transaction, MetaName&
++ptr, ++position)
{
const ValueExprNode* element = *ptr++;
const SLONG lrange = element->as<LiteralNode>()->getSlong();
const SLONG lrange = nodeAs<LiteralNode>(element)->getSlong();
element = *ptr;
const SLONG hrange = element->as<LiteralNode>()->getSlong();
const SLONG hrange = nodeAs<LiteralNode>(element)->getSlong();
if (lrange >= hrange)
{
@ -1547,7 +1547,7 @@ DdlNode* CreateAlterFunctionNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
const NestConst<StmtNode>* ptr = variables->statements.begin();
for (const NestConst<StmtNode>* const end = variables->statements.end(); ptr != end; ++ptr)
{
const DeclareVariableNode* varNode = (*ptr)->as<DeclareVariableNode>();
const DeclareVariableNode* varNode = nodeAs<DeclareVariableNode>(*ptr);
if (varNode)
{
@ -2553,7 +2553,7 @@ DdlNode* CreateAlterProcedureNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
const NestConst<StmtNode>* ptr = variables->statements.begin();
for (const NestConst<StmtNode>* const end = variables->statements.end(); ptr != end; ++ptr)
{
const DeclareVariableNode* varNode = (*ptr)->as<DeclareVariableNode>();
const DeclareVariableNode* varNode = nodeAs<DeclareVariableNode>(*ptr);
if (varNode)
{
@ -6389,7 +6389,7 @@ bool RelationNode::defineDefault(thread_db* /*tdbb*/, DsqlCompilerScratch* dsqlS
value.assign(dsqlScratch->getBlrData());
return ExprNode::is<NullNode>(input);
return nodeIs<NullNode>(input);
}
// Make a constraint object from a legacy node.
@ -8665,22 +8665,21 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
ValueExprNode* nameNode = fieldNode;
const char* aliasName = NULL;
while (nameNode->is<DsqlAliasNode>() || nameNode->is<DerivedFieldNode>() ||
nameNode->is<DsqlMapNode>())
while (nodeIs<DsqlAliasNode>(nameNode) || nodeIs<DerivedFieldNode>(nameNode) || nodeIs<DsqlMapNode>(nameNode))
{
DsqlAliasNode* aliasNode;
DsqlMapNode* mapNode;
DerivedFieldNode* derivedField;
if ((aliasNode = nameNode->as<DsqlAliasNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(nameNode)))
{
if (!aliasName)
aliasName = aliasNode->name.c_str();
nameNode = aliasNode->value;
}
else if ((mapNode = nameNode->as<DsqlMapNode>()))
else if ((mapNode = nodeAs<DsqlMapNode>(nameNode)))
nameNode = mapNode->map->map_node;
else if ((derivedField = nameNode->as<DerivedFieldNode>()))
else if ((derivedField = nodeAs<DerivedFieldNode>(nameNode)))
{
if (!aliasName)
aliasName = derivedField->name.c_str();
@ -8689,7 +8688,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
}
const dsql_fld* nameField = NULL;
const FieldNode* fieldNameNode = nameNode->as<FieldNode>();
const FieldNode* fieldNameNode = nodeAs<FieldNode>(nameNode);
if (fieldNameNode)
nameField = fieldNameNode->dsqlField;
@ -8703,7 +8702,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
// Check if this is a field or an expression.
DsqlAliasNode* aliasNode = fieldNode->as<DsqlAliasNode>();
DsqlAliasNode* aliasNode = nodeAs<DsqlAliasNode>(fieldNode);
if (aliasNode)
fieldNode = aliasNode->value;
@ -8711,7 +8710,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
dsql_fld* field = NULL;
const dsql_ctx* context = NULL;
fieldNameNode = fieldNode->as<FieldNode>();
fieldNameNode = nodeAs<FieldNode>(fieldNode);
if (fieldNameNode)
{
@ -8738,7 +8737,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
if (ptr)
{
if (ptr < end)
fieldStr = (*ptr)->as<FieldNode>()->dsqlName.c_str();
fieldStr = nodeAs<FieldNode>(*ptr)->dsqlName.c_str();
else
{
// Generate an error when going out of this loop.
@ -8951,11 +8950,11 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
Arg::Gds(isc_col_name_err));
}
RseNode* querySpec = selectExpr->querySpec->as<RseNode>();
RseNode* querySpec = nodeAs<RseNode>(selectExpr->querySpec);
fb_assert(querySpec);
if (querySpec->dsqlFrom->items.getCount() != 1 ||
!querySpec->dsqlFrom->items[0]->is<ProcedureSourceNode>())
!nodeIs<ProcedureSourceNode>(querySpec->dsqlFrom->items[0]))
{
// Only one table allowed for VIEW WITH CHECK OPTION
status_exception::raise(
@ -9023,10 +9022,10 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc
dsqlScratch->resetContextStack();
RseNode* querySpec = selectExpr->querySpec->as<RseNode>();
RseNode* querySpec = nodeAs<RseNode>(selectExpr->querySpec);
fb_assert(querySpec);
ProcedureSourceNode* sourceNode = querySpec->dsqlFrom->items[0]->as<ProcedureSourceNode>();
ProcedureSourceNode* sourceNode = nodeAs<ProcedureSourceNode>(querySpec->dsqlFrom->items[0]);
if (triggerType == PRE_MODIFY_TRIGGER)
{
@ -9095,14 +9094,14 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc
NestConst<ValueExprNode> valueNod = *ptr2;
DsqlAliasNode* aliasNode;
if ((aliasNode = fieldNod->as<DsqlAliasNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(fieldNod)))
fieldNod = aliasNode->value;
if ((aliasNode = valueNod->as<DsqlAliasNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(valueNod)))
valueNod = aliasNode->value;
FieldNode* fieldNode = fieldNod->as<FieldNode>();
FieldNode* valueNode = valueNod->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(fieldNod);
FieldNode* valueNode = nodeAs<FieldNode>(valueNod);
// Generate the actual comparisons.
@ -9161,10 +9160,10 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc
ValueExprNode* valueNode = *ptr;
DsqlAliasNode* aliasNode;
if ((aliasNode = valueNode->as<DsqlAliasNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(valueNode)))
valueNode = aliasNode->value;
FieldNode* fieldNode = valueNode->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(valueNode);
fb_assert(fieldNode);
savedNames.add(field->fld_name);
@ -9603,7 +9602,7 @@ void CreateIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
for (; ptr != end; ++ptr)
{
MetaName& column = definition.columns.add();
column = (*ptr)->as<FieldNode>()->dsqlName;
column = nodeAs<FieldNode>(*ptr)->dsqlName;
}
}
else if (computed)
@ -11149,7 +11148,7 @@ void GrantRevokeNode::modifyPrivileges(thread_db* tdbb, jrd_tra* transaction, SS
for (NestConst<ValueExprNode>* ptr = fields->items.begin(); ptr != fields->items.end(); ++ptr)
{
grantRevoke(tdbb, transaction, object, user, privs0,
(*ptr)->as<FieldNode>()->dsqlName, option);
nodeAs<FieldNode>(*ptr)->dsqlName, option);
}
}
else

View File

@ -278,7 +278,7 @@ void DsqlCompilerScratch::putLocalVariables(CompoundStmtNode* parameters, USHORT
DeclareVariableNode* varNode;
if ((varNode = parameter->as<DeclareVariableNode>()))
if ((varNode = nodeAs<DeclareVariableNode>(parameter)))
{
dsql_fld* field = varNode->dsqlDef->type;
const NestConst<StmtNode>* rest = ptr;
@ -287,7 +287,7 @@ void DsqlCompilerScratch::putLocalVariables(CompoundStmtNode* parameters, USHORT
{
const DeclareVariableNode* varNode2;
if ((varNode2 = (*rest)->as<DeclareVariableNode>()))
if ((varNode2 = nodeAs<DeclareVariableNode>(*rest)))
{
const dsql_fld* rest_field = varNode2->dsqlDef->type;
@ -607,11 +607,11 @@ void DsqlCompilerScratch::checkUnusedCTEs() const
SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
{
RecordSourceNode* const query = input->querySpec;
UnionSourceNode* unionQuery = query->as<UnionSourceNode>();
UnionSourceNode* unionQuery = nodeAs<UnionSourceNode>(query);
if (!unionQuery)
{
if (!pass1RseIsRecursive(query->as<RseNode>()))
if (!pass1RseIsRecursive(nodeAs<RseNode>(query)))
return input;
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -640,7 +640,7 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
if (iter == unionQuery->dsqlClauses->items.begin())
{
unionQuery = clause->as<UnionSourceNode>();
unionQuery = nodeAs<UnionSourceNode>(clause);
if (unionQuery)
{
@ -654,7 +654,7 @@ SelectExprNode* DsqlCompilerScratch::pass1RecursiveCte(SelectExprNode* input)
}
}
RseNode* const rse = clause->as<RseNode>();
RseNode* const rse = nodeAs<RseNode>(clause);
fb_assert(rse);
RseNode* const newRse = pass1RseIsRecursive(rse);
@ -815,7 +815,7 @@ RseNode* DsqlCompilerScratch::pass1RseIsRecursive(RseNode* input)
{
*prev++ = *pDstTable = *pSrcTable;
RseNode* rseNode = (*pDstTable)->as<RseNode>();
RseNode* rseNode = nodeAs<RseNode>(*pDstTable);
if (rseNode)
{
@ -841,7 +841,7 @@ RseNode* DsqlCompilerScratch::pass1RseIsRecursive(RseNode* input)
result->dsqlWhere = PASS1_compose(result->dsqlWhere, joinBool, blr_and);
}
}
else if ((*pDstTable)->is<ProcedureSourceNode>() || (*pDstTable)->is<RelationSourceNode>())
else if (nodeIs<ProcedureSourceNode>(*pDstTable) || nodeIs<RelationSourceNode>(*pDstTable))
{
if (pass1RelProcIsRecursive(*pDstTable))
{
@ -858,9 +858,7 @@ RseNode* DsqlCompilerScratch::pass1RseIsRecursive(RseNode* input)
}
}
else
{
fb_assert((*pDstTable)->is<SelectExprNode>());
}
fb_assert(nodeIs<SelectExprNode>(*pDstTable));
}
if (found)
@ -877,12 +875,12 @@ bool DsqlCompilerScratch::pass1RelProcIsRecursive(RecordSourceNode* input)
ProcedureSourceNode* procNode;
RelationSourceNode* relNode;
if ((procNode = input->as<ProcedureSourceNode>()))
if ((procNode = nodeAs<ProcedureSourceNode>(input)))
{
relName = procNode->dsqlName.identifier;
relAlias = procNode->alias;
}
else if ((relNode = input->as<RelationSourceNode>()))
else if ((relNode = nodeAs<RelationSourceNode>(input)))
{
relName = relNode->dsqlName;
relAlias = relNode->alias;
@ -906,7 +904,7 @@ bool DsqlCompilerScratch::pass1RelProcIsRecursive(RecordSourceNode* input)
// outer join or more than one recursive reference is found
BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input)
{
RseNode* inputRse = input->as<RseNode>();
RseNode* inputRse = nodeAs<RseNode>(input);
fb_assert(inputRse);
const UCHAR joinType = inputRse->rse_jointype;
@ -917,7 +915,7 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
NestConst<RecordSourceNode>* joinTable = &inputRse->dsqlFrom->items[0];
RseNode* joinRse;
if ((joinRse = (*joinTable)->as<RseNode>()) && joinRse->dsqlExplicitJoin)
if ((joinRse = nodeAs<RseNode>(*joinTable)) && joinRse->dsqlExplicitJoin)
{
leftBool = pass1JoinIsRecursive(*joinTable->getAddress());
leftRecursive = (leftBool != NULL);
@ -943,7 +941,7 @@ BoolExprNode* DsqlCompilerScratch::pass1JoinIsRecursive(RecordSourceNode*& input
joinTable = &inputRse->dsqlFrom->items[1];
if ((joinRse = (*joinTable)->as<RseNode>()) && joinRse->dsqlExplicitJoin)
if ((joinRse = nodeAs<RseNode>(*joinTable)) && joinRse->dsqlExplicitJoin)
{
rightBool = pass1JoinIsRecursive(*joinTable->getAddress());
rightRecursive = (rightBool != NULL);

View File

@ -148,7 +148,7 @@ namespace
for (ExprNode** node = csb->csb_current_nodes.end() - 1;
node >= csb->csb_current_nodes.begin(); --node)
{
RseNode* const rseNode = (*node)->as<RseNode>();
RseNode* const rseNode = nodeAs<RseNode>(*node);
if (rseNode)
{
@ -195,7 +195,7 @@ void NodeRef::pass2(thread_db* tdbb, CompilerScratch* csb)
{
if (csb->csb_current_nodes.hasData())
{
RseNode* topRseNode = csb->csb_current_nodes[0]->as<RseNode>();
RseNode* topRseNode = nodeAs<RseNode>(csb->csb_current_nodes[0]);
fb_assert(topRseNode);
if (!topRseNode->rse_invariants)
@ -486,7 +486,7 @@ void ArithmeticNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
desc2.setNull();
}
if (arg1->is<NullNode>() && arg2->is<NullNode>())
if (nodeIs<NullNode>(arg1) && nodeIs<NullNode>(arg2))
{
// NULL + NULL = NULL of INT
desc->makeLong(0);
@ -1606,7 +1606,7 @@ bool ArithmeticNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const ArithmeticNode* o = other->as<ArithmeticNode>();
const ArithmeticNode* o = nodeAs<ArithmeticNode>(other);
fb_assert(o);
return dialect1 == o->dialect1 && blrOp == o->blrOp;
@ -1614,7 +1614,7 @@ bool ArithmeticNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
bool ArithmeticNode::sameAs(const ExprNode* other, bool ignoreStreams) const
{
const ArithmeticNode* const otherNode = other->as<ArithmeticNode>();
const ArithmeticNode* const otherNode = nodeAs<ArithmeticNode>(other);
if (!otherNode || blrOp != otherNode->blrOp || dialect1 != otherNode->dialect1)
return false;
@ -1738,15 +1738,15 @@ dsc* ArithmeticNode::execute(thread_db* tdbb, jrd_req* request) const
// This function can be removed when dialect-3 becomes the lowest supported dialect. (Version 7.0?)
dsc* ArithmeticNode::add(const dsc* desc, impure_value* value, const ValueExprNode* node, const UCHAR blrOp)
{
const ArithmeticNode* arithmeticNode = node->as<ArithmeticNode>();
const ArithmeticNode* arithmeticNode = nodeAs<ArithmeticNode>(node);
thread_db* tdbb = JRD_get_thread_data();
#ifdef DEV_BUILD
const SubQueryNode* subQueryNode = node->as<SubQueryNode>();
const SubQueryNode* subQueryNode = nodeAs<SubQueryNode>(node);
fb_assert(
(arithmeticNode && arithmeticNode->dialect1 &&
(arithmeticNode->blrOp == blr_add || arithmeticNode->blrOp == blr_subtract)) ||
node->is<AggNode>() ||
nodeIs<AggNode>(node) ||
(subQueryNode && (subQueryNode->blrOp == blr_total || subQueryNode->blrOp == blr_average)));
#endif
@ -1821,12 +1821,12 @@ dsc* ArithmeticNode::add(const dsc* desc, impure_value* value, const ValueExprNo
// the blr_add, blr_subtract, and blr_agg_total verbs following a blr_version5.
dsc* ArithmeticNode::add2(const dsc* desc, impure_value* value, const ValueExprNode* node, const UCHAR blrOp)
{
const ArithmeticNode* arithmeticNode = node->as<ArithmeticNode>();
const ArithmeticNode* arithmeticNode = nodeAs<ArithmeticNode>(node);
fb_assert(
(arithmeticNode && !arithmeticNode->dialect1 &&
(arithmeticNode->blrOp == blr_add || arithmeticNode->blrOp == blr_subtract)) ||
node->is<AggNode>());
nodeIs<AggNode>(node));
dsc* result = &value->vlu_desc;
@ -2902,7 +2902,7 @@ bool CastNode::setParameterType(DsqlCompilerScratch* /*dsqlScratch*/,
{
// ASF: Attention: CastNode::dsqlPass calls us with NULL node.
ParameterNode* paramNode = source->as<ParameterNode>();
ParameterNode* paramNode = nodeAs<ParameterNode>(source);
if (paramNode)
{
@ -2980,7 +2980,7 @@ bool CastNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const CastNode* o = other->as<CastNode>();
const CastNode* o = nodeAs<CastNode>(other);
fb_assert(o);
return dsqlField == o->dsqlField;
@ -2991,7 +2991,7 @@ bool CastNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const CastNode* const otherNode = other->as<CastNode>();
const CastNode* const otherNode = nodeAs<CastNode>(other);
fb_assert(otherNode);
return DSC_EQUIV(&castDesc, &otherNode->castDesc, true);
@ -4167,13 +4167,13 @@ bool DecodeNode::setParameterType(DsqlCompilerScratch* dsqlScratch,
const dsc* desc, bool /*forceVarChar*/)
{
// Check if there is a parameter in the test/conditions.
bool setParameters = test->is<ParameterNode>();
bool setParameters = nodeIs<ParameterNode>(test);
if (!setParameters)
{
for (auto& condition : conditions->items)
{
if (condition->is<ParameterNode>())
if (nodeIs<ParameterNode>(condition))
{
setParameters = true;
break;
@ -4450,7 +4450,7 @@ bool DefaultNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const DefaultNode* o = other->as<DefaultNode>();
const DefaultNode* o = nodeAs<DefaultNode>(other);
fb_assert(o);
return relationName == o->relationName && fieldName == o->fieldName;
@ -4768,7 +4768,7 @@ ValueExprNode* ExtractNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
case blr_extract_weekday:
case blr_extract_yearday:
case blr_extract_week:
if (!ExprNode::is<NullNode>(sub1) &&
if (!nodeIs<NullNode>(sub1) &&
sub1->nodDesc.dsc_dtype != dtype_sql_date &&
sub1->nodDesc.dsc_dtype != dtype_timestamp)
{
@ -4781,7 +4781,7 @@ ValueExprNode* ExtractNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
case blr_extract_minute:
case blr_extract_second:
case blr_extract_millisecond:
if (!ExprNode::is<NullNode>(sub1) &&
if (!nodeIs<NullNode>(sub1) &&
sub1->nodDesc.dsc_dtype != dtype_sql_time &&
sub1->nodDesc.dsc_dtype != dtype_timestamp)
{
@ -4871,7 +4871,7 @@ bool ExtractNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const ExtractNode* o = other->as<ExtractNode>();
const ExtractNode* o = nodeAs<ExtractNode>(other);
fb_assert(o);
return blrSubOp == o->blrSubOp;
@ -4882,7 +4882,7 @@ bool ExtractNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const ExtractNode* const otherNode = other->as<ExtractNode>();
const ExtractNode* const otherNode = nodeAs<ExtractNode>(other);
fb_assert(otherNode);
return blrSubOp == otherNode->blrSubOp;
@ -5533,7 +5533,7 @@ ValueExprNode* FieldNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch, Rec
for (auto& rseItem : rseItems->items)
{
DerivedFieldNode* selectItem = rseItem->as<DerivedFieldNode>();
DerivedFieldNode* selectItem = nodeAs<DerivedFieldNode>(rseItem);
// select-item should always be a alias!
if (selectItem)
@ -5814,7 +5814,7 @@ bool FieldNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const FieldNode* o = other->as<FieldNode>();
const FieldNode* o = nodeAs<FieldNode>(other);
fb_assert(o);
if (dsqlField != o->dsqlField || dsqlContext != o->dsqlContext)
@ -5831,7 +5831,7 @@ bool FieldNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const FieldNode* const otherNode = other->as<FieldNode>();
const FieldNode* const otherNode = nodeAs<FieldNode>(other);
fb_assert(otherNode);
return fieldId == otherNode->fieldId &&
@ -6373,7 +6373,7 @@ bool GenIdNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const GenIdNode* o = other->as<GenIdNode>();
const GenIdNode* o = nodeAs<GenIdNode>(other);
fb_assert(o);
// I'm not sure if I should include "implicit" in the comparison, but it means different BLR code
@ -6387,7 +6387,7 @@ bool GenIdNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const GenIdNode* const otherNode = other->as<GenIdNode>();
const GenIdNode* const otherNode = nodeAs<GenIdNode>(other);
fb_assert(otherNode);
// I'm not sure if I should include "implicit" in the comparison, but it means different BLR code
@ -6489,7 +6489,7 @@ DmlNode* InternalInfoNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScra
node->arg = PAR_parse_value(tdbb, csb);
LiteralNode* literal = node->arg->as<LiteralNode>();
LiteralNode* literal = nodeAs<LiteralNode>(node->arg);
if (!literal || literal->litDesc.dsc_dtype != dtype_long)
{
@ -6511,7 +6511,7 @@ string InternalInfoNode::internalPrint(NodePrinter& printer) const
void InternalInfoNode::setParameterName(dsql_par* parameter) const
{
SLONG infoType = arg->as<LiteralNode>()->getSlong();
SLONG infoType = nodeAs<LiteralNode>(arg)->getSlong();
parameter->par_name = parameter->par_alias = INFO_TYPE_ATTRIBUTES[infoType].alias;
}
@ -6523,7 +6523,7 @@ void InternalInfoNode::genBlr(DsqlCompilerScratch* dsqlScratch)
void InternalInfoNode::make(DsqlCompilerScratch* /*dsqlScratch*/, dsc* desc)
{
const InfoType infoType = static_cast<InfoType>(arg->as<LiteralNode>()->getSlong());
const InfoType infoType = static_cast<InfoType>(nodeAs<LiteralNode>(arg)->getSlong());
switch (infoType)
{
@ -6558,7 +6558,7 @@ void InternalInfoNode::make(DsqlCompilerScratch* /*dsqlScratch*/, dsc* desc)
void InternalInfoNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
{
fb_assert(arg->is<LiteralNode>());
fb_assert(nodeIs<LiteralNode>(arg));
dsc argDesc;
arg->getDesc(tdbb, csb, &argDesc);
@ -6715,7 +6715,7 @@ dsc* InternalInfoNode::execute(thread_db* tdbb, jrd_req* request) const
ValueExprNode* InternalInfoNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
SLONG infoType = arg->as<LiteralNode>()->getSlong();
SLONG infoType = nodeAs<LiteralNode>(arg)->getSlong();
const InfoAttr& attr = INFO_TYPE_ATTRIBUTES[infoType];
if (attr.mask && !(dsqlScratch->flags & attr.mask))
@ -7142,7 +7142,7 @@ bool LiteralNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const LiteralNode* o = other->as<LiteralNode>();
const LiteralNode* o = nodeAs<LiteralNode>(other);
fb_assert(o);
if (!DSC_EQUIV(&litDesc, &o->litDesc, true))
@ -7158,7 +7158,7 @@ bool LiteralNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const LiteralNode* const otherNode = other->as<LiteralNode>();
const LiteralNode* const otherNode = nodeAs<LiteralNode>(other);
fb_assert(otherNode);
thread_db* tdbb = JRD_get_thread_data();
@ -7348,7 +7348,7 @@ void DsqlMapNode::setParameterName(dsql_par* parameter) const
const ValueExprNode* nestNode = map->map_node;
const DsqlMapNode* mapNode;
while ((mapNode = ExprNode::as<DsqlMapNode>(nestNode)))
while ((mapNode = nodeAs<DsqlMapNode>(nestNode)))
{
// Skip all the DsqlMapNodes.
nestNode = mapNode->map->map_node;
@ -7364,25 +7364,25 @@ void DsqlMapNode::setParameterName(dsql_par* parameter) const
const DerivedFieldNode* derivedField;
const RecordKeyNode* dbKeyNode;
if ((aggNode = ExprNode::as<AggNode>(nestNode)))
if ((aggNode = nodeAs<AggNode>(nestNode)))
aggNode->setParameterName(parameter);
else if ((aliasNode = ExprNode::as<DsqlAliasNode>(nestNode)))
else if ((aliasNode = nodeAs<DsqlAliasNode>(nestNode)))
{
parameter->par_alias = aliasNode->name;
alias = aliasNode->value;
fieldNode = ExprNode::as<FieldNode>(alias);
fieldNode = nodeAs<FieldNode>(alias);
}
else if ((literalNode = ExprNode::as<LiteralNode>(nestNode)))
else if ((literalNode = nodeAs<LiteralNode>(nestNode)))
literalNode->setParameterName(parameter);
else if ((dbKeyNode = ExprNode::as<RecordKeyNode>(nestNode)))
else if ((dbKeyNode = nodeAs<RecordKeyNode>(nestNode)))
nameAlias = dbKeyNode->getAlias(false);
else if ((derivedField = ExprNode::as<DerivedFieldNode>(nestNode)))
else if ((derivedField = nodeAs<DerivedFieldNode>(nestNode)))
{
parameter->par_alias = derivedField->name;
alias = derivedField->value;
fieldNode = ExprNode::as<FieldNode>(alias);
fieldNode = nodeAs<FieldNode>(alias);
}
else if ((fieldNode = ExprNode::as<FieldNode>(nestNode)))
else if ((fieldNode = nodeAs<FieldNode>(nestNode)))
nameAlias = fieldNode->dsqlField->fld_name.c_str();
const dsql_ctx* context = NULL;
@ -7424,7 +7424,7 @@ void DsqlMapNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
bool DsqlMapNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
{
const DsqlMapNode* o = other->as<DsqlMapNode>();
const DsqlMapNode* o = nodeAs<DsqlMapNode>(other);
return o && PASS1_node_match(map->map_node, o->map->map_node, ignoreMapCast);
}
@ -7543,12 +7543,12 @@ void DerivedFieldNode::setParameterName(dsql_par* parameter) const
const FieldNode* fieldNode;
const RecordKeyNode* dbKeyNode;
if ((fieldNode = value->as<FieldNode>()))
if ((fieldNode = nodeAs<FieldNode>(value)))
{
parameter->par_name = fieldNode->dsqlField->fld_name.c_str();
context = fieldNode->dsqlContext;
}
else if ((dbKeyNode = value->as<RecordKeyNode>()))
else if ((dbKeyNode = nodeAs<RecordKeyNode>(value)))
dbKeyNode->setParameterName(parameter);
parameter->par_alias = name;
@ -7564,11 +7564,11 @@ void DerivedFieldNode::genBlr(DsqlCompilerScratch* dsqlScratch)
ValueExprNode* val = value;
while (val->is<DsqlAliasNode>())
val = val->as<DsqlAliasNode>()->value;
while (nodeIs<DsqlAliasNode>(val))
val = nodeAs<DsqlAliasNode>(val)->value;
if (!val->is<FieldNode>() && !val->is<DerivedFieldNode>() &&
!val->is<RecordKeyNode>() && !val->is<DsqlMapNode>())
if (!nodeIs<FieldNode>(val) && !nodeIs<DerivedFieldNode>(val) &&
!nodeIs<RecordKeyNode>(val) && !nodeIs<DsqlMapNode>(val))
{
if (context->ctx_main_derived_contexts.hasData())
{
@ -7615,7 +7615,7 @@ void DerivedFieldNode::genBlr(DsqlCompilerScratch* dsqlScratch)
else if (!(dsqlScratch->flags & DsqlCompilerScratch::FLAG_FETCH) &&
!(context->ctx_flags & CTX_system) &&
(context->ctx_flags & CTX_cursor) &&
val->is<FieldNode>())
nodeIs<FieldNode>(val))
{
// ASF: FieldNode::execute does not verify rpb_number.isValid(), and due to system triggers
// and also singular queries, we cannot start to do it. So to fix CORE-4488, we introduce
@ -7623,7 +7623,7 @@ void DerivedFieldNode::genBlr(DsqlCompilerScratch* dsqlScratch)
// FieldNode::execute by a test of rpb_number.isValid().
dsqlScratch->appendUChar(blr_derived_expr);
dsqlScratch->appendUChar(1);
GEN_stuff_context(dsqlScratch, val->as<FieldNode>()->dsqlContext);
GEN_stuff_context(dsqlScratch, nodeAs<FieldNode>(val)->dsqlContext);
}
GEN_expr(dsqlScratch, value);
@ -7646,7 +7646,7 @@ NegateNode::NegateNode(MemoryPool& pool, ValueExprNode* aArg)
{
addChildNode(arg, arg);
LiteralNode* literal = arg->as<LiteralNode>();
LiteralNode* literal = nodeAs<LiteralNode>(arg);
if (literal && literal->litDesc.dsc_dtype == dtype_dec128)
literal->fixMinSInt64();
}
@ -7679,17 +7679,17 @@ void NegateNode::setParameterName(dsql_par* parameter) const
const ValueExprNode* innerNode = arg;
const NegateNode* innerNegateNode;
while ((innerNegateNode = ExprNode::as<NegateNode>(innerNode)))
while ((innerNegateNode = nodeAs<NegateNode>(innerNode)))
{
innerNode = innerNegateNode->arg;
++level;
}
if (ExprNode::is<NullNode>(innerNode) || ExprNode::is<LiteralNode>(innerNode))
if (nodeIs<NullNode>(innerNode) || nodeIs<LiteralNode>(innerNode))
parameter->par_name = parameter->par_alias = "CONSTANT";
else if (!level)
{
const ArithmeticNode* arithmeticNode = ExprNode::as<ArithmeticNode>(innerNode);
const ArithmeticNode* arithmeticNode = nodeAs<ArithmeticNode>(innerNode);
if (arithmeticNode && (
/*arithmeticNode->blrOp == blr_add ||
@ -7710,7 +7710,7 @@ bool NegateNode::setParameterType(DsqlCompilerScratch* dsqlScratch,
void NegateNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
LiteralNode* literal = arg->as<LiteralNode>();
LiteralNode* literal = nodeAs<LiteralNode>(arg);
if (literal && DTYPE_IS_NUMERIC(literal->litDesc.dsc_dtype))
LiteralNode::genConstant(dsqlScratch, &literal->litDesc, true);
@ -7725,7 +7725,7 @@ void NegateNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, desc, arg);
if (arg->is<NullNode>())
if (nodeIs<NullNode>(arg))
{
// -NULL = NULL of INT
desc->makeLong(0);
@ -7961,7 +7961,7 @@ bool OrderNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const OrderNode* o = other->as<OrderNode>();
const OrderNode* o = nodeAs<OrderNode>(other);
return o && descending == o->descending && nullsPlacement == o->nullsPlacement;
}
@ -7975,7 +7975,7 @@ bool WindowClause::Frame::sameAs(const ExprNode* other, bool ignoreStreams) cons
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const Frame* const otherNode = other->as<Frame>();
const Frame* const otherNode = nodeAs<Frame>(other);
fb_assert(otherNode);
return bound == otherNode->bound;
@ -8007,7 +8007,7 @@ bool WindowClause::FrameExtent::sameAs(const ExprNode* other, bool ignoreStreams
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const FrameExtent* const otherNode = other->as<FrameExtent>();
const FrameExtent* const otherNode = nodeAs<FrameExtent>(other);
fb_assert(otherNode);
return unit == otherNode->unit;
@ -8116,7 +8116,7 @@ WindowClause* WindowClause::dsqlPass(DsqlCompilerScratch* dsqlScratch)
}
else
{
OrderNode* key = node->order->items[0]->as<OrderNode>();
OrderNode* key = nodeAs<OrderNode>(node->order->items[0]);
fb_assert(key);
dsc desc;
@ -8345,7 +8345,7 @@ ValueExprNode* OverNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
OverNode* node = FB_NEW_POOL(getPool()) OverNode(getPool(),
static_cast<AggNode*>(doDsqlPass(dsqlScratch, aggExpr)), doDsqlPass(dsqlScratch, refWindow));
const AggNode* aggNode = node->aggExpr->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(node->aggExpr);
if (node->window &&
node->window->extent &&
@ -8605,7 +8605,7 @@ void ParameterNode::make(DsqlCompilerScratch* /*dsqlScratch*/, dsc* desc)
bool ParameterNode::dsqlMatch(const ExprNode* other, bool /*ignoreMapCast*/) const
{
const ParameterNode* o = other->as<ParameterNode>();
const ParameterNode* o = nodeAs<ParameterNode>(other);
return o && dsqlParameter->par_index == o->dsqlParameter->par_index;
}
@ -9047,7 +9047,7 @@ bool RecordKeyNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const RecordKeyNode* o = other->as<RecordKeyNode>();
const RecordKeyNode* o = nodeAs<RecordKeyNode>(other);
fb_assert(o);
return blrOp == o->blrOp;
@ -9058,7 +9058,7 @@ bool RecordKeyNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const RecordKeyNode* const otherNode = other->as<RecordKeyNode>();
const RecordKeyNode* const otherNode = nodeAs<RecordKeyNode>(other);
fb_assert(otherNode);
return blrOp == otherNode->blrOp && (ignoreStreams || recStream == otherNode->recStream);
@ -9095,7 +9095,7 @@ ValueExprNode* RecordKeyNode::pass1(thread_db* tdbb, CompilerScratch* csb)
for (ValueExprNodeStack::iterator i(stack); i.hasData(); ++i)
{
#ifdef CMP_DEBUG
csb->dump(" %d", ExprNode::as<RecordKeyNode>(i.object())->recStream);
csb->dump(" %d", nodeAs<RecordKeyNode>(i.object())->recStream);
#endif
ValueIfNode* valueIfNode = FB_NEW_POOL(csb->csb_pool) ValueIfNode(csb->csb_pool);
@ -9349,7 +9349,7 @@ DmlNode* ScalarNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c
void ScalarNode::getDesc(thread_db* /*tdbb*/, CompilerScratch* csb, dsc* desc)
{
FieldNode* fieldNode = field->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(field);
fb_assert(fieldNode);
jrd_rel* relation = csb->csb_rpt[fieldNode->fieldStream].csb_relation;
@ -9435,18 +9435,18 @@ DmlNode* StmtExprNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
node->expr = PAR_parse_value(tdbb, csb);
// Avoid blr_stmt_expr in a BLR expression header
CompoundStmtNode* const stmt = node->stmt->as<CompoundStmtNode>();
CompoundStmtNode* const stmt = nodeAs<CompoundStmtNode>(node->stmt);
if (stmt)
{
if (stmt->statements.getCount() != 2 ||
!stmt->statements[0]->is<DeclareVariableNode>() ||
!stmt->statements[1]->is<AssignmentNode>())
!nodeIs<DeclareVariableNode>(stmt->statements[0]) ||
!nodeIs<AssignmentNode>(stmt->statements[1]))
{
return node->expr;
}
}
else if (!node->stmt->is<AssignmentNode>())
else if (!nodeIs<AssignmentNode>(node->stmt))
return node->expr;
return node;
@ -9575,7 +9575,7 @@ bool StrCaseNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const StrCaseNode* o = other->as<StrCaseNode>();
const StrCaseNode* o = nodeAs<StrCaseNode>(other);
fb_assert(o);
return blrOp == o->blrOp;
@ -9586,7 +9586,7 @@ bool StrCaseNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const StrCaseNode* const otherNode = other->as<StrCaseNode>();
const StrCaseNode* const otherNode = nodeAs<StrCaseNode>(other);
fb_assert(otherNode);
return blrOp == otherNode->blrOp;
@ -9790,7 +9790,7 @@ bool StrLenNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const StrLenNode* o = other->as<StrLenNode>();
const StrLenNode* o = nodeAs<StrLenNode>(other);
fb_assert(o);
return blrSubOp == o->blrSubOp;
@ -9801,7 +9801,7 @@ bool StrLenNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const StrLenNode* const otherNode = other->as<StrLenNode>();
const StrLenNode* const otherNode = nodeAs<StrLenNode>(other);
fb_assert(otherNode);
return blrSubOp == otherNode->blrSubOp;
@ -9993,7 +9993,7 @@ ValueExprNode* SubQueryNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
const DsqlContextStack::iterator base(*dsqlScratch->context);
RseNode* rse = PASS1_rse(dsqlScratch, dsqlRse->as<SelectExprNode>(), false);
RseNode* rse = PASS1_rse(dsqlScratch, nodeAs<SelectExprNode>(dsqlRse), false);
SubQueryNode* node = FB_NEW_POOL(getPool()) SubQueryNode(getPool(), blrOp, rse,
rse->dsqlSelectList->items[0], FB_NEW_POOL(getPool()) NullNode(getPool()));
@ -10050,7 +10050,7 @@ bool SubQueryNode::dsqlFieldFinder(FieldFinder& visitor)
ValueExprNode* SubQueryNode::dsqlFieldRemapper(FieldRemapper& visitor)
{
doDsqlFieldRemapper(visitor, dsqlRse);
value1 = dsqlRse->as<RseNode>()->dsqlSelectList->items[0];
value1 = nodeAs<RseNode>(dsqlRse)->dsqlSelectList->items[0];
return this;
}
@ -10244,7 +10244,7 @@ ValueExprNode* SubQueryNode::pass2(thread_db* tdbb, CompilerScratch* csb)
// Bind values of invariant nodes to top-level RSE (if present).
if ((nodFlags & FLAG_INVARIANT) && csb->csb_current_nodes.hasData())
{
RseNode* topRseNode = csb->csb_current_nodes[0]->as<RseNode>();
RseNode* topRseNode = nodeAs<RseNode>(csb->csb_current_nodes[0]);
fb_assert(topRseNode);
if (!topRseNode->rse_invariants)
@ -10522,7 +10522,7 @@ void SubstringNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
{
MAKE_desc(dsqlScratch, &desc3, length);
if (!length->is<LiteralNode>())
if (!nodeIs<LiteralNode>(length))
desc3.dsc_address = NULL;
}
@ -10537,7 +10537,7 @@ void SubstringNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
ValueExprNode* offsetNode = start;
ValueExprNode* decrementNode = NULL;
ArithmeticNode* arithmeticNode = offsetNode->as<ArithmeticNode>();
ArithmeticNode* arithmeticNode = nodeAs<ArithmeticNode>(offsetNode);
// ASF: This code is very strange. The DSQL node is created as dialect 1, but only the dialect
// 3 is verified here. Also, this task seems unnecessary here, as it must be done during
@ -10561,7 +10561,7 @@ void SubstringNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
desc->dsc_flags |= DSC_null;
else
{
if (length->is<LiteralNode>() && desc2.dsc_dtype == dtype_long)
if (nodeIs<LiteralNode>(length) && desc2.dsc_dtype == dtype_long)
{
const SLONG len = MOV_get_long(tdbb, &desc2, 0);
@ -10867,11 +10867,11 @@ ValueExprNode* SubstringSimilarNode::pass1(thread_db* tdbb, CompilerScratch* csb
// If there is no top-level RSE present and patterns are not constant, unmark node as invariant
// because it may be dependent on data or variables.
if ((nodFlags & FLAG_INVARIANT) && (!pattern->is<LiteralNode>() || !escape->is<LiteralNode>()))
if ((nodFlags & FLAG_INVARIANT) && (!nodeIs<LiteralNode>(pattern) || !nodeIs<LiteralNode>(escape)))
{
for (const auto& ctxNode : csb->csb_current_nodes)
{
if (ctxNode->as<RseNode>())
if (nodeAs<RseNode>(ctxNode))
return this;
}
@ -11100,7 +11100,7 @@ void SysFuncCallNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
// dsc_address is verified in makeFunc to get literals. If the node is not a
// literal, set it to NULL, to prevent wrong interpretation of offsets as
// pointers - CORE-2612.
if (!arg->is<LiteralNode>())
if (!nodeIs<LiteralNode>(arg))
targetDesc->dsc_address = NULL;
}
@ -11125,7 +11125,7 @@ bool SysFuncCallNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const SysFuncCallNode* otherNode = other->as<SysFuncCallNode>();
const SysFuncCallNode* otherNode = nodeAs<SysFuncCallNode>(other);
return name == otherNode->name;
}
@ -11135,7 +11135,7 @@ bool SysFuncCallNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const SysFuncCallNode* const otherNode = other->as<SysFuncCallNode>();
const SysFuncCallNode* const otherNode = nodeAs<SysFuncCallNode>(other);
fb_assert(otherNode);
return function && function == otherNode->function;
@ -11356,7 +11356,7 @@ bool TrimNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const TrimNode* o = other->as<TrimNode>();
const TrimNode* o = nodeAs<TrimNode>(other);
fb_assert(o);
return where == o->where;
@ -11367,7 +11367,7 @@ bool TrimNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const TrimNode* const otherNode = other->as<TrimNode>();
const TrimNode* const otherNode = nodeAs<TrimNode>(other);
fb_assert(otherNode);
return where == otherNode->where;
@ -11722,7 +11722,7 @@ bool UdfCallNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
if (!ExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const UdfCallNode* otherNode = other->as<UdfCallNode>();
const UdfCallNode* otherNode = nodeAs<UdfCallNode>(other);
return name == otherNode->name;
}
@ -11732,7 +11732,7 @@ bool UdfCallNode::sameAs(const ExprNode* other, bool ignoreStreams) const
if (!ExprNode::sameAs(other, ignoreStreams))
return false;
const UdfCallNode* const otherNode = other->as<UdfCallNode>();
const UdfCallNode* const otherNode = nodeAs<UdfCallNode>(other);
fb_assert(otherNode);
return function && function == otherNode->function;
@ -12084,31 +12084,31 @@ DmlNode* ValueIfNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
// Get rid of blr_stmt_expr expressions.
// Coalesce.
MissingBoolNode* missing = node->condition->as<MissingBoolNode>();
MissingBoolNode* missing = nodeAs<MissingBoolNode>(node->condition);
if (missing)
{
StmtExprNode* missingCond = missing->arg->as<StmtExprNode>();
StmtExprNode* missingCond = nodeAs<StmtExprNode>(missing->arg);
if (!missingCond)
return node;
CompoundStmtNode* stmt = missingCond->stmt->as<CompoundStmtNode>();
CompoundStmtNode* stmt = nodeAs<CompoundStmtNode>(missingCond->stmt);
DeclareVariableNode* declStmt = NULL;
AssignmentNode* assignStmt;
if (stmt)
{
if (stmt->statements.getCount() != 2 ||
!(declStmt = stmt->statements[0]->as<DeclareVariableNode>()) ||
!(assignStmt = stmt->statements[1]->as<AssignmentNode>()))
!(declStmt = nodeAs<DeclareVariableNode>(stmt->statements[0])) ||
!(assignStmt = nodeAs<AssignmentNode>(stmt->statements[1])))
{
return node;
}
}
else if (!(assignStmt = missingCond->stmt->as<AssignmentNode>()))
else if (!(assignStmt = nodeAs<AssignmentNode>(missingCond->stmt)))
return node;
VariableNode* var = node->falseValue->as<VariableNode>();
VariableNode* var2 = assignStmt->asgnTo->as<VariableNode>();
VariableNode* var = nodeAs<VariableNode>(node->falseValue);
VariableNode* var2 = nodeAs<VariableNode>(assignStmt->asgnTo);
if (!var || !var2 || var->varId != var2->varId || (declStmt && declStmt->varId != var->varId))
return node;
@ -12122,30 +12122,30 @@ DmlNode* ValueIfNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
}
// Decode.
ComparativeBoolNode* cmp = node->condition->as<ComparativeBoolNode>();
ComparativeBoolNode* cmp = nodeAs<ComparativeBoolNode>(node->condition);
if (cmp && cmp->blrOp == blr_eql)
{
StmtExprNode* cmpCond = cmp->arg1->as<StmtExprNode>();
StmtExprNode* cmpCond = nodeAs<StmtExprNode>(cmp->arg1);
if (!cmpCond)
return node;
CompoundStmtNode* stmt = cmpCond->stmt->as<CompoundStmtNode>();
CompoundStmtNode* stmt = nodeAs<CompoundStmtNode>(cmpCond->stmt);
DeclareVariableNode* declStmt = NULL;
AssignmentNode* assignStmt;
if (stmt)
{
if (stmt->statements.getCount() != 2 ||
!(declStmt = stmt->statements[0]->as<DeclareVariableNode>()) ||
!(assignStmt = stmt->statements[1]->as<AssignmentNode>()))
!(declStmt = nodeAs<DeclareVariableNode>(stmt->statements[0])) ||
!(assignStmt = nodeAs<AssignmentNode>(stmt->statements[1])))
{
return node;
}
}
else if (!(assignStmt = cmpCond->stmt->as<AssignmentNode>()))
else if (!(assignStmt = nodeAs<AssignmentNode>(cmpCond->stmt)))
return node;
VariableNode* var = assignStmt->asgnTo->as<VariableNode>();
VariableNode* var = nodeAs<VariableNode>(assignStmt->asgnTo);
if (!var || (declStmt && declStmt->varId != var->varId))
return node;
@ -12159,13 +12159,13 @@ DmlNode* ValueIfNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch*
decodeNode->values->add(node->trueValue);
ValueExprNode* last = node->falseValue;
while ((node = last->as<ValueIfNode>()))
while ((node = nodeAs<ValueIfNode>(last)))
{
ComparativeBoolNode* cmp = node->condition->as<ComparativeBoolNode>();
ComparativeBoolNode* cmp = nodeAs<ComparativeBoolNode>(node->condition);
if (!cmp || cmp->blrOp != blr_eql)
break;
VariableNode* var2 = cmp->arg1->as<VariableNode>();
VariableNode* var2 = nodeAs<VariableNode>(cmp->arg1);
if (!var2 || var2->varId != var->varId)
break;
@ -12248,7 +12248,7 @@ void ValueIfNode::make(DsqlCompilerScratch* dsqlScratch, dsc* desc)
void ValueIfNode::getDesc(thread_db* tdbb, CompilerScratch* csb, dsc* desc)
{
ValueExprNode* val = trueValue->is<NullNode>() ? falseValue : trueValue;
ValueExprNode* val = nodeIs<NullNode>(trueValue) ? falseValue : trueValue;
val->getDesc(tdbb, csb, desc);
}
@ -12367,7 +12367,7 @@ void VariableNode::make(DsqlCompilerScratch* /*dsqlScratch*/, dsc* desc)
bool VariableNode::dsqlMatch(const ExprNode* other, bool /*ignoreMapCast*/) const
{
const VariableNode* o = other->as<VariableNode>();
const VariableNode* o = nodeAs<VariableNode>(other);
if (!o)
return false;

View File

@ -1061,7 +1061,7 @@ public:
if (!ListExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const Frame* o = other->as<Frame>();
const Frame* o = nodeAs<Frame>(other);
fb_assert(o);
return bound == o->bound;
@ -1130,7 +1130,7 @@ public:
if (!ListExprNode::dsqlMatch(other, ignoreMapCast))
return false;
const FrameExtent* o = other->as<FrameExtent>();
const FrameExtent* o = nodeAs<FrameExtent>(other);
fb_assert(o);
return unit == o->unit;
@ -1199,7 +1199,7 @@ public:
if (!DsqlNode::dsqlMatch(other, ignoreMapCast))
return false;
const WindowClause* o = other->as<WindowClause>();
const WindowClause* o = nodeAs<WindowClause>(other);
fb_assert(o);
return exclusion == o->exclusion;

View File

@ -356,6 +356,37 @@ public:
};
template <typename To, typename From> static To* nodeAs(From* fromNode)
{
return fromNode && fromNode->type == To::TYPE ? static_cast<To*>(fromNode) : NULL;
}
template <typename To, typename From> static To* nodeAs(NestConst<From>& fromNode)
{
return fromNode && fromNode->type == To::TYPE ? static_cast<To*>(fromNode.getObject()) : NULL;
}
template <typename To, typename From> static const To* nodeAs(const From* fromNode)
{
return fromNode && fromNode->type == To::TYPE ? static_cast<const To*>(fromNode) : NULL;
}
template <typename To, typename From> static const To* nodeAs(const NestConst<From>& fromNode)
{
return fromNode && fromNode->type == To::TYPE ? static_cast<const To*>(fromNode.getObject()) : NULL;
}
template <typename To, typename From> static bool nodeIs(const From* fromNode)
{
return fromNode && fromNode->type == To::TYPE;
}
template <typename To, typename From> static bool nodeIs(const NestConst<From>& fromNode)
{
return fromNode && fromNode->type == To::TYPE;
}
// Stores a reference to a specialized ExprNode.
// This class and NodeRefImpl exists for nodes to replace themselves (eg. pass1) in a type-safe way.
class NodeRef
@ -507,39 +538,6 @@ public:
{
}
template <typename T> T* as()
{
const ExprNode* const thisPointer = this; // avoid warning
return thisPointer && type == T::TYPE ? static_cast<T*>(this) : NULL;
}
template <typename T> const T* as() const
{
const ExprNode* const thisPointer = this; // avoid warning
return thisPointer && type == T::TYPE ? static_cast<const T*>(this) : NULL;
}
template <typename T> bool is() const
{
const ExprNode* const thisPointer = this; // avoid warning
return thisPointer && type == T::TYPE;
}
template <typename T, typename LegacyType> static T* as(LegacyType* node)
{
return node ? node->template as<T>() : NULL;
}
template <typename T, typename LegacyType> static const T* as(const LegacyType* node)
{
return node ? node->template as<T>() : NULL;
}
template <typename T, typename LegacyType> static bool is(const LegacyType* node)
{
return node ? node->template is<T>() : false;
}
// Allocate and assign impure space for various nodes.
template <typename T> static void doPass2(thread_db* tdbb, CompilerScratch* csb, T** node)
{

View File

@ -209,7 +209,7 @@ private:
BoolExprNode* valueToBool(ValueExprNode* value)
{
BoolAsValueNode* node = value->as<BoolAsValueNode>();
BoolAsValueNode* node = nodeAs<BoolAsValueNode>(value);
if (node)
return node->boolean;

View File

@ -195,7 +195,7 @@ namespace
return NULL;
// nod_returning was already processed
CompoundStmtNode* processedStmt = processed->as<CompoundStmtNode>();
CompoundStmtNode* processedStmt = nodeAs<CompoundStmtNode>(processed);
fb_assert(processed);
// And we create a RETURNING node where the targets are already processed.
@ -211,7 +211,7 @@ namespace
{
AssignmentNode* temp = FB_NEW_POOL(scratch->getPool()) AssignmentNode(scratch->getPool());
temp->asgnFrom = *srcPtr;
temp->asgnTo = (*dstPtr)->as<AssignmentNode>()->asgnTo;
temp->asgnTo = nodeAs<AssignmentNode>(*dstPtr)->asgnTo;
newNode->statements.add(temp);
}
@ -291,7 +291,7 @@ void AssignmentNode::validateTarget(CompilerScratch* csb, const ValueExprNode* t
{
const FieldNode* fieldNode;
if ((fieldNode = target->as<FieldNode>()))
if ((fieldNode = nodeAs<FieldNode>(target)))
{
CompilerScratch::csb_repeat* tail = &csb->csb_rpt[fieldNode->fieldStream];
@ -311,13 +311,13 @@ void AssignmentNode::validateTarget(CompilerScratch* csb, const ValueExprNode* t
if (fieldNode->cursorNumber.specified)
ERR_post(Arg::Gds(isc_read_only_field));
}
else if (!(target->is<ParameterNode>() || target->is<VariableNode>() || target->is<NullNode>()))
else if (!(nodeIs<ParameterNode>(target) || nodeIs<VariableNode>(target) || nodeIs<NullNode>(target)))
ERR_post(Arg::Gds(isc_read_only_field));
}
void AssignmentNode::dsqlValidateTarget(const ValueExprNode* target)
{
const DerivedFieldNode* fieldNode = target->as<DerivedFieldNode>();
const DerivedFieldNode* fieldNode = nodeAs<DerivedFieldNode>(target);
if (fieldNode && fieldNode->context &&
(fieldNode->context->ctx_flags & (CTX_system | CTX_cursor)) == CTX_cursor)
@ -381,7 +381,7 @@ AssignmentNode* AssignmentNode::pass1(thread_db* tdbb, CompilerScratch* csb)
StreamType stream;
CompilerScratch::csb_repeat* tail;
if ((fieldNode = sub->as<FieldNode>()))
if ((fieldNode = nodeAs<FieldNode>(sub)))
{
stream = fieldNode->fieldStream;
jrd_fld* field = MET_get_field(csb->csb_rpt[stream].csb_relation, fieldNode->fieldId);
@ -392,7 +392,7 @@ AssignmentNode* AssignmentNode::pass1(thread_db* tdbb, CompilerScratch* csb)
sub = asgnTo;
if ((fieldNode = sub->as<FieldNode>()))
if ((fieldNode = nodeAs<FieldNode>(sub)))
{
stream = fieldNode->fieldStream;
tail = &csb->csb_rpt[stream];
@ -603,7 +603,7 @@ const StmtNode* BlockNode::execute(thread_db* tdbb, jrd_req* request, ExeState*
ptr != end;
++ptr)
{
const ErrorHandlerNode* const handlerNode = (*ptr)->as<ErrorHandlerNode>();
const ErrorHandlerNode* const handlerNode = nodeAs<ErrorHandlerNode>(*ptr);
if (testAndFixupError(tdbb, request, handlerNode->conditions))
{
@ -2115,7 +2115,7 @@ StmtNode* EraseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
rse->dsqlFlags |= RecordSourceNode::DFLAG_SINGLETON;
node->dsqlRse = rse;
node->dsqlRelation = rse->dsqlStreams->items[0]->as<RelationSourceNode>();
node->dsqlRelation = nodeAs<RelationSourceNode>(rse->dsqlStreams->items[0]);
node->statement = dsqlProcessReturning(dsqlScratch, dsqlReturning, statement);
@ -5153,9 +5153,9 @@ StmtNode* MergeNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
forNode->dsqlForceSingular = true;
// Get the already processed relations.
RseNode* processedRse = forNode->rse->dsqlStreams->items[0]->as<RseNode>();
RseNode* processedRse = nodeAs<RseNode>(forNode->rse->dsqlStreams->items[0]);
source = processedRse->dsqlStreams->items[0];
target = processedRse->dsqlStreams->items[1]->as<RelationSourceNode>();
target = nodeAs<RelationSourceNode>(processedRse->dsqlStreams->items[1]);
DsqlContextStack usingCtxs;
dsqlGetContexts(usingCtxs, source);
@ -5181,7 +5181,7 @@ StmtNode* MergeNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
// Separate the new and org values to process in correct contexts.
for (FB_SIZE_T i = 0; i < stmts->statements.getCount(); ++i)
{
AssignmentNode* const assign = stmts->statements[i]->as<AssignmentNode>();
AssignmentNode* const assign = nodeAs<AssignmentNode>(stmts->statements[i]);
fb_assert(assign);
orgValues.add(assign->asgnFrom);
newValues.add(assign->asgnTo);
@ -5345,7 +5345,7 @@ StmtNode* MergeNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
store->overrideClause = notMatched->overrideClause;
bool needSavePoint; // unused
thisIf->trueAction = store = store->internalDsqlPass(dsqlScratch, false, needSavePoint)->as<StoreNode>();
thisIf->trueAction = store = nodeAs<StoreNode>(store->internalDsqlPass(dsqlScratch, false, needSavePoint));
fb_assert(store);
if (notMatched->condition)
@ -5651,18 +5651,18 @@ StmtNode* ModifyNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch, bool up
Array<NestConst<ValueExprNode> > orgValues, newValues;
CompoundStmtNode* assignments = statement->as<CompoundStmtNode>();
CompoundStmtNode* assignments = nodeAs<CompoundStmtNode>(statement);
fb_assert(assignments);
for (FB_SIZE_T i = 0; i < assignments->statements.getCount(); ++i)
{
AssignmentNode* const assign = assignments->statements[i]->as<AssignmentNode>();
AssignmentNode* const assign = nodeAs<AssignmentNode>(assignments->statements[i]);
fb_assert(assign);
orgValues.add(assign->asgnFrom);
newValues.add(assign->asgnTo);
}
NestConst<RelationSourceNode> relation = dsqlRelation->as<RelationSourceNode>();
NestConst<RelationSourceNode> relation = nodeAs<RelationSourceNode>(dsqlRelation);
fb_assert(relation);
NestConst<ValueExprNode>* ptr;
@ -5851,7 +5851,7 @@ string ModifyNode::internalPrint(NodePrinter& printer) const
void ModifyNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
RseNode* rse = dsqlRse->as<RseNode>();
RseNode* rse = nodeAs<RseNode>(dsqlRse);
const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, rse);
@ -5881,7 +5881,7 @@ void ModifyNode::genBlr(DsqlCompilerScratch* dsqlScratch)
ModifyNode* ModifyNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
preprocessAssignments(tdbb, csb, newStream, statement->as<CompoundStmtNode>(), NULL);
preprocessAssignments(tdbb, csb, newStream, nodeAs<CompoundStmtNode>(statement), NULL);
pass1Modify(tdbb, csb, this);
@ -6446,7 +6446,7 @@ DmlNode* StoreNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* cs
const UCHAR* blrPos = csb->csb_blr_reader.getPos();
node->relationSource = PAR_parseRecordSource(tdbb, csb)->as<RelationSourceNode>();
node->relationSource = nodeAs<RelationSourceNode>(PAR_parseRecordSource(tdbb, csb));
if (!node->relationSource)
{
@ -6486,7 +6486,7 @@ StmtNode* StoreNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch,
if (dsqlRse)
{
SelectExprNode* selExpr = dsqlRse->as<SelectExprNode>();
SelectExprNode* selExpr = nodeAs<SelectExprNode>(dsqlRse);
fb_assert(selExpr);
if (dsqlReturning || statement2)
@ -6537,13 +6537,13 @@ StmtNode* StoreNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch,
const FieldNode* fieldNode;
const DerivedFieldNode* derivedField;
if ((fieldNode = ExprNode::as<FieldNode>(temp2)))
if ((fieldNode = nodeAs<FieldNode>(temp2)))
{
tmp_ctx = fieldNode->dsqlContext;
if (fieldNode->dsqlField)
tmp_name = fieldNode->dsqlField->fld_name.c_str();
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(temp2)))
else if ((derivedField = nodeAs<DerivedFieldNode>(temp2)))
{
tmp_ctx = derivedField->context;
tmp_name = derivedField->name.nullStr();
@ -6591,7 +6591,7 @@ StmtNode* StoreNode::internalDsqlPass(DsqlCompilerScratch* dsqlScratch,
if (!*ptr2)
{
const FieldNode* field = (*ptr)->as<FieldNode>();
const FieldNode* field = nodeAs<FieldNode>(*ptr);
if (field && field->dsqlField)
{
@ -6658,7 +6658,7 @@ StmtNode* StoreNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
StmtNode* node = SavepointEncloseNode::make(getPool(), dsqlScratch,
internalDsqlPass(dsqlScratch, false, needSavePoint));
if (!needSavePoint || node->is<SavepointEncloseNode>())
if (!needSavePoint || nodeIs<SavepointEncloseNode>(node))
return node;
return FB_NEW SavepointEncloseNode(getPool(), node);
@ -6684,7 +6684,7 @@ string StoreNode::internalPrint(NodePrinter& printer) const
void StoreNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, dsqlRse->as<RseNode>());
const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, nodeAs<RseNode>(dsqlRse));
dsqlScratch->appendUChar(overrideClause.specified ? blr_store3 : (statement2 ? blr_store2 : blr_store));
@ -6706,7 +6706,7 @@ void StoreNode::genBlr(DsqlCompilerScratch* dsqlScratch)
StoreNode* StoreNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
preprocessAssignments(tdbb, csb, relationSource->getStream(), statement->as<CompoundStmtNode>(), &overrideClause);
preprocessAssignments(tdbb, csb, relationSource->getStream(), nodeAs<CompoundStmtNode>(statement), &overrideClause);
if (pass1Store(tdbb, csb, this))
makeDefaults(tdbb, csb);
@ -6868,7 +6868,7 @@ void StoreNode::makeDefaults(thread_db* tdbb, CompilerScratch* csb)
if (assign)
{
const FieldNode* fieldNode = assign->asgnTo->as<FieldNode>();
const FieldNode* fieldNode = nodeAs<FieldNode>(assign->asgnTo);
fb_assert(fieldNode);
if (fieldNode && fieldNode->fieldStream == stream && fieldNode->fieldId == fieldId)
@ -6981,7 +6981,7 @@ const StmtNode* StoreNode::store(thread_db* tdbb, jrd_req* request, WhichTrigger
switch (request->req_operation)
{
case jrd_req::req_evaluate:
if (!parentStmt->is<ForNode>())
if (!nodeIs<ForNode>(parentStmt))
request->req_records_affected.clear();
request->req_records_affected.bumpModified(false);
@ -7257,7 +7257,7 @@ SelectNode* SelectNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
// stored procedure occurs in the select list. In these cases all of stored procedure is
// executed under savepoint for open cursor.
RseNode* rseNode = node->dsqlRse->as<RseNode>();
RseNode* rseNode = nodeAs<RseNode>(node->dsqlRse);
if (rseNode->dsqlOrder || rseNode->dsqlDistinct)
{
@ -7285,7 +7285,7 @@ string SelectNode::internalPrint(NodePrinter& printer) const
// Generate BLR for a SELECT statement.
void SelectNode::genBlr(DsqlCompilerScratch* dsqlScratch)
{
RseNode* const rse = dsqlRse->as<RseNode>();
RseNode* const rse = nodeAs<RseNode>(dsqlRse);
fb_assert(rse);
DsqlCompiledStatement* const statement = dsqlScratch->getStatement();
@ -7323,7 +7323,7 @@ void SelectNode::genBlr(DsqlCompilerScratch* dsqlScratch)
RecordSourceNode* const item = *ptr2;
RelationSourceNode* relNode;
if (item && (relNode = ExprNode::as<RelationSourceNode>(item)))
if (item && (relNode = nodeAs<RelationSourceNode>(item)))
{
context = relNode->dsqlContext;
const dsql_rel* const relation = context->ctx_relation;
@ -7682,11 +7682,11 @@ const StmtNode* SuspendNode::execute(thread_db* tdbb, jrd_req* request, ExeState
if (!(request->req_flags & req_proc_fetch))
return statement;
const CompoundStmtNode* list = parentStmt->as<CompoundStmtNode>();
const CompoundStmtNode* list = nodeAs<CompoundStmtNode>(parentStmt);
if (list && !list->parentStmt && list->statements[list->statements.getCount() - 1] == this)
{
list = statement->as<CompoundStmtNode>();
list = nodeAs<CompoundStmtNode>(statement);
if (list && list->onlyAssignments && list->statements.hasData())
{
@ -8166,7 +8166,7 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
if (!dsqlScratch->isPsql())
dsqlScratch->flags |= DsqlCompilerScratch::FLAG_UPDATE_OR_INSERT;
const MetaName& relation_name = relation->as<RelationSourceNode>()->dsqlName;
const MetaName& relation_name = nodeAs<RelationSourceNode>(relation)->dsqlName;
MetaName base_name = relation_name;
bool needSavePoint;
@ -8178,7 +8178,7 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
insert->dsqlValues = values;
insert->dsqlReturning = returning;
insert->overrideClause = overrideClause;
insert = insert->internalDsqlPass(dsqlScratch, true, needSavePoint)->as<StoreNode>();
insert = nodeAs<StoreNode>(insert->internalDsqlPass(dsqlScratch, true, needSavePoint));
fb_assert(insert);
dsql_ctx* context = insert->dsqlRelation->dsqlContext;
@ -8250,7 +8250,7 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
NestConst<ValueExprNode>* valuePtr = values->items.begin();
Array<NestConst<StmtNode> >& insertStatements =
insert->statement->as<CompoundStmtNode>()->statements;
nodeAs<CompoundStmtNode>(insert->statement)->statements;
for (; fieldPtr != fieldsCopy.end(); ++fieldPtr, ++valuePtr)
{
@ -8288,7 +8288,7 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
++matchCount;
const FB_SIZE_T fieldPos = fieldPtr - fieldsCopy.begin();
AssignmentNode* assign2 = insertStatements[fieldPos]->as<AssignmentNode>();
AssignmentNode* assign2 = nodeAs<AssignmentNode>(insertStatements[fieldPos]);
NestConst<ValueExprNode>& expr = assign2->asgnFrom;
ValueExprNode* var = dsqlPassHiddenVariable(dsqlScratch, expr);
@ -8336,7 +8336,7 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
dsqlScratch, returning, insert->statement2);
}
update = update->internalDsqlPass(dsqlScratch, true)->as<ModifyNode>();
update = nodeAs<ModifyNode>(update->internalDsqlPass(dsqlScratch, true));
fb_assert(update);
// test if ROW_COUNT = 0
@ -8365,7 +8365,7 @@ StmtNode* UpdateOrInsertNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
dsqlScratch->getStatement()->setType(DsqlCompiledStatement::TYPE_INSERT);
StmtNode* ret = SavepointEncloseNode::make(getPool(), dsqlScratch, list);
if (!needSavePoint || ret->is<SavepointEncloseNode>())
if (!needSavePoint || nodeIs<SavepointEncloseNode>(ret))
return ret;
return FB_NEW SavepointEncloseNode(getPool(), ret);
@ -8511,13 +8511,13 @@ static dsql_ctx* dsqlGetContext(const RecordSourceNode* node)
const RelationSourceNode* relNode;
const RseNode* rseNode;
if ((procNode = ExprNode::as<ProcedureSourceNode>(node)))
if ((procNode = nodeAs<ProcedureSourceNode>(node)))
return procNode->dsqlContext;
if ((relNode = ExprNode::as<RelationSourceNode>(node)))
if ((relNode = nodeAs<RelationSourceNode>(node)))
return relNode->dsqlContext;
if ((rseNode = ExprNode::as<RseNode>(node)))
if ((rseNode = nodeAs<RseNode>(node)))
return rseNode->dsqlContext;
fb_assert(false);
@ -8531,11 +8531,11 @@ static void dsqlGetContexts(DsqlContextStack& contexts, const RecordSourceNode*
const RelationSourceNode* relNode;
const RseNode* rseNode;
if ((procNode = ExprNode::as<ProcedureSourceNode>(node)))
if ((procNode = nodeAs<ProcedureSourceNode>(node)))
contexts.push(procNode->dsqlContext);
else if ((relNode = ExprNode::as<RelationSourceNode>(node)))
else if ((relNode = nodeAs<RelationSourceNode>(node)))
contexts.push(relNode->dsqlContext);
else if ((rseNode = ExprNode::as<RseNode>(node)))
else if ((rseNode = nodeAs<RseNode>(node)))
{
if (rseNode->dsqlContext) // derived table
contexts.push(rseNode->dsqlContext);
@ -8568,11 +8568,11 @@ static StmtNode* dsqlNullifyReturning(DsqlCompilerScratch* dsqlScratch, StmtNode
ModifyNode* modifyNode;
StoreNode* storeNode;
if (eraseNode = input->as<EraseNode>())
if (eraseNode = nodeAs<EraseNode>(input))
returning = eraseNode->statement;
else if (modifyNode = input->as<ModifyNode>())
else if (modifyNode = nodeAs<ModifyNode>(input))
returning = modifyNode->statement2;
else if (storeNode = input->as<StoreNode>())
else if (storeNode = nodeAs<StoreNode>(input))
returning = storeNode->statement2;
else
{
@ -8589,7 +8589,7 @@ static StmtNode* dsqlNullifyReturning(DsqlCompilerScratch* dsqlScratch, StmtNode
// completely removed.
// nod_returning was already processed
CompoundStmtNode* returningStmt = returning->as<CompoundStmtNode>();
CompoundStmtNode* returningStmt = nodeAs<CompoundStmtNode>(returning);
fb_assert(returningStmt);
CompoundStmtNode* nullAssign = FB_NEW_POOL(pool) CompoundStmtNode(pool);
@ -8603,7 +8603,7 @@ static StmtNode* dsqlNullifyReturning(DsqlCompilerScratch* dsqlScratch, StmtNode
{
AssignmentNode* assign = FB_NEW_POOL(pool) AssignmentNode(pool);
assign->asgnFrom = FB_NEW_POOL(pool) NullNode(pool);
assign->asgnTo = (*ret_ptr)->as<AssignmentNode>()->asgnTo;
assign->asgnTo = nodeAs<AssignmentNode>(*ret_ptr)->asgnTo;
*null_ptr = assign;
}
@ -8625,7 +8625,7 @@ static void dsqlFieldAppearsOnce(const Array<NestConst<ValueExprNode> >& values,
{
for (FB_SIZE_T i = 0; i < values.getCount(); ++i)
{
const FieldNode* field1 = values[i]->as<FieldNode>();
const FieldNode* field1 = nodeAs<FieldNode>(values[i]);
if (!field1)
continue;
@ -8633,7 +8633,7 @@ static void dsqlFieldAppearsOnce(const Array<NestConst<ValueExprNode> >& values,
for (FB_SIZE_T j = i + 1; j < values.getCount(); ++j)
{
const FieldNode* field2 = values[j]->as<FieldNode>();
const FieldNode* field2 = nodeAs<FieldNode>(values[j]);
if (!field2)
continue;
@ -8685,7 +8685,7 @@ static dsql_ctx* dsqlPassCursorContext(DsqlCompilerScratch* dsqlScratch, const M
DeclareCursorNode::CUR_TYPE_ALL, true);
fb_assert(node);
const RseNode* nodeRse = node->rse->as<RseNode>();
const RseNode* nodeRse = nodeAs<RseNode>(node->rse);
fb_assert(nodeRse);
if (nodeRse->dsqlDistinct)
@ -8703,7 +8703,7 @@ static dsql_ctx* dsqlPassCursorContext(DsqlCompilerScratch* dsqlScratch, const M
for (const NestConst<RecordSourceNode>* const end = temp->items.end(); ptr != end; ++ptr)
{
RecordSourceNode* r_node = *ptr;
RelationSourceNode* relNode = ExprNode::as<RelationSourceNode>(r_node);
RelationSourceNode* relNode = nodeAs<RelationSourceNode>(r_node);
if (relNode)
{
@ -8724,7 +8724,7 @@ static dsql_ctx* dsqlPassCursorContext(DsqlCompilerScratch* dsqlScratch, const M
context = candidate;
}
}
else if (ExprNode::as<AggregateSourceNode>(r_node))
else if (nodeAs<AggregateSourceNode>(r_node))
{
// cursor with aggregation is not updatable
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-510) <<
@ -8790,8 +8790,7 @@ static RseNode* dsqlPassCursorReference(DsqlCompilerScratch* dsqlScratch, const
RseNode* rse = FB_NEW_POOL(pool) RseNode(pool);
rse->dsqlStreams = FB_NEW_POOL(pool) RecSourceListNode(pool, 1);
RelationSourceNode* relation_node =
PASS1_relation(dsqlScratch, relation_name)->as<RelationSourceNode>();
RelationSourceNode* relation_node = nodeAs<RelationSourceNode>(PASS1_relation(dsqlScratch, relation_name));
rse->dsqlStreams->items[0] = relation_node;
RecordKeyNode* dbKeyNode = FB_NEW_POOL(pool) RecordKeyNode(pool, blr_dbkey);
@ -9057,7 +9056,7 @@ static void dsqlSetParameterName(ExprNode* exprNode, const ValueExprNode* fld_no
if (!exprNode)
return;
const FieldNode* fieldNode = ExprNode::as<FieldNode>(fld_node);
const FieldNode* fieldNode = nodeAs<FieldNode>(fld_node);
fb_assert(fieldNode); // Could it be something else ???
if (fieldNode->nodDesc.dsc_dtype != dtype_array)
@ -9080,7 +9079,7 @@ static void dsqlSetParameterName(ExprNode* exprNode, const ValueExprNode* fld_no
case ExprNode::TYPE_PARAMETER:
{
ParameterNode* paramNode = exprNode->as<ParameterNode>();
ParameterNode* paramNode = nodeAs<ParameterNode>(exprNode);
dsql_par* parameter = paramNode->dsqlParameter;
parameter->par_name = fieldNode->dsqlField->fld_name.c_str();
parameter->par_rel_name = relation->rel_name.c_str();
@ -9101,7 +9100,7 @@ static void dsqlSetParametersName(CompoundStmtNode* statements, const RecordSour
for (NestConst<StmtNode>* const end = ptr + count; ptr != end; ++ptr)
{
AssignmentNode* assign = (*ptr)->as<AssignmentNode>();
AssignmentNode* assign = nodeAs<AssignmentNode>(*ptr);
if (assign)
dsqlSetParameterName(assign->asgnFrom, assign->asgnTo, relation);
@ -9250,7 +9249,7 @@ static StmtNode* pass1ExpandView(thread_db* tdbb, CompilerScratch* csb, StreamTy
const jrd_fld* field = MET_get_field(relation, id);
if (field->fld_source)
newId = field->fld_source->as<FieldNode>()->fieldId;
newId = nodeAs<FieldNode>(field->fld_source)->fieldId;
else
newId = id;
}
@ -9449,13 +9448,13 @@ static void preprocessAssignments(thread_db* tdbb, CompilerScratch* csb,
for (size_t i = compoundNode->statements.getCount(); i--; )
{
const AssignmentNode* assign = compoundNode->statements[i]->as<AssignmentNode>();
const AssignmentNode* assign = nodeAs<AssignmentNode>(compoundNode->statements[i]);
fb_assert(assign);
if (!assign)
continue;
const ExprNode* assignFrom = assign->asgnFrom;
const FieldNode* assignToField = assign->asgnTo->as<FieldNode>();
const FieldNode* assignToField = nodeAs<FieldNode>(assign->asgnTo);
if (assignToField)
{
@ -9470,7 +9469,7 @@ static void preprocessAssignments(thread_db* tdbb, CompilerScratch* csb,
{
if (insertOverride && fld->fld_identity_type.specified)
{
if (insertOverride->specified || !assignFrom->is<DefaultNode>())
if (insertOverride->specified || !nodeIs<DefaultNode>(assignFrom))
identityType = fld->fld_identity_type;
if (*insertOverride == OverrideClause::USER_VALUE)
@ -9482,7 +9481,7 @@ static void preprocessAssignments(thread_db* tdbb, CompilerScratch* csb,
if (fld->fld_computation)
{
if (assignFrom->is<DefaultNode>())
if (nodeIs<DefaultNode>(assignFrom))
compoundNode->statements.remove(i);
}
else if (relation->rel_view_rse && fld->fld_source_rel_field.first.hasData())
@ -9553,7 +9552,7 @@ static void validateExpressions(thread_db* tdbb, const Array<ValidateInfo>& vali
const_cast<char*>(value)[length] = 0; // safe cast - data is actually on the stack
string name;
const FieldNode* fieldNode = i->value->as<FieldNode>();
const FieldNode* fieldNode = nodeAs<FieldNode>(i->value);
if (fieldNode)
{

View File

@ -108,7 +108,7 @@ void GEN_hidden_variables(DsqlCompilerScratch* dsqlScratch)
**/
void GEN_expr(DsqlCompilerScratch* dsqlScratch, ExprNode* node)
{
RseNode* rseNode = node->as<RseNode>();
RseNode* rseNode = nodeAs<RseNode>(node);
if (rseNode)
{
GEN_rse(dsqlScratch, rseNode);
@ -625,7 +625,7 @@ void GEN_sort(DsqlCompilerScratch* dsqlScratch, UCHAR blrVerb, ValueListNode* li
for (const NestConst<ValueExprNode>* const end = list->items.end(); ptr != end; ++ptr)
{
OrderNode* orderNode = (*ptr)->as<OrderNode>();
OrderNode* orderNode = nodeAs<OrderNode>(*ptr);
switch (orderNode->nullsPlacement)
{

View File

@ -2369,7 +2369,7 @@ column_constraint($addColumnClause)
const NestConst<ValueExprNode>* ptr = refColumns->items.begin();
for (const NestConst<ValueExprNode>* const end = refColumns->items.end(); ptr != end; ++ptr)
constraint.refColumns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.refColumns.add(nodeAs<FieldNode>(*ptr)->dsqlName);
}
constraint.index = $5;
@ -2420,7 +2420,7 @@ table_constraint($relationNode)
const NestConst<ValueExprNode>* ptr = columns->items.begin();
for (const NestConst<ValueExprNode>* const end = columns->items.end(); ptr != end; ++ptr)
constraint.columns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.columns.add(nodeAs<FieldNode>(*ptr)->dsqlName);
constraint.index = $3;
@ -2435,7 +2435,7 @@ table_constraint($relationNode)
const NestConst<ValueExprNode>* ptr = columns->items.begin();
for (const NestConst<ValueExprNode>* const end = columns->items.end(); ptr != end; ++ptr)
constraint.columns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.columns.add(nodeAs<FieldNode>(*ptr)->dsqlName);
constraint.index = $4;
@ -2451,7 +2451,7 @@ table_constraint($relationNode)
const NestConst<ValueExprNode>* ptr = columns->items.begin();
for (const NestConst<ValueExprNode>* const end = columns->items.end(); ptr != end; ++ptr)
constraint.columns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.columns.add(nodeAs<FieldNode>(*ptr)->dsqlName);
constraint.refRelation = *$5;
constraint.refAction = $7;
@ -2462,7 +2462,7 @@ table_constraint($relationNode)
const NestConst<ValueExprNode>* ptr = refColumns->items.begin();
for (const NestConst<ValueExprNode>* const end = refColumns->items.end(); ptr != end; ++ptr)
constraint.refColumns.add((*ptr)->as<FieldNode>()->dsqlName);
constraint.refColumns.add(nodeAs<FieldNode>(*ptr)->dsqlName);
}
constraint.index = $8;
@ -5454,7 +5454,7 @@ select_expr_body
{ $$ = $1; }
| select_expr_body UNION distinct_noise query_term
{
UnionSourceNode* node = $1->as<UnionSourceNode>();
UnionSourceNode* node = nodeAs<UnionSourceNode>($1);
if (node && !node->dsqlAll)
node->dsqlClauses->add($4);
else
@ -5466,7 +5466,7 @@ select_expr_body
}
| select_expr_body UNION ALL query_term
{
UnionSourceNode* node = $1->as<UnionSourceNode>();
UnionSourceNode* node = nodeAs<UnionSourceNode>($1);
if (node && node->dsqlAll)
node->dsqlClauses->add($4);
else
@ -7888,10 +7888,10 @@ searched_case
ValueIfNode* last = $2;
ValueIfNode* next;
while ((next = last->falseValue->as<ValueIfNode>()))
while ((next = nodeAs<ValueIfNode>(last->falseValue)))
last = next;
fb_assert(last->falseValue->is<NullNode>());
fb_assert(nodeIs<NullNode>(last->falseValue));
last->falseValue = $4;
$$ = $2;
@ -7908,10 +7908,10 @@ searched_when_clause
ValueIfNode* last = $1;
ValueIfNode* next;
while ((next = last->falseValue->as<ValueIfNode>()))
while ((next = nodeAs<ValueIfNode>(last->falseValue)))
last = next;
fb_assert(last->falseValue->is<NullNode>());
fb_assert(nodeIs<NullNode>(last->falseValue));
last->falseValue = cond;
$$ = $1;

View File

@ -351,11 +351,11 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, RecordSourceNode*
RelationSourceNode* relNode = NULL;
SelectExprNode* selNode = NULL;
if ((procNode = relationNode->as<ProcedureSourceNode>()))
if ((procNode = nodeAs<ProcedureSourceNode>(relationNode)))
relation_name = procNode->dsqlName.identifier;
else if ((relNode = relationNode->as<RelationSourceNode>()))
else if ((relNode = nodeAs<RelationSourceNode>(relationNode)))
relation_name = relNode->dsqlName;
else if ((selNode = relationNode->as<SelectExprNode>()))
else if ((selNode = nodeAs<SelectExprNode>(relationNode)))
relation_name = selNode->alias.c_str();
SelectExprNode* cte = NULL;
@ -445,11 +445,11 @@ dsql_ctx* PASS1_make_context(DsqlCompilerScratch* dsqlScratch, RecordSourceNode*
// find the context alias name, if it exists.
string str;
if ((procNode = relationNode->as<ProcedureSourceNode>()))
if ((procNode = nodeAs<ProcedureSourceNode>(relationNode)))
str = procNode->alias;
else if ((relNode = relationNode->as<RelationSourceNode>()))
else if ((relNode = nodeAs<RelationSourceNode>(relationNode)))
str = relNode->alias;
else if ((selNode = relationNode->as<SelectExprNode>()))
else if ((selNode = nodeAs<SelectExprNode>(relationNode)))
{
str = selNode->alias;
// ASF: In the case of a UNION contained in a CTE, selNode->querySpec will be a
@ -668,11 +668,11 @@ void PASS1_check_unique_fields_names(StrArray& names, const CompoundStmtNode* fi
const DeclareVariableNode* varNode;
const DeclareCursorNode* cursorNode;
if ((varNode = (*ptr)->as<DeclareVariableNode>()))
if ((varNode = nodeAs<DeclareVariableNode>(*ptr)))
name = varNode->dsqlDef->name.c_str();
else if ((cursorNode = (*ptr)->as<DeclareCursorNode>()))
else if ((cursorNode = nodeAs<DeclareCursorNode>(*ptr)))
name = cursorNode->dsqlName.c_str();
else if ((*ptr)->as<DeclareSubProcNode>() || (*ptr)->as<DeclareSubFuncNode>())
else if (nodeAs<DeclareSubProcNode>(*ptr) || nodeAs<DeclareSubFuncNode>(*ptr))
continue;
fb_assert(name);
@ -796,11 +796,11 @@ bool PASS1_node_match(const ExprNode* node1, const ExprNode* node2, bool ignoreM
if (!node1 || !node2)
return false;
const CastNode* castNode1 = node1->as<CastNode>();
const CastNode* castNode1 = nodeAs<CastNode>(node1);
if (ignoreMapCast && castNode1)
{
const CastNode* castNode2 = node2->as<CastNode>();
const CastNode* castNode2 = nodeAs<CastNode>(node2);
// If node2 is also cast and same type continue with both sources.
if (castNode2 &&
@ -815,11 +815,11 @@ bool PASS1_node_match(const ExprNode* node1, const ExprNode* node2, bool ignoreM
return PASS1_node_match(castNode1->source, node2, ignoreMapCast);
}
const DsqlMapNode* mapNode1 = node1->as<DsqlMapNode>();
const DsqlMapNode* mapNode1 = nodeAs<DsqlMapNode>(node1);
if (ignoreMapCast && mapNode1)
{
const DsqlMapNode* mapNode2 = node2->as<DsqlMapNode>();
const DsqlMapNode* mapNode2 = nodeAs<DsqlMapNode>(node2);
if (mapNode2)
{
@ -832,8 +832,8 @@ bool PASS1_node_match(const ExprNode* node1, const ExprNode* node2, bool ignoreM
return PASS1_node_match(mapNode1->map->map_node, node2, ignoreMapCast);
}
const DsqlAliasNode* aliasNode1 = node1->as<DsqlAliasNode>();
const DsqlAliasNode* aliasNode2 = node2->as<DsqlAliasNode>();
const DsqlAliasNode* aliasNode1 = nodeAs<DsqlAliasNode>(node1);
const DsqlAliasNode* aliasNode2 = nodeAs<DsqlAliasNode>(node2);
// We don't care about the alias itself but only about its field.
if (aliasNode1 || aliasNode2)
@ -850,8 +850,8 @@ bool PASS1_node_match(const ExprNode* node1, const ExprNode* node2, bool ignoreM
// Handle derived fields.
const DerivedFieldNode* derivedField1 = node1->as<DerivedFieldNode>();
const DerivedFieldNode* derivedField2 = node2->as<DerivedFieldNode>();
const DerivedFieldNode* derivedField1 = nodeAs<DerivedFieldNode>(node1);
const DerivedFieldNode* derivedField2 = nodeAs<DerivedFieldNode>(node2);
if (derivedField1 || derivedField2)
{
@ -998,7 +998,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
dsqlScratch->aliasRelationPrefix = pass1_alias_concat(aliasRelationPrefix, alias);
RecordSourceNode* query = input->querySpec;
UnionSourceNode* unionQuery = query->as<UnionSourceNode>();
UnionSourceNode* unionQuery = nodeAs<UnionSourceNode>(query);
RseNode* rse = NULL;
const bool isRecursive = unionQuery && unionQuery->recursive;
USHORT recursive_map_ctx = 0;
@ -1046,7 +1046,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
// the worse thing is that a UNION currently can't be used in
// deciding the JOIN order.
bool foundSubSelect = false;
RseNode* queryNode = query->as<RseNode>();
RseNode* queryNode = nodeAs<RseNode>(query);
if (queryNode)
foundSubSelect = SubSelectFinder::find(queryNode->dsqlSelectList);
@ -1146,7 +1146,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
rse->dsqlSelectList->items[count]);
// Auto-create dummy column name for pass1_any()
if (ignoreColumnChecks && !ExprNode::is<DerivedFieldNode>(select_item))
if (ignoreColumnChecks && !nodeIs<DerivedFieldNode>(select_item))
{
MAKE_desc(dsqlScratch, &select_item->nodDesc, select_item);
@ -1174,7 +1174,7 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
ValueExprNode* select_item = rse->dsqlSelectList->items[count];
DerivedFieldNode* derivedField;
if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
if ((derivedField = nodeAs<DerivedFieldNode>(select_item)))
derivedField->context = context;
else
{
@ -1190,13 +1190,11 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
// Check for ambiguous column names inside this derived table.
for (count = 0; count < rse->dsqlSelectList->items.getCount(); ++count)
{
const DerivedFieldNode* selectItem1 =
rse->dsqlSelectList->items[count]->as<DerivedFieldNode>();
const DerivedFieldNode* selectItem1 = nodeAs<DerivedFieldNode>(rse->dsqlSelectList->items[count]);
for (FB_SIZE_T count2 = (count + 1); count2 < rse->dsqlSelectList->items.getCount(); ++count2)
{
const DerivedFieldNode* selectItem2 =
rse->dsqlSelectList->items[count2]->as<DerivedFieldNode>();
const DerivedFieldNode* selectItem2 = nodeAs<DerivedFieldNode>(rse->dsqlSelectList->items[count2]);
if (selectItem1->name == selectItem2->name)
{
@ -1252,10 +1250,10 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
ValueExprNode* map_item = items->items[0];
DerivedFieldNode* derivedField;
if ((derivedField = ExprNode::as<DerivedFieldNode>(map_item)))
if ((derivedField = nodeAs<DerivedFieldNode>(map_item)))
map_item = derivedField->value;
dsql_ctx* map_context = ExprNode::as<DsqlMapNode>(map_item)->context;
dsql_ctx* map_context = nodeAs<DsqlMapNode>(map_item)->context;
map_context->ctx_flags |= CTX_recursive;
map_context->ctx_recursive = recursive_map_ctx;
@ -1314,7 +1312,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
RelationSourceNode* relNode;
FieldNode* fieldNode;
if ((rseNode = ExprNode::as<RseNode>(node)))
if ((rseNode = nodeAs<RseNode>(node)))
{
ValueListNode* sub_items = rseNode->dsqlSelectList;
@ -1331,7 +1329,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
DerivedFieldNode* derivedField;
if (!(derivedField = select_item->as<DerivedFieldNode>()))
if (!(derivedField = nodeAs<DerivedFieldNode>(select_item)))
{
// Internal dsql error: alias type expected by PASS1_expand_select_node
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -1358,7 +1356,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
}
}
}
else if ((procNode = ExprNode::as<ProcedureSourceNode>(node)))
else if ((procNode = nodeAs<ProcedureSourceNode>(node)))
{
dsql_ctx* context = procNode->dsqlContext;
@ -1378,7 +1376,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
}
}
}
else if ((relNode = ExprNode::as<RelationSourceNode>(node)))
else if ((relNode = nodeAs<RelationSourceNode>(node)))
{
dsql_ctx* context = relNode->dsqlContext;
@ -1398,7 +1396,7 @@ void PASS1_expand_select_node(DsqlCompilerScratch* dsqlScratch, ExprNode* node,
}
}
}
else if ((fieldNode = ExprNode::as<FieldNode>(node)))
else if ((fieldNode = nodeAs<FieldNode>(node)))
{
RecordSourceNode* recSource = NULL;
ValueExprNode* value = fieldNode->internalDsqlPass(dsqlScratch, &recSource);
@ -1455,7 +1453,7 @@ static ValueListNode* pass1_group_by_list(DsqlCompilerScratch* dsqlScratch, Valu
FieldNode* field;
LiteralNode* literal;
if ((field = ExprNode::as<FieldNode>(sub)))
if ((field = nodeAs<FieldNode>(sub)))
{
// check for alias or field node
if (selectList && field->dsqlQualifier.isEmpty() && field->dsqlName.hasData())
@ -1469,7 +1467,7 @@ static ValueListNode* pass1_group_by_list(DsqlCompilerScratch* dsqlScratch, Valu
if (!frnode)
frnode = field->internalDsqlPass(dsqlScratch, NULL);
}
else if ((literal = ExprNode::as<LiteralNode>(sub)) && (literal->litDesc.dsc_dtype == dtype_long))
else if ((literal = nodeAs<LiteralNode>(sub)) && (literal->litDesc.dsc_dtype == dtype_long))
{
const ULONG position = literal->getSlong();
@ -1532,17 +1530,17 @@ ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch* dsqlScratch, const MetaNa
FieldNode* fieldNode;
DerivedFieldNode* derivedField;
if ((aliasNode = node->as<DsqlAliasNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(node)))
{
if (aliasNode->name == name)
matchingNode = node;
}
else if ((fieldNode = node->as<FieldNode>()))
else if ((fieldNode = nodeAs<FieldNode>(node)))
{
if (fieldNode->dsqlField->fld_name == name.c_str())
matchingNode = node;
}
else if ((derivedField = node->as<DerivedFieldNode>()))
else if ((derivedField = nodeAs<DerivedFieldNode>(node)))
{
if (derivedField->name == name)
matchingNode = node;
@ -1559,11 +1557,11 @@ ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch* dsqlScratch, const MetaNa
TEXT buffer1[256];
buffer1[0] = 0;
if (returnNode->is<DsqlAliasNode>())
if (nodeIs<DsqlAliasNode>(returnNode))
strcat(buffer1, "an alias");
else if (returnNode->is<FieldNode>())
else if (nodeIs<FieldNode>(returnNode))
strcat(buffer1, "a field");
else if (returnNode->is<DerivedFieldNode>())
else if (nodeIs<DerivedFieldNode>(returnNode))
strcat(buffer1, "a derived field");
else
strcat(buffer1, "an item");
@ -1571,11 +1569,11 @@ ValueExprNode* PASS1_lookup_alias(DsqlCompilerScratch* dsqlScratch, const MetaNa
TEXT buffer2[256];
buffer2[0] = 0;
if (matchingNode->is<DsqlAliasNode>())
if (nodeIs<DsqlAliasNode>(matchingNode))
strcat(buffer2, "an alias");
else if (matchingNode->is<FieldNode>())
else if (nodeIs<FieldNode>(matchingNode))
strcat(buffer2, "a field");
else if (matchingNode->is<DerivedFieldNode>())
else if (nodeIs<DerivedFieldNode>(matchingNode))
strcat(buffer2, "a derived field");
else
strcat(buffer2, "an item");
@ -1617,7 +1615,7 @@ static ValueExprNode* pass1_make_derived_field(thread_db* tdbb, DsqlCompilerScra
FieldNode* fieldNode;
DerivedFieldNode* derivedField;
if ((aliasNode = ExprNode::as<DsqlAliasNode>(select_item)))
if ((aliasNode = nodeAs<DsqlAliasNode>(select_item)))
{
// Create a derived field and ignore alias node.
DerivedFieldNode* newField = FB_NEW_POOL(pool) DerivedFieldNode(pool,
@ -1625,25 +1623,25 @@ static ValueExprNode* pass1_make_derived_field(thread_db* tdbb, DsqlCompilerScra
newField->nodDesc = aliasNode->value->nodDesc;
return newField;
}
else if ((subQueryNode = ExprNode::as<SubQueryNode>(select_item)))
else if ((subQueryNode = nodeAs<SubQueryNode>(select_item)))
{
// Try to generate derived field from sub-select
ValueExprNode* derived_field = pass1_make_derived_field(tdbb, dsqlScratch,
subQueryNode->value1);
if ((derivedField = ExprNode::as<DerivedFieldNode>(derived_field)))
if ((derivedField = nodeAs<DerivedFieldNode>(derived_field)))
{
derivedField->value = select_item;
return derived_field;
}
}
else if ((mapNode = ExprNode::as<DsqlMapNode>(select_item)))
else if ((mapNode = nodeAs<DsqlMapNode>(select_item)))
{
// Aggregate's have map on top.
ValueExprNode* derived_field = pass1_make_derived_field(tdbb, dsqlScratch, mapNode->map->map_node);
// If we had succesfully made a derived field node change it with orginal map.
if ((derivedField = ExprNode::as<DerivedFieldNode>(derived_field)))
if ((derivedField = nodeAs<DerivedFieldNode>(derived_field)))
{
derivedField->value = select_item;
derivedField->scope = dsqlScratch->scopeLevel;
@ -1651,7 +1649,7 @@ static ValueExprNode* pass1_make_derived_field(thread_db* tdbb, DsqlCompilerScra
return derived_field;
}
}
else if ((fieldNode = ExprNode::as<FieldNode>(select_item)))
else if ((fieldNode = nodeAs<FieldNode>(select_item)))
{
// Create a derived field and hook in.
@ -1660,7 +1658,7 @@ static ValueExprNode* pass1_make_derived_field(thread_db* tdbb, DsqlCompilerScra
newField->nodDesc = fieldNode->nodDesc;
return newField;
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
else if ((derivedField = nodeAs<DerivedFieldNode>(select_item)))
{
// Create a derived field that points to a derived field.
@ -1729,7 +1727,7 @@ static RseNode* pass1_rse(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* in
ValueListNode* order, RowsClause* rows, bool updateLock, USHORT flags)
{
string save_alias;
RseNode* rseNode = input->as<RseNode>();
RseNode* rseNode = nodeAs<RseNode>(input);
const bool isRecursive = rseNode && (rseNode->dsqlFlags & RecordSourceNode::DFLAG_RECURSIVE);
AutoSetRestore<USHORT> autoScopeLevel(&dsqlScratch->scopeLevel, dsqlScratch->scopeLevel);
@ -1764,8 +1762,8 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
thread_db* tdbb = JRD_get_thread_data();
MemoryPool& pool = *tdbb->getDefaultPool();
SelectExprNode* selNode = input->as<SelectExprNode>();
UnionSourceNode* unionNode = input->as<UnionSourceNode>();
SelectExprNode* selNode = nodeAs<SelectExprNode>(input);
UnionSourceNode* unionNode = nodeAs<UnionSourceNode>(input);
if (selNode)
{
@ -1799,7 +1797,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
return pass1_union(dsqlScratch, unionNode, order, rows, updateLock, flags);
}
RseNode* inputRse = input->as<RseNode>();
RseNode* inputRse = nodeAs<RseNode>(input);
fb_assert(inputRse);
// Save the original base of the context stack and process relations
@ -1819,7 +1817,7 @@ static RseNode* pass1_rse_impl(DsqlCompilerScratch* dsqlScratch, RecordSourceNod
if (updateLock &&
(streamList->items.getCount() != 1 ||
!(relNode = streamList->items[0]->as<RelationSourceNode>()) ||
!(relNode = nodeAs<RelationSourceNode>(streamList->items[0])) ||
!(relation = relNode->dsqlContext->ctx_relation) ||
(relation->rel_flags & (REL_view | REL_external))))
{
@ -2308,7 +2306,7 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
for (FB_SIZE_T sortloop = 0; sortloop < input->items.getCount(); ++sortloop)
{
DEV_BLKCHK(input->items[sortloop], dsql_type_nod);
NestConst<OrderNode> node1 = input->items[sortloop]->as<OrderNode>();
NestConst<OrderNode> node1 = nodeAs<OrderNode>(input->items[sortloop]);
if (!node1)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
@ -2320,7 +2318,7 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
// get node of value to be ordered by
NestConst<ValueExprNode> orderValue = node1->value;
NestConst<CollateNode> collateNode = orderValue->as<CollateNode>();
NestConst<CollateNode> collateNode = nodeAs<CollateNode>(orderValue);
if (collateNode)
{
@ -2331,7 +2329,7 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
FieldNode* field;
LiteralNode* literal;
if ((field = orderValue->as<FieldNode>()))
if ((field = nodeAs<FieldNode>(orderValue)))
{
ValueExprNode* aliasNode = NULL;
@ -2346,7 +2344,7 @@ ValueListNode* PASS1_sort(DsqlCompilerScratch* dsqlScratch, ValueListNode* input
orderValue = aliasNode ? aliasNode : field->internalDsqlPass(dsqlScratch, NULL);
}
else if ((literal = orderValue->as<LiteralNode>()) && literal->litDesc.dsc_dtype == dtype_long)
else if ((literal = nodeAs<LiteralNode>(orderValue)) && literal->litDesc.dsc_dtype == dtype_long)
{
const ULONG position = literal->getSlong();
@ -2444,7 +2442,7 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
dsqlScratch->scopeLevel--;
if (updateLock)
(*uptr)->as<RseNode>()->flags &= ~RseNode::FLAG_WRITELOCK;
nodeAs<RseNode>(*uptr)->flags &= ~RseNode::FLAG_WRITELOCK;
while (*(dsqlScratch->context) != base)
dsqlScratch->unionContext.push(dsqlScratch->context->pop());
@ -2457,14 +2455,14 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
} // end scope block
// generate the list of fields to select.
ValueListNode* items = unionSource->dsqlClauses->items[0]->as<RseNode>()->dsqlSelectList;
ValueListNode* items = nodeAs<RseNode>(unionSource->dsqlClauses->items[0])->dsqlSelectList;
// loop through the list nodes, checking to be sure that they have the
// same number of items
for (FB_SIZE_T i = 1; i < unionSource->dsqlClauses->items.getCount(); ++i)
{
const ValueListNode* nod1 = unionSource->dsqlClauses->items[i]->as<RseNode>()->dsqlSelectList;
const ValueListNode* nod1 = nodeAs<RseNode>(unionSource->dsqlClauses->items[i])->dsqlSelectList;
if (items->items.getCount() != nod1->items.getCount())
{
@ -2495,7 +2493,7 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
{
for (FB_SIZE_T i = 0; i < unionSource->dsqlClauses->items.getCount(); ++i)
{
ValueListNode* nod1 = unionSource->dsqlClauses->items[i]->as<RseNode>()->dsqlSelectList;
ValueListNode* nod1 = nodeAs<RseNode>(unionSource->dsqlClauses->items[i])->dsqlSelectList;
MAKE_desc(dsqlScratch, &nod1->items[j]->nodDesc, nod1->items[j]);
tmp_list->items[i] = nod1->items[j];
@ -2520,7 +2518,7 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
pass1_union_auto_cast(dsqlScratch, unionSource->dsqlClauses, desc, j);
}
items = unionSource->dsqlClauses->items[0]->as<RseNode>()->dsqlSelectList;
items = nodeAs<RseNode>(unionSource->dsqlClauses->items[0])->dsqlSelectList;
// Create mappings for union.
@ -2559,14 +2557,14 @@ static RseNode* pass1_union(DsqlCompilerScratch* dsqlScratch, UnionSourceNode* i
ptr != end;
++ptr, ++uptr)
{
OrderNode* order1 = (*ptr)->as<OrderNode>();
OrderNode* order1 = nodeAs<OrderNode>(*ptr);
const ValueExprNode* position = order1->value;
const CollateNode* collateNode = position->as<CollateNode>();
const CollateNode* collateNode = nodeAs<CollateNode>(position);
if (collateNode)
position = collateNode->arg;
const LiteralNode* literal = position->as<LiteralNode>();
const LiteralNode* literal = nodeAs<LiteralNode>(position);
if (!literal || literal->litDesc.dsc_dtype != dtype_long)
{
@ -2645,26 +2643,26 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
RseNode* rseNode;
UnionSourceNode* unionNode;
if ((recSourceList = input->as<RecSourceListNode>()))
if ((recSourceList = nodeAs<RecSourceListNode>(input)))
{
NestConst<RecordSourceNode>* ptr = recSourceList->items.begin();
for (const NestConst<RecordSourceNode>* const end = recSourceList->items.end(); ptr != end; ++ptr)
pass1_union_auto_cast(dsqlScratch, *ptr, desc, position);
}
else if ((rseNode = input->as<RseNode>()) && !rseNode->dsqlExplicitJoin &&
else if ((rseNode = nodeAs<RseNode>(input)) && !rseNode->dsqlExplicitJoin &&
!rseNode->dsqlContext) // not derived table
{
pass1_union_auto_cast(dsqlScratch, rseNode->dsqlStreams, desc, position);
if (rseNode->dsqlStreams->items.getCount() == 1 &&
(unionNode = rseNode->dsqlStreams->items[0]->as<UnionSourceNode>()) &&
(unionNode = nodeAs<UnionSourceNode>(rseNode->dsqlStreams->items[0])) &&
unionNode->dsqlParentRse == rseNode)
{
// We're now in a UNION under a UNION so don't change the existing mappings.
// Only replace the node where the map points to, because they could be changed.
ValueListNode* sub_rse_items =
unionNode->dsqlClauses->items[0]->as<RseNode>()->dsqlSelectList;
dsql_map* map = rseNode->dsqlSelectList->items[position]->as<DsqlMapNode>()->map;
nodeAs<RseNode>(unionNode->dsqlClauses->items[0])->dsqlSelectList;
dsql_map* map = nodeAs<DsqlMapNode>(rseNode->dsqlSelectList->items[position])->map;
map->map_node = sub_rse_items->items[position];
rseNode->dsqlSelectList->items[position]->nodDesc = desc;
}
@ -2697,15 +2695,15 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
DerivedFieldNode* derivedField;
// Pick a existing cast if available else make a new one.
if ((aliasNode = ExprNode::as<DsqlAliasNode>(select_item)) &&
aliasNode->value && (castNode = aliasNode->value->as<CastNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(select_item)) &&
aliasNode->value && (castNode = nodeAs<CastNode>(aliasNode->value)))
{
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)) &&
(castNode = derivedField->value->as<CastNode>()))
else if ((derivedField = nodeAs<DerivedFieldNode>(select_item)) &&
(castNode = nodeAs<CastNode>(derivedField->value)))
{
}
else if ((castNode = ExprNode::as<CastNode>(select_item)))
else if ((castNode = nodeAs<CastNode>(select_item)))
{
}
else
@ -2719,9 +2717,9 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
// We want to leave the ALIAS node on his place, because a UNION
// uses the select_items from the first sub-rse to determine the
// columnname.
if ((aliasNode = ExprNode::as<DsqlAliasNode>(select_item)))
if ((aliasNode = nodeAs<DsqlAliasNode>(select_item)))
castNode->source = aliasNode->value;
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
else if ((derivedField = nodeAs<DerivedFieldNode>(select_item)))
castNode->source = derivedField->value;
else
castNode->source = select_item;
@ -2731,7 +2729,7 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
const ValueExprNode* name_node = select_item;
const DsqlMapNode* mapNode;
while ((mapNode = ExprNode::as<DsqlMapNode>(name_node)))
while ((mapNode = nodeAs<DsqlMapNode>(name_node)))
{
// Skip all the DsqlMapNodes.
name_node = mapNode->map->map_node;
@ -2739,7 +2737,7 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
const FieldNode* fieldNode;
if ((fieldNode = ExprNode::as<FieldNode>(name_node)))
if ((fieldNode = nodeAs<FieldNode>(name_node)))
{
// Create new node for alias and copy fieldname.
newAliasNode = FB_NEW_POOL(*tdbb->getDefaultPool()) DsqlAliasNode(
@ -2776,13 +2774,13 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
if (select_item->nodDesc.dsc_flags & DSC_nullable)
castNode->nodDesc.dsc_flags |= DSC_nullable;
if ((aliasNode = ExprNode::as<DsqlAliasNode>(select_item)))
if ((aliasNode = nodeAs<DsqlAliasNode>(select_item)))
{
aliasNode->value = castNode;
aliasNode->value->nodDesc = desc;
select_item->nodDesc = desc;
}
else if ((derivedField = ExprNode::as<DerivedFieldNode>(select_item)))
else if ((derivedField = nodeAs<DerivedFieldNode>(select_item)))
{
derivedField->value = castNode;
derivedField->value->nodDesc = desc;
@ -2805,7 +2803,7 @@ static void pass1_union_auto_cast(DsqlCompilerScratch* dsqlScratch, ExprNode* in
}
}
}
else if ((unionNode = input->as<UnionSourceNode>()))
else if ((unionNode = nodeAs<UnionSourceNode>(input)))
{
recSourceList = unionNode->dsqlClauses;
@ -2884,28 +2882,28 @@ static void remap_streams_to_parent_context(ExprNode* input, dsql_ctx* parent_co
RseNode* rseNode;
UnionSourceNode* unionNode;
if ((listNode = input->as<RecSourceListNode>()))
if ((listNode = nodeAs<RecSourceListNode>(input)))
{
NestConst<RecordSourceNode>* ptr = listNode->items.begin();
for (const NestConst<RecordSourceNode>* const end = listNode->items.end(); ptr != end; ++ptr)
remap_streams_to_parent_context(*ptr, parent_context);
}
else if ((procNode = input->as<ProcedureSourceNode>()))
else if ((procNode = nodeAs<ProcedureSourceNode>(input)))
{
DEV_BLKCHK(procNode->dsqlContext, dsql_type_ctx);
procNode->dsqlContext->ctx_parent = parent_context;
}
else if ((relNode = input->as<RelationSourceNode>()))
else if ((relNode = nodeAs<RelationSourceNode>(input)))
{
DEV_BLKCHK(relNode->dsqlContext, dsql_type_ctx);
relNode->dsqlContext->ctx_parent = parent_context;
}
else if ((rseNode = input->as<RseNode>()))
else if ((rseNode = nodeAs<RseNode>(input)))
remap_streams_to_parent_context(rseNode->dsqlStreams, parent_context);
else if ((unionNode = input->as<UnionSourceNode>()))
else if ((unionNode = nodeAs<UnionSourceNode>(input)))
remap_streams_to_parent_context(unionNode->dsqlClauses, parent_context);
else
fb_assert(input->as<AggregateSourceNode>());
fb_assert(nodeAs<AggregateSourceNode>(input));
}

View File

@ -70,8 +70,8 @@ bool checkExpressionIndex(const index_desc* idx, ValueExprNode* node, StreamType
// so try to recover it (see CORE-4118).
while (!idx->idx_expression->sameAs(node, true))
{
DerivedExprNode* const derivedExpr = node->as<DerivedExprNode>();
CastNode* const cast = node->as<CastNode>();
DerivedExprNode* const derivedExpr = nodeAs<DerivedExprNode>(node);
CastNode* const cast = nodeAs<CastNode>(node);
if (derivedExpr)
node = derivedExpr->arg;
@ -490,7 +490,7 @@ InversionCandidate* OptimizerRetrieval::generateInversion()
for (OptimizerBlk::opt_conjunct* tail = opt_begin; tail < opt_end; tail++)
{
BoolExprNode* const node = tail->opt_conjunct_node;
BinaryBoolNode* booleanNode = node->as<BinaryBoolNode>();
BinaryBoolNode* booleanNode = nodeAs<BinaryBoolNode>(node);
if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node &&
(!booleanNode || booleanNode->blrOp != blr_or))
@ -505,7 +505,7 @@ InversionCandidate* OptimizerRetrieval::generateInversion()
for (OptimizerBlk::opt_conjunct* tail = opt_begin; tail < opt_end; tail++)
{
BoolExprNode* const node = tail->opt_conjunct_node;
BinaryBoolNode* booleanNode = node->as<BinaryBoolNode>();
BinaryBoolNode* booleanNode = nodeAs<BinaryBoolNode>(node);
if (!(tail->opt_conjunct_flags & opt_conjunct_used) && node &&
(booleanNode && booleanNode->blrOp == blr_or))
@ -566,7 +566,7 @@ InversionCandidate* OptimizerRetrieval::generateInversion()
node->computable(csb, stream, true) &&
!invCandidate->matches.exist(node))
{
const ComparativeBoolNode* const cmpNode = node->as<ComparativeBoolNode>();
const ComparativeBoolNode* const cmpNode = nodeAs<ComparativeBoolNode>(node);
const double factor = (cmpNode && cmpNode->blrOp == blr_eql) ?
REDUCE_SELECTIVITY_FACTOR_EQUALITY : REDUCE_SELECTIVITY_FACTOR_INEQUALITY;
@ -716,7 +716,7 @@ void OptimizerRetrieval::analyzeNavigation()
break;
}
}
else if (!(fieldNode = node->as<FieldNode>()) || fieldNode->fieldStream != stream)
else if (!(fieldNode = nodeAs<FieldNode>(node)) || fieldNode->fieldStream != stream)
{
usableIndex = false;
break;
@ -1029,7 +1029,7 @@ ValueExprNode* OptimizerRetrieval::findDbKey(ValueExprNode* dbkey, SLONG* positi
*
**************************************/
const RecordKeyNode* keyNode = dbkey->as<RecordKeyNode>();
const RecordKeyNode* keyNode = nodeAs<RecordKeyNode>(dbkey);
if (keyNode && keyNode->blrOp == blr_dbkey)
{
@ -1040,7 +1040,7 @@ ValueExprNode* OptimizerRetrieval::findDbKey(ValueExprNode* dbkey, SLONG* positi
return NULL;
}
ConcatenateNode* concatNode = dbkey->as<ConcatenateNode>();
ConcatenateNode* concatNode = nodeAs<ConcatenateNode>(dbkey);
if (concatNode)
{
@ -1652,10 +1652,10 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode*
if (boolean->nodFlags & ExprNode::FLAG_DEOPTIMIZE)
return false;
ComparativeBoolNode* cmpNode = boolean->as<ComparativeBoolNode>();
MissingBoolNode* missingNode = boolean->as<MissingBoolNode>();
NotBoolNode* notNode = boolean->as<NotBoolNode>();
RseBoolNode* rseNode = boolean->as<RseBoolNode>();
ComparativeBoolNode* cmpNode = nodeAs<ComparativeBoolNode>(boolean);
MissingBoolNode* missingNode = nodeAs<MissingBoolNode>(boolean);
NotBoolNode* notNode = nodeAs<NotBoolNode>(boolean);
RseBoolNode* rseNode = nodeAs<RseBoolNode>(boolean);
bool forward = true;
ValueExprNode* value = NULL;
ValueExprNode* match = NULL;
@ -1707,7 +1707,7 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode*
FieldNode* fieldNode;
if (!(fieldNode = match->as<FieldNode>()) ||
if (!(fieldNode = nodeAs<FieldNode>(match)) ||
fieldNode->fieldStream != stream ||
(value && !value->computable(csb, stream, false)))
{
@ -1715,7 +1715,7 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode*
match = value;
value = temp;
if ((!match || !(fieldNode = match->as<FieldNode>())) ||
if ((!match || !(fieldNode = nodeAs<FieldNode>(match))) ||
fieldNode->fieldStream != stream ||
!value->computable(csb, stream, false))
{
@ -1778,7 +1778,7 @@ bool OptimizerRetrieval::matchBoolean(IndexScratch* indexScratch, BoolExprNode*
for (int i = 0; i < indexScratch->idx->idx_count; i++)
{
FieldNode* fieldNode = match->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(match);
if (!(indexScratch->idx->idx_flags & idx_expressn))
{
@ -1996,7 +1996,7 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const
**************************************/
// If this isn't an equality, it isn't even interesting
ComparativeBoolNode* cmpNode = boolean->as<ComparativeBoolNode>();
ComparativeBoolNode* cmpNode = nodeAs<ComparativeBoolNode>(boolean);
if (!cmpNode || cmpNode->blrOp != blr_eql)
return NULL;
@ -2007,15 +2007,15 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const
ValueExprNode* dbkey = cmpNode->arg1;
ValueExprNode* value = cmpNode->arg2;
const RecordKeyNode* keyNode = dbkey->as<RecordKeyNode>();
const RecordKeyNode* keyNode = nodeAs<RecordKeyNode>(dbkey);
if (!(keyNode && keyNode->blrOp == blr_dbkey && keyNode->recStream == stream) &&
!dbkey->is<ConcatenateNode>())
!nodeIs<ConcatenateNode>(dbkey))
{
keyNode = value->as<RecordKeyNode>();
keyNode = nodeAs<RecordKeyNode>(value);
if (!(keyNode && keyNode->blrOp == blr_dbkey && keyNode->recStream == stream) &&
!value->is<ConcatenateNode>())
!nodeIs<ConcatenateNode>(value))
{
return NULL;
}
@ -2032,7 +2032,7 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const
// If this is a concatenation, find an appropriate dbkey
SLONG n = 0;
if (dbkey->is<ConcatenateNode>())
if (nodeIs<ConcatenateNode>(dbkey))
{
dbkey = findDbKey(dbkey, &n);
if (!dbkey)
@ -2041,7 +2041,7 @@ InversionCandidate* OptimizerRetrieval::matchDbKey(BoolExprNode* boolean) const
// Make sure we have the correct stream
keyNode = dbkey->as<RecordKeyNode>();
keyNode = nodeAs<RecordKeyNode>(dbkey);
if (!keyNode || keyNode->blrOp != blr_dbkey || keyNode->recStream != stream)
return NULL;
@ -2083,7 +2083,7 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes(
* inversion candidate could be returned.
*
**************************************/
BinaryBoolNode* binaryNode = boolean->as<BinaryBoolNode>();
BinaryBoolNode* binaryNode = nodeAs<BinaryBoolNode>(boolean);
// Handle the "OR" case up front
if (binaryNode && binaryNode->blrOp == blr_or)
@ -2114,7 +2114,7 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes(
if (invCandidate1)
inversions.add(invCandidate1);
BinaryBoolNode* childBoolNode = binaryNode->arg1->as<BinaryBoolNode>();
BinaryBoolNode* childBoolNode = nodeAs<BinaryBoolNode>(binaryNode->arg1);
// Get usable inversions based on indexOrScratches and scope
if (!childBoolNode || childBoolNode->blrOp != blr_or)
@ -2144,7 +2144,7 @@ InversionCandidate* OptimizerRetrieval::matchOnIndexes(
if (invCandidate2)
inversions.add(invCandidate2);
childBoolNode = binaryNode->arg2->as<BinaryBoolNode>();
childBoolNode = nodeAs<BinaryBoolNode>(binaryNode->arg2);
// Make inversion based on indexOrScratches and scope
if (!childBoolNode || childBoolNode->blrOp != blr_or)
@ -2404,7 +2404,7 @@ bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeB
}
else
{
FieldNode* fieldNode = field->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(field);
if (!fieldNode)
{
@ -2414,7 +2414,7 @@ bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeB
// this must include many matches (think about empty string)
return false;
/*
if (!value->is<FieldNode>())
if (!nodeIs<FieldNode>(value))
return NULL;
field = value;
value = cmpNode->arg1;
@ -2422,7 +2422,7 @@ bool OptimizerRetrieval::validateStarts(IndexScratch* indexScratch, ComparativeB
}
// Every string starts with an empty string so don't bother using an index in that case.
LiteralNode* literal = value->as<LiteralNode>();
LiteralNode* literal = nodeAs<LiteralNode>(value);
if (literal)
{

View File

@ -561,7 +561,7 @@ RecordSourceNode* RelationSourceNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
bool RelationSourceNode::dsqlMatch(const ExprNode* other, bool /*ignoreMapCast*/) const
{
const RelationSourceNode* o = other->as<RelationSourceNode>();
const RelationSourceNode* o = nodeAs<RelationSourceNode>(other);
return o && dsqlContext == o->dsqlContext;
}
@ -1029,7 +1029,7 @@ RecordSourceNode* ProcedureSourceNode::dsqlFieldRemapper(FieldRemapper& visitor)
bool ProcedureSourceNode::dsqlMatch(const ExprNode* other, bool /*ignoreMapCast*/) const
{
const ProcedureSourceNode* o = other->as<ProcedureSourceNode>();
const ProcedureSourceNode* o = nodeAs<ProcedureSourceNode>(other);
return o && dsqlContext == o->dsqlContext;
}
@ -1321,7 +1321,7 @@ RecordSourceNode* AggregateSourceNode::dsqlFieldRemapper(FieldRemapper& visitor)
bool AggregateSourceNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
{
const AggregateSourceNode* o = other->as<AggregateSourceNode>();
const AggregateSourceNode* o = nodeAs<AggregateSourceNode>(other);
return o && dsqlContext == o->dsqlContext &&
PASS1_node_match(dsqlGroup, o->dsqlGroup, ignoreMapCast) &&
@ -1606,7 +1606,7 @@ RecordSource* AggregateSourceNode::generate(thread_db* tdbb, OptimizerBlk* opt,
AggNode* aggNode = NULL;
if (map->sourceList.getCount() == 1 && (ptr = map->sourceList.begin()) &&
(aggNode = (*ptr)->as<AggNode>()) &&
(aggNode = nodeAs<AggNode>(*ptr)) &&
(aggNode->aggInfo.blr == blr_agg_min || aggNode->aggInfo.blr == blr_agg_max))
{
// generate a sort block which the optimizer will try to map to an index
@ -1750,15 +1750,15 @@ void UnionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
ValueExprNode* mapItem = dsqlParentRse->dsqlSelectList->items[0];
// AB: First item could be a virtual field generated by derived table.
DerivedFieldNode* derivedField = mapItem->as<DerivedFieldNode>();
DerivedFieldNode* derivedField = nodeAs<DerivedFieldNode>(mapItem);
if (derivedField)
mapItem = derivedField->value;
if (mapItem->is<CastNode>())
mapItem = mapItem->as<CastNode>()->source;
if (nodeIs<CastNode>(mapItem))
mapItem = nodeAs<CastNode>(mapItem)->source;
DsqlMapNode* mapNode = mapItem->as<DsqlMapNode>();
DsqlMapNode* mapNode = nodeAs<DsqlMapNode>(mapItem);
fb_assert(mapNode);
if (!mapNode)
@ -1780,7 +1780,7 @@ void UnionSourceNode::genBlr(DsqlCompilerScratch* dsqlScratch)
NestConst<RecordSourceNode>* ptr = streams->items.begin();
for (const NestConst<RecordSourceNode>* const end = streams->items.end(); ptr != end; ++ptr)
{
RseNode* sub_rse = (*ptr)->as<RseNode>();
RseNode* sub_rse = nodeAs<RseNode>(*ptr);
GEN_rse(dsqlScratch, sub_rse);
ValueListNode* items = sub_rse->dsqlSelectList;
@ -2506,7 +2506,7 @@ RseNode* RseNode::dsqlFieldRemapper(FieldRemapper& visitor)
bool RseNode::dsqlMatch(const ExprNode* other, bool ignoreMapCast) const
{
const RseNode* o = other->as<RseNode>();
const RseNode* o = nodeAs<RseNode>(other);
if (!o)
return false;
@ -2611,11 +2611,11 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
const TEXT* name = NULL;
if (auto* aliasNode = item->as<DsqlAliasNode>())
if (auto* aliasNode = nodeAs<DsqlAliasNode>(item))
name = aliasNode->name.c_str();
else if (auto* fieldNode = item->as<FieldNode>())
else if (auto* fieldNode = nodeAs<FieldNode>(item))
name = fieldNode->dsqlField->fld_name.c_str();
else if (auto* derivedField = item->as<DerivedFieldNode>())
else if (auto* derivedField = nodeAs<DerivedFieldNode>(item))
name = derivedField->name.c_str();
if (name)
@ -2650,7 +2650,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
for (FB_SIZE_T i = 0; i < usingList->items.getCount(); ++i)
{
const FieldNode* field = usingList->items[i]->as<FieldNode>();
const FieldNode* field = nodeAs<FieldNode>(usingList->items[i]);
// verify if the column was already used
FB_SIZE_T pos;
@ -2710,7 +2710,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
ValueListNode* stack = FB_NEW_POOL(getPool()) ValueListNode(getPool(), 0u);
NestConst<ValueExprNode> tempNode = impJoinLeft->value;
NestConst<DsqlAliasNode> aliasNode = tempNode->as<DsqlAliasNode>();
NestConst<DsqlAliasNode> aliasNode = nodeAs<DsqlAliasNode>(tempNode);
NestConst<CoalesceNode> coalesceNode;
if (aliasNode)
@ -2719,7 +2719,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{ // scope
PsqlChanger changer(dsqlScratch, false);
if ((coalesceNode = tempNode->as<CoalesceNode>()))
if ((coalesceNode = nodeAs<CoalesceNode>(tempNode)))
{
ValueListNode* list = coalesceNode->args;
@ -2735,10 +2735,10 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
tempNode = impJoinRight->value;
if ((aliasNode = tempNode->as<DsqlAliasNode>()))
if ((aliasNode = nodeAs<DsqlAliasNode>(tempNode)))
tempNode = aliasNode->value;
if ((coalesceNode = tempNode->as<CoalesceNode>()))
if ((coalesceNode = nodeAs<CoalesceNode>(tempNode)))
{
ValueListNode* list = coalesceNode->args;
@ -2836,7 +2836,7 @@ RseNode* RseNode::pass1(thread_db* tdbb, CompilerScratch* csb)
for (ExprNode** node = csb->csb_current_nodes.begin();
node != csb->csb_current_nodes.end(); ++node)
{
if ((*node)->as<RseNode>())
if (nodeAs<RseNode>(*node))
{
topLevelRse = false;
break;
@ -3431,8 +3431,8 @@ RseNode* SelectExprNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
static RecordSourceNode* dsqlPassRelProc(DsqlCompilerScratch* dsqlScratch, RecordSourceNode* source)
{
ProcedureSourceNode* procNode = source->as<ProcedureSourceNode>();
RelationSourceNode* relNode = source->as<RelationSourceNode>();
ProcedureSourceNode* procNode = nodeAs<ProcedureSourceNode>(source);
RelationSourceNode* relNode = nodeAs<RelationSourceNode>(source);
fb_assert(procNode || relNode);
@ -3483,7 +3483,7 @@ static RecordSourceNode* dsqlPassRelProc(DsqlCompilerScratch* dsqlScratch, Recor
}
RecordSourceNode* const query = cte->querySpec;
UnionSourceNode* unionQuery = ExprNode::as<UnionSourceNode>(query);
UnionSourceNode* unionQuery = nodeAs<UnionSourceNode>(query);
const bool isRecursive = unionQuery && unionQuery->recursive;
const string saveCteName = cte->alias;
@ -3576,7 +3576,7 @@ static void processMap(thread_db* tdbb, CompilerScratch* csb, MapNode* map, Form
source != sourceEnd;
++source, ++target)
{
FieldNode* field = (*target)->as<FieldNode>();
FieldNode* field = nodeAs<FieldNode>(*target);
const USHORT id = field->fieldId;
if (id >= format->fmt_count)
@ -3677,7 +3677,7 @@ static void genDeliverUnmapped(thread_db* tdbb, BoolExprNodeStack* deliverStack,
// Handle the "OR" case first
BinaryBoolNode* const binaryNode = boolean->as<BinaryBoolNode>();
BinaryBoolNode* const binaryNode = nodeAs<BinaryBoolNode>(boolean);
if (binaryNode && binaryNode->blrOp == blr_or)
{
BoolExprNodeStack orgStack, newStack;
@ -3708,8 +3708,8 @@ static void genDeliverUnmapped(thread_db* tdbb, BoolExprNodeStack* deliverStack,
// Reduce to simple comparisons
ComparativeBoolNode* const cmpNode = boolean->as<ComparativeBoolNode>();
MissingBoolNode* const missingNode = boolean->as<MissingBoolNode>();
ComparativeBoolNode* const cmpNode = nodeAs<ComparativeBoolNode>(boolean);
MissingBoolNode* const missingNode = nodeAs<MissingBoolNode>(boolean);
HalfStaticArray<ValueExprNode*, 2> children;
if (cmpNode &&
@ -3732,7 +3732,7 @@ static void genDeliverUnmapped(thread_db* tdbb, BoolExprNodeStack* deliverStack,
for (indexArg = 0; (indexArg < children.getCount()) && !mappingFound; ++indexArg)
{
FieldNode* fieldNode = children[indexArg]->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(children[indexArg]);
if (fieldNode && fieldNode->fieldStream == shellStream)
mappingFound = true;
@ -3777,7 +3777,7 @@ static void genDeliverUnmapped(thread_db* tdbb, BoolExprNodeStack* deliverStack,
// forget to leave aggregate-functions alone in case of aggregate rse).
// Because this is only to help using an index we keep it simple.
FieldNode* fieldNode = children[indexArg]->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(children[indexArg]);
if (fieldNode && fieldNode->fieldStream == shellStream)
{
@ -3827,11 +3827,11 @@ static ValueExprNode* resolveUsingField(DsqlCompilerScratch* dsqlScratch, const
FieldNode* fieldNode;
DerivedFieldNode* derivedField;
if ((aliasNode = ExprNode::as<DsqlAliasNode>(node)))
if ((aliasNode = nodeAs<DsqlAliasNode>(node)))
ctx = aliasNode->implicitJoin->visibleInContext;
else if ((fieldNode = ExprNode::as<FieldNode>(node)))
else if ((fieldNode = nodeAs<FieldNode>(node)))
ctx = fieldNode->dsqlContext;
else if ((derivedField = ExprNode::as<DerivedFieldNode>(node)))
else if ((derivedField = nodeAs<DerivedFieldNode>(node)))
ctx = derivedField->context;
else
{

View File

@ -999,13 +999,13 @@ void blb::move(thread_db* tdbb, dsc* from_desc, dsc* to_desc, const ValueExprNod
if (field)
{
if ((fieldNode = ExprNode::as<FieldNode>(field)))
if ((fieldNode = nodeAs<FieldNode>(field)))
{
// We should not materialize the blob if the destination field
// stream (nod_union, for example) doesn't have a relation.
simpleMove = tdbb->getRequest()->req_rpb[fieldNode->fieldStream].rpb_relation == NULL;
}
else if (!(ExprNode::is<ParameterNode>(field) || ExprNode::is<VariableNode>(field)))
else if (!(nodeIs<ParameterNode>(field) || nodeIs<VariableNode>(field)))
BUGCHECK(199); // msg 199 expected field node
}

View File

@ -120,7 +120,7 @@ ValueExprNode* CMP_clone_node_opt(thread_db* tdbb, CompilerScratch* csb, ValueEx
DEV_BLKCHK(csb, type_csb);
if (node->is<ParameterNode>())
if (nodeIs<ParameterNode>(node))
return node;
SubExprNodeCopier copier(csb);

View File

@ -148,7 +148,7 @@ dsc* EVL_assign_to(thread_db* tdbb, const ValueExprNode* node)
const VariableNode* varNode;
const FieldNode* fieldNode;
if ((paramNode = ExprNode::as<ParameterNode>(node)))
if ((paramNode = nodeAs<ParameterNode>(node)))
{
message = paramNode->message;
arg_number = paramNode->argNumber;
@ -175,15 +175,15 @@ dsc* EVL_assign_to(thread_db* tdbb, const ValueExprNode* node)
return &impure->vlu_desc;
}
else if (ExprNode::is<NullNode>(node))
else if (nodeIs<NullNode>(node))
return NULL;
else if ((varNode = ExprNode::as<VariableNode>(node)))
else if ((varNode = nodeAs<VariableNode>(node)))
{
// Calculate descriptor
impure = request->getImpure<impure_value>(varNode->varDecl->impureOffset);
return &impure->vlu_desc;
}
else if ((fieldNode = ExprNode::as<FieldNode>(node)))
else if ((fieldNode = nodeAs<FieldNode>(node)))
{
record = request->req_rpb[fieldNode->fieldStream].rpb_record;

View File

@ -287,7 +287,7 @@ void EXE_assignment(thread_db* tdbb, const ValueExprNode* to, dsc* from_desc, bo
const ParameterNode* toParam;
const VariableNode* toVar;
if ((toParam = ExprNode::as<ParameterNode>(to)))
if ((toParam = nodeAs<ParameterNode>(to)))
{
const MessageNode* message = toParam->message;
@ -300,7 +300,7 @@ void EXE_assignment(thread_db* tdbb, const ValueExprNode* to, dsc* from_desc, bo
impure_flags = request->getImpure<USHORT>(
message->impureFlags + (sizeof(USHORT) * toParam->argNumber));
}
else if ((toVar = ExprNode::as<VariableNode>(to)))
else if ((toVar = nodeAs<VariableNode>(to)))
{
if (toVar->varInfo)
{
@ -432,7 +432,7 @@ void EXE_assignment(thread_db* tdbb, const ValueExprNode* to, dsc* from_desc, bo
// Handle the null flag as appropriate for fields and message arguments.
const FieldNode* toField = ExprNode::as<FieldNode>(to);
const FieldNode* toField = nodeAs<FieldNode>(to);
if (toField)
{
Record* record = request->req_rpb[toField->fieldStream].rpb_record;
@ -793,10 +793,10 @@ void EXE_send(thread_db* tdbb, jrd_req* request, USHORT msg, ULONG length, const
for (const NestConst<StmtNode>* end = selectNode->statements.end(); ptr != end; ++ptr)
{
const ReceiveNode* receiveNode = (*ptr)->as<ReceiveNode>();
const ReceiveNode* receiveNode = nodeAs<ReceiveNode>(*ptr);
message = receiveNode->message;
if (message->as<MessageNode>()->messageNumber == msg)
if (nodeAs<MessageNode>(message)->messageNumber == msg)
{
request->req_next = *ptr;
break;

View File

@ -432,7 +432,7 @@ bool EXT_get(thread_db* tdbb, record_param* rpb, FB_UINT64& position)
if (!desc_ptr->dsc_length || !field)
continue;
const LiteralNode* literal = ExprNode::as<LiteralNode>(field->fld_missing_value);
const LiteralNode* literal = nodeAs<LiteralNode>(field->fld_missing_value);
if (literal)
{
@ -534,7 +534,7 @@ void EXT_store(thread_db* tdbb, record_param* rpb)
if (field && !field->fld_computation && desc_ptr->dsc_length && record->isNull(i))
{
UCHAR* p = record->getData() + (IPTR) desc_ptr->dsc_address;
LiteralNode* literal = ExprNode::as<LiteralNode>(field->fld_missing_value);
LiteralNode* literal = nodeAs<LiteralNode>(field->fld_missing_value);
if (literal)
{

View File

@ -936,7 +936,7 @@ ULONG INF_request_info(const jrd_req* request, const ULONG item_length, const UC
{
const StmtNode* node = request->req_next;
if (node->is<SelectNode>())
if (nodeIs<SelectNode>(node))
state = isc_info_req_select;
else
state = isc_info_req_receive;

View File

@ -1117,8 +1117,8 @@ static void check_sorts(RseNode* rse)
for (; project_ptr != project_end; ++project_ptr)
{
const FieldNode* sortField = (*sort_ptr)->as<FieldNode>();
const FieldNode* projectField = (*project_ptr)->as<FieldNode>();
const FieldNode* sortField = nodeAs<FieldNode>(*sort_ptr);
const FieldNode* projectField = nodeAs<FieldNode>(*project_ptr);
if (sortField && projectField &&
sortField->fieldStream == projectField->fieldStream &&
@ -1157,7 +1157,7 @@ static void check_sorts(RseNode* rse)
{
const FieldNode* sortField;
if ((sortField = (*sort_ptr)->as<FieldNode>()))
if ((sortField = nodeAs<FieldNode>(*sort_ptr)))
{
// Get stream for this field at this position.
const StreamType current_stream = sortField->fieldStream;
@ -1329,8 +1329,8 @@ static SLONG decompose(thread_db* tdbb, BoolExprNode* boolNode, BoolExprNodeStac
**************************************/
DEV_BLKCHK(csb, type_csb);
BinaryBoolNode* binaryNode = boolNode->as<BinaryBoolNode>();
ComparativeBoolNode* cmpNode = boolNode->as<ComparativeBoolNode>();
BinaryBoolNode* binaryNode = nodeAs<BinaryBoolNode>(boolNode);
ComparativeBoolNode* cmpNode = nodeAs<ComparativeBoolNode>(boolNode);
if (binaryNode)
{
@ -1469,17 +1469,17 @@ static USHORT distribute_equalities(BoolExprNodeStack& org_stack, CompilerScratc
if (boolean->nodFlags & ExprNode::FLAG_DEOPTIMIZE)
continue;
ComparativeBoolNode* const cmpNode = boolean->as<ComparativeBoolNode>();
ComparativeBoolNode* const cmpNode = nodeAs<ComparativeBoolNode>(boolean);
if (!cmpNode || cmpNode->blrOp != blr_eql)
continue;
ValueExprNode* const node1 = cmpNode->arg1;
if (!node1->is<FieldNode>())
if (!nodeIs<FieldNode>(node1))
continue;
ValueExprNode* const node2 = cmpNode->arg2;
if (!node2->is<FieldNode>())
if (!nodeIs<FieldNode>(node2))
continue;
for (eq_class = classes.begin(); eq_class != classes.end(); ++eq_class)
@ -1562,7 +1562,7 @@ static USHORT distribute_equalities(BoolExprNodeStack& org_stack, CompilerScratc
for (BoolExprNodeStack::iterator iter(org_stack); iter.hasData(); ++iter)
{
BoolExprNode* const boolean = iter.object();
ComparativeBoolNode* const cmpNode = boolean->as<ComparativeBoolNode>();
ComparativeBoolNode* const cmpNode = nodeAs<ComparativeBoolNode>(boolean);
ValueExprNode* node1;
ValueExprNode* node2;
@ -1580,7 +1580,7 @@ static USHORT distribute_equalities(BoolExprNodeStack& org_stack, CompilerScratc
bool reverse = false;
if (!node1->is<FieldNode>())
if (!nodeIs<FieldNode>(node1))
{
ValueExprNode* swap_node = node1;
node1 = node2;
@ -1588,10 +1588,10 @@ static USHORT distribute_equalities(BoolExprNodeStack& org_stack, CompilerScratc
reverse = true;
}
if (!node1->is<FieldNode>())
if (!nodeIs<FieldNode>(node1))
continue;
if (!node2->is<LiteralNode>() && !node2->is<ParameterNode>() && !node2->is<VariableNode>())
if (!nodeIs<LiteralNode>(node2) && !nodeIs<ParameterNode>(node2) && !nodeIs<VariableNode>(node2))
continue;
for (eq_class = classes.begin(); eq_class != classes.end(); ++eq_class)
@ -1883,7 +1883,7 @@ void OPT_gen_aggregate_distincts(thread_db* tdbb, CompilerScratch* csb, MapNode*
for (const NestConst<ValueExprNode>* const end = map->sourceList.end(); ptr != end; ++ptr)
{
ValueExprNode* from = *ptr;
AggNode* aggNode = from->as<AggNode>();
AggNode* aggNode = nodeAs<AggNode>(from);
if (aggNode && aggNode->distinct)
{
@ -2445,7 +2445,7 @@ SortedStream* OPT_gen_sort(thread_db* tdbb, CompilerScratch* csb, const StreamLi
node_ptr != end_node;
++node_ptr)
{
FieldNode* fieldNode = (*node_ptr)->as<FieldNode>();
FieldNode* fieldNode = nodeAs<FieldNode>(*node_ptr);
if (fieldNode && fieldNode->fieldStream == *ptr && fieldNode->fieldId == id)
{
@ -2558,7 +2558,7 @@ SortedStream* OPT_gen_sort(thread_db* tdbb, CompilerScratch* csb, const StreamLi
FieldNode* fieldNode;
if ((fieldNode = node->as<FieldNode>()))
if ((fieldNode = nodeAs<FieldNode>(node)))
{
map_item->stream = fieldNode->fieldStream;
map_item->fieldId = fieldNode->fieldId;
@ -2748,7 +2748,7 @@ static bool gen_equi_join(thread_db* tdbb, OptimizerBlk* opt, RiverList& org_riv
continue;
BoolExprNode* const node = tail->opt_conjunct_node;
ComparativeBoolNode* cmpNode = node->as<ComparativeBoolNode>();
ComparativeBoolNode* cmpNode = nodeAs<ComparativeBoolNode>(node);
if (!cmpNode || (cmpNode->blrOp != blr_eql && cmpNode->blrOp != blr_equiv))
continue;
@ -3077,7 +3077,7 @@ static BoolExprNode* make_inference_node(CompilerScratch* csb, BoolExprNode* boo
thread_db* tdbb = JRD_get_thread_data();
DEV_BLKCHK(csb, type_csb);
ComparativeBoolNode* cmpNode = boolean->as<ComparativeBoolNode>();
ComparativeBoolNode* cmpNode = nodeAs<ComparativeBoolNode>(boolean);
fb_assert(cmpNode); // see our caller
// Clone the input predicate
@ -3125,8 +3125,8 @@ static bool map_equal(const ValueExprNode* field1, const ValueExprNode* field2,
* Order of the input fields is important.
*
**************************************/
const FieldNode* fieldNode1 = field1->as<FieldNode>();
const FieldNode* fieldNode2 = field2->as<FieldNode>();
const FieldNode* fieldNode1 = nodeAs<FieldNode>(field1);
const FieldNode* fieldNode2 = nodeAs<FieldNode>(field2);
if (!fieldNode1 || !fieldNode2)
return false;
@ -3139,8 +3139,8 @@ static bool map_equal(const ValueExprNode* field1, const ValueExprNode* field2,
sourcePtr != sourceEnd;
++sourcePtr, ++targetPtr)
{
const FieldNode* mapFrom = (*sourcePtr)->as<FieldNode>();
const FieldNode* mapTo = (*targetPtr)->as<FieldNode>();
const FieldNode* mapFrom = nodeAs<FieldNode>(*sourcePtr);
const FieldNode* mapTo = nodeAs<FieldNode>(*targetPtr);
if (!mapFrom || !mapTo)
continue;
@ -3230,8 +3230,8 @@ static bool node_equality(const ValueExprNode* node1, const ValueExprNode* node2
if (node1 == node2)
return true;
const FieldNode* fieldNode1 = node1->as<FieldNode>();
const FieldNode* fieldNode2 = node2->as<FieldNode>();
const FieldNode* fieldNode1 = nodeAs<FieldNode>(node1);
const FieldNode* fieldNode2 = nodeAs<FieldNode>(node2);
if (fieldNode1 && fieldNode2)
{
@ -3256,8 +3256,8 @@ static bool node_equality(const BoolExprNode* node1, const BoolExprNode* node2)
if (node1 == node2)
return true;
const ComparativeBoolNode* cmpNode = node1->as<ComparativeBoolNode>();
const ComparativeBoolNode* cmpNode2 = node2->as<ComparativeBoolNode>();
const ComparativeBoolNode* cmpNode = nodeAs<ComparativeBoolNode>(node1);
const ComparativeBoolNode* cmpNode2 = nodeAs<ComparativeBoolNode>(node2);
if (cmpNode && cmpNode2 && cmpNode->blrOp == cmpNode2->blrOp &&
(cmpNode->blrOp == blr_eql || cmpNode->blrOp == blr_equiv))
@ -3307,17 +3307,17 @@ static ValueExprNode* optimize_like(thread_db* tdbb, CompilerScratch* csb, Compa
// if the pattern string or the escape string can't be
// evaluated at compile time, forget it
if (!pattern_node->is<LiteralNode>() || (escape_node && !escape_node->is<LiteralNode>()))
if (!nodeIs<LiteralNode>(pattern_node) || (escape_node && !nodeIs<LiteralNode>(escape_node)))
return NULL;
dsc match_desc;
match_node->getDesc(tdbb, csb, &match_desc);
dsc* pattern_desc = &pattern_node->as<LiteralNode>()->litDesc;
dsc* pattern_desc = &nodeAs<LiteralNode>(pattern_node)->litDesc;
dsc* escape_desc = NULL;
if (escape_node)
escape_desc = &escape_node->as<LiteralNode>()->litDesc;
escape_desc = &nodeAs<LiteralNode>(escape_node)->litDesc;
// if either is not a character expression, forget it
if ((match_desc.dsc_dtype > dtype_any_text) ||
@ -3544,8 +3544,8 @@ static void set_position(const SortNode* from_clause, SortNode* to_clause, const
for (const NestConst<ValueExprNode>* const to_end = to_ptr + count;
to_ptr != to_end; ++to_ptr)
{
const FieldNode* fromField = (*from_ptr)->as<FieldNode>();
const FieldNode* toField = (*to_ptr)->as<FieldNode>();
const FieldNode* fromField = nodeAs<FieldNode>(*from_ptr);
const FieldNode* toField = nodeAs<FieldNode>(*to_ptr);
if ((map && map_equal(*to_ptr, *from_ptr, map)) ||
(!map &&

View File

@ -205,11 +205,11 @@ void BaseAggWinStream<ThisType, NextType>::aggInit(thread_db* tdbb, jrd_req* req
source != sourceEnd;
++source, ++target)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (aggNode)
aggNode->aggInit(tdbb, request);
else if ((*source)->is<LiteralNode>())
else if (nodeIs<LiteralNode>(*source))
EXE_assignment(tdbb, *source, *target);
}
}
@ -227,7 +227,7 @@ bool BaseAggWinStream<ThisType, NextType>::aggPass(thread_db* tdbb, jrd_req* req
source != sourceEnd;
++source, ++target)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (aggNode)
{
@ -256,11 +256,11 @@ void BaseAggWinStream<ThisType, NextType>::aggExecute(thread_db* tdbb, jrd_req*
source != sourceEnd;
++source, ++target)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (aggNode)
{
const FieldNode* field = (*target)->as<FieldNode>();
const FieldNode* field = nodeAs<FieldNode>(*target);
const USHORT id = field->fieldId;
Record* record = request->req_rpb[field->fieldStream].rpb_record;
@ -287,7 +287,7 @@ void BaseAggWinStream<ThisType, NextType>::aggFinish(thread_db* tdbb, jrd_req* r
source != sourceEnd;
++source)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (aggNode)
aggNode->aggFinish(tdbb, request);

View File

@ -159,7 +159,7 @@ bool FilteredStream::evaluateBoolean(thread_db* tdbb) const
{
// see if there's a select node to work with
const BinaryBoolNode* booleanNode = column_node->as<BinaryBoolNode>();
const BinaryBoolNode* booleanNode = nodeAs<BinaryBoolNode>(column_node);
if (booleanNode && booleanNode->blrOp == blr_and)
{

View File

@ -329,7 +329,7 @@ void SortedStream::mapData(thread_db* tdbb, jrd_req* request, UCHAR* data) const
from = item->desc;
from.dsc_address = data + (IPTR) from.dsc_address;
if (item->node && !item->node->is<FieldNode>())
if (item->node && !nodeIs<FieldNode>(item->node))
continue;
// if moving a TEXT item into the key portion of the sort record,

View File

@ -205,7 +205,7 @@ WindowedStream::WindowedStream(thread_db* tdbb, CompilerScratch* csb,
source != end;
++source)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (aggNode)
{
@ -443,7 +443,7 @@ WindowedStream::WindowStream::WindowStream(thread_db* tdbb, CompilerScratch* csb
source != sourceEnd;
++source, ++target)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (aggNode)
{
@ -494,9 +494,9 @@ WindowedStream::WindowStream::WindowStream(thread_db* tdbb, CompilerScratch* csb
//// TODO: Better check for invariants.
if (frame->value &&
(frame->value->is<LiteralNode>() ||
frame->value->is<VariableNode>() ||
frame->value->is<ParameterNode>()))
(nodeIs<LiteralNode>(frame->value) ||
nodeIs<VariableNode>(frame->value) ||
nodeIs<ParameterNode>(frame->value)))
{
m_invariantOffsets |= i == 0 ? 0x1 : 0x2;
}
@ -839,9 +839,9 @@ bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
source != sourceEnd;
++source, ++target)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
const FieldNode* field = (*target)->as<FieldNode>();
const FieldNode* field = nodeAs<FieldNode>(*target);
const USHORT id = field->fieldId;
Record* record = request->req_rpb[field->fieldStream].rpb_record;
@ -869,7 +869,7 @@ bool WindowedStream::WindowStream::getRecord(thread_db* tdbb) const
source != sourceEnd;
++source, ++target)
{
const AggNode* aggNode = (*source)->as<AggNode>();
const AggNode* aggNode = nodeAs<AggNode>(*source);
if (!aggNode)
EXE_assignment(tdbb, *source, *target);

View File

@ -330,7 +330,7 @@ void TraceDscFromValues::fillParams()
const VariableNode* var;
const LiteralNode* literal;
if ((param = prm->as<ParameterNode>()))
if ((param = nodeAs<ParameterNode>(prm)))
{
//const impure_value* impure = m_request->getImpure<impure_value>(param->impureOffset)
const MessageNode* message = param->message;
@ -350,14 +350,14 @@ void TraceDscFromValues::fillParams()
desc.dsc_flags |= DSC_null;
}
}
else if ((var = prm->as<VariableNode>()))
else if ((var = nodeAs<VariableNode>(prm)))
{
impure_value* impure = m_request->getImpure<impure_value>(var->impureOffset);
from_desc = &impure->vlu_desc;
}
else if ((literal = prm->as<LiteralNode>()))
else if ((literal = nodeAs<LiteralNode>(prm)))
from_desc = &literal->litDesc;
else if (prm->is<NullNode>())
else if (nodeIs<NullNode>(prm))
{
desc.clear();
desc.setNull();