diff --git a/src/pmie/src/GNUmakefile b/src/pmie/src/GNUmakefile index 736381d..52251ff 100644 --- a/src/pmie/src/GNUmakefile +++ b/src/pmie/src/GNUmakefile @@ -35,10 +35,10 @@ include $(TOPDIR)/src/include/builddefs TARGET = pmie$(EXECSUFFIX) CFILES = pmie.c symbol.c dstruct.c lexicon.c syntax.c pragmatics.c eval.c \ - show.c match_inst.c syslog.c stomp.c + show.c match_inst.c syslog.c stomp.c conjunct.c HFILES = fun.h dstruct.h eval.h lexicon.h pmiestats.h pragmatics.h \ - show.h symbol.h syntax.h syslog.h stomp.h + show.h symbol.h syntax.h syslog.h stomp.h conjunct.h SKELETAL = hdr.sk fetch.sk misc.sk aggregate.sk unary.sk binary.sk \ merge.sk act.sk diff --git a/src/pmie/src/conjunct.c b/src/pmie/src/conjunct.c new file mode 100644 index 0000000..a31a731 --- /dev/null +++ b/src/pmie/src/conjunct.c @@ -0,0 +1,552 @@ +/* + * Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, + * Mountain View, CA 94043, USA, or: http://www.sgi.com + */ + +/*********************************************************************** + * conjunct.c + * + * These functions were originally generated from skeletons .sk + * by the shell-script './meta', then modified to support the semantics + * of the boolean AND/OR operators correctly. These are different to + * every other operator in that they do not always require both sides + * of the expression to be available in order to be evaluated, i.e. + * OR: if either side of the expression is true, expr is true + * AND: if either side of the expression is false, expr is false + ***********************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pmapi.h" +#include "dstruct.h" +#include "pragmatics.h" +#include "fun.h" +#include "show.h" +#include "stomp.h" + + +/* + * operator: cndOr + */ + +#define OR(x,y) (((x) == TRUE || (y) == TRUE) ? TRUE : (((x) == FALSE && (y) == FALSE) ? FALSE : DUNNO)) +#define OR1(x) (((x) == TRUE) ? TRUE : DUNNO) + +void +cndOr_n_n(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + Truth *ip1; + Truth *ip2; + Truth *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + ip1 = (Truth *)is1->ptr; + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = OR(*ip1, *ip2); + ip1++; + ip2++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + Truth answer = DUNNO; + + ip1 = (Truth *)is1->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = OR1(*ip1)) == TRUE) + answer = TRUE; + ip1++; + } + if (answer == TRUE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + Truth answer = DUNNO; + + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = OR1(*ip2)) == TRUE) + answer = TRUE; + ip2++; + } + if (answer == TRUE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndOr_n_n(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +cndOr_n_1(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + Truth *ip1; + Truth iv2; + Truth *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + ip1 = (Truth *)is1->ptr; + iv2 = *(Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = OR(*ip1, iv2); + ip1++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + Truth answer = DUNNO; + + ip1 = (Truth *)is1->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = OR1(*ip1)) == TRUE) + answer = TRUE; + ip1++; + } + if (answer == TRUE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + if ((*(Truth *)os->ptr = OR1(*(Truth *)is2->ptr)) == TRUE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndOr_n_1(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +cndOr_1_n(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + Truth iv1; + Truth *ip2; + Truth *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + iv1 = *(Truth *)is1->ptr; + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = OR(iv1, *ip2); + ip2++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + if ((*(Truth *)os->ptr = OR1(*(Truth *)is1->ptr)) == TRUE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + Truth answer = DUNNO; + + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = OR1(*ip2)) == TRUE) + answer = TRUE; + ip2++; + } + if (answer == TRUE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndOr_1_n(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +cndOr_1_1(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + *(Truth *)os->ptr = OR(*(Truth *)is1->ptr, *(Truth *)is2->ptr); + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + if ((*(Truth *)os->ptr = OR1(*(Truth *)is1->ptr)) == TRUE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + if ((*(Truth *)os->ptr = OR1(*(Truth *)is2->ptr)) == TRUE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndOr_1_1(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +/* + * operator: cndAnd + */ + +#define AND(x,y) (((x) == TRUE && (y) == TRUE) ? TRUE : (((x) == FALSE || (y) == FALSE) ? FALSE : DUNNO)) +#define AND1(x) (((x) == FALSE) ? FALSE : DUNNO) + +void +cndAnd_n_n(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + Truth *ip1; + Truth *ip2; + Truth *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + ip1 = (Truth *)is1->ptr; + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = AND(*ip1, *ip2); + ip1++; + ip2++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + Truth answer = DUNNO; + + ip1 = (Truth *)is1->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = AND1(*ip1)) == FALSE) + answer = FALSE; + ip1++; + } + if (answer == FALSE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + Truth answer = DUNNO; + + ip1 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = AND1(*ip2)) == FALSE) + answer = FALSE; + ip2++; + } + if (answer == FALSE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndAnd_n_n(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +cndAnd_n_1(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + Truth *ip1; + Truth iv2; + Truth *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + ip1 = (Truth *)is1->ptr; + iv2 = *(Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = AND(*ip1, iv2); + ip1++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + Truth answer = DUNNO; + + ip1 = (Truth *)is1->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = AND1(*ip1)) == FALSE) + answer = FALSE; + ip1++; + } + if (answer == FALSE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + if ((*(Truth *)os->ptr = AND1(*(Truth *)is2->ptr)) == FALSE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndAnd_n_1(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +cndAnd_1_n(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + Truth iv1; + Truth *ip2; + Truth *op; + int n; + int i; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + iv1 = *(Truth *)is1->ptr; + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + *op++ = AND(iv1, *ip2); + ip2++; + } + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + if ((*(Truth *)os->ptr = AND1(*(Truth *)is1->ptr)) == FALSE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + Truth answer = DUNNO; + + ip2 = (Truth *)is2->ptr; + op = (Truth *)os->ptr; + n = x->tspan; + for (i = 0; i < n; i++) { + if ((*op++ = AND1(*ip2)) == FALSE) + answer = FALSE; + ip2++; + } + if (answer == FALSE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndAnd_1_n(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} + +void +cndAnd_1_1(Expr *x) +{ + Expr *arg1 = x->arg1; + Expr *arg2 = x->arg2; + Sample *is1 = &arg1->smpls[0]; + Sample *is2 = &arg2->smpls[0]; + Sample *os = &x->smpls[0]; + + EVALARG(arg1) + EVALARG(arg2) + ROTATE(x) + + if (arg1->valid && arg2->valid) { + *(Truth *)os->ptr = AND(*(Truth *)is1->ptr, *(Truth *)is2->ptr); + os->stamp = (is1->stamp > is2->stamp) ? is1->stamp : is2->stamp; + x->valid++; + } + else if (arg1->valid) { + if ((*(Truth *)os->ptr = AND1(*(Truth *)is1->ptr)) == FALSE) { + os->stamp = is1->stamp; + x->valid++; + } + else x->valid = 0; + } + else if (arg2->valid) { + if ((*(Truth *)os->ptr = AND1(*(Truth *)is2->ptr)) == FALSE) { + os->stamp = is2->stamp; + x->valid++; + } + else x->valid = 0; + } + else x->valid = 0; + +#if PCP_DEBUG + if (pmDebug & DBG_TRACE_APPL2) { + fprintf(stderr, "cndAnd_1_1(" PRINTF_P_PFX "%p) ...\n", x); + dumpExpr(x); + } +#endif +} diff --git a/src/pmie/src/conjunct.h b/src/pmie/src/conjunct.h new file mode 100644 index 0000000..a12130b --- /dev/null +++ b/src/pmie/src/conjunct.h @@ -0,0 +1,37 @@ +/*********************************************************************** + * conjunt.h - Logical AND/OR expression evaluator functions + *********************************************************************** + * + * Copyright (c) 1995 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, + * Mountain View, CA 94043, USA, or: http://www.sgi.com + */ +#ifndef CONJUNCT_H +#define CONJUNCT_H + +/* expression evaluator function prototypes */ +void cndOr_n_n(Expr *); +void cndOr_1_n(Expr *); +void cndOr_n_1(Expr *); +void cndOr_1_1(Expr *); +void cndAnd_n_n(Expr *); +void cndAnd_1_n(Expr *); +void cndAnd_n_1(Expr *); +void cndAnd_1_1(Expr *); + +#endif /* CONJUNCT_H */ diff --git a/src/pmie/src/fun.h b/src/pmie/src/fun.h index ba26ea6..fd0b128 100644 --- a/src/pmie/src/fun.h +++ b/src/pmie/src/fun.h @@ -28,6 +28,7 @@ #define FUN_H #include "dstruct.h" +#include "conjunct.h" #define ROTATE(x) if ((x)->nsmpls > 1) rotate(x); #define EVALARG(x) if ((x)->op < NOP) ((x)->eval)(x); @@ -101,14 +102,6 @@ void cndRise_n(Expr *); void cndRise_1(Expr *); void cndFall_n(Expr *); void cndFall_1(Expr *); -void cndAnd_n_n(Expr *); -void cndAnd_1_n(Expr *); -void cndAnd_n_1(Expr *); -void cndAnd_1_1(Expr *); -void cndOr_n_n(Expr *); -void cndOr_1_n(Expr *); -void cndOr_n_1(Expr *); -void cndOr_1_1(Expr *); void cndMatch_inst(Expr *); void cndAll_host(Expr *); void cndAll_inst(Expr *); diff --git a/src/pmie/src/meta b/src/pmie/src/meta index 3955602..582c078 100755 --- a/src/pmie/src/meta +++ b/src/pmie/src/meta @@ -237,14 +237,6 @@ fun=cndNot op="OP(x) (((x) == TRUE || (x) == FALSE) ? !(x) : DUNNO)" _unary -fun=cndAnd -op="OP(x,y) (((x) == TRUE \\&\\& (y) == TRUE) ? TRUE : (((x) == FALSE || (y) == FALSE) ? FALSE : DUNNO))" -_binary - -fun=cndOr -op="OP(x,y) (((x) == TRUE || (y) == TRUE) ? TRUE : (((x) == FALSE \\&\\& (y) == FALSE) ? FALSE : DUNNO))" -_binary - fun=cndRise delta="" op=">"