@@ -14,12 +14,18 @@ import 'dartfuzz_ffiapi.dart';
14
14
// Version of DartFuzz. Increase this each time changes are made
15
15
// to preserve the property that a given version of DartFuzz yields
16
16
// the same fuzzed program for a deterministic random seed.
17
- const String version = '1.46 ' ;
17
+ const String version = '1.47 ' ;
18
18
19
19
// Restriction on statements and expressions.
20
- const int stmtLength = 2 ;
21
20
const int stmtDepth = 1 ;
22
21
const int exprDepth = 2 ;
22
+ const int numStatements = 2 ;
23
+ const int numGlobalVars = 4 ;
24
+ const int numLocalVars = 4 ;
25
+ const int numGlobalMethods = 4 ;
26
+ const int numClassMethods = 3 ;
27
+ const int numMethodParams = 4 ;
28
+ const int numClasses = 4 ;
23
29
24
30
// Naming conventions.
25
31
const varName = 'var' ;
@@ -123,17 +129,22 @@ class DartFuzz {
123
129
// Setup the types.
124
130
localVars = < DartType > [];
125
131
iterVars = < String > [];
126
- globalVars = fillTypes1 ();
132
+
133
+ globalVars = fillTypes1 (limit: numGlobalVars);
127
134
globalVars.addAll (DartType .allTypes); // always one each
128
- globalMethods = fillTypes2 ();
129
- classFields = fillTypes2 (limit: 4 );
130
- classMethods = fillTypes3 (classFields.length);
135
+ globalMethods =
136
+ fillTypes2 (limit2: numGlobalMethods, limit1: numMethodParams);
137
+ classFields = fillTypes2 (limit2: numClasses, limit1: numLocalVars);
138
+ classMethods = fillTypes3 (classFields.length,
139
+ limit2: numClassMethods, limit1: numMethodParams);
140
+
131
141
virtualClassMethods = < Map <int , List <int >>> [];
132
142
classParents = < int > [];
133
143
// Setup optional ffi methods and types.
134
144
final ffiStatus = < bool > [for (final _ in globalMethods) false ];
135
145
if (ffi) {
136
- List <List <DartType >> globalMethodsFfi = fillTypes2 (isFfi: true );
146
+ List <List <DartType >> globalMethodsFfi = fillTypes2 (
147
+ limit2: numGlobalMethods, limit1: numMethodParams, isFfi: true );
137
148
for (var m in globalMethodsFfi) {
138
149
globalMethods.add (m);
139
150
ffiStatus.add (true );
@@ -769,7 +780,7 @@ class DartFuzz {
769
780
770
781
// Emit statements. Returns true if code may fall-through.
771
782
bool emitStatements (int depth) {
772
- int s = 1 + rand.nextInt (stmtLength );
783
+ int s = 1 + rand.nextInt (numStatements );
773
784
for (int i = 0 ; i < s; i++ ) {
774
785
if (! emitStatement (depth)) {
775
786
return false ; // rest would be dead code
@@ -1427,9 +1438,9 @@ class DartFuzz {
1427
1438
}
1428
1439
}
1429
1440
1430
- List <DartType > fillTypes1 ({bool isFfi = false }) {
1441
+ List <DartType > fillTypes1 ({int limit = 4 , bool isFfi = false }) {
1431
1442
final list = < DartType > [];
1432
- for (int i = 0 , n = 1 + rand.nextInt (4 ); i < n; i++ ) {
1443
+ for (int i = 0 , n = 1 + rand.nextInt (limit ); i < n; i++ ) {
1433
1444
if (isFfi) {
1434
1445
list.add (fp ? oneOf ([DartType .INT , DartType .DOUBLE ]) : DartType .INT );
1435
1446
} else {
@@ -1439,18 +1450,20 @@ class DartFuzz {
1439
1450
return list;
1440
1451
}
1441
1452
1442
- List <List <DartType >> fillTypes2 ({bool isFfi = false , int limit = 4 }) {
1453
+ List <List <DartType >> fillTypes2 (
1454
+ {bool isFfi = false , int limit2 = 4 , int limit1 = 4 }) {
1443
1455
final list = < List <DartType >> [];
1444
- for (int i = 0 , n = 1 + rand.nextInt (limit ); i < n; i++ ) {
1445
- list.add (fillTypes1 (isFfi: isFfi));
1456
+ for (int i = 0 , n = 1 + rand.nextInt (limit2 ); i < n; i++ ) {
1457
+ list.add (fillTypes1 (limit : limit1, isFfi: isFfi));
1446
1458
}
1447
1459
return list;
1448
1460
}
1449
1461
1450
- List <List <List <DartType >>> fillTypes3 (int n) {
1462
+ List <List <List <DartType >>> fillTypes3 (int n,
1463
+ {int limit2 = 4 , int limit1 = 4 }) {
1451
1464
final list = < List <List <DartType >>> [];
1452
1465
for (int i = 0 ; i < n; i++ ) {
1453
- list.add (fillTypes2 ());
1466
+ list.add (fillTypes2 (limit2 : limit2, limit1 : limit1 ));
1454
1467
}
1455
1468
return list;
1456
1469
}
0 commit comments