visitEnumDeclaration method

  1. @override
void visitEnumDeclaration(
  1. SEnumDeclaration node
)
override

Visit a SEnumDeclaration.

Implementation

@override
void visitEnumDeclaration(SEnumDeclaration node) {
  final enumName = node.name?.name ?? '';
  if (environment.isDefinedLocally(enumName)) {
    return;
  }

  // Extract constant names - needed for ordering later
  final valueNames = node.constants.map((c) => c.name?.name ?? '').toList();

  // Create the placeholder enum runtime object, storing only names for now
  final enumPlaceholder =
      InterpretedEnum.placeholder(enumName, environment, valueNames);

  // Define the enum type placeholder in the current environment
  environment.define(enumName, enumPlaceholder);
  Logger.debug(
      "[DeclarationVisitor] Defined placeholder for enum '$enumName' with value order [${valueNames.join(', ')}] in env: ${environment.hashCode}");

  // Do NOT process members or constants here. That happens in Pass 2 (InterpreterVisitor).
}