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

Function AddLogNotNode

NULLC/Callbacks.cpp:814–840  ·  view source on GitHub ↗

Function that creates unary operation node for logical NOT

Source from the content-addressed store, hash-verified

812
813// Function that creates unary operation node for logical NOT
814void AddLogNotNode(const char* pos)
815{
816 CodeInfo::lastKnownStartPos = pos;
817 if(AddFunctionCallNode(pos, "!", 1, true))
818 return;
819
820 if(CodeInfo::nodeList.back()->typeInfo == typeDouble || CodeInfo::nodeList.back()->typeInfo == typeFloat)
821 ThrowError(pos, "ERROR: logical NOT is not available on floating-point numbers");
822 // If the last node is a number, we can just make operation in compile-time
823 if(CodeInfo::nodeList.back()->nodeType == typeNodeNumber)
824 {
825 TypeInfo *aType = CodeInfo::nodeList.back()->typeInfo;
826 NodeZeroOP* Rd = NULL;
827 if(aType == typeLong)
828 Rd = new NodeNumber((long long)!static_cast<NodeNumber*>(CodeInfo::nodeList.back())->GetLong(), typeBool);
829 else if(aType == typeInt || aType == typeShort || aType == typeChar || aType == typeBool)
830 Rd = new NodeNumber(!static_cast<NodeNumber*>(CodeInfo::nodeList.back())->GetInteger(), typeBool);
831 else
832 ThrowError(pos, "addLogNotNode() ERROR: unknown type %s", aType->name);
833
834 CodeInfo::nodeList.pop_back();
835 CodeInfo::nodeList.push_back(Rd);
836 }else{
837 // Otherwise, just create node
838 CodeInfo::nodeList.push_back(new NodeUnaryOp(cmdLogNot));
839 }
840}
841
842// Function that creates unary operation node for binary NOT
843void AddBitNotNode(const char* pos)

Callers 1

ParseTerminalFunction · 0.85

Calls 6

AddFunctionCallNodeFunction · 0.85
ThrowErrorFunction · 0.85
GetLongMethod · 0.80
GetIntegerMethod · 0.80
pop_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected