head 1.15; access; symbols Version_2_1:1.8 Version_2:1.6 C_Demo_1:1.4 Retrieve_x_1:1.3; locks; strict; comment @ * @; 1.15 date 92.07.24.21.20.12; author mao; state Exp; branches; next 1.14; 1.14 date 92.07.15.04.33.40; author mer; state Exp; branches; next 1.13; 1.13 date 91.11.14.14.58.36; author jolly; state Exp; branches; next 1.12; 1.12 date 91.10.01.16.38.01; author glass; state Exp; branches; next 1.11; 1.11 date 91.04.28.09.15.37; author cimarron; state Exp; branches; next 1.10; 1.10 date 91.04.04.17.06.25; author kemnitz; state Exp; branches; next 1.9; 1.9 date 91.04.02.21.11.08; author kemnitz; state Exp; branches; next 1.8; 1.8 date 91.02.05.15.45.18; author sp; state Exp; branches; next 1.7; 1.7 date 90.08.17.08.52.37; author cimarron; state Exp; branches; next 1.6; 1.6 date 90.06.04.16.38.46; author cimarron; state Version_2; branches; next 1.5; 1.5 date 90.05.29.13.05.21; author cimarron; state Exp; branches; next 1.4; 1.4 date 89.09.05.17.08.53; author mao; state C_Demo_1; branches; next 1.3; 1.3 date 89.08.01.16.17.35; author goh; state Exp; branches; next 1.2; 1.2 date 89.08.01.16.13.43; author goh; state Exp; branches; next 1.1; 1.1 date 89.07.20.09.28.03; author goh; state Exp; branches; next ; desc @@ 1.15 log @define accessor macro for and clauses @ text @/* * nodes.h -- * Definitions for tagged nodes. * * Identification: * $Header: /private/mao/postgres/src/lib/H/nodes/RCS/nodes.h,v 1.14 1992/07/15 04:33:40 mer Exp $ * * NOTES: * Why do things this way, you ask. * * (1) Eventually this code should be transmogrified into C++ classes, * and this is more or less compatible with those things. * (2) Unions suck. * * As long as all inheritance declarations are put at the beginning of * the structure in a consistent order this is perfectly legal (sharing * of initial structure members is K&R C). */ #ifndef NodesIncluded #define NodesIncluded #include "tmp/c.h" #include "tags.h" /* ---------------------------------------------------------------- * miscellanious node defines * ---------------------------------------------------------------- */ /* ---------------- * NO_NODE_CHECKING, if defined, turns off the built in * argument sanity checking done within the generated * set_ and get_ accessor functions. * * If not defined, then sanity checking is done. This makes * things a bit slower but makes debugging easier.. * ---------------- */ /* * We define NO_NODE_CHECKING for now because we are trying to get speed * out of this thing... */ #define NO_NODE_CHECKING /* ---------------- * I don't know why this is here. Most likely a hack.. * -cim 6/3/90 * ---------------- */ typedef float Cost; /* * Set up a single-inheritance mechanism based on cpp. Ick. * * public() is a noise-word that exists solely for our inheritance-graph * generation script. */ #define public(_x_) /* * inheritsN is necessary because ANSI C cpp doesn't expand a macro that * occurs in a definition more than once. * * example: now the old inherits macros would turn * class (Var) public (Expr) { * inherits(Expr); * Index varno; * * into: * typedef struct _Var *Var; struct _Var { * inherits(Node); * Index varno; * ... * * instead of: * typedef struct _Var *Var; struct _Var { * NodeTag type; * void (*outFunc)(); * char (*equalFunc)(); * char (*copyFunc)() ; * Index varno; * ... * * so now we have inheritsN instead of inherits. If you define * a subclass which inhertsN(foo) then you have to use inheritsN+1(foo) * or everything breaks. */ #define inherits0(_x_) CppConcat0(_x_,Defs) #define inherits1(_x_) CppConcat1(_x_,Defs) #define inherits2(_x_) CppConcat2(_x_,Defs) #define inherits3(_x_) CppConcat3(_x_,Defs) #define inherits4(_x_) CppConcat4(_x_,Defs) #define classObj(_x_) struct CppConcat(_,_x_) #define classSize(_x_) ((Size) sizeof(classObj(_x_))) #define classTag(_x_) ((NodeTag) CppConcat(T_,_x_)) #define class(_x_) typedef classObj(_x_) *_x_; classObj(_x_) /* * TypeId * XXX An "enum" would be slightly cleaner but * (1) "enum" isn't universal yet * (2) the Saber disbelief of typedefs makes them a pain */ typedef unsigned int TypeId; typedef unsigned int NodeTag; #define TypeIdIsValid(t) ((t) < (TypeId)_InvalidTypeId) /* ---------------------------------------------------------------- * Node class definition * * The Node class is the superclass for all other classes * in this inheritance system. * ---------------------------------------------------------------- */ class (Node) { #define NodeDefs \ NodeTag type; \ void (*outFunc)(); \ bool (*equalFunc)(); \ bool (*copyFunc)() /* private: */ NodeDefs; /* public: */ }; #define NullTag ((NodeTag) NULL) #define NodeType(_node_) ((Node)_node_)->type #define NodeIsValid(_node_) PointerIsValid((Pointer)(_node_)) #define IsA(_node_,_tag_) NodeIsType((Node)(_node_), classTag(_tag_)) #define New_Node(_x_) ((_x_)NewNode(classSize(_x_),classTag(_x_))) #define CreateNode(_x_) ((_x_)NewNode(classSize(_x_),classTag(_x_))) /* * "Clause" macros for finding various nodes follow */ #define fast_is_clause(_clause_) (ExactNodeType(CAR((LispValue) _clause_),Oper)) #define fast_is_funcclause(_clause_) (ExactNodeType(CAR((LispValue) _clause_),Func)) #define fast_not_clause(_clause_) (CInteger(CAR((LispValue) _clause_)) == NOT) #define fast_or_clause(_clause_) (CInteger(CAR((LispValue) _clause_)) == OR) #define fast_and_clause(_clause_) (CInteger(CAR((LispValue) _clause_)) == AND) /* * NodeTagIsValid -- * True iff node tag is valid. */ #define NodeTagIsValid(tag) \ ((bool)((tag) < _InvalidTypeId)) /* * NodeGetTag -- * Returns tag of a node. * * Note: * Assumes node is valid. */ #define NodeGetTag(node) \ ((NodeTag) (AssertMacro(NodeIsValid(node)) ? NodeType(node) : NullTag)) /* * NodeSetTag -- * Sets tag of a node. * * Note: * Assumes node is valid pointer. * Assumes tag is valid. */ #define NodeSetTag(node, tag) \ Assert(PointerIsValid(node)); \ Assert(NodeTagIsValid(tag)); \ NodeType(node) = tag /* * NodeHasTag -- * True iff node or one of its ancestors has the given tag. * * Note: * See also: NodeIsTagged. */ #define NodeHasTag(node, tag) \ ((bool) (NodeGetTag(node) == (tag))) #define ExactNodeType(_node_,_tag_) \ (NodeType(_node_) == classTag(_tag_)) /* ---------------------------------------------------------------- * extern declarations follow * ---------------------------------------------------------------- */ /* * NewNode -- * Returns a new node of the given size and tag. */ extern Node NewNode ARGS((Size size, NodeTag tag )); void SetNodeType ARGS((Node thisNode , TypeId tag )); Size NodeTagGetSize ARGS((TypeId tag )); extern TypeId _InvalidTypeId; #endif /* NodesIncluded */ @ 1.14 log @ changed Cost from double to float @ text @d6 1 a6 1 * $Header: /users/mer/pg/src/lib/H/nodes/RCS/nodes.h,v 1.13 1991/11/14 14:58:36 jolly Exp mer $ d149 1 @ 1.13 log @added function prototypes for SetNodeType() and NodeTagGetSize() @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.12 91/10/01 16:38:01 glass Exp Locker: jolly $ d53 1 a53 1 typedef double Cost; @ 1.12 log @initial ansi c compatibility checkin @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.11 91/04/28 09:15:37 cimarron Exp $ d205 3 @ 1.11 log @Converted IsValid code into macros and added an improved NodeIsType scheme @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.10 91/04/04 17:06:25 kemnitz Exp Locker: cimarron $ d63 34 a96 1 #define inherits(_x_) CppConcat(_x_,Defs) @ 1.10 log @fixed problem with fast_clause routines. @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.9 91/04/02 21:11:08 kemnitz Exp Locker: kemnitz $ a40 2 /* #undef NO_NODE_CHECKING */ d78 1 a78 1 extern TypeId _InvalidTypeId; d100 1 a107 2 #define ExactNodeType(_node_,_tag_) (NodeType(_node_) == classTag(_tag_)) a116 4 /* ---------------------------------------------------------------- * extern declarations follow * ---------------------------------------------------------------- */ a117 7 extern Node NewNode ARGS((Size size, TypeId type)); extern void SetNodeType ARGS((Node node, TypeId tag)); extern bool NodeIsType ARGS((Node node, TypeId tag)); */ /* d121 2 a122 1 extern bool NodeTagIsValid ARGS(( NodeTag tag )); d131 2 a132 3 extern NodeTag NodeGetTag ARGS(( Node node )); a134 8 * NewNode -- * Returns a new node of the given size and tag. */ extern Node NewNode ARGS((Size size,NodeTag tag )); /* d142 4 a145 6 extern void NodeSetTag ARGS(( Node node, NodeTag tag )); d154 15 d170 2 a171 2 bool NodeHasTag ARGS((Node node,NodeTag tag )); d173 1 a173 1 @ 1.9 log @Some new macros - now defines NO_NODE_CHECKING by default to turn off node checking in the node accessor functions. @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.8 91/02/05 15:45:18 sp Exp Locker: kemnitz $ d117 2 a118 2 #define fast_not_clause(_clause_) (CInteger(CAR(_clause_)) == NOT) #define fast_or_clause(_clause_) (CInteger(CAR(_clause_)) == OR) @ 1.8 log @The 'printFunc's (associated with every POSTGRES node) have been replaced by the 'outFunc's which instead of printing the ascii representation of an node to a file, they store it in a string. @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.7 90/08/17 08:52:37 cimarron Exp Locker: sp $ a39 1 #undef NO_NODE_CHECKING d41 9 d108 11 @ 1.7 log @added pathnames to #include statements @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.6 90/06/04 16:38:46 cimarron Version_2 Locker: cimarron $ d86 1 a86 1 void (*printFunc)(); \ @ 1.6 log @making AssertArg() checking in accessor functions conditional on #define in nodes.h @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.6 90/06/04 16:32:37 cimarron Exp $ d23 1 a23 1 #include "c.h" @ 1.5 log @added (*copyFunc)() to the definition of Node to support deep copying of nodes.. @ text @d6 1 a6 1 * $Header: RCS/nodes.h,v 1.4 89/09/05 17:08:53 mao C_Demo_1 $ d26 4 d31 16 a47 1 /* #define List LispValue */ a48 3 /* char *malloc(); #define palloc malloc*/ d75 2 a76 4 /* * ==== * NODE * ==== d78 3 a80 1 * Fake superclass for all tagged nodes. d92 2 a95 1 }; d97 8 a110 3 #define IsA(_node_,_tag_) NodeIsType((Node)(_node_), classTag(_tag_)) #define New_Node(_x_) ((_x_)NewNode(classSize(_x_),classTag(_x_))) #define CreateNode(_x_) ((_x_)NewNode(classSize(_x_),classTag(_x_))) @ 1.4 log @Working version of C-only demo @ text @d6 1 a6 1 * $Header: /usr6/postgres/mao/postgres/src/lib/H/RCS/nodes.h,v 1.3 89/08/01 16:17:35 goh Exp $ d71 2 a72 1 bool (*equalFunc)() d108 1 a108 1 * CreateNode -- d131 1 a131 1 * NodeIsType -- @ 1.3 log @retrieve (x=1) checkin @ text @d6 1 a6 1 * $Header: nodes.h,v 1.2 89/08/01 16:13:43 goh Locked $ @ 1.2 log @*** empty log message *** @ text @d6 1 a6 1 * $Header: nodes.h,v 1.1 89/07/20 09:28:03 goh Locked $ @ 1.1 log @Initial revision @ text @d6 1 a6 1 * $Header: /usr6/postgres/goh/newpost/src/planner/util/RCS/nodes.h,v 1.1 89/06/23 16:12:08 goh Exp $ a24 1 #include "pg_lisp.h" d26 1 d28 5 a32 3 #define List LispValue char *malloc(); #define palloc malloc d44 1 a44 1 #define classTag(_x_) ((TypeId) CppConcat(T_,_x_)) d55 1 d69 3 a71 1 TypeId type d75 1 a75 1 #define NodeType(_node_) (((Node)(_node_))->type) d79 1 a79 1 a82 4 /* extern Node NewNode(); extern void SetNodeType(); extern bool NodeIsType(); d88 53 @