Skip to content

Conversation

@dak2
Copy link
Owner

@dak2 dak2 commented Jan 27, 2026

Implement compact representation for qualified names (e.g., Api::V1::User)
using SmallVec to minimize heap allocations - up to 16 segments stored
inline on stack.

Changes

Type System (types.rs)

  • Add QualifiedName struct with compact representation
    • Single String for full name + SmallVec<[u16; 16]> for segment offsets
    • O(1) operations: name(), parent(), child()
    • Only 1 heap allocation regardless of nesting depth
  • Update Type enum: class_name -> name: QualifiedName
  • Add Type::instance() and Type::singleton() constructors

AST Parsing (definitions.rs)

  • Add extract_constant_path() to handle ConstantPathNode recursively
  • Support both simple names (User) and qualified names (Api::V1::User)

Scope Management (scope.rs)

  • Add current_qualified_name() method
  • Traverse scope chain to build fully qualified name from nested scopes

Other Updates

  • Update install_self() to use qualified names
  • Migrate all Type::Instance { class_name } usages to Type::instance()
  • Add comprehensive tests (127 total)

Implement compact representation for qualified names (e.g., Api::V1::User)
using SmallVec to minimize heap allocations - up to 16 segments stored
inline on stack.

## Changes

### Type System (types.rs)
- Add QualifiedName struct with compact representation
  - Single String for full name + SmallVec<[u16; 16]> for segment offsets
  - O(1) operations: name(), parent(), child()
  - Only 1 heap allocation regardless of nesting depth
- Update Type enum: class_name -> name: QualifiedName
- Add Type::instance() and Type::singleton() constructors

### AST Parsing (definitions.rs)
- Add extract_constant_path() to handle ConstantPathNode recursively
- Support both simple names (User) and qualified names (Api::V1::User)

### Scope Management (scope.rs)
- Add current_qualified_name() method
- Traverse scope chain to build fully qualified name from nested scopes

### Other Updates
- Update install_self() to use qualified names
- Migrate all Type::Instance { class_name } usages to Type::instance()
- Add comprehensive tests (127 total)
@dak2 dak2 force-pushed the support-nested-class branch from c95de38 to e06a001 Compare January 29, 2026 13:18
@dak2 dak2 changed the title support nested classes Add fully qualified name support for nested classes/modules Jan 29, 2026
@dak2 dak2 merged commit ca9074d into main Jan 29, 2026
2 checks passed
@dak2 dak2 deleted the support-nested-class branch January 29, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants