Changes On Branch mistake

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch mistake Excluding Merge-Ins

This is equivalent to a diff from f0a5b96c21 to 7b7db4603d

2013-11-28
03:52
Development checkpoint. Add many methods to the bdd system class. No tests yet. check-in: 14905fca9f user: kennykb tags: trunk
2013-10-10
00:28
try to constrain the old code brought over - bring only the minimum needed to link and test Closed-Leaf check-in: 7b7db4603d user: kennykb tags: mistake
2013-10-05
22:01
try to constrain the old code brought over - bring only the minimum needed to link and test check-in: f0a5b96c21 user: kennykb tags: trunk
21:43
Checkpoint: construction and destruction of a BDD system in TclOO. check-in: ec56155d6d user: kennykb tags: trunk

Changes to generic/tclBdd.c.

64
65
66
67
68
69
70
71
72
73
74
75
76





















77
78
79
80
81
82


83
84

85
86


87
88
89











90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109








110
111
112
113
114
115
116
} BddSystemData;
#define IncrBddSystemDataRefCount(x) \
    do {			  \
	++((x)->refCount);	  \
    } while(0)
#define DecrBddSystemDataRefCount(x)		\
    do {					\
	BddSystemData* sys = x;		\
	if ((--(sys->refCount)) <= 0) {	\
	    DeleteBddSystemData(sys);		\
	}					\
    } while(0)






















/*
 * Static functions defined within this file
 */

static void DeletePerInterpData(PerInterpData*);



static int BddSystemConstructor(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				int, Tcl_Obj* const[]);

static int CloneBddSystemObject(Tcl_Interp*, ClientData, ClientData*);
static int CloneMethod(Tcl_Interp*, ClientData, ClientData*);


static void DeleteBddSystemData(BddSystemData*);
static void DeleteBddSystemObject(ClientData);
static void DeleteMethod(ClientData);












/*
 * TclOO data types defined within this file
 */

const static Tcl_ObjectMetadataType BddSystemDataType = {
    TCL_OO_METADATA_VERSION_CURRENT, /* version */
    "BddSystemData",		     /* name */
    DeleteBddSystemObject,	     /* deleteProc */
    CloneBddSystemObject	     /* cloneProc */
};

/*
 * TclOO methods defined within this file
 */

const static Tcl_MethodType BddSystemConstructorType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "CONSTRUCTOR",		   /* name */
    BddSystemConstructor,	   /* callProc */








    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
};

/*
 *-----------------------------------------------------------------------------
 *







|
|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






>
>


>


>
>



>
>
>
>
>
>
>
>
>
>
>




















>
>
>
>
>
>
>
>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
} BddSystemData;
#define IncrBddSystemDataRefCount(x) \
    do {			  \
	++((x)->refCount);	  \
    } while(0)
#define DecrBddSystemDataRefCount(x)		\
    do {					\
	BddSystemData* sys = (x);		\
	if ((--(sys->refCount)) <= 0) {		\
	    DeleteBddSystemData(sys);		\
	}					\
    } while(0)

/*
 * Structure that represents a single bead (or a BDD) to TclOO
 */

typedef struct BddBeadData {
    unsigned int refCount;	/* Reference count */
    BddSystemData* sdata;	/* BDD system data */
    unsigned int bead;		/* Bead index */
} BddBeadData;
#define IncrBddBeadDataRefCount(x) \
    do {			   \
        ++((x)->refCount);         \
    } while(0)
#define DecrBddBeadDataRefCount(x) 		\
    do {					\
        BddBeadData* bdata = (x);		\
	if ((--(bdata->refCount)) <= 0) {	\
	    DeleteBddBeadData(bdata);		\
	}					\
    } while(0)

/*
 * Static functions defined within this file
 */

static void DeletePerInterpData(PerInterpData*);

static int BddBeadConstructor(ClientData, Tcl_Interp*, Tcl_ObjectContext,
			      int, Tcl_Obj* const[]);
static int BddSystemConstructor(ClientData, Tcl_Interp*, Tcl_ObjectContext,
				int, Tcl_Obj* const[]);
static int CloneBddBeadObject(Tcl_Interp*, ClientData, ClientData*);
static int CloneBddSystemObject(Tcl_Interp*, ClientData, ClientData*);
static int CloneMethod(Tcl_Interp*, ClientData, ClientData*);
static void DeleteBddBeadData(BddBeadData*);
static void DeleteBddBeadObject(ClientData);
static void DeleteBddSystemData(BddSystemData*);
static void DeleteBddSystemObject(ClientData);
static void DeleteMethod(ClientData);

/*
 * TclOO data types defined within this file
 */

const static Tcl_ObjectMetadataType BddBeadDataType = {
    TCL_OO_METADATA_VERSION_CURRENT, /* version */
    "BddBeadData",		     /* name */
    DeleteBddBeadObject,	     /* deleteProc */
    CloneBddBeadObject		     /* cloneProc */
};

/*
 * TclOO data types defined within this file
 */

const static Tcl_ObjectMetadataType BddSystemDataType = {
    TCL_OO_METADATA_VERSION_CURRENT, /* version */
    "BddSystemData",		     /* name */
    DeleteBddSystemObject,	     /* deleteProc */
    CloneBddSystemObject	     /* cloneProc */
};

/*
 * TclOO methods defined within this file
 */

const static Tcl_MethodType BddSystemConstructorType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "CONSTRUCTOR",		   /* name */
    BddSystemConstructor,	   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
};

const static Tcl_MethodType BddSystemBeadConstructorType = {
    TCL_OO_METHOD_VERSION_CURRENT, /* version */
    "CONSTRUCTOR",		   /* name */
    BddBeadConstructor,		   /* callProc */
    DeleteMethod,		   /* method delete proc */
    CloneMethod			   /* method clone proc */
};

/*
 *-----------------------------------------------------------------------------
 *
241
242
243
244
245
246
247


248
249
250
251
252
253
254
255
256
257
258




















































259
260
261
262
263
264
265
			 Tcl_NewStringObj("BDD initial size must be at least 4",
					  -1));
	Tcl_SetErrorCode(interp, "BDD", "InitialSize<4",
			 Tcl_GetString(objv[skip]), NULL);
	return TCL_ERROR;
    }



    /* Create the BDD system */

    sdata = (BddSystemData*) ckalloc(sizeof(BddSystemData));
    sdata->refCount = 1;
    sdata->pidata = pidata;
    IncrPerInterpRefCount(pidata);
    sdata->system = BDD_NewSystem(size);
    
    Tcl_ObjectSetMetadata(thisObject, &BddSystemDataType, (ClientData) sdata);
    return TCL_OK;
}





















































/*
 *-----------------------------------------------------------------------------
 *
 * CloneBddSystemObject --
 *
 *	Tries to clone a system of BDD's.







>
>











>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
			 Tcl_NewStringObj("BDD initial size must be at least 4",
					  -1));
	Tcl_SetErrorCode(interp, "BDD", "InitialSize<4",
			 Tcl_GetString(objv[skip]), NULL);
	return TCL_ERROR;
    }

    Tcl_ObjectContextInvokeNext(interp, objectContext, skip, objv, skip);

    /* Create the BDD system */

    sdata = (BddSystemData*) ckalloc(sizeof(BddSystemData));
    sdata->refCount = 1;
    sdata->pidata = pidata;
    IncrPerInterpRefCount(pidata);
    sdata->system = BDD_NewSystem(size);
    
    Tcl_ObjectSetMetadata(thisObject, &BddSystemDataType, (ClientData) sdata);
    return TCL_OK;
}

/*
 *-----------------------------------------------------------------------------
 *
 * BddBeadConstructor --
 *
 *	Constructs a bead in a Binary Decision Diagram.
 *
 * Parameters:
 *	None.
 *
 * Results:
 *	Returns a standard Tcl result.
 *
 *-----------------------------------------------------------------------------
 */

static int
BddBeadConstructor(
    ClientData clientData,	     /* Pointer to the per-interp data */
    Tcl_Interp* interp,		     /* Tcl interpreter */
    Tcl_ObjectContext objectContext, /* Object context */
    int objc,			     /* Parameter count */
    Tcl_Obj *const objv[]	     /* Parameter vector */
) {
    BddSystemData* sdata = (BddSystemData*) clientData;
				/* Per-interp data for the BDD package */
    Tcl_Object thisObject = Tcl_ObjectContextObject(objectContext);
				/* Current object */
    int skip = Tcl_ObjectContextSkippedArgs(objectContext);
				/* Number of leading args to skip */
    BddBeadData* bdata;
    
    /* Check arguments */

    if (objc != skip) {
	Tcl_WrongNumArgs(interp, skip, objv, "");
	return TCL_ERROR;
    }
    Tcl_ObjectContextInvokeNext(interp, objectContext, skip, objv, skip);

    /* Create the BDD system */

    bdata = (BddBeadData*) ckalloc(sizeof(BddBeadData));
    bdata->refCount = 1;
    bdata->sdata = sdata;
    bdata->bead = 0;
    IncrBddSystemDataRefCount(sdata);
    
    Tcl_ObjectSetMetadata(thisObject, &BddBeadDataType, (ClientData) bdata);
    return TCL_OK;
}

/*
 *-----------------------------------------------------------------------------
 *
 * CloneBddSystemObject --
 *
 *	Tries to clone a system of BDD's.
332
333
334
335
336
337
338

















339
340
341
342
343
344
345
DeleteBddSystemData(BddSystemData* sdata)
{
    BDD_DeleteSystem(sdata->system);
    sdata->system = NULL;
    DecrPerInterpRefCount(sdata->pidata);
    ckfree(sdata);
}


















/*
 *-----------------------------------------------------------------------------
 *
 * DeleteBddSystemObject --
 *
 *	Cleans up when a system of BDD's is deleted.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
DeleteBddSystemData(BddSystemData* sdata)
{
    BDD_DeleteSystem(sdata->system);
    sdata->system = NULL;
    DecrPerInterpRefCount(sdata->pidata);
    ckfree(sdata);
}

/*
 *-----------------------------------------------------------------------------
 *
 * DeleteBddBeadObject --
 *
 *	Cleans up when a bead in a BDD is deleted.
 *
 *-----------------------------------------------------------------------------
 */

void
DeleteBddBeadObject(
    ClientData clientData
) {
    DecrBddBeadDataRefCount((BddBeadData*) clientData);
}

/*
 *-----------------------------------------------------------------------------
 *
 * DeleteBddSystemObject --
 *
 *	Cleans up when a system of BDD's is deleted.

Changes to library/tclbdd.tcl.

9
10
11
12
13
14
15
















16

17









#
#------------------------------------------------------------------------------

namespace eval bdd {
    namespace export system
}

















oo::class create bdd::system {

}
















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>

>
>
>
>
>
>
>
>
>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
#------------------------------------------------------------------------------

namespace eval bdd {
    namespace export system
}

oo::class create bdd::System {
    variable beadseq
    constructor args {
	namespace eval Bead {}
	set beadseq 0
	bdd::bead create Bead::false [self]
	bdd::bead create Bead::true [self]
	Bead::true = 1
    }
    method false {} {
	return [namespace which Bead::false]
    }
    method true {} {
	return [namespace which Bead::true]
    }
}
oo::class create bdd::system {
    superclass bdd::System
}

oo::class create bdd::Bead {
    constructor args {
    }
}

oo::class create bdd::bead {
    superclass bdd::Bead
}