Skip to content

Feature/bson#108

Merged
M-jerez merged 16 commits intomion-run-typesfrom
feature/bson
Sep 24, 2025
Merged

Feature/bson#108
M-jerez merged 16 commits intomion-run-typesfrom
feature/bson

Conversation

@M-jerez
Copy link
Contributor

@M-jerez M-jerez commented Sep 24, 2025

add binary serialization feature, WIP

M-jerez and others added 16 commits August 27, 2025 14:16
- Add BSON utilities (BSONWriter, BSONReader) with proper type handling
- Implement toBSON and fromBSON JIT compilation functions
- Add BSON type constants and helper functions
- Update core types to include ToBSONFn and FromBSONFn
- Add BSON functions to JIT compiler and base RunType classes
- Create comprehensive test suite for BSON serialization
- Support atomic types: null, boolean, number, string, bigint
- Support collection types: arrays, objects, literals
- Follow BSON 1.1 specification for binary format
- Fix linting issues and code formatting
- Fix BSON function configuration to use expression type and standard jitArgs
- Implement atomic types: null, boolean, number, string, bigint, literal
- Generate JIT code that returns Uint8Array expressions instead of modifying shared buffer
- Use dynamic variable names with comp.getNestLevel() for unique naming
- Follow BSON 1.1 specification for binary format
- All atomic type tests passing: null, boolean, string, int32 number serialization
- Use self-invoking functions for complex logic to return single expressions
- Fix linting issues by removing unused imports and parameters
- Remove bsonUtils.ts file as it's not needed for JIT approach
- Rewrite bson.spec.ts to test JIT-generated code following toCode.spec.ts pattern
- Fix fromBSON.ts import to use inline BSON_TYPES constants
- Add comprehensive tests for all atomic types: null, boolean, string, number, bigint
- Add tests for literal types: string, number, boolean literals
- Verify JIT code generation with DEBUG_JIT flag shows correct optimized code
- All 10 BSON serialization tests passing
- JIT generates proper BSON format with type detection and dynamic variable names
- Fix code formatting with Prettier
- Add tests for empty strings, Unicode strings, negative numbers, zero, and large bigints
- Verify proper UTF-8 encoding for Unicode characters including emojis
- Test boundary conditions for number types and string lengths
- All 15 BSON tests passing including edge cases
- Verify existing functionality still works (toCode and string runType tests passing)
- JIT code generation handles all edge cases correctly
- Add back bsonUtils.ts with class-based BSONWriter/BSONReader for reference
- Create bsonPureFunctions.ts with pure functional BSON utilities
- Pure functions have no external dependencies, all constants defined inside
- Buffer state passed as parameters, immutable functional approach
- Add comprehensive tests for both class-based and pure functional approaches
- Create bsonExamples.ts demonstrating all three approaches:
  1. JIT-generated (production)
  2. Class-based (reference)
  3. Pure functional (alternative reference)
- All 18 tests passing including reference implementation tests
- Examples show identical output from all three approaches
- Fix linting issues with const/let usage
@M-jerez M-jerez merged commit 6c2b1fc into mion-run-types Sep 24, 2025
1 check failed
@M-jerez M-jerez deleted the feature/bson branch September 24, 2025 19:18
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.

1 participant