00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <Basics.H>
00026
00027
00028 #include <FP.H>
00029
00030
00031 #include "BitVector.H"
00032 #include "FV.H"
00033 #include "Model.H"
00034 #include "CacheIndex.H"
00035 #include "Derived.H"
00036 #include "VestaVal.H"
00037 #include "Debug.H"
00038 #include "NewVal.H"
00039
00040 void NewVal::NewNames( FV::List& names, unsigned int num) throw ()
00041 {
00042 if (num < 1) num = Debug::MyRand(1, 5);
00043 names.len = num;
00044 names.name = NEW_ARRAY(FV::T, num);
00045 for (int i = 0; i < num; i++) {
00046 names.name[i] = FV::T("name-");
00047 char buff[20];
00048 int printLen = sprintf(buff, "%d", i);
00049 assert(printLen < 20);
00050 names.name[i] += FV::T(buff);
00051 }
00052 }
00053
00054 void NewVal::NewFP( FP::Tag& fp, int vals) throw ()
00055
00056 {
00057 int pk = Debug::MyRand(0, vals-1);
00058 fp = FP::Tag((char *)(&pk), sizeof(pk));
00059 }
00060
00061 void NewVal::NewFPs( FP::List& fps, unsigned int num, int vals) throw ()
00062 {
00063 if (num < 1) num = Debug::MyRand(1, 5);
00064 fps.len = num;
00065 fps.fp = NEW_PTRFREE_ARRAY(FP::Tag, num);
00066 for (int i = 0; i < num; i++) {
00067 NewVal::NewFP(fps.fp[i], vals);
00068 }
00069 }
00070
00071 void NewVal::NewModel( Model::T &model) throw ()
00072 {
00073 model = (Model::T)Debug::MyRand(0, 99999);
00074 }
00075
00076 void NewVal::NewCI( CacheEntry::Index &index) throw ()
00077 {
00078 index = (CacheEntry::Index)Debug::MyRand(0, 9999);
00079 }
00080
00081 void NewVal::NewCIs( CacheEntry::Indices &kids, unsigned int num)
00082 throw ()
00083 {
00084 if (num < 1) num = Debug::MyRand(1, 6);
00085 kids.len = num;
00086 kids.index = NEW_PTRFREE_ARRAY(CacheEntry::Index, num);
00087 for (int i = 0; i < num; i++) {
00088 NewVal::NewCI(kids.index[i]);
00089 }
00090 }
00091
00092 void NewVal::NewDI( Derived::Index &index) throw ()
00093 {
00094 index = (Derived::Index)Debug::MyRand(0, 9999);
00095 }
00096
00097 void NewVal::NewDIs( Derived::Indices &kids, unsigned int num) throw ()
00098 {
00099 if (num < 1) num = Debug::MyRand(1, 6);
00100 kids.len = num;
00101 kids.index = NEW_PTRFREE_ARRAY(Derived::Index, num);
00102 for (int i = 0; i < num; i++) {
00103 NewVal::NewDI(kids.index[i]);
00104 }
00105 }
00106
00107 void NewVal::NewValue( VestaVal::T &value) throw ()
00108 {
00109 NewVal::NewFP(value.fp);
00110 NewVal::NewDIs(value.dis);
00111 value.len = (int)Debug::MyRand(1, 20);
00112 value.bytes = NEW_PTRFREE_ARRAY(char, value.len);
00113 for (int i = 0; i < value.len; i++) {
00114 value.bytes[i] = (char)Debug::MyRand(0, 255);
00115 }
00116 }
00117
00118 void NewVal::NewBV( BitVector &bv) throw ()
00119 {
00120 int num = Debug::MyRand(0, 5), curr = -1;
00121 while (num-- > 0) {
00122 int skip = Debug::MyRand(1, 10);
00123 curr += skip;
00124 bv.Set(curr);
00125 }
00126 }
00127
00128 void NewVal::NewBool( bool &b) throw ()
00129 {
00130 b = (Debug::MyRand(0, 1) == 0) ? false : true;
00131 }