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

Method NodeUnaryOp

NULLC/SyntaxTree.cpp:276–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274// Node that applies selected operation on value on top of the stack
275
276NodeUnaryOp::NodeUnaryOp(CmdID cmd, unsigned int argument)
277{
278 // Unary operation
279 vmCmd.cmd = cmd;
280 vmCmd.argument = argument;
281
282 first = TakeLastNode();
283 // Resulting type is the same as source type with exception for logical NOT
284 bool logicalOp = cmd == cmdLogNot;
285 typeInfo = logicalOp ? typeBool : first->typeInfo;
286
287 if(cmd != cmdCheckedRet && ((first->typeInfo->refLevel != 0 && !logicalOp) || (first->typeInfo->type == TypeInfo::TYPE_COMPLEX && first->typeInfo != typeObject) || (!logicalOp && first->typeInfo == typeBool) || first->typeInfo->type == TypeInfo::TYPE_VOID))
288 ThrowError(CodeInfo::lastKnownStartPos, "ERROR: unary operation '%s' is not supported on '%s'", unaryCommandToText[cmd - cmdNeg], first->typeInfo->GetFullTypeName());
289
290 nodeType = typeNodeUnaryOp;
291
292 parentFunc = NULL;
293}
294NodeUnaryOp::~NodeUnaryOp()
295{
296}

Callers

nothing calls this directly

Calls 3

TakeLastNodeFunction · 0.85
ThrowErrorFunction · 0.85
GetFullTypeNameMethod · 0.80

Tested by

no test coverage detected