Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ pub enum ExprKind {
/// RG-7b
Use(String),
Spread(Box<Expr>),
/// RG-4b: an object rest, `{ a, ...rest } = e` (the parser's own; Solid's `omit`)
Omit { e: Box<Expr>, keys: Vec<String> },
/// R-f-3
Throw(Box<Expr>),
/// R-f-4: `e catch (x: A | B) => alt`; classes absent: every failure
Expand Down Expand Up @@ -422,6 +424,7 @@ impl Expr {
ExprKind::Draft { .. } => "draft",
ExprKind::Use(_) => "use",
ExprKind::Spread(_) => "spread",
ExprKind::Omit { .. } => "omit",
ExprKind::Throw(_) => "throw",
ExprKind::Catch { .. } => "catch",
ExprKind::StyleMap { .. } => "stylemap",
Expand All @@ -439,6 +442,7 @@ impl Expr {
ExprKind::Un { op, e } => obj(vec![("k", k), ("op", s(op)), ("e", b(e))]),
ExprKind::Pre { name, init } => obj(vec![("k", k), ("name", s(name)), ("init", ob(init))]),
ExprKind::Peek(e) | ExprKind::Latest(e) | ExprKind::Pending(e) | ExprKind::Spread(e) | ExprKind::Throw(e) => obj(vec![("k", k), ("e", b(e))]),
ExprKind::Omit { e, keys } => obj(vec![("k", k), ("e", b(e)), ("keys", Some(strs(keys)))]),
ExprKind::Await { e, init, stream } => obj(vec![("k", k), ("e", b(e)), ("init", ob(init)), ("stream", Some(Value::Bool(*stream)))]),
ExprKind::If { c, t, f } => obj(vec![("k", k), ("c", b(c)), ("t", b(t)), ("f", b(f))]),
ExprKind::Tpl(parts) => obj(vec![
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ pub(crate) fn children<'a>(n: Node<'a>, paths: bool) -> Vec<Node<'a>> {
Node::E(e) => match &e.k {
ExprKind::Lit(_) | ExprKind::Id(_) | ExprKind::Use(_) | ExprKind::StyleMap { .. } => {}
ExprKind::Bin { l, r, .. } => out.extend([Node::E(l), Node::E(r)]),
ExprKind::Un { e, .. } | ExprKind::Peek(e) | ExprKind::Latest(e) | ExprKind::Pending(e) | ExprKind::Spread(e) | ExprKind::Throw(e) => out.push(Node::E(e)),
ExprKind::Un { e, .. } | ExprKind::Peek(e) | ExprKind::Latest(e) | ExprKind::Pending(e) | ExprKind::Spread(e) | ExprKind::Omit { e, .. } | ExprKind::Throw(e) => out.push(Node::E(e)),
ExprKind::Pre { init, .. } => out.extend(init.iter().map(|x| Node::E(x))),
ExprKind::Await { e, init, .. } => {
out.push(Node::E(e));
Expand Down Expand Up @@ -438,7 +438,7 @@ fn free_names(e: &Expr, bound: &HashSet<String>, out: &mut IndexSet<String>) {
go(i, out);
}
}
ExprKind::Latest(x) | ExprKind::Pending(x) | ExprKind::Un { e: x, .. } | ExprKind::Spread(x) => go(x, out),
ExprKind::Latest(x) | ExprKind::Pending(x) | ExprKind::Un { e: x, .. } | ExprKind::Spread(x) | ExprKind::Omit { e: x, .. } => go(x, out),
ExprKind::Bin { l, r, .. } => {
go(l, out);
go(r, out);
Expand Down Expand Up @@ -2051,7 +2051,7 @@ impl<'a> Checker<'a> {
self.expr(x, env, ctx, None);
self.model.probe = save;
}
ExprKind::Un { e: x, .. } | ExprKind::Spread(x) => self.expr(x, env, ctx, None),
ExprKind::Un { e: x, .. } | ExprKind::Spread(x) | ExprKind::Omit { e: x, .. } => self.expr(x, env, ctx, None),
ExprKind::Await { e: inner, init, .. } => {
if ctx.imperative && !self.stmt_awaits.contains(&(e as *const Expr)) {
let sh = show(e);
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,8 @@ impl<'p> Gen<'p> {
rtc("preOr", vec![call(id(p), vec![]), thunk(i)])
}
ExprKind::Peek(x) => rtc("untrack", vec![thunk(self.expr(x, env, &sub)?)]),
// RG-4b: Solid's live view
ExprKind::Omit { e: x, keys } => rtc("omit", std::iter::once(self.expr(x, env, &sub)).chain(keys.iter().map(|k| Ok(str(k.clone())))).collect::<Result<Vec<_>, _>>()?),
ExprKind::Await { e: x, stream, .. } => {
if let Some(v) = self.hoisted.get(&(e as *const Expr)) {
return Ok(call(id(v.clone()), vec![]));
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl Walker {
self.read(l, st, sh, local, depth);
self.read(r, st, sh, local, depth);
}
ExprKind::Un { e, .. } | ExprKind::Spread(e) | ExprKind::Throw(e) => self.read(e, st, sh, local, depth),
ExprKind::Un { e, .. } | ExprKind::Spread(e) | ExprKind::Omit { e, .. } | ExprKind::Throw(e) => self.read(e, st, sh, local, depth),
ExprKind::Await { e, init, .. } => {
self.read(e, st, sh, local, depth);
if let Some(i) = init {
Expand Down Expand Up @@ -362,7 +362,7 @@ impl Walker {
self.deps(l, st, sh, out);
self.deps(r, st, sh, out);
}
ExprKind::Un { e, .. } | ExprKind::Spread(e) | ExprKind::Throw(e) => self.deps(e, st, sh, out),
ExprKind::Un { e, .. } | ExprKind::Spread(e) | ExprKind::Omit { e, .. } | ExprKind::Throw(e) => self.deps(e, st, sh, out),
ExprKind::If { c, t, f } => {
self.deps(c, st, sh, out);
self.deps(t, st, sh, out);
Expand Down
Loading
Loading