summaryrefslogtreecommitdiffstats
path: root/generic/tclCompExpr.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-12-11 18:54:10 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-12-11 18:54:10 (GMT)
commitd9089b0f76f5224ffc6d7f52e0cd6d8306820853 (patch)
tree62f996db7293dd70be80d53ca9a9a586181631a0 /generic/tclCompExpr.c
parent4a3621293e6822c41b4e6455bb06429a032c6eae (diff)
downloadtcl-d9089b0f76f5224ffc6d7f52e0cd6d8306820853.zip
tcl-d9089b0f76f5224ffc6d7f52e0cd6d8306820853.tar.gz
tcl-d9089b0f76f5224ffc6d7f52e0cd6d8306820853.tar.bz2
* generic/tclBasic.c: Another step with all sorting operator commands
* generic/tclCompExpr.c: now routing through TEBC via * generic/tclCompile.h: TclSortingOpCmd().
Diffstat (limited to 'generic/tclCompExpr.c')
-rw-r--r--generic/tclCompExpr.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 195f67e..e893390 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.42 2006/12/08 20:48:09 dgp Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.43 2006/12/11 18:54:11 dgp Exp $
*/
#include "tclInt.h"
@@ -2637,6 +2637,61 @@ TclSingleOpCmd(
return OpCmd(interp, nodes, objv+1);
}
+int
+TclSortingOpCmd(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ int code = TCL_OK;
+
+ if (objc < 3) {
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1));
+ } else {
+ TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
+ Tcl_Obj **litObjv = (Tcl_Obj **) ckalloc(2*(objc-2)*sizeof(Tcl_Obj *));
+ OpNode *nodes = (OpNode *) ckalloc(2*(objc-2)*sizeof(OpNode));
+ unsigned char lexeme;
+ int i, lastBitAnd = 1;
+
+ ParseLexeme(occdPtr->operator, strlen(occdPtr->operator),
+ &lexeme, NULL);
+
+ litObjv[0] = objv[1];
+ nodes[0].lexeme = START;
+ for (i=2; i<objc-1; i++) {
+ litObjv[2*(i-1)-1] = objv[i];
+ nodes[2*(i-1)-1].lexeme = lexeme;
+ nodes[2*(i-1)-1].left = OT_LITERAL;
+ nodes[2*(i-1)-1].right = OT_LITERAL;
+
+ litObjv[2*(i-1)] = objv[i];
+ nodes[2*(i-1)].lexeme = BIT_AND;
+ nodes[2*(i-1)].left = lastBitAnd;
+ nodes[lastBitAnd].parent = 2*(i-1);
+
+ nodes[2*(i-1)].right = 2*(i-1)+1;
+ nodes[2*(i-1)+1].parent= 2*(i-1);
+
+ lastBitAnd = 2*(i-1);
+ }
+ litObjv[2*(objc-2)-1] = objv[objc-1];
+
+ nodes[2*(objc-2)-1].lexeme = lexeme;
+ nodes[2*(objc-2)-1].left = OT_LITERAL;
+ nodes[2*(objc-2)-1].right = OT_LITERAL;
+
+ nodes[0].right = lastBitAnd;
+ nodes[lastBitAnd].parent = 0;
+
+ code = OpCmd(interp, nodes, litObjv);
+
+ ckfree((char *) nodes);
+ ckfree((char *) litObjv);
+ }
+ return code;
+}
/*