refactor(ast): rename value types to Number/Decimal/Text/Boolean
Renamed AST value types for v0.3 naming convention: - Value::Int -> Value::Number - Value::Float -> Value::Decimal - Value::String -> Value::Text - Value::Bool -> Value::Boolean - Expr::IntLit -> Expr::NumberLit - Expr::FloatLit -> Expr::DecimalLit - Expr::StringLit -> Expr::TextLit - Expr::BoolLit -> Expr::BooleanLit Updated all references across parser, resolver, validator, LSP, query engine, tests, and editor.
This commit is contained in:
16
src/query.rs
16
src/query.rs
@@ -50,7 +50,7 @@ where
|
||||
max: i64,
|
||||
) -> Box<dyn Iterator<Item = &'a ResolvedCharacter> + 'a> {
|
||||
Box::new(self.filter(move |c| {
|
||||
if let Some(Value::Int(age)) = c.fields.get("age") {
|
||||
if let Some(Value::Number(age)) = c.fields.get("age") {
|
||||
*age >= min && *age <= max
|
||||
} else {
|
||||
false
|
||||
@@ -65,7 +65,7 @@ where
|
||||
max: f64,
|
||||
) -> Box<dyn Iterator<Item = &'a ResolvedCharacter> + 'a> {
|
||||
Box::new(self.filter(move |c| {
|
||||
if let Some(Value::Float(value)) = c.fields.get(trait_name) {
|
||||
if let Some(Value::Decimal(value)) = c.fields.get(trait_name) {
|
||||
*value >= min && *value <= max
|
||||
} else {
|
||||
false
|
||||
@@ -121,7 +121,7 @@ where
|
||||
max: f64,
|
||||
) -> Box<dyn Iterator<Item = &'a ResolvedRelationship> + 'a> {
|
||||
Box::new(self.filter(move |r| {
|
||||
if let Some(Value::Float(bond)) = r.fields.get("bond") {
|
||||
if let Some(Value::Decimal(bond)) = r.fields.get("bond") {
|
||||
*bond >= min && *bond <= max
|
||||
} else {
|
||||
false
|
||||
@@ -178,8 +178,8 @@ mod tests {
|
||||
|
||||
fn make_character(name: &str, age: i64, trust: f64) -> ResolvedCharacter {
|
||||
let mut fields = HashMap::new();
|
||||
fields.insert("age".to_string(), Value::Int(age));
|
||||
fields.insert("trust".to_string(), Value::Float(trust));
|
||||
fields.insert("age".to_string(), Value::Number(age));
|
||||
fields.insert("trust".to_string(), Value::Decimal(trust));
|
||||
|
||||
ResolvedCharacter {
|
||||
name: name.to_string(),
|
||||
@@ -248,7 +248,7 @@ mod tests {
|
||||
let mut char1 = make_character("Alice", 25, 0.8);
|
||||
char1
|
||||
.fields
|
||||
.insert("job".to_string(), Value::String("baker".to_string()));
|
||||
.insert("job".to_string(), Value::Text("baker".to_string()));
|
||||
|
||||
let char2 = make_character("Bob", 35, 0.6);
|
||||
|
||||
@@ -263,10 +263,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_relationship_with_bond_range() {
|
||||
let mut fields1 = HashMap::new();
|
||||
fields1.insert("bond".to_string(), Value::Float(0.9));
|
||||
fields1.insert("bond".to_string(), Value::Decimal(0.9));
|
||||
|
||||
let mut fields2 = HashMap::new();
|
||||
fields2.insert("bond".to_string(), Value::Float(0.5));
|
||||
fields2.insert("bond".to_string(), Value::Decimal(0.5));
|
||||
|
||||
let relationships = [
|
||||
ResolvedRelationship {
|
||||
|
||||
Reference in New Issue
Block a user