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

Function AddCaseNode

NULLC/Callbacks.cpp:4793–4814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4791}
4792
4793void AddCaseNode(const char* pos)
4794{
4795 assert(CodeInfo::nodeList.size() >= 3);
4796 if(CodeInfo::nodeList[CodeInfo::nodeList.size()-2]->typeInfo == typeVoid)
4797 ThrowError(pos, "ERROR: case value type cannot be void");
4798 NodeZeroOP* temp = CodeInfo::nodeList[CodeInfo::nodeList.size()-3];
4799 assert(temp->nodeType == typeNodeSwitchExpr);
4800 NodeSwitchExpr *node = (NodeSwitchExpr*)temp;
4801 if(NodeZeroOP *cond = node->IsComplex())
4802 {
4803 NodeZeroOP *body = CodeInfo::nodeList.back(); CodeInfo::nodeList.pop_back();
4804
4805 NodeOneOP *wrap = new NodeOneOP();
4806 wrap->SetFirstNode(cond);
4807 CodeInfo::nodeList.push_back(wrap);
4808 AddFunctionCallNode(pos, "==", 2);
4809 if(CodeInfo::nodeList.back()->typeInfo->stackType != STYPE_INT)
4810 ThrowError(pos, "ERROR: '==' operator result type must be bool, char, short or int");
4811 CodeInfo::nodeList.push_back(body);
4812 }
4813 node->AddCase();
4814}
4815
4816void AddDefaultNode()
4817{

Callers 1

ParseSwitchExprFunction · 0.85

Calls 9

assertFunction · 0.85
ThrowErrorFunction · 0.85
AddFunctionCallNodeFunction · 0.85
IsComplexMethod · 0.80
SetFirstNodeMethod · 0.80
AddCaseMethod · 0.80
sizeMethod · 0.45
pop_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected