Refactor: Rename map to record
This commit renames `Map` to `Record` and updates all related AST nodes, binders, type checkers, and runtime values to reflect this change. This is a semantic change to better align with common programming language terminology.
This commit is contained in:
+34
-17
@@ -313,13 +313,13 @@ macro_rules! dispatch_eval {
|
||||
for e in elements {
|
||||
vals.push($self.$eval_method($($observer,)? e)?);
|
||||
}
|
||||
Ok(Value::make_list(vals))
|
||||
Ok(Value::make_tuple(vals))
|
||||
},
|
||||
|
||||
BoundKind::Map { entries } => {
|
||||
let mut keys = Vec::with_capacity(entries.len());
|
||||
let mut values = Vec::with_capacity(entries.len());
|
||||
for (k, v) in entries {
|
||||
BoundKind::Record { fields } => {
|
||||
let mut keys = Vec::with_capacity(fields.len());
|
||||
let mut values = Vec::with_capacity(fields.len());
|
||||
for (k, v) in fields {
|
||||
let key = $self.$eval_method($($observer,)? k)?;
|
||||
let val = $self.$eval_method($($observer,)? v)?;
|
||||
|
||||
@@ -327,7 +327,7 @@ macro_rules! dispatch_eval {
|
||||
keys.push(kw);
|
||||
values.push(val);
|
||||
} else {
|
||||
return Err(format!("Map key must be keyword, got {}", key));
|
||||
return Err(format!("Record key must be keyword, got {}", key));
|
||||
}
|
||||
}
|
||||
Ok(Value::make_record(keys, values))
|
||||
@@ -601,12 +601,18 @@ impl VM {
|
||||
}
|
||||
|
||||
fn flatten_value(val: Value, into: &mut Vec<Value>) {
|
||||
if let Value::Tuple(t) = val {
|
||||
for item in t.values.iter() {
|
||||
Self::flatten_value(item.clone(), into);
|
||||
match val {
|
||||
Value::Tuple(values) => {
|
||||
for item in values.iter() {
|
||||
Self::flatten_value(item.clone(), into);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
into.push(val);
|
||||
Value::Record(r) => {
|
||||
for item in r.values.iter() {
|
||||
Self::flatten_value(item.clone(), into);
|
||||
}
|
||||
}
|
||||
_ => into.push(val),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,13 +687,24 @@ impl VM {
|
||||
BoundKind::Tuple { elements } => {
|
||||
// If the current value at offset is a Tuple (List or Record), we dive into it.
|
||||
// Otherwise, we assume the sequence was already flattened (e.g. by Specializer).
|
||||
if let Some(Value::Tuple(t)) = values.get(*offset) {
|
||||
*offset += 1;
|
||||
let mut sub_offset = 0;
|
||||
for el in elements {
|
||||
self.unpack(el, &t.values, &mut sub_offset)?;
|
||||
match values.get(*offset) {
|
||||
Some(Value::Tuple(t)) => {
|
||||
*offset += 1;
|
||||
let mut sub_offset = 0;
|
||||
for el in elements {
|
||||
self.unpack(el, t, &mut sub_offset)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
return Ok(());
|
||||
Some(Value::Record(r)) => {
|
||||
*offset += 1;
|
||||
let mut sub_offset = 0;
|
||||
for el in elements {
|
||||
self.unpack(el, &r.values, &mut sub_offset)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
for el in elements {
|
||||
|
||||
Reference in New Issue
Block a user