2013-07-24 23:59:18 +00:00
|
|
|
/*
|
|
|
|
abCalcOpNot.c
|
|
|
|
By: Jeremy Rand
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "abCalcOpNot.h"
|
|
|
|
|
|
|
|
#include "abCalcOp.h"
|
|
|
|
#include "abCalcError.h"
|
|
|
|
#include "abCalcExpr.h"
|
2013-07-25 02:28:20 +00:00
|
|
|
#include "abCalcExprInt.h"
|
2013-07-24 23:59:18 +00:00
|
|
|
#include "abCalcStack.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define OP_NAME "NOT"
|
|
|
|
|
|
|
|
|
|
|
|
static void notExecute(void);
|
|
|
|
|
|
|
|
|
|
|
|
void abCalcOpNotInit(void)
|
|
|
|
{
|
|
|
|
abCalcOpRegister(OP_NAME, notExecute);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void notExecute(void)
|
|
|
|
{
|
|
|
|
abCalcExpr result;
|
|
|
|
AB_CALC_OP_ONE_ARG(OP_NAME);
|
|
|
|
|
|
|
|
if (expr->type != abCalcExprTypeInt) {
|
|
|
|
abCalcRaiseError(abCalcBadArgTypeError, OP_NAME);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-25 02:28:20 +00:00
|
|
|
abCalcExprIntSet(&result, ~(expr->u.integer));
|
2013-07-24 23:59:18 +00:00
|
|
|
|
|
|
|
abCalcStackExprPop(NULL);
|
|
|
|
abCalcStackExprPush(&result);
|
|
|
|
}
|