Fork of daniellemaywood.uk/gleam — Wasm codegen work
1

Configure Feed

Select the types of activity you want to include in your feed.

Allow matching against records

author
Danielle Maywood
committer
nandi
date (Jul 26, 2026, 12:11 PM -0700) commit 7ebc2fc0 parent a9943d88 change-id yzmkqqst
+108 -4
+1
compiler-core/src/cranelift.rs
··· 189 189 mir::ast::Expression::StringConcat { lhs: _, rhs: _ } => todo!(), 190 190 mir::ast::Expression::List { items: _, tail: _ } => todo!(), 191 191 mir::ast::Expression::Struct { tag: _, items: _ } => todo!(), 192 + mir::ast::Expression::StructTag { value: _ } => todo!(), 192 193 mir::ast::Expression::StructAccess { value: _, index: _ } => todo!(), 193 194 mir::ast::Expression::Set { name, value } => { 194 195 let var = self.make_var(name.name);
+35 -4
compiler-core/src/cranelift/mir.rs
··· 996 996 rhs: Box::new(Expression::Int { value }), 997 997 } 998 998 } 999 - exhaustiveness::RuntimeCheck::Float { value: _ } => todo!(), 1000 - exhaustiveness::RuntimeCheck::String { value: _ } => todo!(), 999 + exhaustiveness::RuntimeCheck::Float { value } => Expression::Equals { 1000 + lhs: Box::new(against), 1001 + rhs: Box::new(Expression::Float { 1002 + value: value.clone(), 1003 + }), 1004 + }, 1005 + exhaustiveness::RuntimeCheck::String { value } => Expression::Equals { 1006 + lhs: Box::new(against), 1007 + rhs: Box::new(Expression::String { 1008 + value: value.clone(), 1009 + }), 1010 + }, 1001 1011 exhaustiveness::RuntimeCheck::StringPrefix { prefix: _, rest: _ } => todo!(), 1002 1012 exhaustiveness::RuntimeCheck::Tuple { 1003 1013 size: _, ··· 1006 1016 exhaustiveness::RuntimeCheck::BitArray { test: _ } => todo!(), 1007 1017 exhaustiveness::RuntimeCheck::Variant { 1008 1018 match_: _, 1009 - index: _, 1019 + index, 1010 1020 labels: _, 1011 1021 fields: _, 1012 - } => todo!(), 1022 + } => Expression::Equals { 1023 + lhs: Box::new(Expression::Int { 1024 + value: BigInt::from(*index), 1025 + }), 1026 + rhs: Box::new(Expression::StructTag { 1027 + value: Box::new(against), 1028 + }), 1029 + }, 1013 1030 exhaustiveness::RuntimeCheck::NonEmptyList { first: _, rest: _ } => todo!(), 1014 1031 exhaustiveness::RuntimeCheck::EmptyList => todo!(), 1015 1032 } ··· 1209 1226 insta::assert_debug_snapshot!(translate( 1210 1227 r#"pub fn pipe() { 1211 1228 [1, 2, 3, ..[4, 5, 6]] 1229 + }"# 1230 + )); 1231 + 1232 + insta::assert_debug_snapshot!(translate( 1233 + r#"pub type Wibble { 1234 + Wibble 1235 + Wobble 1236 + } 1237 + 1238 + pub fn check(wibble: Wibble) { 1239 + case wibble { 1240 + Wibble -> 0 1241 + Wobble -> 1 1242 + } 1212 1243 }"# 1213 1244 )); 1214 1245 }
+4
compiler-core/src/cranelift/mir/ast.rs
··· 174 174 items: Vec<Expression>, 175 175 }, 176 176 177 + StructTag { 178 + value: Box<Expression>, 179 + }, 180 + 177 181 StructAccess { 178 182 value: Box<Expression>, 179 183 index: u64,
+12
compiler-core/src/cranelift/mir/visit.rs
··· 161 161 visit_expression_struct(self, tag, items); 162 162 } 163 163 164 + fn visit_expression_struct_tag(&mut self, value: &'mir mut Expression) { 165 + visit_expression_struct_tag(self, value); 166 + } 167 + 164 168 fn visit_expression_struct_access( 165 169 &mut self, 166 170 value: &'mir mut Expression, ··· 245 249 Expression::StringConcat { lhs, rhs } => v.visit_expression_string_concat(lhs, rhs), 246 250 Expression::List { items, tail } => v.visit_expression_list(items, tail), 247 251 Expression::Struct { tag, items } => v.visit_expression_struct(tag, items), 252 + Expression::StructTag { value } => v.visit_expression_struct_tag(value), 248 253 Expression::StructAccess { value, index } => v.visit_expression_struct_access(value, index), 249 254 Expression::Set { name, value } => v.visit_expression_set(name, value), 250 255 Expression::If { cond, then, else_ } => v.visit_expression_if(cond, then, else_), ··· 546 551 for item in items { 547 552 v.visit_expression(item); 548 553 } 554 + } 555 + 556 + pub fn visit_expression_struct_tag<'mir, V>(v: &mut V, value: &'mir mut Expression) 557 + where 558 + V: Visit<'mir> + ?Sized, 559 + { 560 + v.visit_expression(value); 549 561 } 550 562 551 563 pub fn visit_expression_struct_access<'mir, V>(
+56
compiler-core/src/cranelift/snapshots/gleam_core__cranelift__mir__tests__translates_samples-13.snap
··· 1 + --- 2 + source: compiler-core/src/cranelift/mir.rs 3 + expression: "translate(r#\"pub type Wibble {\n Wibble\n Wobble\n }\n\n pub fn check(wibble: Wibble) {\n case wibble {\n Wibble -> 0\n Wobble -> 1\n }\n }\"#)" 4 + --- 5 + Module { 6 + functions: [ 7 + Function { 8 + name: "check", 9 + return_type: Int, 10 + parameters: [ 11 + FunctionParameter { 12 + type_: Struct { 13 + elements: [], 14 + }, 15 + name: Some( 16 + "wibble$1", 17 + ), 18 + }, 19 + ], 20 + body: Block( 21 + [ 22 + Set { 23 + name: Var { 24 + name: "_tmp$2", 25 + }, 26 + value: Var( 27 + Var { 28 + name: "wibble$1", 29 + }, 30 + ), 31 + }, 32 + If { 33 + cond: Equals { 34 + lhs: Int { 35 + value: 0, 36 + }, 37 + rhs: StructTag { 38 + value: Var( 39 + Var { 40 + name: "_tmp$2", 41 + }, 42 + ), 43 + }, 44 + }, 45 + then: Int { 46 + value: 0, 47 + }, 48 + else_: Int { 49 + value: 1, 50 + }, 51 + }, 52 + ], 53 + ), 54 + }, 55 + ], 56 + }