@@ -268,7 +268,7 @@ public let CodeGenerators: [CodeGenerator] = [
268268 }
269269
270270 let o = b. buildObjectLiteral { obj in
271- b. build ( n: Int . random ( in: 0 ... 10 ) )
271+ b. buildRecursive ( n: Int . random ( in: 0 ... 10 ) )
272272 }
273273
274274 objType = b. type ( of: o)
@@ -344,7 +344,7 @@ public let CodeGenerators: [CodeGenerator] = [
344344
345345 // Create the class.
346346 let c = b. buildClassDefinition ( withSuperclass: superclass, isExpression: probability ( 0.3 ) ) { cls in
347- b. build ( n: defaultCodeGenerationAmount)
347+ b. buildRecursive ( n: defaultCodeGenerationAmount)
348348 }
349349
350350 // And construct a few instances of it.
@@ -426,12 +426,11 @@ public let CodeGenerators: [CodeGenerator] = [
426426 " DisposableVariableGenerator " , inContext: . single( . subroutine) , inputs: . one
427427 ) { b, val in
428428 assert ( b. context. contains ( . subroutine) )
429- let dispose = b. getProperty (
430- " dispose " , of: b. createNamedVariable ( forBuiltin: " Symbol " ) )
429+ let dispose = b. createSymbolProperty ( " dispose " )
431430 let disposableVariable = b. buildObjectLiteral { obj in
432431 obj. addProperty ( " value " , as: val)
433432 obj. addComputedMethod ( dispose, with: . parameters( n: 0 ) ) { args in
434- b. doReturn ( b . randomJsVariable ( ) )
433+ b. maybeReturnRandomJsVariable ( 0.9 )
435434 }
436435 }
437436 b. loadDisposableVariable ( disposableVariable)
@@ -442,13 +441,12 @@ public let CodeGenerators: [CodeGenerator] = [
442441 inputs: . one
443442 ) { b, val in
444443 assert ( b. context. contains ( . asyncFunction) )
445- let asyncDispose = b. getProperty (
446- " asyncDispose " , of: b. createNamedVariable ( forBuiltin: " Symbol " ) )
444+ let asyncDispose = b. createSymbolProperty ( " asyncDispose " )
447445 let asyncDisposableVariable = b. buildObjectLiteral { obj in
448446 obj. addProperty ( " value " , as: val)
449447 obj. addComputedMethod ( asyncDispose, with: . parameters( n: 0 ) ) {
450448 args in
451- b. doReturn ( b . randomJsVariable ( ) )
449+ b. maybeReturnRandomJsVariable ( 0.9 )
452450 }
453451 }
454452 b. loadAsyncDisposableVariable ( asyncDisposableVariable)
@@ -861,7 +859,7 @@ public let CodeGenerators: [CodeGenerator] = [
861859 " ClassInstanceMethodEndGenerator " ,
862860 inContext: . single( [ . javascript, . subroutine, . method, . classMethod] )
863861 ) { b in
864- b. doReturn ( b . randomJsVariable ( ) )
862+ b. maybeReturnRandomJsVariable ( 0.9 )
865863 b. emit ( EndClassInstanceMethod ( ) )
866864 } ,
867865 ] ) ,
@@ -899,7 +897,7 @@ public let CodeGenerators: [CodeGenerator] = [
899897 " ClassInstanceComputedMethodEndGenerator " ,
900898 inContext: . single( [ . javascript, . subroutine, . method, . classMethod] )
901899 ) { b in
902- b. doReturn ( b . randomJsVariable ( ) )
900+ b. maybeReturnRandomJsVariable ( 0.9 )
903901 b. emit ( EndClassInstanceComputedMethod ( ) )
904902 } ,
905903 ] ) ,
@@ -1107,7 +1105,7 @@ public let CodeGenerators: [CodeGenerator] = [
11071105 " ClassStaticMethodEndGenerator " ,
11081106 inContext: . single( [ . javascript, . classMethod, . subroutine, . method] )
11091107 ) { b in
1110- b. doReturn ( b . randomJsVariable ( ) )
1108+ b. maybeReturnRandomJsVariable ( 0.9 )
11111109 b. emit ( EndClassStaticMethod ( ) )
11121110 } ,
11131111 ] ) ,
@@ -1145,7 +1143,7 @@ public let CodeGenerators: [CodeGenerator] = [
11451143 " ClassStaticComputedMethodEndGenerator " ,
11461144 inContext: . single( [ . javascript, . subroutine, . method, . classMethod] )
11471145 ) { b in
1148- b. doReturn ( b . randomJsVariable ( ) )
1146+ b. maybeReturnRandomJsVariable ( 0.9 )
11491147 b. emit ( EndClassStaticComputedMethod ( ) )
11501148 } ,
11511149 ] ) ,
@@ -1283,7 +1281,7 @@ public let CodeGenerators: [CodeGenerator] = [
12831281 " ClassPrivateInstanceMethodEndGenerator " ,
12841282 inContext: . single( [ . javascript, . subroutine, . method, . classMethod] )
12851283 ) { b in
1286- b. doReturn ( b . randomJsVariable ( ) )
1284+ b. maybeReturnRandomJsVariable ( 0.9 )
12871285 b. emit ( EndClassPrivateInstanceMethod ( ) )
12881286 } ,
12891287 ] ) ,
@@ -1345,7 +1343,7 @@ public let CodeGenerators: [CodeGenerator] = [
13451343 " ClassPrivateStaticMethodEndGenerator " ,
13461344 inContext: . single( [ . javascript, . subroutine, . method, . classMethod] )
13471345 ) { b in
1348- b. doReturn ( b . randomJsVariable ( ) )
1346+ b. maybeReturnRandomJsVariable ( 0.9 )
13491347 b. emit ( EndClassPrivateStaticMethod ( ) )
13501348 } ,
13511349
@@ -2414,7 +2412,7 @@ public let CodeGenerators: [CodeGenerator] = [
24142412 let loopVar = b. loadInt ( 0 )
24152413 b. buildDoWhileLoop (
24162414 do: {
2417- b. build ( n: defaultCodeGenerationAmount)
2415+ b. buildRecursive ( n: defaultCodeGenerationAmount)
24182416 b. unary ( . PostInc, loopVar)
24192417 } ,
24202418 while: {
@@ -2462,7 +2460,7 @@ public let CodeGenerators: [CodeGenerator] = [
24622460 // Generate a for-loop without any loop variables.
24632461 let counter = b. loadInt ( 10 )
24642462 b. buildForLoop ( { } , { b. unary ( . PostDec, counter) } ) {
2465- b. build ( n: 4 )
2463+ b. buildRecursive ( n: 4 )
24662464 }
24672465 } else {
24682466 // Generate a for-loop with two loop variables.
@@ -2475,7 +2473,7 @@ public let CodeGenerators: [CodeGenerator] = [
24752473 b. unary ( . PostDec, vs [ 1 ] )
24762474 }
24772475 ) { _ in
2478- b. build ( n: 4 )
2476+ b. buildRecursive ( n: 4 )
24792477 }
24802478 }
24812479 } ,
@@ -2672,22 +2670,17 @@ public let CodeGenerators: [CodeGenerator] = [
26722670 CodeGenerator (
26732671 " WellKnownPropertyLoadGenerator " , inputs: . preferred( . object( ) )
26742672 ) { b, obj in
2675- let Symbol = b. createNamedVariable ( forBuiltin: " Symbol " )
2676- // The Symbol constructor is just a "side effect" of this generator and probably shouldn't be used by following generators.
2677- b. hide ( Symbol)
2678- let name = chooseUniform ( from: JavaScriptEnvironment . wellKnownSymbols)
2679- let propertyName = b. getProperty ( name, of: Symbol)
2673+ let propertyName = b. createSymbolProperty (
2674+ chooseUniform ( from: JavaScriptEnvironment . wellKnownSymbols) )
26802675 let needGuard = b. type ( of: obj) . MayBe ( . nullish)
26812676 b. getComputedProperty ( propertyName, of: obj, guard: needGuard)
26822677 } ,
26832678
26842679 CodeGenerator (
26852680 " WellKnownPropertyStoreGenerator " , inputs: . preferred( . object( ) )
26862681 ) { b, obj in
2687- let Symbol = b. createNamedVariable ( forBuiltin: " Symbol " )
2688- b. hide ( Symbol)
2689- let name = chooseUniform ( from: JavaScriptEnvironment . wellKnownSymbols)
2690- let propertyName = b. getProperty ( name, of: Symbol)
2682+ let propertyName = b. createSymbolProperty (
2683+ chooseUniform ( from: JavaScriptEnvironment . wellKnownSymbols) )
26912684 let val = b. randomJsVariable ( )
26922685 b. setComputedProperty ( propertyName, of: obj, to: val)
26932686 } ,
@@ -2932,18 +2925,16 @@ public let CodeGenerators: [CodeGenerator] = [
29322925 if probability ( 0.5 ) {
29332926 imitation = b. buildObjectLiteral { obj in
29342927 obj. addMethod ( " valueOf " , with: . parameters( n: 0 ) ) { _ in
2935- b. build ( n: 3 )
2928+ b. buildRecursive ( n: 3 )
29362929 b. doReturn ( orig)
29372930 }
29382931 }
29392932 } else {
2940- let toPrimitive = b. getProperty (
2941- " toPrimitive " ,
2942- of: b. createNamedVariable ( forBuiltin: " Symbol " ) )
2933+ let toPrimitive = b. createSymbolProperty ( " toPrimitive " )
29432934 imitation = b. buildObjectLiteral { obj in
29442935 obj. addComputedMethod ( toPrimitive, with: . parameters( n: 0 ) )
29452936 { _ in
2946- b. build ( n: 3 )
2937+ b. buildRecursive ( n: 3 )
29472938 b. doReturn ( orig)
29482939 }
29492940 }
@@ -2961,14 +2952,14 @@ public let CodeGenerators: [CodeGenerator] = [
29612952 let constructor = b. getProperty ( " constructor " , of: orig)
29622953 let cls = b. buildClassDefinition ( withSuperclass: constructor, isExpression: probability ( 0.3 ) ) {
29632954 _ in
2964- b. build ( n: 3 )
2955+ b. buildRecursive ( n: 3 )
29652956 }
29662957 imitation = b. construct (
29672958 cls, withArgs: b. randomArguments ( forCalling: cls) )
29682959 } else {
29692960 imitation = b. buildObjectLiteral { obj in
29702961 obj. setPrototype ( to: orig)
2971- b. build ( n: 3 )
2962+ b. buildRecursive ( n: 3 )
29722963 }
29732964 }
29742965 } else {
@@ -3081,9 +3072,7 @@ public let CodeGenerators: [CodeGenerator] = [
30813072 } ,
30823073
30833074 CodeGenerator ( " IteratorGenerator " , produces: [ . iterable] ) { b in
3084- let Symbol = b. createNamedVariable ( forBuiltin: " Symbol " )
3085- b. hide ( Symbol)
3086- let iteratorSymbol = b. getProperty ( " iterator " , of: Symbol)
3075+ let iteratorSymbol = b. createSymbolProperty ( " iterator " )
30873076 b. hide ( iteratorSymbol)
30883077 let iterableObject = b. buildObjectLiteral { obj in
30893078 obj. addComputedMethod ( iteratorSymbol, with: . parameters( n: 0 ) ) {
0 commit comments