Record Class GenerationPolicy
java.lang.Object
java.lang.Record
org.ek9lang.compiler.fuzz.GenerationPolicy
Named generation policy that biases construct selection and exploration depth.
Policies rotate periodically to systematically cover different grammar regions
and break ATN saturation from uniform random distribution.
Each policy defines 19 weights corresponding to the 19 construct cases
in AtnBasedGenerator.appendRandomConstruct():
0=class, 1=function, 2=record, 3=constant, 4=program, 5=trait,
6=component, 7=application, 8=text, 9=package, 10=enumeration,
11=constrained-type, 12=trait-impl, 13=generic-type, 14=class-hierarchy,
15=service, 16=dispatcher, 17=dynamic-function, 18=dynamic-class.
-
Constructor Summary
ConstructorsConstructorDescriptionGenerationPolicy(String name, int[] constructWeights, int maxNestingDepth) Creates an instance of aGenerationPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescription(package private) static GenerationPolicybalanced()Balanced: uniform weights (reproduces original behavior).int[]Returns the value of theconstructWeightsrecord component.(package private) static GenerationPolicyControl-flow-heavy: deeper nesting, more functions and programs.booleanIndicates whether some other object is "equal to" this one.(package private) static GenerationPolicyError-heavy: favors dispatcher, constrained-type, dynamic constructs for more errors.(package private) static GenerationPolicyforIteration(long iteration) Get the appropriate policy for a given iteration count.(package private) static GenerationPolicyGenerics-heavy: favors generic-type, function, constrained-type.inthashCode()Returns a hash code value for this object.(package private) static GenerationPolicyHierarchy-heavy: favors class, trait, class-hierarchy, trait-impl.intReturns the value of themaxNestingDepthrecord component.name()Returns the value of thenamerecord component.(package private) intselectConstruct(Random random) Select a construct case using weighted random distribution.(package private) static GenerationPolicyService-heavy: favors service, application, component.toString()Returns a string representation of this record class.
-
Constructor Details
-
GenerationPolicy
GenerationPolicy(String name, int[] constructWeights, int maxNestingDepth) Creates an instance of aGenerationPolicyrecord class.- Parameters:
name- the value for thenamerecord componentconstructWeights- the value for theconstructWeightsrecord componentmaxNestingDepth- the value for themaxNestingDepthrecord component
-
-
Method Details
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
hashCode
-
toString
-
balanced
Balanced: uniform weights (reproduces original behavior). -
hierarchyHeavy
Hierarchy-heavy: favors class, trait, class-hierarchy, trait-impl. -
genericsHeavy
Generics-heavy: favors generic-type, function, constrained-type. -
serviceHeavy
Service-heavy: favors service, application, component. -
controlFlowHeavy
Control-flow-heavy: deeper nesting, more functions and programs. -
errorHeavy
Error-heavy: favors dispatcher, constrained-type, dynamic constructs for more errors. -
selectConstruct
Select a construct case using weighted random distribution.- Returns:
- index 0-18 corresponding to a construct case
-
forIteration
Get the appropriate policy for a given iteration count. Rotates through all policies every ROTATION_INTERVAL iterations. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
constructWeights
public int[] constructWeights()Returns the value of theconstructWeightsrecord component.- Returns:
- the value of the
constructWeightsrecord component
-
maxNestingDepth
public int maxNestingDepth()Returns the value of themaxNestingDepthrecord component.- Returns:
- the value of the
maxNestingDepthrecord component
-