Function that creates unary operation node for logical NOT
| 812 | |
| 813 | // Function that creates unary operation node for logical NOT |
| 814 | void 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 |
| 843 | void AddBitNotNode(const char* pos) |
no test coverage detected