Function that creates unary operation node for binary NOT
| 841 | |
| 842 | // Function that creates unary operation node for binary NOT |
| 843 | void 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 | |
| 870 | void RemoveLastNode(bool swap) |
| 871 | { |
no test coverage detected