MCPcopy Create free account
hub / github.com/WheretIB/nullc / NodeIfElseExpr

Method NodeIfElseExpr

NULLC/SyntaxTree.cpp:1382–1398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1380// Node for compilation of if(){}else{} statement and conditional operator ?:
1381
1382NodeIfElseExpr::NodeIfElseExpr(bool haveElse, bool isTerm)
1383{
1384 // If else block is present
1385 if(haveElse)
1386 third = TakeLastNode();
1387
1388 second = TakeLastNode();
1389 first = TakeLastNode();
1390
1391 if((first->typeInfo->type == TypeInfo::TYPE_COMPLEX && first->typeInfo != typeObject) || first->typeInfo->type == TypeInfo::TYPE_VOID)
1392 ThrowError(CodeInfo::lastKnownStartPos, "ERROR: condition type cannot be '%s' and function for conversion to bool is undefined", first->typeInfo->GetFullTypeName());
1393 // If it is a conditional operator, the there is a resulting type different than void
1394 if(isTerm)
1395 typeInfo = second->typeInfo != third->typeInfo ? ChooseBinaryOpResultType(second->typeInfo, third->typeInfo) : second->typeInfo;
1396
1397 nodeType = typeNodeIfElseExpr;
1398}
1399NodeIfElseExpr::~NodeIfElseExpr()
1400{
1401}

Callers

nothing calls this directly

Calls 4

TakeLastNodeFunction · 0.85
ThrowErrorFunction · 0.85
ChooseBinaryOpResultTypeFunction · 0.85
GetFullTypeNameMethod · 0.80

Tested by

no test coverage detected