Class GenerationContext

java.lang.Object
org.ek9lang.compiler.fuzz.GenerationContext

final class GenerationContext extends Object
Shared mutable state for all AtnBasedGenerator helpers. Follows the pattern of SymbolsAndScopes in compiler phases: a single context object passed to all focused helper classes via constructor injection.

Holds per-instance state (harvested names, pools) and per-generation state (planned mutations, param counts) that is reset on each generate() call.

  • Field Details

    • REQUIRE_DENOMINATOR

      static final int REQUIRE_DENOMINATOR
      See Also:
    • HARVEST_TYPE_PERCENT

      static final int HARVEST_TYPE_PERCENT
      See Also:
    • HARVEST_METHOD_PERCENT

      static final int HARVEST_METHOD_PERCENT
      See Also:
    • HARVEST_FIELD_PERCENT

      static final int HARVEST_FIELD_PERCENT
      See Also:
    • RESERVED

      static final Set<String> RESERVED
    • IDENTIFIER_POOL

      static final String[] IDENTIFIER_POOL
    • BAD_IDENTIFIER_POOL

      static final String[] BAD_IDENTIFIER_POOL
    • METHOD_NAME_POOL

      static final String[] METHOD_NAME_POOL
    • BUILT_IN_TYPES

      static final String[] BUILT_IN_TYPES
    • DEFAULTABLE_OPERATORS

      static final String[] DEFAULTABLE_OPERATORS
    • OP_PURE_0_BOOLEAN

      static final String[] OP_PURE_0_BOOLEAN
    • OP_PURE_0_INTEGER

      static final String[] OP_PURE_0_INTEGER
    • OP_PURE_0_SELF

      static final String[] OP_PURE_0_SELF
    • OP_PURE_0_ANY

      static final String[] OP_PURE_0_ANY
    • OP_PURE_1_BOOLEAN

      static final String[] OP_PURE_1_BOOLEAN
    • OP_PURE_1_INTEGER

      static final String[] OP_PURE_1_INTEGER
    • OP_PURE_1_ANY

      static final String[] OP_PURE_1_ANY
    • OP_MUTATING_1

      static final String[] OP_MUTATING_1
    • OP_MUTATING_0

      static final String[] OP_MUTATING_0
    • OP_INVALID

      static final String[] OP_INVALID
    • ALL_OPERATOR_SYMBOLS

      static final String[] ALL_OPERATOR_SYMBOLS
    • OPERATOR_RETURN_TYPES

      static final String[] OPERATOR_RETURN_TYPES
    • HTTP_VERBS

      static final String[] HTTP_VERBS
    • VALID_SERVICE_OPERATORS

      static final String[] VALID_SERVICE_OPERATORS
    • INVALID_SERVICE_OPERATORS

      static final String[] INVALID_SERVICE_OPERATORS
    • HTTP_ACCESS_TYPES

      static final String[] HTTP_ACCESS_TYPES
    • SERVICE_PARAM_TYPES

      static final String[] SERVICE_PARAM_TYPES
    • SERVICE_RETURN_TYPES

      static final String[] SERVICE_RETURN_TYPES
    • STREAM_OPS_WITH_FN

      static final String[] STREAM_OPS_WITH_FN
    • STREAM_OPS_NUMERIC

      static final String[] STREAM_OPS_NUMERIC
    • STREAM_CONNECTORS

      static final String[] STREAM_CONNECTORS
    • STREAM_COLLECT_TYPES

      static final String[] STREAM_COLLECT_TYPES
    • FAKE_TYPES

      static final String[] FAKE_TYPES
    • KEYWORD_MODULE_SEGMENTS

      static final String[] KEYWORD_MODULE_SEGMENTS
    • SIMPLE_STRINGS

      static final String[] SIMPLE_STRINGS
    • PARAM_NAMES

      static final String[] PARAM_NAMES
    • STRING_METHODS_NO_ARG

      static final String[] STRING_METHODS_NO_ARG
    • STRING_METHODS_ONE_ARG

      static final String[] STRING_METHODS_ONE_ARG
    • PREFIX_OPERATORS_SYMBOLIC

      static final String[] PREFIX_OPERATORS_SYMBOLIC
  • Constructor Details

    • GenerationContext

      GenerationContext(int maxDepth, List<String> harvestedTypeNames, List<String> harvestedMethodNames, List<String> harvestedFieldNames)
  • Method Details

    • maxDepth

      int maxDepth()
    • programCounter

      AtomicInteger programCounter()
    • currentParamCounts

      List<Integer> currentParamCounts()
    • harvestedTypeNames

      List<String> harvestedTypeNames()
    • harvestedMethodNames

      List<String> harvestedMethodNames()
    • harvestedFieldNames

      List<String> harvestedFieldNames()
    • policy

    • setPolicy

      void setPolicy(GenerationPolicy policy)
    • resetForGeneration

      void resetForGeneration()
      Reset per-generation state. Called at the start of each generate() invocation.
    • addPlannedMutation

      void addPlannedMutation(GenerationContext.MutationKind kind)
    • shouldInject

      boolean shouldInject(GenerationContext.MutationKind kind)
      Check whether a pre-planned mutation should be injected at this site. Returns true exactly once per file per kind — only if the mutation was pre-planned.
    • randomIdentifier

      String randomIdentifier(Random random)
    • uniqueMethodName

      String uniqueMethodName(Set<String> usedNames, Random random)
    • uniqueDispatchType

      String uniqueDispatchType(Set<String> usedTypes, Random random)
    • randomBuiltInType

      String randomBuiltInType(Random random)
    • randomDefaultableOperator

      String randomDefaultableOperator(Random random)
    • returnInit

      String returnInit(String type, Random random)
    • maybeKeywordModule

      String maybeKeywordModule(String base, int counter, Random random)
    • randomLiteral

      String randomLiteral(Random random)
    • randomStringMethodNoArg

      String randomStringMethodNoArg(Random random)
    • randomStringMethodCallWithArgs

      String randomStringMethodCallWithArgs(Random random)
    • randomSimpleString

      String randomSimpleString(Random random)
    • capitalise

      static String capitalise(String s)