Refactor: Implement Record Layouts and Optimized Field Access
Introduces a new `RecordLayout` system for efficient and type-safe record handling. Key changes: - `RecordLayout` struct with `O(1)` field lookup using FMap optimization. - Field accessors (`.name`) are now first-class callable values. - Parser recognizes dot-prefixed identifiers as field accessors. - Binder and TypeChecker handle field accessors. - Optimizer transforms field accessor calls into specialized `GetField` nodes. - VM executes `GetField` efficiently by directly accessing record values. - Adds a new `records.myc` example showcasing record features. - Improves comparison logic for records to use pointer equality for layout.
This commit is contained in:
@@ -100,6 +100,9 @@ impl<'a> Parser<'a> {
|
||||
TokenKind::Keyword(k) => UntypedKind::Constant(Value::Keyword(Keyword::intern(&k))),
|
||||
TokenKind::Identifier(id) => match id.as_ref() {
|
||||
"..." => UntypedKind::Nop,
|
||||
s if s.starts_with('.') && s.len() > 1 => {
|
||||
UntypedKind::FieldAccessor(Keyword::intern(&s[1..]))
|
||||
}
|
||||
_ => UntypedKind::Identifier(id.into()),
|
||||
},
|
||||
_ => {
|
||||
|
||||
Reference in New Issue
Block a user