abCalc/ops/abCOpStws.c

51 lines
825 B
C
Raw Normal View History

2013-07-24 20:20:54 -05:00
/*
abCOpStws.c
2013-07-24 20:20:54 -05:00
By: Jeremy Rand
*/
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "abCMode.h"
2013-07-24 20:20:54 -05:00
#include "expr/abCExpr.h"
#include "ops/abCOp.h"
#include "ops/abCOpStws.h"
2013-07-24 20:20:54 -05:00
#define STWS_NAME "STWS"
2013-07-24 20:20:54 -05:00
static void stwsExecute(void);
void abCalcOpStwsInit(void)
{
abCalcOpRegister(STWS_NAME, stwsExecute);
2013-07-24 20:20:54 -05:00
}
void stwsExecute(void)
{
int newWidth;
AB_CALC_OP_ONE_ARG(STWS_NAME);
2013-07-24 20:20:54 -05:00
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, STWS_NAME);
2013-07-24 20:20:54 -05:00
return;
}
newWidth = (int)expr->u.real;
if ((newWidth < 1) ||
(newWidth > AB_CALC_EXPR_MAX_INT_WIDTH)) {
abCalcRaiseError(abCalcBadArgValueError, STWS_NAME);
2013-07-24 20:20:54 -05:00
return;
}
abCalcModeSetIntWidth(newWidth);
abCalcStackExprPop(NULL);
}