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

Function AddBitNotNode

NULLC/Callbacks.cpp:843–868  ·  view source on GitHub ↗

Function that creates unary operation node for binary NOT

Source from the content-addressed store, hash-verified

841
842// Function that creates unary operation node for binary NOT
843void AddBitNotNode(const char* pos)
844{
845 CodeInfo::lastKnownStartPos = pos;
846 if(AddFunctionCallNode(pos, "~", 1, true))
847 return;
848
849 if(CodeInfo::nodeList.back()->typeInfo == typeDouble || CodeInfo::nodeList.back()->typeInfo == typeFloat)
850 ThrowError(pos, "ERROR: binary NOT is not available on floating-point numbers");
851 // If the last node is a number, we can just make operation in compile-time
852 if(CodeInfo::nodeList.back()->nodeType == typeNodeNumber && CodeInfo::nodeList.back()->typeInfo != typeBool)
853 {
854 TypeInfo *aType = CodeInfo::nodeList.back()->typeInfo;
855 NodeZeroOP* Rd = NULL;
856 if(aType == typeLong)
857 Rd = new NodeNumber(~static_cast<NodeNumber*>(CodeInfo::nodeList.back())->GetLong(), aType);
858 else if(aType == typeInt || aType == typeShort || aType == typeChar)
859 Rd = new NodeNumber(~static_cast<NodeNumber*>(CodeInfo::nodeList.back())->GetInteger(), aType);
860 else
861 ThrowError(pos, "addBitNotNode() ERROR: unknown type %s", aType->name);
862
863 CodeInfo::nodeList.pop_back();
864 CodeInfo::nodeList.push_back(Rd);
865 }else{
866 CodeInfo::nodeList.push_back(new NodeUnaryOp(cmdBitNot));
867 }
868}
869
870void RemoveLastNode(bool swap)
871{

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