2013-07-24 23:59:18 +00:00
|
|
|
/*
|
2013-07-25 14:42:02 +00:00
|
|
|
abCOpAnd.c
|
2013-07-24 23:59:18 +00:00
|
|
|
By: Jeremy Rand
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-07-25 14:42:02 +00:00
|
|
|
#include "abCError.h"
|
|
|
|
#include "abCStack.h"
|
2013-07-24 23:59:18 +00:00
|
|
|
|
2013-07-25 15:21:21 +00:00
|
|
|
#include "expr/abCExpr.h"
|
|
|
|
#include "expr/abCExprInt.h"
|
|
|
|
|
|
|
|
#include "ops/abCOp.h"
|
|
|
|
#include "ops/abCOpAnd.h"
|
|
|
|
|
2013-07-24 23:59:18 +00:00
|
|
|
|
|
|
|
#define OP_NAME "AND"
|
|
|
|
|
|
|
|
|
|
|
|
static void andExecute(void);
|
|
|
|
|
|
|
|
|
|
|
|
void abCalcOpAndInit(void)
|
|
|
|
{
|
|
|
|
abCalcOpRegister(OP_NAME, andExecute);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void andExecute(void)
|
|
|
|
{
|
|
|
|
abCalcExpr result;
|
|
|
|
AB_CALC_OP_TWO_ARGS(OP_NAME);
|
|
|
|
|
|
|
|
if (expr1->type != abCalcExprTypeInt) {
|
|
|
|
abCalcRaiseError(abCalcBadArgTypeError, OP_NAME);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (expr2->type != abCalcExprTypeInt) {
|
|
|
|
abCalcRaiseError(abCalcBadArgTypeError, OP_NAME);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-25 02:28:20 +00:00
|
|
|
abCalcExprIntSet(&result, expr2->u.integer & expr1->u.integer);
|
2013-07-24 23:59:18 +00:00
|
|
|
|
|
|
|
abCalcStackExprPop(NULL);
|
|
|
|
abCalcStackExprPop(NULL);
|
|
|
|
abCalcStackExprPush(&result);
|
|
|
|
}
|