Diff
Not logged in

Differences From Artifact [b1c9432958]:

To Artifact [602a3fdc2f]:


1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20












-
+







/*
 * tclCompExpr.c --
 *
 *	This file contains the code to compile Tcl expressions.
 *
 * Copyright (c) 1997 Sun Microsystems, Inc.
 * Copyright (c) 1998-2000 by Scriptics Corporation.
 * Contributions from Don Porter, NIST, 2006.  (not subject to US copyright)
 *
 * 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.41 2006/12/08 18:08:33 dgp Exp $
 * RCS: @(#) $Id: tclCompExpr.c,v 1.42 2006/12/08 20:48:09 dgp Exp $
 */

#include "tclInt.h"
#include "tclCompile.h"

#define USE_EXPR_TOKENS 
#define PARSE_DIRECT_EXPR_TOKENS
2580
2581
2582
2583
2584
2585
2586
2587
2588


2589
2590
2591
2592


2593
2594
2595
2596
2597
2598


2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616

2617
2618
2619
2620
2621
2622
2623
2624
2625
2626





























2627
2628
2629
2630
2631
2632
2633
2580
2581
2582
2583
2584
2585
2586


2587
2588

2589


2590
2591
2592
2593
2594



2595
2596





2597
2598
2599
2600
2601








2602
2603

2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647







-
-
+
+
-

-
-
+
+



-
-
-
+
+
-
-
-
-
-





-
-
-
-
-
-
-
-
+

-








+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







		nodePtr = nodes + nodePtr->parent;
	    }
	    break;
	}
    }
}

int
TclInvertOpCmd(
static int
OpCmd(
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
    OpNode *nodes,
    Tcl_Obj * const litObjv[])
{
    CompileEnv compEnv;
    ByteCode *byteCodePtr;
    OpNode nodes[2];
    int code, tmp = 1;
    Tcl_Obj *byteCodeObj;
    int code, tmp=1;
    Tcl_Obj *byteCodeObj = Tcl_NewObj();

    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "number");
	return TCL_ERROR;
    }

    /* Note we are compiling an expression with literal arguments.
     * This means there can be no [info frame] calls when we execute
     * the resulting bytecode, so there's no need to tend to TIP 280 issues */
    TclInitCompileEnv(interp, &compEnv, NULL, 0, NULL, 0);

    nodes[0].lexeme = START;
    nodes[0].right = 1;
    nodes[1].lexeme = BIT_NOT;
    nodes[1].right = OT_LITERAL;
    nodes[1].parent = 0;

    CompileExprTree(interp, nodes, objv+1, NULL, NULL, &tmp, &compEnv);
    CompileExprTree(interp, nodes, litObjv, NULL, NULL, &tmp, &compEnv);
    TclEmitOpcode(INST_DONE, &compEnv);
    byteCodeObj = Tcl_NewObj();
    Tcl_IncrRefCount(byteCodeObj);
    TclInitByteCodeObj(byteCodeObj, &compEnv);
    TclFreeCompileEnv(&compEnv);
    byteCodePtr = (ByteCode *) byteCodeObj->internalRep.otherValuePtr;
    code = TclExecuteByteCode(interp, byteCodePtr);
    Tcl_DecrRefCount(byteCodeObj);
    return code;
}

int
TclSingleOpCmd(
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
{
    TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData;
    unsigned char lexeme;
    OpNode nodes[2];

    if (objc != 1+occdPtr->numArgs) {
	Tcl_WrongNumArgs(interp, 1, objv, occdPtr->expected);
	return TCL_ERROR;
    }

    ParseLexeme(occdPtr->operator, strlen(occdPtr->operator), &lexeme, NULL);
    nodes[0].lexeme = START;
    nodes[0].right = 1;
    nodes[1].lexeme = lexeme;
    nodes[1].left = OT_LITERAL;
    nodes[1].right = OT_LITERAL;
    nodes[1].parent = 0;

    return OpCmd(interp, nodes, objv+1);
}



/*
 *----------------------------------------------------------------------
 *
 * TclFinalizeCompilation --
 *
 *	Clean up the compilation environment so it can later be properly