extend calc, calcout and sub records and calc expressions to inputs A - U

To accomodate for the increased number of inputs, the size of CALC and OCAL
fields has been doubled to 160 characters.
This commit is contained in:
2025-05-22 11:14:16 +02:00
committed by Andrew Johnson
parent 15ed1643cd
commit 79624b72e5
15 changed files with 686 additions and 83 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ stringchar [^"\n\\]
name [a-zA-Z0-9_\-+:.\[\]<>;]
digit [0-9]
punctuation [(){},]
link [A-L]
link [A-U]
%{
static ASINPUTFUNCPTR *my_yyinput;
+36
View File
@@ -86,6 +86,15 @@ LIBCOM_API long
case FETCH_J:
case FETCH_K:
case FETCH_L:
case FETCH_M:
case FETCH_N:
case FETCH_O:
case FETCH_P:
case FETCH_Q:
case FETCH_R:
case FETCH_S:
case FETCH_T:
case FETCH_U:
*++ptop = parg[op - FETCH_A];
break;
@@ -101,6 +110,15 @@ LIBCOM_API long
case STORE_J:
case STORE_K:
case STORE_L:
case STORE_M:
case STORE_N:
case STORE_O:
case STORE_P:
case STORE_Q:
case STORE_R:
case STORE_S:
case STORE_T:
case STORE_U:
parg[op - STORE_A] = *ptop--;
break;
@@ -441,6 +459,15 @@ calcArgUsage(const char *pinst, unsigned long *pinputs, unsigned long *pstores)
case FETCH_J:
case FETCH_K:
case FETCH_L:
case FETCH_M:
case FETCH_N:
case FETCH_O:
case FETCH_P:
case FETCH_Q:
case FETCH_R:
case FETCH_S:
case FETCH_T:
case FETCH_U:
/* Don't claim to use an arg we already stored to */
inputs |= (1 << (op - FETCH_A)) & ~stores;
break;
@@ -457,6 +484,15 @@ calcArgUsage(const char *pinst, unsigned long *pinputs, unsigned long *pstores)
case STORE_J:
case STORE_K:
case STORE_L:
case STORE_M:
case STORE_N:
case STORE_O:
case STORE_P:
case STORE_Q:
case STORE_R:
case STORE_S:
case STORE_T:
case STORE_U:
stores |= (1 << (op - STORE_A));
break;
+14 -1
View File
@@ -117,20 +117,29 @@ static const ELEMENT operands[] = {
{"LN", 7, 8, 0, UNARY_OPERATOR, LOG_E},
{"LOG", 7, 8, 0, UNARY_OPERATOR, LOG_10},
{"LOGE", 7, 8, 0, UNARY_OPERATOR, LOG_E},
{"M", 0, 0, 1, OPERAND, FETCH_M},
{"MAX", 7, 8, 0, VARARG_OPERATOR,MAX},
{"MIN", 7, 8, 0, VARARG_OPERATOR,MIN},
{"N", 0, 0, 1, OPERAND, FETCH_N},
{"NINT", 7, 8, 0, UNARY_OPERATOR, NINT},
{"NAN", 0, 0, 1, LITERAL_OPERAND,LITERAL_DOUBLE},
{"NOT", 7, 8, 0, UNARY_OPERATOR, BIT_NOT},
{"O", 0, 0, 1, OPERAND, FETCH_O},
{"P", 0, 0, 1, OPERAND, FETCH_P},
{"PI", 0, 0, 1, OPERAND, CONST_PI},
{"Q", 0, 0, 1, OPERAND, FETCH_Q},
{"R", 0, 0, 1, OPERAND, FETCH_R},
{"R2D", 0, 0, 1, OPERAND, CONST_R2D},
{"RNDM", 0, 0, 1, OPERAND, RANDOM},
{"S", 0, 0, 1, OPERAND, FETCH_S},
{"SIN", 7, 8, 0, UNARY_OPERATOR, SIN},
{"SINH", 7, 8, 0, UNARY_OPERATOR, SINH},
{"SQR", 7, 8, 0, UNARY_OPERATOR, SQU_RT},
{"SQRT", 7, 8, 0, UNARY_OPERATOR, SQU_RT},
{"T", 0, 0, 1, OPERAND, FETCH_T},
{"TAN", 7, 8, 0, UNARY_OPERATOR, TAN},
{"TANH", 7, 8, 0, UNARY_OPERATOR, TANH},
{"U", 0, 0, 1, OPERAND, FETCH_U},
{"VAL", 0, 0, 1, OPERAND, FETCH_VAL},
{"~", 7, 8, 0, UNARY_OPERATOR, BIT_NOT},
};
@@ -286,7 +295,7 @@ LIBCOM_API long
case STORE_OPERATOR:
if (pout == pdest || pstacktop > stack ||
*--pout < FETCH_A || *pout > FETCH_L) {
*--pout < FETCH_A || *pout >= FETCH_A + CALCPERFORM_NARGS) {
*perror = CALC_ERR_BAD_ASSIGNMENT;
goto bad;
}
@@ -542,9 +551,13 @@ LIBCOM_API void
"LITERAL_DOUBLE", "LITERAL_INT", "VAL",
"FETCH_A", "FETCH_B", "FETCH_C", "FETCH_D", "FETCH_E", "FETCH_F",
"FETCH_G", "FETCH_H", "FETCH_I", "FETCH_J", "FETCH_K", "FETCH_L",
"FETCH_M", "FETCH_N", "FETCH_O", "FETCH_P", "FETCH_Q", "FETCH_R",
"FETCH_S", "FETCH_T", "FETCH_U",
/* Assignment */
"STORE_A", "STORE_B", "STORE_C", "STORE_D", "STORE_E", "STORE_F",
"STORE_G", "STORE_H", "STORE_I", "STORE_J", "STORE_K", "STORE_L",
"STORE_M", "STORE_N", "STORE_O", "STORE_P", "STORE_Q", "STORE_R",
"STORE_S", "STORE_T", "STORE_U",
/* Trigonometry Constants */
"CONST_PI",
"CONST_D2R",
+11 -8
View File
@@ -22,8 +22,11 @@
#include "libComAPI.h"
/** \brief Number of input arguments to a calc expression (A-L) */
#define CALCPERFORM_NARGS 12
/** \brief Number of input arguments to a calc expression (A-U)
*
* Since UNRELEASED the number of inputs has been increased from 12 to 21.
*/
#define CALCPERFORM_NARGS 21
/** \brief Size of the internal partial result stack */
#define CALCPERFORM_STACK 80
@@ -61,7 +64,7 @@
*
* This is not a hard limit, just the default size for the database
*/
#define MAX_INFIX_SIZE 100
#define MAX_INFIX_SIZE 160
/**
* \brief Size of a "standard" postfix buffer.
*
@@ -161,13 +164,13 @@ extern "C" {
* angle from radians to degrees.
*
* -# **Variables** are used to provide inputs to an expression, and are
* named using the single letters \c A through \c L inclusive or the
* named using the single letters \c A through \c U inclusive or the
* keyword \c VAL which refers to the previous result of this
* calculation.
* The software that makes use of the expression evaluation code should
* document how the individual variables are given values.
* For the calc and calcout record types the input links \c INPA through
* \c INPL can be used to obtain values from other record fields, and \c
* \c INPU can be used to obtain values from other record fields, and \c
* VAL refers to the the VAL field (which can be overwritten from
* outside the record via Channel Access or a database link).
*
@@ -323,7 +326,7 @@ LIBCOM_API long
* Evaluates the postfix expression against a set ot input values.
*
* \param parg Pointer to an array of double values for the arguments
* \c A-L that can appear in the expression.
* \c A-U that can appear in the expression.
* Note that the argument values may be modified if the expression uses
* the assignment operator.
* \param presult Where to put the calculated result, which may be a NaN
@@ -345,8 +348,8 @@ LIBCOM_API long
* for either of these pointers is legal if only the other is needed.
*
* The least significant bit (bit 0) of the bitmap at \c *pinputs will be set
* if the expression depends on the argument A, and so on through bit 11 for
* the argument L. An argument that is not used until after a value has been
* if the expression depends on the argument A, and so on through bit 20 for
* the argument U. An argument that is not used until after a value has been
* assigned to it will not be set in the pinputs bitmap, thus the bits can
* be used to determine whether a value needs to be supplied for their
* associated argument or not for the purposes of evaluating the expression.
+5 -1
View File
@@ -13,7 +13,7 @@
*/
/* Notes:
* 1. The FETCH_A through FETCH_L and STORE_A through STORE_L opcodes must
* 1. The FETCH_A through FETCH_U and STORE_A through STORE_U opcodes must
* be contiguous.
* 2. The LITERAL opcodes are followed by a binary representation of their
* values, but these are not aligned properly.
@@ -34,9 +34,13 @@ typedef enum {
LITERAL_DOUBLE, LITERAL_INT, FETCH_VAL,
FETCH_A, FETCH_B, FETCH_C, FETCH_D, FETCH_E, FETCH_F,
FETCH_G, FETCH_H, FETCH_I, FETCH_J, FETCH_K, FETCH_L,
FETCH_M, FETCH_N, FETCH_O, FETCH_P, FETCH_Q, FETCH_R,
FETCH_S, FETCH_T, FETCH_U,
/* Assignment */
STORE_A, STORE_B, STORE_C, STORE_D, STORE_E, STORE_F,
STORE_G, STORE_H, STORE_I, STORE_J, STORE_K, STORE_L,
STORE_M, STORE_N, STORE_O, STORE_P, STORE_Q, STORE_R,
STORE_S, STORE_T, STORE_U,
/* Trigonometry Constants */
CONST_PI,
CONST_D2R,