2013-07-24 18:59:18 -05:00
|
|
|
/*
|
2013-07-25 09:42:02 -05:00
|
|
|
abCOpOr.c
|
2013-07-24 18:59:18 -05:00
|
|
|
By: Jeremy Rand
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-07-25 09:42:02 -05:00
|
|
|
#include "abCError.h"
|
|
|
|
#include "abCStack.h"
|
2013-07-24 18:59:18 -05:00
|
|
|
|
2013-07-25 10:21:21 -05:00
|
|
|
#include "expr/abCExpr.h"
|
|
|
|
#include "expr/abCExprInt.h"
|
|
|
|
|
|
|
|
#include "ops/abCOp.h"
|
|
|
|
#include "ops/abCOpOr.h"
|
|
|
|
|
2013-07-24 18:59:18 -05:00
|
|
|
|
2013-07-26 21:27:29 -05:00
|
|
|
#define OR_NAME "OR"
|
2013-07-24 18:59:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
static void orExecute(void);
|
|
|
|
|
|
|
|
|
|
|
|
void abCalcOpOrInit(void)
|
|
|
|
{
|
2013-07-26 21:27:29 -05:00
|
|
|
abCalcOpRegister(OR_NAME, orExecute);
|
2013-07-24 18:59:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void orExecute(void)
|
|
|
|
{
|
|
|
|
abCalcExpr result;
|
2013-07-26 21:27:29 -05:00
|
|
|
AB_CALC_OP_TWO_ARGS(OR_NAME);
|
2013-07-24 18:59:18 -05:00
|
|
|
|
|
|
|
if (expr1->type != abCalcExprTypeInt) {
|
2013-07-26 21:27:29 -05:00
|
|
|
abCalcRaiseError(abCalcBadArgTypeError, OR_NAME);
|
2013-07-24 18:59:18 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (expr2->type != abCalcExprTypeInt) {
|
2013-07-26 21:27:29 -05:00
|
|
|
abCalcRaiseError(abCalcBadArgTypeError, OR_NAME);
|
2013-07-24 18:59:18 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-24 21:28:20 -05:00
|
|
|
abCalcExprIntSet(&result, expr2->u.integer | expr1->u.integer);
|
2013-07-24 18:59:18 -05:00
|
|
|
|
|
|
|
abCalcStackExprPop(NULL);
|
|
|
|
abCalcStackExprPop(NULL);
|
|
|
|
abCalcStackExprPush(&result);
|
|
|
|
}
|