From: bdemsky Date: Fri, 16 Jun 2017 06:27:39 +0000 (-0700) Subject: Fix functionencoder to have correct pointers... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=satune.git;a=commitdiff_plain;h=7b33ea08b973bcf2c949614ca1a697b4984766d1 Fix functionencoder to have correct pointers... --- 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