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

Function AddIfElseTermNode

NULLC/Callbacks.cpp:4690–4714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4688 CodeInfo::nodeList.back()->SetCodeInfo(pos);
4689}
4690void AddIfElseTermNode(const char* pos)
4691{
4692 CodeInfo::lastKnownStartPos = pos;
4693 assert(CodeInfo::nodeList.size() >= 3);
4694
4695 if(OptimizeIfElse(true))
4696 return;
4697
4698 NodeZeroOP *bodyE = CodeInfo::nodeList.back(); CodeInfo::nodeList.pop_back();
4699 NodeZeroOP *bodyT = CodeInfo::nodeList.back(); CodeInfo::nodeList.pop_back();
4700
4701 if(CodeInfo::nodeList.back()->typeInfo->type == TypeInfo::TYPE_COMPLEX && CodeInfo::nodeList.back()->typeInfo != typeObject)
4702 AddFunctionCallNode(pos, "bool", 1, true);
4703
4704 CodeInfo::nodeList.push_back(bodyT);
4705 CodeInfo::nodeList.push_back(bodyE);
4706
4707 TypeInfo* typeA = CodeInfo::nodeList[CodeInfo::nodeList.size()-1]->typeInfo;
4708 TypeInfo* typeB = CodeInfo::nodeList[CodeInfo::nodeList.size()-2]->typeInfo;
4709 if(typeA == typeVoid || typeB == typeVoid)
4710 ThrowError(pos, "ERROR: one of ternary operator ?: result type is void (%s : %s)", typeB->name, typeA->name);
4711 if(typeA != typeB && (typeA->type == TypeInfo::TYPE_COMPLEX || typeB->type == TypeInfo::TYPE_COMPLEX))
4712 ThrowError(pos, "ERROR: ternary operator ?: result types are not equal (%s : %s)", typeB->name, typeA->name);
4713 CodeInfo::nodeList.push_back(new NodeIfElseExpr(true, true));
4714}
4715
4716void IncreaseCycleDepth()
4717{

Callers 1

ParseTernaryExprFunction · 0.85

Calls 7

assertFunction · 0.85
OptimizeIfElseFunction · 0.85
AddFunctionCallNodeFunction · 0.85
ThrowErrorFunction · 0.85
sizeMethod · 0.45
pop_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected