From 7b33ea08b973bcf2c949614ca1a697b4984766d1 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 15 Jun 2017 23:27:39 -0700 Subject: [PATCH] Fix functionencoder to have correct pointers... --- src/Encoders/functionencoder.c | 11 +++++++++-- src/Encoders/functionencoder.h | 13 +++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Encoders/functionencoder.c b/src/Encoders/functionencoder.c index 119623a..fa51fba 100644 --- a/src/Encoders/functionencoder.c +++ b/src/Encoders/functionencoder.c @@ -1,8 +1,15 @@ #include "functionencoder.h" -FunctionEncoder * allocFunctionEncoder(FunctionEncoderType type, Function *function) { +FunctionEncoder * allocFunctionEncoder(FunctionEncoderType type, Element *function) { FunctionEncoder * this=(FunctionEncoder *)ourmalloc(sizeof(FunctionEncoder)); - this->function=function; + this->op.function=function; + this->type=type; + return this; +} + +FunctionEncoder * allocPredicateEncoder(FunctionEncoderType type, Boolean *predicate) { + FunctionEncoder * this=(FunctionEncoder *)ourmalloc(sizeof(FunctionEncoder)); + this->op.predicate=predicate; this->type=type; return this; } diff --git a/src/Encoders/functionencoder.h b/src/Encoders/functionencoder.h index 6827535..4a6ba80 100644 --- a/src/Encoders/functionencoder.h +++ b/src/Encoders/functionencoder.h @@ -8,11 +8,20 @@ enum FunctionEncoderType { typedef enum FunctionEncoderType FunctionEncoderType; +union ElementPredicate { + Element * function; + Boolean * predicate; +}; + +typedef union ElementPredicate ElementPredicate; + struct FunctionEncoder { FunctionEncoderType type; - Function * function; + bool isFunction; //true for function, false for predicate + ElementPredicate op; }; -FunctionEncoder * allocFunctionEncoder(FunctionEncoderType type, Function *function); +FunctionEncoder * allocFunctionEncoder(FunctionEncoderType type, Element *function); +FunctionEncoder * allocPredicateEncoder(FunctionEncoderType type, Boolean *predicate); void deleteFunctionEncoder(FunctionEncoder *this); #endif -- 2.34.1